2 * $Id: snmp_rip2.c,v 5.0 2002/04/20 07:30:06 hardaker Exp $
6 * Smux module authored by Rohit Dube.
9 #include <net-snmp/net-snmp-config.h>
26 #if TIME_WITH_SYS_TIME
27 # include <sys/time.h>
31 # include <sys/time.h>
40 #include <sys/socket.h>
42 #include <sys/filio.h>
46 #include <netinet/in.h>
49 #include <net-snmp/net-snmp-includes.h>
50 #include <net-snmp/agent/net-snmp-agent-includes.h>
52 #include "snmp_rip2.h"
54 static oid max_rip_mib[] =
55 { 1, 3, 6, 1, 2, 1, 23, 3, 1, 9, 255, 255, 255, 255 };
56 static oid min_rip_mib[] = { 1, 3, 6, 1, 2, 1, 23, 1, 1, 0 };
57 extern u_char smux_type;
59 struct variable13 rip2_variables[] = {
60 {RIP2GLOBALROUTECHANGES, ASN_COUNTER, RONLY, var_rip2, 2, {1, 1}},
61 {RIP2GLOBALQUERIES, ASN_COUNTER, RONLY, var_rip2, 2, {1, 2}},
62 {RIP2IFSTATADDRESS, ASN_IPADDRESS, RONLY, var_rip2, 3, {2, 1, 1}},
63 {RIP2IFSTATRCVBADPKTS, ASN_COUNTER, RONLY, var_rip2, 3, {2, 1, 2}},
64 {RIP2IFSTATRCVBADROUTES, ASN_COUNTER, RONLY, var_rip2, 3, {2, 1, 3}},
65 {RIP2IFSTATSENTUPDATES, ASN_COUNTER, RONLY, var_rip2, 3, {2, 1, 4}},
66 {RIP2IFSTATSTATUS, ASN_INTEGER, RWRITE, var_rip2, 3, {2, 1, 5}},
67 {RIP2IFCONFADDRESS, ASN_IPADDRESS, RONLY, var_rip2, 3, {3, 1, 1}},
68 {RIP2IFCONFDOMAIN, ASN_OCTET_STR, RWRITE, var_rip2, 3, {3, 1, 2}},
69 {RIP2IFCONFAUTHTYPE, ASN_INTEGER, RWRITE, var_rip2, 3, {3, 1, 3}},
70 {RIP2IFCONFAUTHKEY, ASN_OCTET_STR, RWRITE, var_rip2, 3, {3, 1, 4}},
71 {RIP2IFCONFSEND, ASN_INTEGER, RWRITE, var_rip2, 3, {3, 1, 5}},
72 {RIP2IFCONFRECEIVE, ASN_INTEGER, RWRITE, var_rip2, 3, {3, 1, 6}},
73 {RIP2IFCONFDEFAULTMETRIC, ASN_INTEGER, RWRITE, var_rip2, 3, {3, 1, 7}},
74 {RIP2IFCONFSTATUS, ASN_INTEGER, RWRITE, var_rip2, 3, {3, 1, 8}},
75 {RIP2IFCONFSRCADDRESS, ASN_IPADDRESS, RWRITE, var_rip2, 3, {3, 1, 9}},
76 {RIP2PEERADDRESS, ASN_IPADDRESS, RONLY, var_rip2, 3, {4, 1, 1}},
77 {RIP2PEERDOMAIN, ASN_OCTET_STR, RONLY, var_rip2, 3, {4, 1, 2}},
78 {RIP2PEERLASTUPDATE, ASN_TIMETICKS, RONLY, var_rip2, 3, {4, 1, 3}},
79 {RIP2PEERVERSION, ASN_INTEGER, RONLY, var_rip2, 3, {4, 1, 4}},
80 {RIP2PEERRCVBADPKTS, ASN_COUNTER, RONLY, var_rip2, 3, {4, 1, 5}},
81 {RIP2PEERRCVBADROUTES, ASN_COUNTER, RONLY, var_rip2, 3, {4, 1, 6}}
84 oid rip2_variables_oid[] = { MIB, 23 };
89 REGISTER_MIB("smux/snmp_rip2", rip2_variables, variable13,
94 var_rip2(struct variable *vp,
96 int *length, int exact, int *var_len, WriteMethod ** write_method)
101 DEBUGMSGTL(("smux/snmp_rip2",
102 "[var_rip2] var len %d, oid requested Len %d-", *var_len,
104 DEBUGMSGOID(("smux/snmp_rip2", name, *length));
105 DEBUGMSG(("smux/snmp_rip2", "\n"));
108 * Pass on the request to Gated.
109 * If the request sent out was a get next, check to see if
110 * it lies in the rip2 range. If it doesn't, return NULL.
111 * In either case, make sure that errors are checked on the
118 *write_method = NULL;
121 * Donot allow access to the peer stuff as it crashes gated.
122 * However A GetNext on the last 23.3.1.9 variable will force gated into
123 * the peer stuff and cause it to crash.
124 * The only way to fix this is to either solve the Gated problem, or
125 * remove the peer variables from Gated itself and cause it to return
126 * NULL at the crossing. Currently doing the later.
130 * Reject GET and GETNEXT for anything above rip2ifconf range
132 result = snmp_oid_compare(name, *length, max_rip_mib,
133 sizeof(max_rip_mib) / sizeof(u_int));
136 DEBUGMSGTL(("smux/snmp_rip2", "Over shot\n"));
141 * for GETs we need to be in the rip2 range so reject anything below
143 result = snmp_oid_compare(name, *length, min_rip_mib,
144 sizeof(min_rip_mib) / sizeof(u_int));
145 if (exact && (result < 0)) {
146 DEBUGMSGTL(("smux/snmp_rip2",
147 "Exact but doesn't match length %d, size %d\n",
148 *length, sizeof(min_rip_mib)));
153 * On return, 'var' points to the value returned which is of length
154 * '*var_len'. 'name' points to the new (same as the one passed in for
155 * GETs) oid which has 'length' suboids.
156 * 'smux_type' contains the type of the variable.
158 var = smux_snmp_process(exact, name, length, var_len);
160 DEBUGMSGTL(("smux/snmp_rip2",
161 "[var_rip2] var len %d, oid obtained Len %d-", *var_len,
163 DEBUGMSGOID(("smux/snmp_rip2", name, *length));
164 DEBUGMSG(("smux/snmp_rip2", "\n"));
166 vp->type = smux_type;
169 * XXX Need a mechanism to return errors in gated's responses
176 * Any resullt returned should be within the rip2 tree.
177 * rip_mib - static u_int rip_mib[] = {1, 3, 6, 1, 2, 1, 23};
179 if (memcmp(rip_mib, name, sizeof(rip_mib)) != 0) {