Debian Codegraph @

agent/mibgroup/mibII/ipCidrRouteTable_access.c

raw
1
2 /*
3 * Note: this file originally auto-generated by mib2c using
4 * : mib2c.access_functions.conf$
5 */
6
7 #include <net-snmp/net-snmp-config.h>
8 #include "route_headers.h"
9 #include <net-snmp/net-snmp-includes.h>
10 #include <net-snmp/agent/net-snmp-agent-includes.h>
11 #include "ipCidrRouteTable_access.h"
12 #include "ipCidrRouteTable_enums.h"
13
14 /*
15 * NOTE:
16 * - these GET routines MUST return freshly malloced data and must not
17 * return a pointer which is still in use somewhere else.
18 * - these SET routines must copy the incoming data and can not take
19 * ownership of the memory passed in by the val pointer.
20 */
21
22 /** a global static we'll make use of a lot to map to the right
23 datatype to return (which for SNMP integer's is always a long). */
24 static u_long long_ret;
25 static in_addr_t addr_ret;
26
27 /*
28 * User-defined data access functions for data in table ipCidrRouteTable
29 */
30
31 u_long *
32 get_ipCidrRouteDest(void *data_context, size_t * ret_len)
33 {
34 RTENTRY *ourroute = (RTENTRY *) data_context;
35 addr_ret = ((struct sockaddr_in *) (&ourroute->rt_dst))->sin_addr.s_addr;
36 *ret_len = sizeof(addr_ret);
37 return &addr_ret;
38 }
39
40 u_long *
41 get_ipCidrRouteMask(void *data_context, size_t * ret_len)
42 {
43 RTENTRY *ourroute = (RTENTRY *) data_context;
44 addr_ret = ((struct sockaddr_in *) (&ourroute->rt_genmask))->sin_addr.s_addr;
45 *ret_len = sizeof(addr_ret);
46 return &addr_ret;
47 }
48
49 long *
50 get_ipCidrRouteTos(void *data_context, size_t * ret_len)
51 {
52 RTENTRY *ourroute = (RTENTRY *) data_context;
53 long_ret = ourroute->rt_tos;
54 *ret_len = sizeof(long_ret);
55 return &long_ret;
56 }
57
58 u_long *
59 get_ipCidrRouteNextHop(void *data_context, size_t * ret_len)
60 {
61 RTENTRY *ourroute = (RTENTRY *) data_context;
62 addr_ret = ((struct sockaddr_in *) (&ourroute->rt_gateway))->sin_addr.s_addr;
63 *ret_len = sizeof(addr_ret);
64 return &addr_ret;
65 }
66
67 long *
68 get_ipCidrRouteIfIndex(void *data_context, size_t * ret_len)
69 {
70 RTENTRY *ourroute = (RTENTRY *) data_context;
71 long_ret = ourroute->rt_unit;
72 *ret_len = sizeof(long_ret);
73 return &long_ret;
74 }
75
76 int
77 set_ipCidrRouteIfIndex(void *data_context, long *val, size_t val_len)
78 {
79 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
80 }
81
82 long *
83 get_ipCidrRouteType(void *data_context, size_t * ret_len)
84 {
85 RTENTRY *ourroute = (RTENTRY *) data_context;
86
87 if (ourroute->rt_flags & RTF_UP) {
88 if (ourroute->rt_flags & RTF_GATEWAY) {
89 long_ret = IPCIDRROUTETYPE_REMOTE;
90 } else {
91 long_ret = IPCIDRROUTETYPE_LOCAL;
92 }
93 } else {
94 long_ret = IPCIDRROUTETYPE_REJECT;
95 }
96 *ret_len = sizeof(long_ret);
97 return &long_ret;
98
99 }
100
101 int
102 set_ipCidrRouteType(void *data_context, long *val, size_t val_len)
103 {
104 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
105 }
106
107 long *
108 get_ipCidrRouteProto(void *data_context, size_t * ret_len)
109 {
110 RTENTRY *ourroute = (RTENTRY *) data_context;
111 /* XXX: this is wacked */
112 long_ret = (ourroute->rt_flags & RTF_DYNAMIC)
113 ? IPCIDRROUTEPROTO_ICMP : IPCIDRROUTEPROTO_LOCAL;
114 *ret_len = sizeof(long_ret);
115 return &long_ret;
116 }
117
118 long *
119 get_ipCidrRouteAge(void *data_context, size_t * ret_len)
120 {
121 long_ret = 0; /* we don't know, and defval = 0 */
122 *ret_len = sizeof(long_ret);
123 return &long_ret;
124 }
125
126 oid *
127 get_ipCidrRouteInfo(void *data_context, size_t * ret_len)
128 {
129 static oid zerodotzero[2] = { 0, 0 };
130 *ret_len = sizeof(zerodotzero);
131 return zerodotzero;
132 }
133
134 int
135 set_ipCidrRouteInfo(void *data_context, oid * val, size_t val_len)
136 {
137 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
138 }
139
140 /** XXX: return a data pointer to the data for the ipCidrRouteNextHopAS column and set
141 ret_len to its proper size in bytes. */
142 long *
143 get_ipCidrRouteNextHopAS(void *data_context, size_t * ret_len)
144 {
145 long_ret = 0; /* we don't know, and defval = 0 */
146 *ret_len = sizeof(long_ret);
147 return &long_ret;
148 }
149
150 int
151 set_ipCidrRouteNextHopAS(void *data_context, long *val, size_t val_len)
152 {
153 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
154 }
155
156 long *
157 get_ipCidrRouteMetric1(void *data_context, size_t * ret_len)
158 {
159 RTENTRY *ourroute = (RTENTRY *) data_context;
160 long_ret = ourroute->rt_metric;
161 *ret_len = sizeof(long_ret);
162 return &long_ret;
163 }
164
165 int
166 set_ipCidrRouteMetric1(void *data_context, long *val, size_t val_len)
167 {
168 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
169 }
170
171 long *
172 get_ipCidrRouteMetric2(void *data_context, size_t * ret_len)
173 {
174 long_ret = -1; /* unused */
175 *ret_len = sizeof(long_ret);
176 return &long_ret;
177 }
178
179 /** XXX: Set the value of the ipCidrRouteMetric2 column and return
180 SNMPERR_SUCCESS on SNMPERR_GENERR on failure. */
181 int
182 set_ipCidrRouteMetric2(void *data_context, long *val, size_t val_len)
183 {
184 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
185 }
186
187 /** XXX: return a data pointer to the data for the ipCidrRouteMetric3 column and set
188 ret_len to its proper size in bytes. */
189 long *
190 get_ipCidrRouteMetric3(void *data_context, size_t * ret_len)
191 {
192 long_ret = -1; /* unused */
193 *ret_len = sizeof(long_ret);
194 return &long_ret;
195 }
196
197 /** XXX: Set the value of the ipCidrRouteMetric3 column and return
198 SNMPERR_SUCCESS on SNMPERR_GENERR on failure. */
199 int
200 set_ipCidrRouteMetric3(void *data_context, long *val, size_t val_len)
201 {
202 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
203 }
204
205 /** XXX: return a data pointer to the data for the ipCidrRouteMetric4 column and set
206 ret_len to its proper size in bytes. */
207 long *
208 get_ipCidrRouteMetric4(void *data_context, size_t * ret_len)
209 {
210 long_ret = -1; /* unused */
211 *ret_len = sizeof(long_ret);
212 return &long_ret;
213 }
214
215 /** XXX: Set the value of the ipCidrRouteMetric4 column and return
216 SNMPERR_SUCCESS on SNMPERR_GENERR on failure. */
217 int
218 set_ipCidrRouteMetric4(void *data_context, long *val, size_t val_len)
219 {
220 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
221 }
222
223 /** XXX: return a data pointer to the data for the ipCidrRouteMetric5 column and set
224 ret_len to its proper size in bytes. */
225 long *
226 get_ipCidrRouteMetric5(void *data_context, size_t * ret_len)
227 {
228 long_ret = -1; /* unused */
229 *ret_len = sizeof(long_ret);
230 return &long_ret;
231 }
232
233 /** XXX: Set the value of the ipCidrRouteMetric5 column and return
234 SNMPERR_SUCCESS on SNMPERR_GENERR on failure. */
235 int
236 set_ipCidrRouteMetric5(void *data_context, long *val, size_t val_len)
237 {
238 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
239 }
240
241 /** XXX: return a data pointer to the data for the ipCidrRouteStatus column and set
242 ret_len to its proper size in bytes. */
243 long *
244 get_ipCidrRouteStatus(void *data_context, size_t * ret_len)
245 {
246 /* the only value supported for real routes */
247 long_ret = IPCIDRROUTESTATUS_ACTIVE;
248 *ret_len = sizeof(long_ret);
249 return &long_ret;
250 }
251
252 /** XXX: Set the value of the ipCidrRouteStatus column and return
253 SNMPERR_SUCCESS on SNMPERR_GENERR on failure. */
254 int
255 set_ipCidrRouteStatus(void *data_context, long *val, size_t val_len)
256 {
257 return SNMP_ERR_NOERROR; /** XXX: change if an error occurs */
258 }