]>
Commit | Line | Data |
---|---|---|
0e2cd867 | 1 | /* |
262a0e14 | 2 | * $Id$ |
0e2cd867 | 3 | */ |
b5638623 | 4 | #ifndef SQUID_SNMP_API_UTIL_H |
5 | #define SQUID_SNMP_API_UTIL_H | |
54f642bf | 6 | |
e1f7507e AJ |
7 | /* NP: required for typedef ipaddr and indirect config.h */ |
8 | #include "snmp_pdu.h" | |
9 | ||
54f642bf | 10 | /*********************************************************** |
11 | Copyright 1997 by Carnegie Mellon University | |
12 | ||
13 | All Rights Reserved | |
14 | ||
c5dd4956 AJ |
15 | Permission to use, copy, modify, and distribute this software and its |
16 | documentation for any purpose and without fee is hereby granted, | |
54f642bf | 17 | provided that the above copyright notice appear in all copies and that |
c5dd4956 | 18 | both that copyright notice and this permission notice appear in |
54f642bf | 19 | supporting documentation, and that the name of CMU not be |
20 | used in advertising or publicity pertaining to distribution of the | |
c5dd4956 | 21 | software without specific, written prior permission. |
54f642bf | 22 | |
23 | CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | |
24 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
25 | CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
26 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
27 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
28 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
29 | SOFTWARE. | |
30 | ******************************************************************/ | |
31 | ||
32 | /* | |
33 | * snmp_api_util.h - API management. | |
34 | * Didier DESIDERIO (SINFOR) - November 26th, 1997 | |
35 | */ | |
36 | ||
37 | #define PACKET_LENGTH 4500 | |
38 | ||
39 | /* | |
40 | * A list of all the outstanding requests for a particular session. | |
41 | */ | |
42 | struct request_list { | |
43 | struct request_list *next_request; | |
43d4303e | 44 | int request_id; /* request id */ |
45 | int retries; /* Number of retries */ | |
46 | u_int timeout; /* length to wait for timeout */ | |
47 | struct timeval time; /* Time this request was made */ | |
48 | struct timeval expire; /* time this request is due to expire */ | |
49 | struct snmp_pdu *pdu; /* The pdu for this request (saved so it can be retransmitted */ | |
54f642bf | 50 | }; |
51 | ||
52 | /* | |
53 | * The list of active/open sessions. | |
54 | */ | |
55 | struct session_list { | |
56 | struct session_list *next; | |
57 | struct snmp_session *session; | |
58 | struct snmp_internal_session *internal; | |
59 | }; | |
60 | ||
61 | struct snmp_internal_session { | |
43d4303e | 62 | int sd; /* socket descriptor for this connection */ |
63 | ipaddr addr; /* address of connected peer */ | |
64 | struct request_list *requests; /* Info about outstanding requests */ | |
54f642bf | 65 | }; |
66 | ||
67 | /* Define these here, as they aren't defined normall under | |
68 | * cygnus Win32 stuff. | |
69 | */ | |
70 | #undef timercmp | |
71 | #define timercmp(tvp, uvp, cmp) \ | |
72 | (((tvp)->tv_sec) cmp ((uvp)->tv_sec)) || \ | |
73 | ((((tvp)->tv_sec) == ((uvp)->tv_sec)) && \ | |
74 | (((tvp)->tv_usec) cmp ((uvp)->tv_usec))) | |
75 | ||
76 | #undef timerclear | |
77 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 | |
78 | ||
79 | #undef timerisset | |
80 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) | |
81 | ||
82 | #ifdef HAVE_SRAND | |
83 | #define random rand | |
84 | #define srandom srand | |
85 | #endif /* HAVE_SRAND */ | |
86 | ||
87 | #ifdef __cplusplus | |
e1381638 | 88 | extern "C" { |
54f642bf | 89 | #endif |
90 | ||
43d4303e | 91 | int snmp_get_socket_session(struct snmp_session *session_); |
92 | int snmp_select_info_session(struct snmp_session *session_, struct timeval *timeout); | |
93 | int snmp_timeout_session(struct snmp_session *sp_); | |
54f642bf | 94 | |
95 | #ifdef __cplusplus | |
96 | } | |
54f642bf | 97 | |
43d4303e | 98 | #endif |
b5638623 | 99 | |
100 | #endif /* SQUID_SNMP_API_UTIL_H */ |