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
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
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. */
52 /* SYNTAX RowStatus from SNMPv2-TC. */
54 #define SNMP_INVALID 2
56 #define IN_ADDR_SIZE sizeof(struct in_addr)
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
,
74 typedef u_char
*(FindVarMethod
)(struct variable
*v
,
79 WriteMethod
**write_method
);
84 /* Index of the MIB.*/
87 /* Type of variable. */
90 /* Access control list. */
93 /* Callback function. */
94 FindVarMethod
*findVar
;
96 /* Suffix of the MIB. */
98 oid name
[MAX_OID_LEN
];
105 oid name
[MAX_OID_LEN
];
108 /* List of the variables. */
109 struct variable
*variables
;
111 /* Length of the variables list. */
114 /* Width of the variables list. */
117 /* Registered flag. */
123 FindVarMethod
*findVar
;
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), \
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 */