On Fri, Apr 16, 2021 at 04:41:43PM +0200, dga via Net-snmp-coders wrote: > 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 ?
ifXEntry is a table and so ifAlias has an index value last. ifAlias has the oid .1.3.6.1.2.1.31.1.1.1.18 and you want 50000 to be the table index. It sounds as if you are registering ifXEntry.*.50000 as singular values and those should have a trailing 0, like e.g. sysContact and the helpers are adding those for you. You want to add a table row, not a number of values. /MF > > 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 > Net-snmp-coders@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/net-snmp-coders _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders