]> git.ipfire.org Git - thirdparty/squid.git/blob - include/snmp_vars.h
SourceFormat Enforcement
[thirdparty/squid.git] / include / snmp_vars.h
1 /*
2 * Copyright (C) 1996-2015 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_VARS_H
10 #define SQUID_SNMP_VARS_H
11
12 /**********************************************************************
13 *
14 * Copyright 1997 by Carnegie Mellon University
15 *
16 * All Rights Reserved
17 *
18 * Permission to use, copy, modify, and distribute this software and its
19 * documentation for any purpose and without fee is hereby granted,
20 * provided that the above copyright notice appear in all copies and that
21 * both that copyright notice and this permission notice appear in
22 * supporting documentation, and that the name of CMU not be
23 * used in advertising or publicity pertaining to distribution of the
24 * software without specific, written prior permission.
25 *
26 * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
27 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
28 * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
29 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
31 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
32 * SOFTWARE.
33 *
34 * Author: Ryan Troll <ryan+@andrew.cmu.edu>
35 *
36 **********************************************************************/
37
38 #include "asn1.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 struct variable_list {
45 struct variable_list *next_variable; /* NULL for last variable */
46 oid *name; /* Object identifier of variable */
47 int name_length; /* number of subid's in name */
48 u_char type; /* ASN type of variable */
49 union { /* value of variable */
50 int *integer;
51 u_char *string;
52 oid *objid;
53 } val;
54 int val_len;
55 };
56
57 struct variable_list *snmp_var_new(oid *, int);
58 struct variable_list *snmp_var_new_integer(oid *, int, int, unsigned char);
59 struct variable_list *snmp_var_clone(struct variable_list *);
60 void snmp_var_free(struct variable_list *);
61
62 u_char *snmp_var_EncodeVarBind(u_char *, int *, struct variable_list *, int);
63 u_char *snmp_var_DecodeVarBind(u_char *, int *, struct variable_list **, int);
64
65 #define MAX_NAME_LEN 64 /* number of subid's in a objid */
66
67 /* RFC 1902: Structure of Management Information for SNMPv2
68 *
69 * Defined Types
70 */
71 #define SMI_INTEGER ASN_INTEGER
72 #define SMI_STRING ASN_OCTET_STR
73 #define SMI_OBJID ASN_OBJECT_ID
74 #define SMI_NULLOBJ ASN_NULL
75 #define SMI_IPADDRESS (ASN_APPLICATION | 0) /* OCTET STRING, net byte order */
76 #define SMI_COUNTER32 (ASN_APPLICATION | 1) /* INTEGER */
77 #define SMI_GAUGE32 (ASN_APPLICATION | 2) /* INTEGER */
78 #define SMI_UNSIGNED32 SMI_GAUGE32
79 #define SMI_TIMETICKS (ASN_APPLICATION | 3) /* INTEGER */
80 #define SMI_OPAQUE (ASN_APPLICATION | 4) /* OCTET STRING */
81 #define SMI_COUNTER64 (ASN_APPLICATION | 6) /* INTEGER */
82
83 /* constants for enums for the MIB nodes
84 * cachePeerAddressType (InetAddressType / ASN_INTEGER)
85 * cacheClientAddressType (InetAddressType / ASN_INTEGER)
86 * Defined Types
87 */
88
89 #ifndef INETADDRESSTYPE_ENUMS
90 #define INETADDRESSTYPE_ENUMS
91
92 #define INETADDRESSTYPE_UNKNOWN 0
93 #define INETADDRESSTYPE_IPV4 1
94 #define INETADDRESSTYPE_IPV6 2
95 #define INETADDRESSTYPE_IPV4Z 3
96 #define INETADDRESSTYPE_IPV6Z 4
97 #define INETADDRESSTYPE_DNS 16
98
99 #endif /* INETADDRESSTYPE_ENUMS */
100
101 /*
102 * RFC 1905: Protocol Operations for SNMPv2
103 *
104 * Variable binding.
105 *
106 * VarBind ::=
107 * SEQUENCE {
108 * name ObjectName
109 * CHOICE {
110 * value ObjectSyntax
111 * unSpecified NULL
112 * noSuchObject[0] NULL
113 * noSuchInstance[1] NULL
114 * endOfMibView[2] NULL
115 * }
116 * }
117 */
118 #define SMI_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* noSuchObject[0] */
119 #define SMI_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* noSuchInstance[1] */
120 #define SMI_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* endOfMibView[2] */
121 typedef struct variable variable;
122 typedef struct variable_list variable_list;
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif /* SQUID_SNMP_VARS_H */
129