Re: MacAddress type
Bill Fenner <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <CAF4Sogbm583QLagneG562R5NvTG8Mvjzgx=B68Y_ftN38TCARw@mail.gmail.com> |
On Wed, Sep 26, 2012 at 4:54 PM, Francois Bouchard <[email protected]> wrote: > Hi list, > > Question about one MacAddress SNMP oject type we have in the MIB. > > When sending a snmpget request to the MacAddress Object with the textual > names: > > $ snmpget -v 3 -u ...... MPBC-RMH-MIB::mpbcRMHMacAddress.0 we get garbage: > MPBC-RMH-MIB::mpbcRMHMacAddress.0 = STRING: > 36:43:3a:46:46:3a:42:45:3a:30:31:3a:30:30:3a:31:35 > > Then, if sending the getsnmp to the same object, but using the OID we get > the correct value "6C:FF:BE:01:00:15": > $ snmpget -v 3 -u ... .1.3.6.1.4.1.4464.2.1.4.1.5.0 > SNMPv2-SMI::enterprises.4464.2.1.4.1.5.0 = STRING: "6C:FF:BE:01:00:15" > > > So in the code I should limit the string to 6 Bytes. So must I omit the > colon separated string when writing (see C source)? Yes, you must turn the colon separated ASCII string that you get from the Exec_Popen_Cmd() call into 6 bytes, and return that. Make sure not to use strlen, since 0 is a valid value inside a MAC address. Bill > > Thanks, > > Francois > > > From the C source: > > // Get MAC, format : "11:22:33:44:55:66" > if(!Exec_Popen_Cmd(s_mac_addr, sizeof(s_mac_addr), "ifconfig -a eth0 | > grep HWaddr | awk ' {print $5}'")) > { > strcpy(s_mac_addr, "??:??:??:??:??:??"); > } > > > /* We are never called for a GETNEXT if it's registered as a > "instance", as it's "magically" handled for us. */ > > /* a instance handler also only hands us one request at a time, so > we don't need to loop over a list of requests; we'll only get one. */ > > switch(reqinfo->mode) { > > case MODE_GET: > > snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR, > s_mac_addr, strlen(s_mac_addr)); // the length of the data in bytes > break; > > > default: > /* we should never get here, so this is a really bad error */ > snmp_log(LOG_ERR, "unknown mode (%d) in > handle_mpbcRMHMacAddress\n", reqinfo->mode ); > return SNMP_ERR_GENERR; > } > > (...) > > > ------------------------------------------------------------------------------ > How fast is your code? > 3 out of 4 devs don\\\'t know how their code performs in production. > Find out how slow your code is with AppDynamics Lite. > http://ad.doubleclick.net/clk;262219672;13503038;z? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > _______________________________________________ > Net-snmp-users mailing list > [email protected] > Please see the following page to unsubscribe or change other options: > https://lists.sourceforge.net/lists/listinfo/net-snmp-users > ------------------------------------------------------------------------------ Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users