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