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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors