]>
git.proxmox.com Git - mirror_frr.git/blob - lib/smux.h
2 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * This file is part of GNU Zebra.
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
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.
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
24 #include <net-snmp/agent/net-snmp-agent-includes.h>
25 #include <net-snmp/agent/snmp_vars.h>
34 /* Structures here are mostly compatible with UCD SNMP 4.1.1 */
35 #define MATCH_FAILED (-1)
36 #define MATCH_SUCCEEDED 0
38 /* SYNTAX TruthValue from SNMPv2-TC. */
42 /* SYNTAX RowStatus from SNMPv2-TC. */
44 #define SNMP_INVALID 2
46 #define IN_ADDR_SIZE sizeof(struct in_addr)
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
67 #define INETADDRESSTYPEUNKNOWN 0
68 #define INETADDRESSTYPEIPV4 1
69 #define INETADDRESSTYPEIPV6 2
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))
79 int namelen
; /* Negative if the object is not indexed */
80 oid name
[MAX_OID_LEN
];
85 oid indexname
[MAX_OID_LEN
];
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)
96 #define SNMP_OCTET(V) \
97 (*var_len = sizeof(snmp_octet_val), snmp_octet_val = V, \
98 (uint8_t *)&snmp_octet_val)
100 #define SNMP_IPADDRESS(V) \
101 (*var_len = sizeof(struct in_addr), snmp_in_addr_val = V, \
102 (uint8_t *)&snmp_in_addr_val)
104 #define SNMP_IP6ADDRESS(V) (*var_len = sizeof(struct in6_addr), (uint8_t *)&V)
106 extern int smux_enabled(void);
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,
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 *,
117 /* For traps, three OID are provided:
119 1. The enterprise OID to use (the last argument will be appended to
120 it to form the SNMP trap OID)
122 2. The base OID for objects to be sent in traps.
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.
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.
132 The two first arguments are the MIB registry used to locate the trap
135 The use of the arguments may differ depending on the implementation
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);
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
);
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
);
161 DECLARE_HOOK(agentx_enabled
, (), ());
167 #endif /* _ZEBRA_SNMP_H */