On 25/01/2008, Giuseppe Modugno <[EMAIL PROTECTED]> wrote:
> In my sub-agent I want to print an OID in a numerical fashion.
> I have "oid *name" and "size_t name_len".
>
> I'm sure there is a function in the Net-SNMP source code like the following:
>   print_objid_num( oid *name, size_t name_len );
> that prints (on stdout or on a buffer or on a file stream)
>   1.2.3.1....

Not as such, no.
The routine to output an OID is snprint_objid() (and related variants).

The way in which the OID is presented depends on an internal
formatting token.   Try something like the following:

     int old_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
                      NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
     netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
                      NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
                      NETSNMP_OID_OUTPUT_NUMERIC);

     print_objid( name, name_len );

     netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID,
                      NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
                      old_format);



> An what about print the OID textual up to enterprises node and numerically
> afterward?

The only way to do this is to ensure that the relevant enterprise-specific
MIB files are not loaded.   If the library has MIB definitions available
for an OID, then it will use them (unless explicitly told not to).
   There's no way to say "use just these MIBs, but not these others",
except by controlling which MIBs are read in.

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to