OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / ucd-snmp / original / man3 / snmp_sess_api.3
1 .\" /***********************************************************
2 .\"     Copyright 1989 by Carnegie Mellon University
3 .\" 
4 .\"                       All Rights Reserved
5 .\" 
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.  
13 .\" 
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
20 .\" SOFTWARE.
21 .\" ******************************************************************/
22 .TH SNMP_SESS_API 3 "21 Oct 1999"
23 .UC 5
24 .SH NAME
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
29 .SH SYNOPSIS
30 #include <sys/types>
31 .br
32 #include <netinet/in.h>
33 .br
34 #include <sys/time.h>
35 .br
36 #include <ucd-snmp/snmp.h>
37 .br
38 #include <ucd-snmp/snmp_impl.h>
39 .br
40 #include <ucd-snmp/asn1.h>
41 .br
42 #include <ucd-snmp/snmp_api.h>
43 .PP
44 void snmp_sess_init ( struct snmp_session * );
45 .PP
46 void * snmp_sess_open ( struct snmp_session * );
47 .PP
48 struct snmp_session * snmp_sess_session ( void * );
49 .PP
50 int snmp_sess_send ( void * opaque,
51 .RS
52 struct snmp_pdu *pdu );
53 .RE
54 .PP
55 int snmp_sess_async_send ( void * opaque,
56 .RS
57 struct snmp_pdu *pdu,
58 .RE
59 .RS
60 snmp_callback callback, void * callbackData );
61 .RE
62 .PP
63 int snmp_sess_select_info ( void * opaque,
64 .RS
65 int *numfds, fd_set *fdset,
66 .RE
67 .RS
68 struct timeval *timeout, int *block );
69 .RE
70 .PP
71 void snmp_sess_read ( void * opaque, fd_set *fdset );
72 .RE
73 .PP
74 void snmp_sess_timeout ( void * opaque );
75 .PP
76 int snmp_sess_close ( void * opaque );
77 .PP
78 void snmp_sess_error ( void * opaque,
79 .RS
80 int *pcliberr,
81 int *psnmperr,
82 char **pperrstring );
83 .RE
84 .PP
85 .SH DESCRIPTION
86 These functions define a subset of the API that can be used
87 to manage single SNMP sessions in a multi-threaded application.
88 Except for
89 .I snmp_sess_session,
90 these functions are single session versions of the traditional
91 SNMP library API.
92 .PP
93 Note that these functions use an
94 .I Opaque
95 pointer to identify a single session in lieu of a
96 .I session
97 pointer.
98 .PP
99 .I Snmp_sess_init
100 prepares a struct snmp_session that sources transport characteristics
101 and common information that will be used for a set of SNMP transactions.
102 After this structure is passed to
103 .I snmp_open
104 to create an SNMP session, the structure is not used.
105 .PP
106 SNMP sessions that are created with
107 .I snmp_sess_open
108 are not affected by and should not be used with
109 .I snmp_select_info,
110 .I snmp_read,
111 .I snmp_timeout,
112 nor
113 .I snmp_close.
114 Use the other functions described here with similar capabilities.
115 .PP
116 .I Snmp_sess_init
117 and
118 .I snmp_sess_open
119 each take as input a pointer to a struct snmp_session object.
120 This structure contains information for a set of transactions that
121 will share similar transport characteristics.
122 .I Snmp_sess_session
123 takes the opaque session handle and returns a pointer to
124 its associated struct snmp_session.
125 .PP
126 .I Snmp_sess_send
127 and
128 .I snmp_sess_async_send
129 each take as input an additional pointer to a struct snmp_pdu object.
130 This structure contains information that describes a transaction
131 that will be performed over an open session.
132 .PP
133 Consult snmp_api.h for the definitions of these structures.
134 .PP
135 .I Snmp_sess_select_info, snmp_sess_read,
136 and
137 .I snmp_sess_timeout
138 provide an interface for the use of the
139 .IR select (2)
140 system call so that SNMP transactions for a single session can occur asynchronously.
141 .PP
142 .I Snmp_sess_select_info
143 is given the information that would have been passed to
144 .I select
145 in the absence of SNMP.  For example, this might include window update information.
146 This information is modified so that SNMP will get the service it requires from the
147 call to
148 .I select.
149 In this case,
150 .I numfds, fdset,
151 and
152 .I timeout
153 correspond to the
154 .I nfds, readfds,
155 and
156 .I timeout
157 arguments to
158 .I select,
159 respectively.  The only exception is that timeout must always point to an allocated (but perhaps uninitialized)
160 .I struct timeval.
161 If
162 .I timeout
163 would have been passed as NULL,
164 .I block
165 is set to true, and
166 .I timeout
167 is treated as undefined.  This same rule applies upon return from
168 .I snmp_select_info.
169 .PP
170 After calling
171 .I snmp_sess_select_info, select
172 is called with the returned data.  When select returns,
173 .I snmp_sess_read
174 is called with the
175 .I fd_set
176 returned from
177 .I select.
178 This will read any input from this session's SNMP socket.
179 If
180 .I select
181 times out,
182 .I snmp_sess_timeout
183 should be called to see if the timeout was intended for SNMP.
184 .SH DIAGNOSTICS
185 .PP
186 Error return status from 
187 .I snmp_sess_open
188 is indicated by return of a null pointer.
189 Error return status from 
190 .I snmp_sess_close
191 and
192 .I snmp_sess_send
193 is indicated by return of 0.  A successful status will return a 1.
194 .PP
195 Further information can be obtained by using
196 .I snmp_sess_error
197 to see what type of error has occurred.
198 This function returns the SNMP "snmp_errno" variable,
199 the value of the system "errno" variable,
200 and a string interpretation of both variables.
201 The string must be freed after use by the caller.
202 .PP
203 For errors returned by
204 .I snmp_sess_open,
205 use the corresponding function
206 .I snmp_error
207 instead of
208 .I snmp_sess_error.
209 .PP
210 Consult snmp_api.h for the complete set of SNMP library
211 error values.
212 The SNMP library error value
213 .IR snmperr
214 can be one of the following values:
215 .RS 2n
216 .IP SNMPERR_GENERR \w'SNMPERR_BAD_REPETITIONS'u+2n
217 A generic error occurred.
218 .IP SNMPERR_BAD_LOCPORT \w'SNMPERR_BAD_REPETITIONS'u+2n
219 The local port was bad because it had already been
220 allocated or permission was denied.
221 .IP SNMPERR_BAD_ADDRESS \w'SNMPERR_BAD_REPETITIONS'u+2n
222 The host name or address given was not useable.
223 .IP SNMPERR_BAD_SESSION \w'SNMPERR_BAD_REPETITIONS'u+2n
224 The specified session was not open.
225 .IP SNMPERR_TOO_LONG \w'SNMPERR_BAD_REPETITIONS'u+2n
226 .IP SNMPERR_NO_SOCKET \w'SNMPERR_BAD_REPETITIONS'u+2n
227 .IP SNMPERR_V2_IN_V1 \w'SNMPERR_BAD_REPETITIONS'u+2n
228 .IP SNMPERR_V1_IN_V2 \w'SNMPERR_BAD_REPETITIONS'u+2n
229 .IP SNMPERR_BAD_REPEATERS \w'SNMPERR_BAD_REPETITIONS'u+2n
230 .IP SNMPERR_BAD_REPETITIONS \w'SNMPERR_BAD_REPETITIONS'u+2n
231 .IP SNMPERR_BAD_ASN1_BUILD \w'SNMPERR_BAD_REPETITIONS'u+2n
232 .IP SNMPERR_BAD_SENDTO \w'SNMPERR_BAD_REPETITIONS'u+2n
233 .IP SNMPERR_BAD_RCVFROM \w'SNMPERR_BAD_REPETITIONS'u+2n
234 .IP SNMPERR_BAD_PARSE \w'SNMPERR_BAD_REPETITIONS'u+2n
235 .IP SNMPERR_BAD_VERSION \w'SNMPERR_BAD_REPETITIONS'u+2n
236 .IP SNMPERR_BAD_COMMUNITY \w'SNMPERR_BAD_REPETITIONS'u+2n
237 .IP SNMPERR_NOAUTH_DESPRIV \w'SNMPERR_BAD_REPETITIONS'u+2n
238 .IP SNMPERR_ABORT \w'SNMPERR_BAD_REPETITIONS'u+2n
239 .IP SNMPERR_UNKNOWN_PDU \w'SNMPERR_BAD_REPETITIONS'u+2n
240 .IP SNMPERR_TIMEOUT \w'SNMPERR_BAD_REPETITIONS'u+2n
241 .RE
242 .PP
243 .SH "SEE ALSO"
244 select(2), snmp_api(3), snmp_api.h