]>
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 |
d62a17ae | 44 | #define REGISTER_MIB(descr, var, vartype, theoid) \ |
45 | smux_register_mib(descr, (struct variable *)var, \ | |
46 | sizeof(struct vartype), \ | |
47 | sizeof(var) / sizeof(struct vartype), theoid, \ | |
48 | sizeof(theoid) / sizeof(oid)) | |
49 | ||
50 | struct trap_object { | |
51 | int namelen; /* Negative if the object is not indexed */ | |
52 | oid name[MAX_OID_LEN]; | |
718e3744 | 53 | }; |
54 | ||
55 | /* Declare SMUX return value. */ | |
d62a17ae | 56 | #define SNMP_LOCAL_VARIABLES \ |
57 | static long snmp_int_val __attribute__((unused)); \ | |
58 | static struct in_addr snmp_in_addr_val __attribute__((unused)); | |
59 | ||
60 | #define SNMP_INTEGER(V) \ | |
61 | (*var_len = sizeof(snmp_int_val), snmp_int_val = V, \ | |
62 | (u_char *)&snmp_int_val) | |
63 | ||
64 | #define SNMP_IPADDRESS(V) \ | |
65 | (*var_len = sizeof(struct in_addr), snmp_in_addr_val = V, \ | |
66 | (u_char *)&snmp_in_addr_val) | |
67 | ||
68 | extern void smux_init(struct thread_master *tm); | |
69 | extern void smux_register_mib(const char *, struct variable *, size_t, int, | |
70 | oid[], size_t); | |
71 | extern int smux_header_generic(struct variable *, oid[], size_t *, int, | |
72 | size_t *, WriteMethod **); | |
73 | extern int smux_header_table(struct variable *, oid *, size_t *, int, size_t *, | |
74 | WriteMethod **); | |
b7c0d065 VB |
75 | |
76 | /* For traps, three OID are provided: | |
77 | ||
78 | 1. The enterprise OID to use (the last argument will be appended to | |
79 | it to form the SNMP trap OID) | |
80 | ||
81 | 2. The base OID for objects to be sent in traps. | |
82 | ||
83 | 3. The index OID for objects to be sent in traps. This index is used | |
84 | to designate a particular instance of a column. | |
85 | ||
86 | The provided trap object contains the bindings to be sent with the | |
87 | trap. The base OID will be prefixed to the provided OID and, if the | |
88 | length is positive, the requested OID is assumed to be a columnar | |
89 | object and the index OID will be appended. | |
90 | ||
91 | The two first arguments are the MIB registry used to locate the trap | |
92 | objects. | |
93 | ||
94 | The use of the arguments may differ depending on the implementation | |
95 | used. | |
96 | */ | |
d62a17ae | 97 | extern int smux_trap(struct variable *, size_t, const oid *, size_t, |
98 | const oid *, size_t, const oid *, size_t, | |
99 | const struct trap_object *, size_t, u_char); | |
100 | ||
101 | extern int oid_compare(const oid *, int, const oid *, int); | |
102 | extern void oid2in_addr(oid[], int, struct in_addr *); | |
103 | extern void *oid_copy(void *, const void *, size_t); | |
104 | extern void oid_copy_addr(oid[], struct in_addr *, int); | |
718e3744 | 105 | |
106 | #endif /* _ZEBRA_SNMP_H */ |