blob: 78460e68b83ef04f7ea1542b4b2968dea8c89c9a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#ifndef _ZEBRA_SNMP_H
23#define _ZEBRA_SNMP_H
24
Vincent Bernat3a4c9682012-05-23 00:52:46 +020025#include <net-snmp/agent/net-snmp-agent-includes.h>
26#include <net-snmp/agent/snmp_vars.h>
paul718e3742002-12-13 20:15:29 +000027
28/* Structures here are mostly compatible with UCD SNMP 4.1.1 */
29#define MATCH_FAILED (-1)
30#define MATCH_SUCCEEDED 0
31
32/* SYNTAX TruthValue from SNMPv2-TC. */
33#define SNMP_TRUE 1
34#define SNMP_FALSE 2
35
36/* SYNTAX RowStatus from SNMPv2-TC. */
37#define SNMP_VALID 1
38#define SNMP_INVALID 2
39
40#define IN_ADDR_SIZE sizeof(struct in_addr)
41
Vincent Bernat3a4c9682012-05-23 00:52:46 +020042#undef REGISTER_MIB
paul718e3742002-12-13 20:15:29 +000043#define REGISTER_MIB(descr, var, vartype, theoid) \
44 smux_register_mib(descr, (struct variable *)var, sizeof(struct vartype), \
45 sizeof(var)/sizeof(struct vartype), \
46 theoid, sizeof(theoid)/sizeof(oid))
47
paul718e3742002-12-13 20:15:29 +000048struct trap_object
49{
50 FindVarMethod *findVar;
vincent5e4914c2005-09-29 16:34:30 +000051 int namelen;
paul718e3742002-12-13 20:15:29 +000052 oid name[MAX_OID_LEN];
53};
54
55/* Declare SMUX return value. */
56#define SNMP_LOCAL_VARIABLES \
Chris Caputo42176e62009-06-02 18:37:11 +010057 static long snmp_int_val; \
paul718e3742002-12-13 20:15:29 +000058 static struct in_addr snmp_in_addr_val;
59
60#define SNMP_INTEGER(V) \
61 ( \
Chris Caputo42176e62009-06-02 18:37:11 +010062 *var_len = sizeof (snmp_int_val), \
paul718e3742002-12-13 20:15:29 +000063 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
paul8cc41982005-05-06 21:25:49 +000074extern void smux_init (struct thread_master *tm);
paul8cc41982005-05-06 21:25:49 +000075extern void smux_register_mib(const char *, struct variable *,
76 size_t, int, oid [], size_t);
77extern int smux_header_generic (struct variable *, oid [], size_t *,
78 int, size_t *, WriteMethod **);
Stephen Hemminger65d3fbb2009-05-15 09:59:03 -070079extern int smux_trap (const oid *, size_t, const oid *, size_t,
80 const struct trap_object *,
Vincent Bernat4b89e452012-05-24 21:22:01 +020081 size_t, u_char);
Vincent Bernat3a4c9682012-05-23 00:52:46 +020082
paul8cc41982005-05-06 21:25:49 +000083extern int oid_compare (oid *, int, oid *, int);
84extern void oid2in_addr (oid [], int, struct in_addr *);
Stephen Hemminger65d3fbb2009-05-15 09:59:03 -070085extern void *oid_copy (void *, const void *, size_t);
paul8cc41982005-05-06 21:25:49 +000086extern void oid_copy_addr (oid [], struct in_addr *, int);
paul718e3742002-12-13 20:15:29 +000087
88#endif /* _ZEBRA_SNMP_H */