How to avoid having ".0" at the end of the oids coming from a module

dga via Net-snmp-coders <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
Hello,

I have written a module allowing to add "specifics" interfaces at a 
fixed oid (50000) following the "linux" interfaces provided by default 
by the package (version 5.7.3).

However, it's not good for the customer has there is ".0" at the end of 
the oids inserted for the "specifics" interfaces (the same oids for the 
"linux" interfaces do not have this ".0" at the end).

Example: request on the "alias field" of the mib2 (in ifXEntry)

$ snmpwalk -v2c -c neufnet 192.168.247.123 1.3.6.1.2.1.31.1.1.1.18
iso.3.6.1.2.1.31.1.1.1.18.1 = ""
iso.3.6.1.2.1.31.1.1.1.18.2 = ""
iso.3.6.1.2.1.31.1.1.1.18.3 = ""
iso.3.6.1.2.1.31.1.1.1.18.4 = ""
iso.3.6.1.2.1.31.1.1.1.18.5 = ""
iso.3.6.1.2.1.31.1.1.1.18.6 = ""
iso.3.6.1.2.1.31.1.1.1.18.7 = ""
iso.3.6.1.2.1.31.1.1.1.18.8 = ""
iso.3.6.1.2.1.31.1.1.1.18.9 = ""
iso.3.6.1.2.1.31.1.1.1.18.10 = ""
iso.3.6.1.2.1.31.1.1.1.18.11 = ""
iso.3.6.1.2.1.31.1.1.1.18.50000.0 = STRING: "description of the specific 
interface"        <= Here is the oid inserted by the module with the 
".0" at the end

Instead of having:

iso.3.6.1.2.1.31.1.1.1.18.50000.0 = STRING: "description of the specific 
interface"

I would like having:

iso.3.6.1.2.1.31.1.1.1.18.50000 = STRING: "description of the specific 
interface"


May be someone has ever faced the same issue ?


Best Regards,

Damien GARCIA


Bellow the some parts of the code I use to create the module:


#define OFFSET_TO_GPON 50000

#define ALIAS    18

static struct variable2 gpon_fields_alias[] = { ALIAS, ASN_OCTET_STR, 
RONLY, var_update_field, 2, { 18, 0 } };

static oid gpon_fields_alias_oid[] = { 1, 3, 6, 1, 2, 1, 31, 1, 1, 1 }; 
/* .1.3.6.1.2.1.31.1.1.1  (ifXEntry) */

static void register_mib_interface_tree()
{
     /* Register OID for gpon0 alias in ifXEntry*/
     gpon_fields_alias[0].name[1] = OFFSET_TO_GPON;
     REGISTER_MIB("gpon_fields_alias", gpon_fields_alias, variable2, 
gpon_fields_alias_oid);
}

static u_char* var_update_field(struct variable *vp, oid * name, size_t 
* length, int exact, size_t * var_len, WriteMethod ** write_method)
{
     DEBUGMSGTL(("gpon0", "var_update_field entered\n"));
     if (header_generic(vp, name, length, exact, var_len, write_method) 
== MATCH_FAILED) {
         snmp_log(LOG_ERR, "Error header_generic_fix: return 
MATCH_FAILED !\n");
         return NULL;
     }

     switch (vp->magic) {
     case ALIAS: /* This object is an 'alias' name for the interface as 
specified by a network manager, and provides a non-volatile 'handle' for 
the interface */
         *var_len = strlen(descriptionGpon_g);
         return (u_char *) descriptionGpon_g;

     default:
         DEBUGMSGTL(("snmpd", "unknown sub-id %d in 
mib_gpon/var_update_field\n", vp->magic));

     }
     return NULL;
}



_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.