]> git.proxmox.com Git - mirror_frr.git/blame - lib/smux.h
tests: Add test consecutive frrscript_call
[mirror_frr.git] / lib / smux.h
CommitLineData
718e3744 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 *
896014f4
DL
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
718e3744 19 */
20
21#ifndef _ZEBRA_SNMP_H
22#define _ZEBRA_SNMP_H
23
3a4c9688
VB
24#include <net-snmp/agent/net-snmp-agent-includes.h>
25#include <net-snmp/agent/snmp_vars.h>
718e3744 26
1cc5e682 27#include "thread.h"
ec48460e 28#include "hook.h"
1cc5e682 29
5e244469
RW
30#ifdef __cplusplus
31extern "C" {
32#endif
33
718e3744 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
8902dba6
PR
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
62e66e55
PR
66
67#define INETADDRESSTYPEUNKNOWN 0
68#define INETADDRESSTYPEIPV4 1
69#define INETADDRESSTYPEIPV6 2
70
3a4c9688 71#undef REGISTER_MIB
d62a17ae 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
78struct trap_object {
79 int namelen; /* Negative if the object is not indexed */
80 oid name[MAX_OID_LEN];
718e3744 81};
82
4eb8c74f
PR
83struct index_oid {
84 int indexlen;
85 oid indexname[MAX_OID_LEN];
86};
718e3744 87/* Declare SMUX return value. */
d62a17ae 88#define SNMP_LOCAL_VARIABLES \
89 static long snmp_int_val __attribute__((unused)); \
90 static struct in_addr snmp_in_addr_val __attribute__((unused));
834182ba 91 static uint8_t snmp_octet_val __attribute__((unused));
d62a17ae 92#define SNMP_INTEGER(V) \
93 (*var_len = sizeof(snmp_int_val), snmp_int_val = V, \
d7c0a89a 94 (uint8_t *)&snmp_int_val)
d62a17ae 95
834182ba
PR
96#define SNMP_OCTET(V) \
97 (*var_len = sizeof(snmp_octet_val), snmp_octet_val = V, \
98 (uint8_t *)&snmp_octet_val)
99
d62a17ae 100#define SNMP_IPADDRESS(V) \
101 (*var_len = sizeof(struct in_addr), snmp_in_addr_val = V, \
d7c0a89a 102 (uint8_t *)&snmp_in_addr_val)
d62a17ae 103
8902dba6
PR
104#define SNMP_IP6ADDRESS(V) (*var_len = sizeof(struct in6_addr), (uint8_t *)&V)
105
1ee746d9 106extern int smux_enabled(void);
107
d62a17ae 108extern void smux_init(struct thread_master *tm);
ec48460e 109extern void smux_agentx_enable(void);
d62a17ae 110extern void smux_register_mib(const char *, struct variable *, size_t, int,
111 oid[], size_t);
112extern int smux_header_generic(struct variable *, oid[], size_t *, int,
113 size_t *, WriteMethod **);
114extern int smux_header_table(struct variable *, oid *, size_t *, int, size_t *,
115 WriteMethod **);
b7c0d065
VB
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*/
97e21b4b
DS
138extern 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);
d62a17ae 141
4eb8c74f
PR
142extern 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);
1ee746d9 148
149extern void smux_events_update(void);
d62a17ae 150extern int oid_compare(const oid *, int, const oid *, int);
151extern void oid2in_addr(oid[], int, struct in_addr *);
5a224c19 152extern void oid2in6_addr(oid oid[], struct in6_addr *addr);
4f13e83d 153extern void oid2int(oid oid[], int *dest);
d62a17ae 154extern void *oid_copy(void *, const void *, size_t);
9e263221
PR
155extern void oid_copy_in_addr(oid[], const struct in_addr *);
156extern void oid_copy_in6_addr(oid[], const struct in6_addr *);
4f13e83d 157extern void oid_copy_int(oid oid[], int *val);
0d020cd6
PR
158extern void oid2string(oid oid[], int len, char *string);
159extern void oid_copy_str(oid oid[], const char *string, int len);
718e3744 160
8451921b 161DECLARE_HOOK(agentx_enabled, (), ());
ec48460e 162
5e244469
RW
163#ifdef __cplusplus
164}
165#endif
166
718e3744 167#endif /* _ZEBRA_SNMP_H */