1 .\" /***********************************************************
2 .\" Copyright 1989 by Carnegie Mellon University
4 .\" All Rights Reserved
6 .\" Permission to use, copy, modify, and distribute this software and its
7 .\" documentation for any purpose and without fee is hereby granted,
8 .\" provided that the above copyright notice appear in all copies and that
9 .\" both that copyright notice and this permission notice appear in
10 .\" supporting documentation, and that the name of CMU not be
11 .\" used in advertising or publicity pertaining to distribution of the
12 .\" software without specific, written prior permission.
14 .\" CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 .\" ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 .\" CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 .\" ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 .\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 .\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21 .\" ******************************************************************/
22 .TH SNMP_SESS_API 3 "07 Mar 2002" VVERSIONINFO "Net-SNMP"
25 snmp_sess_init, snmp_sess_open, snmp_sess_session,
26 snmp_sess_send, snmp_sess_async_send,
27 snmp_sess_select_info, snmp_sess_read,
28 snmp_sess_timeout, snmp_sess_close, snmp_sess_error - session functions
30 .B #include <net-snmp/session_api.h>
32 .BI "void snmp_sess_init(struct snmp_session *" session ");"
34 .BI "void *snmp_sess_open(struct snmp_session *" session ");"
36 .BI "struct snmp_session *snmp_sess_session(void *" handle ");"
38 .BI "int snmp_sess_send(void *" handle ", struct snmp_pdu *" pdu ");"
40 .BI "int snmp_sess_async_send(void *" handle ","
42 .BI " struct snmp_pdu *" pdu ", "
44 .BI " snmp_callback " callback ", "
46 .BI " void *" callbackData ");"
48 .BI "int snmp_sess_select_info(void *" handle ","
50 .BI " int *" numfds ", fd_set *" fdset ", "
52 .BI " struct timeval *" timeout ", "
54 .BI " int *" block ");"
56 .BI "void snmp_sess_read(void *" handle ", fd_set *" fdset ");"
58 .BI "void snmp_sess_timeout(void *" handle ");"
60 .BI "int snmp_sess_close(void *" handle ");"
62 .BI "void snmp_sess_error(void *" handle ", int *" pcliberr ", "
64 .BI " int *" psnmperr ", char **" pperrstring ");"
66 These functions define a subset of the API that can be used
67 to manage single SNMP sessions in a multi-threaded application.
69 .BR snmp_sess_session() ,
70 these functions are single session versions of the traditional
73 Note that these functions use an opaque pointer
75 in the above prototypes) to identify a single session in lieu of a
77 pointer (as in the traditional API).
80 prepares a struct snmp_session that sources transport characteristics
81 and common information that will be used for a set of SNMP transactions.
82 After this structure is passed to
84 to create an SNMP session, the structure is no longer used. Instead
85 the opaque pointer returned by
87 is used to refer to that session henceforth.
89 SNMP sessions that are created with
91 are not affected by, and SHOULD NOT BE USED WITH,
92 .BR snmp_select_info() ", " snmp_read() ", " snmp_timeout() " nor"
94 Rather the equivalent single session functions described here should
100 each take as input a pointer to a struct snmp_session object.
101 This structure contains information for a set of transactions that
102 will share similar transport characteristics.
103 .B snmp_sess_session()
104 takes the opaque session handle and returns a pointer to
105 its associated struct snmp_session.
109 .B snmp_sess_async_send()
112 parameter, which points to a struct snmp_pdu object containing
113 information that describes a transaction that will be performed over
116 Consult snmp_api.h for the definitions of these structures.
118 .BR snmp_sess_select_info() ", " snmp_sess_read() " and " snmp_sess_timeout()
119 provide an interface for the use of the
121 system call so that SNMP transactions for a single session can occur
124 .B snmp_sess_select_info()
125 is passed the information that would have been passed to
127 in the absence of SNMP. For example, this might include file
128 descriptors associated with the main loop of a graphical
129 application. This information is modified so that SNMP will get the
130 service it requires from the call to
133 .IR numfds ", " fdset " and " timeout
135 .IR nfds ", " readfds " and " timeout
138 respectively. The only exception is that timeout must ALWAYS point to
139 an allocated (but perhaps uninitialized)
141 (it cannot be NULL as for
145 would have been passed as NULL,
147 is instead set to true, and
149 is treated as undefined. This same rule applies upon return from
150 .BR snmp_select_info() .
153 .B snmp_sess_select_info() ,
155 should be called with the returned data. When it returns,
157 should then be called with the
161 This will read any input from this session's SNMP socket. If
163 times out (that is, it returns zero),
164 .B snmp_sess_timeout()
165 should be called to see if a timeout has occurred on the SNMP
169 Error return status from
171 is indicated by return of a NULL pointer.
172 Error return status from
176 is indicated by a return value of 0. A successful status will return
179 Further information can be obtained by using
181 to see what type of error has occurred. This function returns the
184 variable, the value of the system
186 variable, and a string interpretation of both variables. The string
187 must be freed after use by the caller.
189 For errors returned by
190 .BR snmp_sess_open() ,
191 use the corresponding function
194 .BR snmp_sess_error() .
196 Consult snmp_api.h for the complete set of SNMP library
198 The SNMP library error value
200 can be one of the following values:
202 .IP SNMPERR_GENERR \w'SNMPERR_BAD_REPETITIONS'u+2n
203 A generic error occurred.
204 .IP SNMPERR_BAD_LOCPORT \w'SNMPERR_BAD_REPETITIONS'u+2n
205 The local port was bad because it had already been
206 allocated or permission was denied.
207 .IP SNMPERR_BAD_ADDRESS \w'SNMPERR_BAD_REPETITIONS'u+2n
208 The host name or address given was not useable.
209 .IP SNMPERR_BAD_SESSION \w'SNMPERR_BAD_REPETITIONS'u+2n
210 The specified session was not open.
211 .IP SNMPERR_TOO_LONG \w'SNMPERR_BAD_REPETITIONS'u+2n
212 .IP SNMPERR_NO_SOCKET \w'SNMPERR_BAD_REPETITIONS'u+2n
213 .IP SNMPERR_V2_IN_V1 \w'SNMPERR_BAD_REPETITIONS'u+2n
214 .IP SNMPERR_V1_IN_V2 \w'SNMPERR_BAD_REPETITIONS'u+2n
215 .IP SNMPERR_BAD_REPEATERS \w'SNMPERR_BAD_REPETITIONS'u+2n
216 .IP SNMPERR_BAD_REPETITIONS \w'SNMPERR_BAD_REPETITIONS'u+2n
217 .IP SNMPERR_BAD_ASN1_BUILD \w'SNMPERR_BAD_REPETITIONS'u+2n
218 .IP SNMPERR_BAD_SENDTO \w'SNMPERR_BAD_REPETITIONS'u+2n
219 .IP SNMPERR_BAD_RCVFROM \w'SNMPERR_BAD_REPETITIONS'u+2n
220 .IP SNMPERR_BAD_PARSE \w'SNMPERR_BAD_REPETITIONS'u+2n
221 .IP SNMPERR_BAD_VERSION \w'SNMPERR_BAD_REPETITIONS'u+2n
222 .IP SNMPERR_BAD_COMMUNITY \w'SNMPERR_BAD_REPETITIONS'u+2n
223 .IP SNMPERR_NOAUTH_DESPRIV \w'SNMPERR_BAD_REPETITIONS'u+2n
224 .IP SNMPERR_ABORT \w'SNMPERR_BAD_REPETITIONS'u+2n
225 .IP SNMPERR_UNKNOWN_PDU \w'SNMPERR_BAD_REPETITIONS'u+2n
226 .IP SNMPERR_TIMEOUT \w'SNMPERR_BAD_REPETITIONS'u+2n
230 .BR select "(2), " snmp_api "(3), " snmp_api.h