[lib] remove autogenerated file, update .cvsignore
[jleu-quagga.git] / lib / smux.h
blob79d23e7065a25fdb65922aee0b18a8a7b1e379bf
1 /* SNMP support
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
9 * later version.
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
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.
22 #ifndef _ZEBRA_SNMP_H
23 #define _ZEBRA_SNMP_H
25 #define SMUX_PORT_DEFAULT 199
27 #define SMUXMAXPKTSIZE 1500
28 #define SMUXMAXSTRLEN 256
30 #define SMUX_OPEN (ASN_APPLICATION | ASN_CONSTRUCTOR | 0)
31 #define SMUX_CLOSE (ASN_APPLICATION | ASN_PRIMITIVE | 1)
32 #define SMUX_RREQ (ASN_APPLICATION | ASN_CONSTRUCTOR | 2)
33 #define SMUX_RRSP (ASN_APPLICATION | ASN_PRIMITIVE | 3)
34 #define SMUX_SOUT (ASN_APPLICATION | ASN_PRIMITIVE | 4)
36 #define SMUX_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0)
37 #define SMUX_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1)
38 #define SMUX_GETRSP (ASN_CONTEXT | ASN_CONSTRUCTOR | 2)
39 #define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
40 #define SMUX_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
42 #define SMUX_MAX_FAILURE 3
44 /* Structures here are mostly compatible with UCD SNMP 4.1.1 */
45 #define MATCH_FAILED (-1)
46 #define MATCH_SUCCEEDED 0
48 /* SYNTAX TruthValue from SNMPv2-TC. */
49 #define SNMP_TRUE 1
50 #define SNMP_FALSE 2
52 /* SYNTAX RowStatus from SNMPv2-TC. */
53 #define SNMP_VALID 1
54 #define SNMP_INVALID 2
56 #define IN_ADDR_SIZE sizeof(struct in_addr)
58 struct variable;
60 #define REGISTER_MIB(descr, var, vartype, theoid) \
61 smux_register_mib(descr, (struct variable *)var, sizeof(struct vartype), \
62 sizeof(var)/sizeof(struct vartype), \
63 theoid, sizeof(theoid)/sizeof(oid))
65 typedef int (WriteMethod)(int action,
66 u_char *var_val,
67 u_char var_val_type,
68 size_t var_val_len,
69 u_char *statP,
70 oid *name,
71 size_t length,
72 struct variable *v);
74 typedef u_char *(FindVarMethod)(struct variable *v,
75 oid *name,
76 size_t *length,
77 int exact,
78 size_t *var_len,
79 WriteMethod **write_method);
81 /* SNMP variable */
82 struct variable
84 /* Index of the MIB.*/
85 u_char magic;
87 /* Type of variable. */
88 char type;
90 /* Access control list. */
91 u_short acl;
93 /* Callback function. */
94 FindVarMethod *findVar;
96 /* Suffix of the MIB. */
97 int namelen;
98 oid name[MAX_OID_LEN];
101 /* SNMP tree. */
102 struct subtree
104 /* Tree's oid. */
105 oid name[MAX_OID_LEN];
106 u_char name_len;
108 /* List of the variables. */
109 struct variable *variables;
111 /* Length of the variables list. */
112 int variables_num;
114 /* Width of the variables list. */
115 int variables_width;
117 /* Registered flag. */
118 int registered;
121 struct trap_object
123 FindVarMethod *findVar;
124 int namelen;
125 oid name[MAX_OID_LEN];
128 /* Declare SMUX return value. */
129 #define SNMP_LOCAL_VARIABLES \
130 static int32_t snmp_int_val; \
131 static struct in_addr snmp_in_addr_val;
133 #define SNMP_INTEGER(V) \
135 *var_len = sizeof (int32_t), \
136 snmp_int_val = V, \
137 (u_char *) &snmp_int_val \
140 #define SNMP_IPADDRESS(V) \
142 *var_len = sizeof (struct in_addr), \
143 snmp_in_addr_val = V, \
144 (u_char *) &snmp_in_addr_val \
147 extern void smux_init (struct thread_master *tm);
148 extern void smux_start (void);
149 extern void smux_register_mib(const char *, struct variable *,
150 size_t, int, oid [], size_t);
151 extern int smux_header_generic (struct variable *, oid [], size_t *,
152 int, size_t *, WriteMethod **);
153 extern int smux_trap (oid *, size_t, oid *, size_t, struct trap_object *,
154 size_t, unsigned int, u_char);
155 extern int oid_compare (oid *, int, oid *, int);
156 extern void oid2in_addr (oid [], int, struct in_addr *);
157 extern void *oid_copy (void *, void *, size_t);
158 extern void oid_copy_addr (oid [], struct in_addr *, int);
160 #endif /* _ZEBRA_SNMP_H */