]> git.ipfire.org Git - thirdparty/squid.git/blob - include/snmp_api_util.h
3.1 Cleanups pt 1: Add testheaders.sh script
[thirdparty/squid.git] / include / snmp_api_util.h
1 /*
2 * $Id: snmp_api_util.h,v 1.5 2003/01/23 00:36:47 robertc Exp $
3 */
4 #ifndef SQUID_SNMP_API_UTIL_H
5 #define SQUID_SNMP_API_UTIL_H
6
7 /* NP: required for typedef ipaddr and indirect config.h */
8 #include "snmp_pdu.h"
9
10 /***********************************************************
11 Copyright 1997 by Carnegie Mellon University
12
13 All Rights Reserved
14
15 Permission to use, copy, modify, and distribute this software and its
16 documentation for any purpose and without fee is hereby granted,
17 provided that the above copyright notice appear in all copies and that
18 both that copyright notice and this permission notice appear in
19 supporting documentation, and that the name of CMU not be
20 used in advertising or publicity pertaining to distribution of the
21 software without specific, written prior permission.
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;
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 */
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 {
62 int sd; /* socket descriptor for this connection */
63 ipaddr addr; /* address of connected peer */
64 struct request_list *requests; /* Info about outstanding requests */
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
88 extern "C" {
89 #endif
90
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_);
94
95 #ifdef __cplusplus
96 }
97
98 #endif
99
100 #endif /* SQUID_SNMP_API_UTIL_H */