Display of BITS

Hi Frank,
I have a question on display format of ‘SYNTAX BITS’.
Very appreciated if you could give some advice.
Take this one for example:

    pktcEScTapMediationCapabilities OBJECT-TYPE
SYNTAX BITS {
ipV4SrcInterface(0),
ipV6SrcInterface(1),
udp(2)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This object displays the device capabilities with respect to
certain fields in Mediation Device table. This may be
dependent
on hardware capabilities, software capabilities.
The following values may be supported:
ipV4SrcInterface: SNMP ifIndex Value may be used to
select
the interface (denoted by
pktcEScTapMediationSrcInterface) on the
intercepting device from which to
transmit intercepted data to an IPv4
address Mediation Device.
ipV6SrcInterface: SNMP ifIndex Value may be used to
select
the interface (denoted by
pktcEScTapMediationSrcInterface) on the
intercepting device from which to
transmit intercepted data to an IPv6
address Mediation Device.
PKT-SP-ES-INF-I02-061013 PacketCable?2.0
42 CableLabs?10/13/06
udp: UDP may be used as transport protocol
(denoted by
pktcEScTapMediationTransport) in
transferring intercepted data to the
Mediation Device."
::= { pktcEScTapMediationGroup 3 }

We have below auto-generated code from AgenPro:

pktcEScTapMediationCapabilities = moFactory.createScalar(oidPktcEScTapMediationCapabilities,
            moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY), new OctetString());

And we set value for it:

    OctetString mdCap = new OctetString("0x20");
    SnmpAgent.getInstance().getModules().getPktcEsTapMib().getPktcEScTapMediationCapabilities().setValue(mdCap);

Then we do ‘snmpwalk’ with oid and get expected result.

$ snmpwalk -v 3 -u li_user -l authPriv -a MD5 -A 12345678 -x AES -X 12345678 100.100.1.20:161 1.3.6.1.4.1.4491.2.2.9.1.1.1.1.3
SNMPv2-SMI::enterprises.4491.2.2.9.1.1.1.1.3.0 = STRING: "0x20"

But ‘snmpwalk’ with MIB name gives us below result.

$ snmpwalk -v 3 -u li_user -l authPriv -a MD5 -A 12345678 -x AES -X 12345678 100.100.1.20:161 PKTC-ES-TAP-MIB::pktcEScTapMediationCapabilities
PKTC-ES-TAP-MIB::pktcEScTapMediationCapabilities.0 = BITS: 30 78 32 30 udp(2) 3 9 10 11 12 18 19 22 26 27 

I’m confused why it displays so many numbers which we don’t set to it.
Do you have any advice on this?
Thanks again.

When you create the OctetString with

new OctetString("0x20")

you create an octet string with the string (not hex string) “0x20” which is four characters long and starts with the character ‘0’ whose hex representation is ‘30’.

To create an OctetString from a HEX string use:

OctetString.fromHexString("20")

instead. (If you have a longer hex string, separate each hex byte with “:” or use the OctetString.fromHexStringPairs function.

Thanks Frank.
This could fix the issue when doing ‘snmpwalk’ with MIB name.

But now ‘snmpwalk’ with oid replies with: STRING: " "
And
when I set the value with ‘OctetString.fromHexString(“30”)’,
‘snmpwalk’ with oid replies with: STRING: “0”

Is this correct behavior for ‘SYNTAX BITS’?

Yes, that is correct.