]> git.proxmox.com Git - mirror_frr.git/blob - lib/smux.h
Merge pull request #10816 from anlancs/fix-bgdp-local-es-rt
[mirror_frr.git] / lib / smux.h
1 /* SNMP support
2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef _ZEBRA_SNMP_H
22 #define _ZEBRA_SNMP_H
23
24 #include <net-snmp/agent/net-snmp-agent-includes.h>
25 #include <net-snmp/agent/snmp_vars.h>
26
27 #include "thread.h"
28 #include "hook.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /* Structures here are mostly compatible with UCD SNMP 4.1.1 */
35 #define MATCH_FAILED (-1)
36 #define MATCH_SUCCEEDED 0
37
38 /* SYNTAX TruthValue from SNMPv2-TC. */
39 #define SNMP_TRUE 1
40 #define SNMP_FALSE 2
41
42 /* SYNTAX RowStatus from SNMPv2-TC. */
43 #define SNMP_VALID 1
44 #define SNMP_INVALID 2
45
46 #define IN_ADDR_SIZE sizeof(struct in_addr)
47
48 /* IANAipRouteProtocol */
49 #define IANAIPROUTEPROTOCOLOTHER 1
50 #define IANAIPROUTEPROTOCOLLOCAL 2
51 #define IANAIPROUTEPROTOCOLNETMGMT 3
52 #define IANAIPROUTEPROTOCOLICMP 4
53 #define IANAIPROUTEPROTOCOLEGP 5
54 #define IANAIPROUTEPROTOCOLGGP 6
55 #define IANAIPROUTEPROTOCOLHELLO 7
56 #define IANAIPROUTEPROTOCOLRIP 8
57 #define IANAIPROUTEPROTOCOLISIS 9
58 #define IANAIPROUTEPROTOCOLESIS 10
59 #define IANAIPROUTEPROTOCOLCISCOIGRP 11
60 #define IANAIPROUTEPROTOCOLBBNSPFIGP 12
61 #define IANAIPROUTEPROTOCOLOSPF 13
62 #define IANAIPROUTEPROTOCOLBGP 14
63 #define IANAIPROUTEPROTOCOLIDPR 15
64 #define IANAIPROUTEPROTOCOLCISCOEIGRP 16
65 #define IANAIPROUTEPROTOCOLDVMRP 17
66
67 #define INETADDRESSTYPEUNKNOWN 0
68 #define INETADDRESSTYPEIPV4 1
69 #define INETADDRESSTYPEIPV6 2
70
71 #undef REGISTER_MIB
72 #define REGISTER_MIB(descr, var, vartype, theoid) \
73 smux_register_mib(descr, (struct variable *)var, \
74 sizeof(struct vartype), \
75 sizeof(var) / sizeof(struct vartype), theoid, \
76 sizeof(theoid) / sizeof(oid))
77
78 struct trap_object {
79 int namelen; /* Negative if the object is not indexed */
80 oid name[MAX_OID_LEN];
81 };
82
83 struct index_oid {
84 int indexlen;
85 oid indexname[MAX_OID_LEN];
86 };
87 /* Declare SMUX return value. */
88 #define SNMP_LOCAL_VARIABLES \
89 static long snmp_int_val __attribute__((unused)); \
90 static struct in_addr snmp_in_addr_val __attribute__((unused));
91 static uint8_t snmp_octet_val __attribute__((unused));
92 #define SNMP_INTEGER(V) \
93 (*var_len = sizeof(snmp_int_val), snmp_int_val = V, \
94 (uint8_t *)&snmp_int_val)
95
96 #define SNMP_OCTET(V) \
97 (*var_len = sizeof(snmp_octet_val), snmp_octet_val = V, \
98 (uint8_t *)&snmp_octet_val)
99
100 #define SNMP_IPADDRESS(V) \
101 (*var_len = sizeof(struct in_addr), snmp_in_addr_val = V, \
102 (uint8_t *)&snmp_in_addr_val)
103
104 #define SNMP_IP6ADDRESS(V) (*var_len = sizeof(struct in6_addr), (uint8_t *)&V)
105
106 extern int smux_enabled(void);
107
108 extern void smux_init(struct thread_master *tm);
109 extern void smux_agentx_enable(void);
110 extern void smux_register_mib(const char *, struct variable *, size_t, int,
111 oid[], size_t);
112 extern int smux_header_generic(struct variable *, oid[], size_t *, int,
113 size_t *, WriteMethod **);
114 extern int smux_header_table(struct variable *, oid *, size_t *, int, size_t *,
115 WriteMethod **);
116
117 /* For traps, three OID are provided:
118
119 1. The enterprise OID to use (the last argument will be appended to
120 it to form the SNMP trap OID)
121
122 2. The base OID for objects to be sent in traps.
123
124 3. The index OID for objects to be sent in traps. This index is used
125 to designate a particular instance of a column.
126
127 The provided trap object contains the bindings to be sent with the
128 trap. The base OID will be prefixed to the provided OID and, if the
129 length is positive, the requested OID is assumed to be a columnar
130 object and the index OID will be appended.
131
132 The two first arguments are the MIB registry used to locate the trap
133 objects.
134
135 The use of the arguments may differ depending on the implementation
136 used.
137 */
138 extern void smux_trap(struct variable *, size_t, const oid *, size_t,
139 const oid *, size_t, const oid *, size_t,
140 const struct trap_object *, size_t, uint8_t);
141
142 extern int smux_trap_multi_index(struct variable *vp, size_t vp_len,
143 const oid *ename, size_t enamelen,
144 const oid *name, size_t namelen,
145 struct index_oid *iname, size_t index_len,
146 const struct trap_object *trapobj,
147 size_t trapobjlen, uint8_t sptrap);
148
149 extern void smux_events_update(void);
150 extern int oid_compare(const oid *, int, const oid *, int);
151 extern void oid2in_addr(oid[], int, struct in_addr *);
152 extern void oid2in6_addr(oid oid[], struct in6_addr *addr);
153 extern void oid2int(oid oid[], int *dest);
154 extern void *oid_copy(void *, const void *, size_t);
155 extern void oid_copy_in_addr(oid[], const struct in_addr *);
156 extern void oid_copy_in6_addr(oid[], const struct in6_addr *);
157 extern void oid_copy_int(oid oid[], int *val);
158 extern void oid2string(oid oid[], int len, char *string);
159 extern void oid_copy_str(oid oid[], const char *string, int len);
160
161 DECLARE_HOOK(agentx_enabled, (), ());
162
163 #ifdef __cplusplus
164 }
165 #endif
166
167 #endif /* _ZEBRA_SNMP_H */