2 * Copyright (C) 2000 Jochen Friedrich <jochen@scram.de>
3 * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
5 * You should have received a copy of the GNU General Public License
6 * along with GNU Zebra; see the file COPYING. If not, write to the Free
7 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
14 #define SMUX_PORT_DEFAULT 199
16 #define SMUXMAXPKTSIZE 1500
17 #define SMUXMAXSTRLEN 256
19 #define SMUX_OPEN (ASN_APPLICATION | ASN_CONSTRUCTOR | 0)
20 #define SMUX_CLOSE (ASN_APPLICATION | ASN_PRIMITIVE | 1)
21 #define SMUX_RREQ (ASN_APPLICATION | ASN_CONSTRUCTOR | 2)
22 #define SMUX_RRSP (ASN_APPLICATION | ASN_PRIMITIVE | 3)
23 #define SMUX_SOUT (ASN_APPLICATION | ASN_PRIMITIVE | 4)
25 #define SMUX_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0)
26 #define SMUX_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1)
27 #define SMUX_GETRSP (ASN_CONTEXT | ASN_CONSTRUCTOR | 2)
28 #define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
30 /* Structures here are mostly compatible with UCD SNMP 4.1.1 */
32 #define MATCH_FAILED (-1)
33 #define MATCH_SUCCEEDED 0
37 #define REGISTER_MIB(descr, var, vartype, theoid) \
38 smux_register_mib(descr, (struct variable *)var, sizeof(struct vartype), \
39 sizeof(var)/sizeof(struct vartype), \
40 theoid, sizeof(theoid)/sizeof(oid))
42 typedef int (WriteMethod)(int action,
46 const unsigned char *statP,
50 typedef const unsigned char *(FindVarMethod)(struct variable *vp,
55 WriteMethod **write_method);
67 /* Index of the MIB.*/
70 /* Type of variable. */
73 /* Access control list. */
76 /* Callback function. */
77 FindVarMethod *findVar;
79 /* Suffix of the MIB. */
81 oid name[MAX_OID_LEN];
88 oid name[MAX_OID_LEN];
91 /* List of the variables. */
92 struct variable *variables;
94 /* Length of the variables list. */
97 /* Width of the variables list. */
100 /* Registered flag. */
104 /* Declare SMUX return value. */
105 #define SNMP_LOCAL_VARIABLES \
106 static int32_t snmp_int_val; \
107 static struct in_addr snmp_in_addr_val;
109 #define SNMP_INTEGER(V) \
111 *var_len = sizeof (int32_t), \
113 (u_char *) &snmp_int_val \
116 #define SNMP_IPADDRESS(V) \
118 *var_len = sizeof (struct in_addr), \
119 snmp_in_addr_val = V, \
120 (u_char *) &snmp_in_addr_val \
123 typedef enum smux_event_t {
124 SMUX_NONE, SMUX_CONNECT, SMUX_READ
127 void smux_init(oid [], size_t);
128 void smux_start(void);
129 void smux_stop(void);
130 void smux_register_mib(const char *, struct variable *, size_t, int, oid [], size_t);
131 int smux_header_generic (struct variable *, oid [], size_t *, int, size_t *,
134 int smux_str2oid (char *str, oid *my_oid, size_t *oid_len);
135 oid *smux_oid_dup (oid *objid, size_t objid_len);
136 int smux_register(void);