File: snmpstructfiller_append.3

package info (click to toggle)
snmpkit 0.9-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,928 kB
  • ctags: 338
  • sloc: sh: 10,345; cpp: 2,342; makefile: 100; ansic: 1
file content (111 lines) | stat: -rw-r--r-- 4,328 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
.TH snmpstructfiller 3 "November 2000" "GNU snmpkit 0.4"
.SH NAME
snmpstrucfiller \- snmpkit functions for taking making snmp requests based upon a structure.
.SH SYNOPSIS
.nf
.B #include <snmpkit.h>
.sp
.BI "SNMPSTRUCTFILLER *new_snmpstructfiller(SNMPSESSION *" session ");"
.BI "void delete_snmpstructfiller(SNMPSTRUCTFILLER *" doomed ");"
.BI "void snmpstructfiller_append(SNMPSTRUCTFILLER *" sf ", const char *" oidstr ",Tags " tag ", unsigned int " offset ");"
.BI "void snmpstructfiller_remove(SNMPSTRUCTFILLER *" sf ",const char *" oidstr ");"
.BI "void *snmpstructfiller_get(SNMPSTRUCTFILLER *" sf ",void *" tobefilled ");"
.BI "void *snmpstructfiller_get_next(SNMPSTRUCTFILLER *" sf ", void *" tobefilled ");"
.SH DESCRIPTION
A snmpstructfiller is an opaque data structure used fill C structures 
with data from the snmp requests. 
.sp
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.
.sp
The
.B 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
.B snmpstructfiller_append()
function. To actually do the request, use the 
.B snmpstructfiller_get() 
or the
.B snmpstructfiller_get_next()
functions.
.sp
The
.B delete_snmpstructfiller()
function is the opposite of the new function. It frees all the
resources used by  the structfiller structure.
.sp
The
.B snmpstructfiller_append()
function appends a new snmp object to the structure filler. It
requires the oidstring. 
.B "This snmp library doesn't 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:
.TP
.B INT_TAG long
.TP
.B STRING_TAG char*
.TP
.B 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.
.TP
.B 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..
.TP
.B TIME_TICK_TAG long
.PD
.PP
The final parameter is offset into the structure. For example if you
have a structure and a variable like:
.in 10
struct info {
.in 14
char *descr;
char *contact;
.in 10
} foo;
.PD
.PP
Then the offset of descr would be 
.B "(char*)&(foo.descr)-(char*)&foo" 
and the offset of contact would be
.B "(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.
.SH AUTHOR
Ben Woodard <ben@users.sourceforge.net>
.SH 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.
.sp
There is no support for SNMP sets.
.sp
There is no support for getting back an OID.
.sp
There is no support for 
.SH "SEE ALSO"
.BR libsnmpkit "(3), " snmpsession "(3), " snmpsock "(3), " snmptable "(3), " snmpstructfiller "(3)"