]>
Commit | Line | Data |
---|---|---|
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 DL |
27 | #include "thread.h" |
28 | ||
5e244469 RW |
29 | #ifdef __cplusplus |
30 | extern "C" { | |
31 | #endif | |
32 | ||
718e3744 | 33 | /* Structures here are mostly compatible with UCD SNMP 4.1.1 */ |
34 | #define MATCH_FAILED (-1) | |
35 | #define MATCH_SUCCEEDED 0 | |
36 | ||
37 | /* SYNTAX TruthValue from SNMPv2-TC. */ | |
38 | #define SNMP_TRUE 1 | |
39 | #define SNMP_FALSE 2 | |
40 | ||
41 | /* SYNTAX RowStatus from SNMPv2-TC. */ | |
42 | #define SNMP_VALID 1 | |
43 | #define SNMP_INVALID 2 | |
44 | ||
45 | #define IN_ADDR_SIZE sizeof(struct in_addr) | |
46 | ||
3a4c9688 | 47 | #undef REGISTER_MIB |
d62a17ae | 48 | #define REGISTER_MIB(descr, var, vartype, theoid) \ |
49 | smux_register_mib(descr, (struct variable *)var, \ | |
50 | sizeof(struct vartype), \ | |
51 | sizeof(var) / sizeof(struct vartype), theoid, \ | |
52 | sizeof(theoid) / sizeof(oid)) | |
53 | ||
54 | struct trap_object { | |
55 | int namelen; /* Negative if the object is not indexed */ | |
56 | oid name[MAX_OID_LEN]; | |
718e3744 | 57 | }; |
58 | ||
59 | /* Declare SMUX return value. */ | |
d62a17ae | 60 | #define SNMP_LOCAL_VARIABLES \ |
61 | static long snmp_int_val __attribute__((unused)); \ | |
62 | static struct in_addr snmp_in_addr_val __attribute__((unused)); | |
63 | ||
64 | #define SNMP_INTEGER(V) \ | |
65 | (*var_len = sizeof(snmp_int_val), snmp_int_val = V, \ | |
d7c0a89a | 66 | (uint8_t *)&snmp_int_val) |
d62a17ae | 67 | |
68 | #define SNMP_IPADDRESS(V) \ | |
69 | (*var_len = sizeof(struct in_addr), snmp_in_addr_val = V, \ | |
d7c0a89a | 70 | (uint8_t *)&snmp_in_addr_val) |
d62a17ae | 71 | |
72 | extern void smux_init(struct thread_master *tm); | |
73 | extern void smux_register_mib(const char *, struct variable *, size_t, int, | |
74 | oid[], size_t); | |
75 | extern int smux_header_generic(struct variable *, oid[], size_t *, int, | |
76 | size_t *, WriteMethod **); | |
77 | extern int smux_header_table(struct variable *, oid *, size_t *, int, size_t *, | |
78 | WriteMethod **); | |
b7c0d065 VB |
79 | |
80 | /* For traps, three OID are provided: | |
81 | ||
82 | 1. The enterprise OID to use (the last argument will be appended to | |
83 | it to form the SNMP trap OID) | |
84 | ||
85 | 2. The base OID for objects to be sent in traps. | |
86 | ||
87 | 3. The index OID for objects to be sent in traps. This index is used | |
88 | to designate a particular instance of a column. | |
89 | ||
90 | The provided trap object contains the bindings to be sent with the | |
91 | trap. The base OID will be prefixed to the provided OID and, if the | |
92 | length is positive, the requested OID is assumed to be a columnar | |
93 | object and the index OID will be appended. | |
94 | ||
95 | The two first arguments are the MIB registry used to locate the trap | |
96 | objects. | |
97 | ||
98 | The use of the arguments may differ depending on the implementation | |
99 | used. | |
100 | */ | |
d62a17ae | 101 | extern int smux_trap(struct variable *, size_t, const oid *, size_t, |
102 | const oid *, size_t, const oid *, size_t, | |
d7c0a89a | 103 | const struct trap_object *, size_t, uint8_t); |
d62a17ae | 104 | |
105 | extern int oid_compare(const oid *, int, const oid *, int); | |
106 | extern void oid2in_addr(oid[], int, struct in_addr *); | |
107 | extern void *oid_copy(void *, const void *, size_t); | |
4ce217af | 108 | extern void oid_copy_addr(oid[], const struct in_addr *, int); |
718e3744 | 109 | |
5e244469 RW |
110 | #ifdef __cplusplus |
111 | } | |
112 | #endif | |
113 | ||
718e3744 | 114 | #endif /* _ZEBRA_SNMP_H */ |