With my limited knowledge of SNMP MIB constructs and such, I kindly ask for help in understanding how to approach my problem.
I have today a working solution for configuring an IPv4 address and Port in one object using this:
TransportAddressIPv4 ::= TEXTUAL-CONVENTION
DISPLAY-HINT "1d.1d.1d.1d:2d"
STATUS current
DESCRIPTION
"Represents a transport address consisting of an IPv4
address and a port number (as used for example by UDP,
TCP and SCTP):
octets contents encoding
1-4 IPv4 address network-byte order
5-6 port number network-byte order
This textual convention SHOULD NOT be used directly in object
definitions since it restricts addresses to a specific format.
However, if it is used, it MAY be used either on its own or
**in conjunction with TransportAddressType** or TransportDomain
**as a pair.**"
SYNTAX OCTET STRING (SIZE (6))
Now I need to extend this object to also include IPv6 and Dns as choices and the description of TransportAddressIPv4 implies that there should be a way to combine it with TransportAddressType as a pair. How would that be done? I can’t find anything in any RFC nor elsewhere that does this…
TransportAddressIPv6 ::= TEXTUAL-CONVENTION
DISPLAY-HINT "0a[2x:2x:2x:2x:2x:2x:2x:2x]0a:2d"
STATUS current
DESCRIPTION
"Represents a transport address consisting of an IPv6
address and a port number (as used for example by UDP,
TCP and SCTP):
octets contents encoding
1-16 IPv6 address network-byte order
17-18 port number network-byte order
This textual convention SHOULD NOT be used directly in object
definitions since it restricts addresses to a specific format.
However, if it is used, it MAY be used either on its own or
in conjunction with TransportAddressType or TransportDomain
as a pair."
SYNTAX OCTET STRING (SIZE (18))
Some clarification from my side, I have this object, which is limited to IPv4 addresses.
myAddress OBJECT-TYPE
SYNTAX TransportAddressIPv4
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"IPv4 address and Port.
"
::= { myObject 2 }
…and now I’d like to replace TransportAddressIPv4 in this object with a pair, using TransportAddressType in some way. I suppose that it would be going together with the general definition TransportAddress (I also don’t know how to do that), but how could I also include the specific TransportAddressIPv4, TransportAddressIPv6 and TransportAddressDns as choices in order to benefit from e.g. the DISPLAY-HINTs in those TEXTUAL-CONVENTIONs?
You could try with two entries: One with TransportAddressType and the other with
TransportAddress (the “base type” for all addresses). Or combine them into one
with a SEQUENCE:
myTransport OBJECT-TYPE
SYNTAX MyTransport
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"BLA BLA BLA."
::= { myObject 8 }
MyTransport ::= SEQUENCE {
type TransportAddressType,
addr TransportAddress
}
Or you could create your own using the CHOICE construct.
I could not find any good examples of CHOICE with a quick web search.
I suppose I could use that construction if I just can get it to compile, but in any case I’d prefer a solution using CHOICE. I have also not been able to find any examples with the CHOICE construct. Anyone else…?