]>
Commit | Line | Data |
---|---|---|
5c193dec | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
5c193dec AJ |
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 | ||
b5638623 | 9 | #ifndef SQUID_SNMP_PDU_H |
10 | #define SQUID_SNMP_PDU_H | |
54f642bf | 11 | |
e1f7507e AJ |
12 | /* required for oid typedef */ |
13 | #include "asn1.h" | |
14 | ||
15 | #if HAVE_NETINET_IN_H | |
e1f7507e AJ |
16 | #include <netinet/in.h> |
17 | #endif | |
18 | ||
54f642bf | 19 | /********************************************************************** |
20 | * | |
21 | * Copyright 1997 by Carnegie Mellon University | |
c5dd4956 | 22 | * |
54f642bf | 23 | * All Rights Reserved |
c5dd4956 | 24 | * |
54f642bf | 25 | * Permission to use, copy, modify, and distribute this software and its |
26 | * documentation for any purpose and without fee is hereby granted, | |
27 | * provided that the above copyright notice appear in all copies and that | |
28 | * both that copyright notice and this permission notice appear in | |
29 | * supporting documentation, and that the name of CMU not be | |
30 | * used in advertising or publicity pertaining to distribution of the | |
31 | * software without specific, written prior permission. | |
c5dd4956 | 32 | * |
54f642bf | 33 | * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
34 | * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
35 | * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
36 | * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
37 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
38 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
39 | * SOFTWARE. | |
c5dd4956 | 40 | * |
54f642bf | 41 | * Author: Ryan Troll <ryan+@andrew.cmu.edu> |
c5dd4956 | 42 | * |
54f642bf | 43 | **********************************************************************/ |
44 | ||
e6ccf245 | 45 | #ifdef __cplusplus |
e1381638 | 46 | extern "C" { |
e6ccf245 | 47 | #endif |
48 | ||
f53969cc SM |
49 | /* An SNMP PDU */ |
50 | struct snmp_pdu { | |
51 | int command; /* Type of this PDU */ | |
52 | struct sockaddr_in address; /* Address of peer */ | |
53 | ||
54 | int reqid; /* Integer32: Request id */ | |
55 | int errstat; /* INTEGER: Error status */ | |
56 | int errindex; /* INTEGER: Error index */ | |
57 | ||
58 | /* SNMPv2 Bulk Request */ | |
59 | int non_repeaters; /* INTEGER: */ | |
60 | int max_repetitions; /* INTEGER: */ | |
61 | ||
62 | struct variable_list *variables; /* Variable Bindings */ | |
63 | ||
64 | /* Trap information */ | |
65 | oid *enterprise; /* System OID */ | |
66 | int enterprise_length; | |
67 | struct sockaddr_in agent_addr; /* address of object generating trap */ | |
68 | int trap_type; /* generic trap type */ | |
69 | int specific_type; /* specific type */ | |
70 | u_int time; /* Uptime */ | |
71 | }; | |
72 | ||
73 | struct snmp_pdu *snmp_pdu_create(int); | |
74 | struct snmp_pdu *snmp_pdu_clone(struct snmp_pdu *); | |
75 | struct snmp_pdu *snmp_pdu_fix(struct snmp_pdu *, int); | |
76 | struct snmp_pdu *snmp_fix_pdu(struct snmp_pdu *, int); | |
77 | void snmp_free_pdu(struct snmp_pdu *); | |
78 | void snmp_pdu_free(struct snmp_pdu *); | |
79 | ||
80 | u_char *snmp_pdu_encode(u_char *, int *, struct snmp_pdu *); | |
81 | u_char *snmp_pdu_decode(u_char *, int *, struct snmp_pdu *); | |
82 | ||
83 | /* Add a NULL Variable to a PDU */ | |
84 | void snmp_add_null_var(struct snmp_pdu *, oid *, int); | |
85 | ||
86 | /* RFC 1905: Protocol Operations for SNMPv2 | |
87 | * | |
88 | * RFC 1157: A Simple Network Management Protocol (SNMP) | |
89 | * | |
90 | * PDU Types | |
91 | */ | |
92 | #define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) | |
54f642bf | 93 | #define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) |
94 | #define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) | |
a56db080 | 95 | #ifdef UNUSED_CODE |
54f642bf | 96 | #define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) |
f53969cc | 97 | #define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /*Obsolete */ |
b2dcd1b0 | 98 | #endif |
54f642bf | 99 | #define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) |
b2dcd1b0 | 100 | #ifdef UNUSED_CODE |
54f642bf | 101 | #define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) |
102 | #define SNMP_PDU_V2TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) | |
103 | #define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) | |
a56db080 | 104 | #endif |
f53969cc SM |
105 | #define MAX_BINDINGS 2147483647 /* PDU Defaults */ |
106 | #define SNMP_DEFAULT_ERRSTAT -1 | |
107 | #define SNMP_DEFAULT_ERRINDEX -1 | |
108 | #define SNMP_DEFAULT_ADDRESS 0 | |
109 | #define SNMP_DEFAULT_REQID 0 | |
110 | ||
111 | /* RFC 1907: Management Information Base for SNMPv2 | |
112 | * | |
113 | * RFC 1157: A Simple Network Management Protocol (SNMP) | |
114 | * | |
115 | * Trap Types | |
116 | */ | |
c7b2de31 | 117 | #if UNUSED_CODE |
54f642bf | 118 | #define SNMP_TRAP_COLDSTART (0x0) |
119 | #define SNMP_TRAP_WARMSTART (0x1) | |
120 | #define SNMP_TRAP_LINKDOWN (0x2) | |
121 | #define SNMP_TRAP_LINKUP (0x3) | |
122 | #define SNMP_TRAP_AUTHENTICATIONFAILURE (0x4) | |
123 | #define SNMP_TRAP_EGPNEIGHBORLOSS (0x5) | |
124 | #define SNMP_TRAP_ENTERPRISESPECIFIC (0x6) | |
c7b2de31 | 125 | #endif |
b5638623 | 126 | |
e6ccf245 | 127 | #ifdef __cplusplus |
128 | } | |
129 | #endif | |
130 | ||
b5638623 | 131 | #endif /* SQUID_SNMP_PDU_H */ |
f53969cc | 132 |