SNMP++/Agent++: SnmpSyntax BITS: Type information internallylost?!

Frank Fock Frank.Fock____t-online.de
Mon Jul 28 20:01:12 CEST 2003


The sNMP_SYNTAX_BITS type is a relict from SNMP++v2.8
and is not really used within AGENT++/SNMP++. As defined
in SNMP++/include/smi.h it reflects the BIT STRING type
that have never been an official SNMP (SMI) type. It
has been introduced in an experimental version of SNMP.

The BITS type which is part of SNMPv2c and SNMPv3 and
which can be used when defining MIBs with SMIv2, is
*not* distinguishable from OCTET STRING on the wire.

Consequently, the SNMP++v3.x code is correct, although
it may be better to remove all occurrances of
sNMP_SYNTAX_BITS from the source code to avoid any
misunderstandings.

Best regards,
Frank Fock

Jens Engel wrote:
> sNMP_SYNTAX_BITS syntax information is partially lost in some functions.
> NOTE: Class OctetStr returns sNMP_SYNTAX_OCTETS for OctetStr::get_syntax().
> 
> A class SnmpBits should be provided that is derived from OctetStr class.
> But the 2 functions below will replace it with an OctetStr object again.
> Therefore, it would be better to use a pluggable factory in both cases to
> avoid code duplication.
> The second case needs an extended factory (by deriving it from the first
> one).
> 
> 
> CODE-LOCATIONS:
> 1. file:vb.cpp
> void Vb::set_syntax(SmiUINT32 syntax)
> {
>       ...
>       case sNMP_SYNTAX_BITS:
>       case sNMP_SYNTAX_OCTETS:
>             iv_vb_value = new OctetStr();
>             break;
>       ...
> }
> 
> BUT:
>       vb.set_syntax(sNMP_SYNTAX_BITS)
>       POSTCONDITION(vb.get_syntax() == sNMP_SYNTAX_OCTETS)
>       // -- EXPECTED: POSTCONDITION(vb.get_syntax() == sNMP_SYNTAX_BITS);
> 
> 
> 2. file:mib.cpp
> void MibLeaf::set_syntax(SmiUINT32 syntax)
> {
>             ...
>         case sNMP_SYNTAX_OCTETS:
>         case sNMP_SYNTAX_BITS:
>                 value = new OctetStr();
>                 break;
>             ...
> }
> 
> BUT:
>     MibLeaf& MyMibLeaf = MyMibObject;
>       MyMibLeaf.set_syntax(sNMP_SYNTAX_BITS);
>       POSTCONDITION(MyMibLeaf.get_syntax() == sNMP_SYNTAX_OCTETS)
>       // -- EXPECTED: POSTCONDITION(MyMibLeaf.get_syntax() ==
> sNMP_SYNTAX_BITS);
> 
> 
> 
> 






More information about the AGENTPP mailing list