Man Linux: Main Page and Category List

NAME

       snmpstrucfiller  -  snmpkit  functions  for taking making snmp requests
       based upon a structure.

SYNOPSIS

       #include <snmpkit.h>

       SNMPSTRUCTFILLER *new_snmpstructfiller(SNMPSESSION *session);
       void delete_snmpstructfiller(SNMPSTRUCTFILLER *doomed);
       void snmpstructfiller_append(SNMPSTRUCTFILLER *sf, const char *oidstr,Tags tag, unsigned int offset);
       void snmpstructfiller_remove(SNMPSTRUCTFILLER *sf,const char *oidstr);
       void *snmpstructfiller_get(SNMPSTRUCTFILLER *sf,void *tobefilled);
       void *snmpstructfiller_get_next(SNMPSTRUCTFILLER *sf, void *tobefilled);

DESCRIPTION

       A snmpstructfiller is an opaque data structure used fill  C  structures
       with data from the snmp requests.

       The  SNMP  protocol  is  designed  in  a way where there is significant
       overhead in process of encoding and exchanging a packet.  Therefore  it
       is  very  inefficient  and time consuming to exchange many variables in
       individual request packets. The way around this is to bulk up  a  bunch
       of  snmp  requests  into  one  packet.  Since  you  are most frequently
       fetching information which is related  the  snmp  structure  filler  is
       designed  to associate the snmp objects and data types with the offsets
       into the structure. That way when you do a get or a get_next  you  will
       get back a completely filled in structure.

       The  new_snmpstructfiller() function creates new structfiller. You will
       need one of these for every different set of objects that you  want  to
       fetch. It starts out not having any requests associated with it. To add
       requests to this structure use the snmpstructfiller_append()  function.
       To  actually  do  the  request,  use  the snmpstructfiller_get() or the
       snmpstructfiller_get_next() functions.

       The delete_snmpstructfiller() function  is  the  opposite  of  the  new
       function.  It  frees  all  the  resources  used  by   the  structfiller
       structure.

       The snmpstructfiller_append() function appends a new snmp object to the
       structure filler. It requires the oidstring.  This snmp library doesnt
       bother attempting to read MIBS.  You must specify the  snmp  object  in
       dotted    decimal    notation.    For    example,   system.sysDesc   is
       "1.3.6.1.2.1.1.1.0". This means that you must look up the objects  ID’s
       before  hand. This sounds like a lot of work but I have found that when
       writing an application it is really not that much of a problem. The tag
       is  the  type of data that the object is supposed to have as defined in
       the MIB and cooresponds directly to the space used in the structure you
       are filling. The tag can be one of the following:

       INT_TAG long

       STRING_TAG char*

       IPADDR_TAG unsigned long
              You  get the IPADDR back in binary format. You must translate it
              byte for byte to get an IPADDR in the  format  that  is  usually
              expected.

       COUNTER_TAG long
              This   could   concievably   be  an  unsigned  long  but  enough
              implementations of MIBS are fouled up in such that  even  though
              the mib specifies a counter, the device returns an integer. That
              it is best to store this number in an  integer  rather  than  an
              unsigned..

       TIME_TICK_TAG long

       The  final  parameter  is offset into the structure. For example if you
       have a structure and a variable like:
          struct info {
              char *descr; char *contact;
          } foo;

       Then the offset of descr would be  (char*)&(foo.descr)-(char*)&foo  and
       the offset of contact would be (char*)&(foo.contact)-(char*)&foo I know
       that this is a very bad way of doing things and I intend to  change  it
       in  the  future.  Probably  what I will do is change this to a function
       pointer which when called takes the pointer to the structure that it is
       supposed  to insert the data in as well as the value of the data and it
       will insert it into the data into the structure.

AUTHOR

       Ben Woodard <ben@users.sourceforge.net>

BUGS

       The library can possibly throw different kinds of C++  execptions  that
       won’t  be  caught  by  the  glue  code  and therefore it can cause your
       program to crash inexplicably.

       There is no support for SNMP sets.

       There is no support for getting back an OID.

       There is no support for

SEE ALSO

       libsnmpkit(3),     snmpsession(3),      snmpsock(3),      snmptable(3),
       snmpstructfiller(3)