Debian Codegraph @

agent/mibgroup/udp-mib/udpEndpointTable/udpEndpointTable_interface.c

raw
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * version : 1.67 $ of : mfd-interface.m2c,v $
4 *
5 * $Id$
6 */
7 /*
8 * *********************************************************************
9 * *********************************************************************
10 * *********************************************************************
11 * *** ***
12 * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ***
13 * *** ***
14 * *** ***
15 * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. ***
16 * *** ***
17 * *** ***
18 * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND ***
19 * *** ***
20 * *** ***
21 * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. ***
22 * *** ***
23 * *** ***
24 * *********************************************************************
25 * *********************************************************************
26 * *********************************************************************
27 */
28
29 /*
30 * standard Net-SNMP includes
31 */
32 #include <net-snmp/net-snmp-config.h>
33 #include <net-snmp/net-snmp-features.h>
34 #include <net-snmp/net-snmp-includes.h>
35 #include <net-snmp/agent/net-snmp-agent-includes.h>
36
37 /*
38 * include our parent header
39 */
40 #include "udpEndpointTable.h"
41
42
43 #include <net-snmp/agent/table_container.h>
44 #include <net-snmp/library/container.h>
45
46 #include "udpEndpointTable_interface.h"
47
48 #include <ctype.h>
49
50 netsnmp_feature_child_of(udpEndpointTable_external_access, libnetsnmpmibs);
51
52 netsnmp_feature_require(row_merge);
53 netsnmp_feature_require(baby_steps);
54 netsnmp_feature_require(check_all_requests_error);
55
56
57 netsnmp_feature_child_of(udpEndpointTable_container_size, udpEndpointTable_external_access);
58 netsnmp_feature_child_of(udpEndpointTable_registration_set, udpEndpointTable_external_access);
59 netsnmp_feature_child_of(udpEndpointTable_registration_get, udpEndpointTable_external_access);
60 netsnmp_feature_child_of(udpEndpointTable_container_get, udpEndpointTable_external_access);
61
62 /**********************************************************************
63 **********************************************************************
64 ***
65 *** Table udpEndpointTable
66 ***
67 **********************************************************************
68 **********************************************************************/
69 /*
70 * UDP-MIB::udpEndpointTable is subid 7 of udp.
71 * Its status is Current.
72 * OID: .1.3.6.1.2.1.7.7, length: 8
73 */
74 typedef struct udpEndpointTable_interface_ctx_s {
75
76 netsnmp_container *container;
77 netsnmp_cache *cache;
78
79 udpEndpointTable_registration *user_ctx;
80
81 netsnmp_table_registration_info tbl_info;
82
83 netsnmp_baby_steps_access_methods access_multiplexer;
84
85 } udpEndpointTable_interface_ctx;
86
87 static udpEndpointTable_interface_ctx udpEndpointTable_if_ctx;
88
89 static void
90 _udpEndpointTable_container_init(udpEndpointTable_interface_ctx * if_ctx);
91 static void
92 _udpEndpointTable_container_shutdown(udpEndpointTable_interface_ctx *
93 if_ctx);
94
95 #ifndef NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_CONTAINER_GET
96 netsnmp_container *
97 udpEndpointTable_container_get(void)
98 {
99 return udpEndpointTable_if_ctx.container;
100 }
101 #endif /* NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_CONTAINER_GET */
102
103 #ifndef NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_REGISTRATION_GET
104 udpEndpointTable_registration *
105 udpEndpointTable_registration_get(void)
106 {
107 return udpEndpointTable_if_ctx.user_ctx;
108 }
109 #endif /* NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_REGISTRATION_GET */
110
111 #ifndef NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_REGISTRATION_SET
112 udpEndpointTable_registration *
113 udpEndpointTable_registration_set(udpEndpointTable_registration * newreg)
114 {
115 udpEndpointTable_registration *old = udpEndpointTable_if_ctx.user_ctx;
116 udpEndpointTable_if_ctx.user_ctx = newreg;
117 return old;
118 }
119 #endif /* NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_REGISTRATION_SET */
120
121 #ifndef NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_CONTAINER_SIZE
122 int
123 udpEndpointTable_container_size(void)
124 {
125 return CONTAINER_SIZE(udpEndpointTable_if_ctx.container);
126 }
127 #endif /* NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_CONTAINER_SIZE */
128
129 /*
130 * mfd multiplexer modes
131 */
132 static Netsnmp_Node_Handler _mfd_udpEndpointTable_pre_request;
133 static Netsnmp_Node_Handler _mfd_udpEndpointTable_post_request;
134 static Netsnmp_Node_Handler _mfd_udpEndpointTable_object_lookup;
135 static Netsnmp_Node_Handler _mfd_udpEndpointTable_get_values;
136 /**
137 * @internal
138 * Initialize the table udpEndpointTable
139 * (Define its contents and how it's structured)
140 */
141 void
142 _udpEndpointTable_initialize_interface(udpEndpointTable_registration *
143 reg_ptr, u_long flags)
144 {
145 netsnmp_baby_steps_access_methods *access_multiplexer =
146 &udpEndpointTable_if_ctx.access_multiplexer;
147 netsnmp_table_registration_info *tbl_info =
148 &udpEndpointTable_if_ctx.tbl_info;
149 netsnmp_handler_registration *reginfo;
150 netsnmp_mib_handler *handler;
151 int mfd_modes = 0;
152
153 DEBUGMSGTL(("internal:udpEndpointTable:_udpEndpointTable_initialize_interface", "called\n"));
154
155
156 /*************************************************
157 *
158 * save interface context for udpEndpointTable
159 */
160 /*
161 * Setting up the table's definition
162 */
163 netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
164 /** index: udpEndpointLocalAddressType */
165 ASN_OCTET_STR,
166 /** index: udpEndpointLocalAddress */
167 ASN_UNSIGNED,
168 /** index: udpEndpointLocalPort */
169 ASN_INTEGER,
170 /** index: udpEndpointRemoteAddressType */
171 ASN_OCTET_STR,
172 /** index: udpEndpointRemoteAddress */
173 ASN_UNSIGNED,
174 /** index: udpEndpointRemotePort */
175 ASN_UNSIGNED,
176 /** index: udpEndpointInstance */
177 0);
178
179 /*
180 * Define the minimum and maximum accessible columns. This
181 * optimizes retrieval.
182 */
183 tbl_info->min_column = UDPENDPOINTTABLE_MIN_COL;
184 tbl_info->max_column = UDPENDPOINTTABLE_MAX_COL;
185
186 /*
187 * save users context
188 */
189 udpEndpointTable_if_ctx.user_ctx = reg_ptr;
190
191 /*
192 * call data access initialization code
193 */
194 udpEndpointTable_init_data(reg_ptr);
195
196 /*
197 * set up the container
198 */
199 _udpEndpointTable_container_init(&udpEndpointTable_if_ctx);
200 if (NULL == udpEndpointTable_if_ctx.container) {
201 snmp_log(LOG_ERR,
202 "could not initialize container for udpEndpointTable\n");
203 return;
204 }
205
206 /*
207 * access_multiplexer: REQUIRED wrapper for get request handling
208 */
209 access_multiplexer->object_lookup =
210 _mfd_udpEndpointTable_object_lookup;
211 access_multiplexer->get_values = _mfd_udpEndpointTable_get_values;
212
213 /*
214 * no wrappers yet
215 */
216 access_multiplexer->pre_request = _mfd_udpEndpointTable_pre_request;
217 access_multiplexer->post_request = _mfd_udpEndpointTable_post_request;
218
219
220 /*************************************************
221 *
222 * Create a registration, save our reg data, register table.
223 */
224 DEBUGMSGTL(("udpEndpointTable:init_udpEndpointTable",
225 "Registering udpEndpointTable as a mibs-for-dummies table.\n"));
226 handler =
227 netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
228 reginfo =
229 netsnmp_handler_registration_create("udpEndpointTable", handler,
230 udpEndpointTable_oid,
231 udpEndpointTable_oid_size,
232 HANDLER_CAN_BABY_STEP |
233 HANDLER_CAN_RONLY);
234 if (NULL == reginfo) {
235 snmp_log(LOG_ERR, "error registering table udpEndpointTable\n");
236 return;
237 }
238 reginfo->my_reg_void = &udpEndpointTable_if_ctx;
239
240 /*************************************************
241 *
242 * set up baby steps handler, create it and inject it
243 */
244 if (access_multiplexer->object_lookup)
245 mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
246 if (access_multiplexer->pre_request)
247 mfd_modes |= BABY_STEP_PRE_REQUEST;
248 if (access_multiplexer->post_request)
249 mfd_modes |= BABY_STEP_POST_REQUEST;
250
251 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
252 /* XXX - are these actually necessary? */
253 if (access_multiplexer->set_values)
254 mfd_modes |= BABY_STEP_SET_VALUES;
255 if (access_multiplexer->irreversible_commit)
256 mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
257 if (access_multiplexer->object_syntax_checks)
258 mfd_modes |= BABY_STEP_CHECK_OBJECT;
259
260 if (access_multiplexer->undo_setup)
261 mfd_modes |= BABY_STEP_UNDO_SETUP;
262 if (access_multiplexer->undo_cleanup)
263 mfd_modes |= BABY_STEP_UNDO_CLEANUP;
264 if (access_multiplexer->undo_sets)
265 mfd_modes |= BABY_STEP_UNDO_SETS;
266
267 if (access_multiplexer->row_creation)
268 mfd_modes |= BABY_STEP_ROW_CREATE;
269 if (access_multiplexer->consistency_checks)
270 mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
271 if (access_multiplexer->commit)
272 mfd_modes |= BABY_STEP_COMMIT;
273 if (access_multiplexer->undo_commit)
274 mfd_modes |= BABY_STEP_UNDO_COMMIT;
275 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
276
277 handler = netsnmp_baby_steps_handler_get(mfd_modes);
278 netsnmp_inject_handler(reginfo, handler);
279
280 /*************************************************
281 *
282 * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
283 */
284 handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
285 netsnmp_inject_handler(reginfo, handler);
286
287 /*************************************************
288 *
289 * inject container_table helper
290 */
291 handler =
292 netsnmp_container_table_handler_get(tbl_info,
293 udpEndpointTable_if_ctx.
294 container,
295 TABLE_CONTAINER_KEY_NETSNMP_INDEX);
296 netsnmp_inject_handler(reginfo, handler);
297
298 /*************************************************
299 *
300 * inject cache helper
301 */
302 if (NULL != udpEndpointTable_if_ctx.cache) {
303 handler = netsnmp_cache_handler_get(udpEndpointTable_if_ctx.cache);
304 netsnmp_inject_handler(reginfo, handler);
305 }
306
307 /*
308 * register table
309 */
310 netsnmp_register_table(reginfo, tbl_info);
311
312 } /* _udpEndpointTable_initialize_interface */
313
314 /**
315 * @internal
316 * Shutdown the table udpEndpointTable
317 */
318 void
319 _udpEndpointTable_shutdown_interface(udpEndpointTable_registration *
320 reg_ptr)
321 {
322 /*
323 * shutdown the container
324 */
325 _udpEndpointTable_container_shutdown(&udpEndpointTable_if_ctx);
326 }
327
328 void
329 udpEndpointTable_valid_columns_set(netsnmp_column_info *vc)
330 {
331 udpEndpointTable_if_ctx.tbl_info.valid_columns = vc;
332 } /* udpEndpointTable_valid_columns_set */
333
334 /**
335 * @internal
336 * convert the index component stored in the context to an oid
337 */
338 int
339 udpEndpointTable_index_to_oid(netsnmp_index * oid_idx,
340 udpEndpointTable_mib_index * mib_idx)
341 {
342 int err = SNMP_ERR_NOERROR;
343
344 /*
345 * temp storage for parsing indexes
346 */
347 /*
348 * udpEndpointLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
349 */
350 netsnmp_variable_list var_udpEndpointLocalAddressType;
351 /*
352 * udpEndpointLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
353 */
354 netsnmp_variable_list var_udpEndpointLocalAddress;
355 /*
356 * udpEndpointLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
357 */
358 netsnmp_variable_list var_udpEndpointLocalPort;
359 /*
360 * udpEndpointRemoteAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
361 */
362 netsnmp_variable_list var_udpEndpointRemoteAddressType;
363 /*
364 * udpEndpointRemoteAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
365 */
366 netsnmp_variable_list var_udpEndpointRemoteAddress;
367 /*
368 * udpEndpointRemotePort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
369 */
370 netsnmp_variable_list var_udpEndpointRemotePort;
371 /*
372 * udpEndpointInstance(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h
373 */
374 netsnmp_variable_list var_udpEndpointInstance;
375
376 /*
377 * set up varbinds
378 */
379 memset(&var_udpEndpointLocalAddressType, 0x00,
380 sizeof(var_udpEndpointLocalAddressType));
381 var_udpEndpointLocalAddressType.type = ASN_INTEGER;
382 memset(&var_udpEndpointLocalAddress, 0x00,
383 sizeof(var_udpEndpointLocalAddress));
384 var_udpEndpointLocalAddress.type = ASN_OCTET_STR;
385 memset(&var_udpEndpointLocalPort, 0x00,
386 sizeof(var_udpEndpointLocalPort));
387 var_udpEndpointLocalPort.type = ASN_UNSIGNED;
388 memset(&var_udpEndpointRemoteAddressType, 0x00,
389 sizeof(var_udpEndpointRemoteAddressType));
390 var_udpEndpointRemoteAddressType.type = ASN_INTEGER;
391 memset(&var_udpEndpointRemoteAddress, 0x00,
392 sizeof(var_udpEndpointRemoteAddress));
393 var_udpEndpointRemoteAddress.type = ASN_OCTET_STR;
394 memset(&var_udpEndpointRemotePort, 0x00,
395 sizeof(var_udpEndpointRemotePort));
396 var_udpEndpointRemotePort.type = ASN_UNSIGNED;
397 memset(&var_udpEndpointInstance, 0x00,
398 sizeof(var_udpEndpointInstance));
399 var_udpEndpointInstance.type = ASN_UNSIGNED;
400
401 /*
402 * chain temp index varbinds together
403 */
404 var_udpEndpointLocalAddressType.next_variable =
405 &var_udpEndpointLocalAddress;
406 var_udpEndpointLocalAddress.next_variable = &var_udpEndpointLocalPort;
407 var_udpEndpointLocalPort.next_variable =
408 &var_udpEndpointRemoteAddressType;
409 var_udpEndpointRemoteAddressType.next_variable =
410 &var_udpEndpointRemoteAddress;
411 var_udpEndpointRemoteAddress.next_variable =
412 &var_udpEndpointRemotePort;
413 var_udpEndpointRemotePort.next_variable = &var_udpEndpointInstance;
414 var_udpEndpointInstance.next_variable = NULL;
415
416
417 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_index_to_oid",
418 "called\n"));
419
420 /*
421 * udpEndpointLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
422 */
423 snmp_set_var_value(&var_udpEndpointLocalAddressType,
424 (u_char *) & mib_idx->udpEndpointLocalAddressType,
425 sizeof(mib_idx->udpEndpointLocalAddressType));
426
427 /*
428 * udpEndpointLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
429 */
430 snmp_set_var_value(&var_udpEndpointLocalAddress,
431 (u_char *) & mib_idx->udpEndpointLocalAddress,
432 mib_idx->udpEndpointLocalAddress_len *
433 sizeof(mib_idx->udpEndpointLocalAddress[0]));
434
435 /*
436 * udpEndpointLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
437 */
438 snmp_set_var_value(&var_udpEndpointLocalPort,
439 (u_char *) & mib_idx->udpEndpointLocalPort,
440 sizeof(mib_idx->udpEndpointLocalPort));
441
442 /*
443 * udpEndpointRemoteAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
444 */
445 snmp_set_var_value(&var_udpEndpointRemoteAddressType,
446 (u_char *) & mib_idx->udpEndpointRemoteAddressType,
447 sizeof(mib_idx->udpEndpointRemoteAddressType));
448
449 /*
450 * udpEndpointRemoteAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
451 */
452 snmp_set_var_value(&var_udpEndpointRemoteAddress,
453 (u_char *) & mib_idx->udpEndpointRemoteAddress,
454 mib_idx->udpEndpointRemoteAddress_len *
455 sizeof(mib_idx->udpEndpointRemoteAddress[0]));
456
457 /*
458 * udpEndpointRemotePort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
459 */
460 snmp_set_var_value(&var_udpEndpointRemotePort,
461 (u_char *) & mib_idx->udpEndpointRemotePort,
462 sizeof(mib_idx->udpEndpointRemotePort));
463
464 /*
465 * udpEndpointInstance(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h
466 */
467 snmp_set_var_value(&var_udpEndpointInstance,
468 (u_char *) & mib_idx->udpEndpointInstance,
469 sizeof(mib_idx->udpEndpointInstance));
470
471
472 err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
473 NULL, 0, &var_udpEndpointLocalAddressType);
474 if (err)
475 snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
476
477 /*
478 * parsing may have allocated memory. free it.
479 */
480 snmp_reset_var_buffers(&var_udpEndpointLocalAddressType);
481
482 return err;
483 } /* udpEndpointTable_index_to_oid */
484
485 /**
486 * extract udpEndpointTable indexes from a netsnmp_index
487 *
488 * @retval SNMP_ERR_NOERROR : no error
489 * @retval SNMP_ERR_GENERR : error
490 */
491 int
492 udpEndpointTable_index_from_oid(netsnmp_index * oid_idx,
493 udpEndpointTable_mib_index * mib_idx)
494 {
495 int err = SNMP_ERR_NOERROR;
496
497 /*
498 * temp storage for parsing indexes
499 */
500 /*
501 * udpEndpointLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
502 */
503 netsnmp_variable_list var_udpEndpointLocalAddressType;
504 /*
505 * udpEndpointLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
506 */
507 netsnmp_variable_list var_udpEndpointLocalAddress;
508 /*
509 * udpEndpointLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
510 */
511 netsnmp_variable_list var_udpEndpointLocalPort;
512 /*
513 * udpEndpointRemoteAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
514 */
515 netsnmp_variable_list var_udpEndpointRemoteAddressType;
516 /*
517 * udpEndpointRemoteAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
518 */
519 netsnmp_variable_list var_udpEndpointRemoteAddress;
520 /*
521 * udpEndpointRemotePort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H
522 */
523 netsnmp_variable_list var_udpEndpointRemotePort;
524 /*
525 * udpEndpointInstance(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/h
526 */
527 netsnmp_variable_list var_udpEndpointInstance;
528
529 /*
530 * set up varbinds
531 */
532 memset(&var_udpEndpointLocalAddressType, 0x00,
533 sizeof(var_udpEndpointLocalAddressType));
534 var_udpEndpointLocalAddressType.type = ASN_INTEGER;
535 memset(&var_udpEndpointLocalAddress, 0x00,
536 sizeof(var_udpEndpointLocalAddress));
537 var_udpEndpointLocalAddress.type = ASN_OCTET_STR;
538 memset(&var_udpEndpointLocalPort, 0x00,
539 sizeof(var_udpEndpointLocalPort));
540 var_udpEndpointLocalPort.type = ASN_UNSIGNED;
541 memset(&var_udpEndpointRemoteAddressType, 0x00,
542 sizeof(var_udpEndpointRemoteAddressType));
543 var_udpEndpointRemoteAddressType.type = ASN_INTEGER;
544 memset(&var_udpEndpointRemoteAddress, 0x00,
545 sizeof(var_udpEndpointRemoteAddress));
546 var_udpEndpointRemoteAddress.type = ASN_OCTET_STR;
547 memset(&var_udpEndpointRemotePort, 0x00,
548 sizeof(var_udpEndpointRemotePort));
549 var_udpEndpointRemotePort.type = ASN_UNSIGNED;
550 memset(&var_udpEndpointInstance, 0x00,
551 sizeof(var_udpEndpointInstance));
552 var_udpEndpointInstance.type = ASN_UNSIGNED;
553
554 /*
555 * chain temp index varbinds together
556 */
557 var_udpEndpointLocalAddressType.next_variable =
558 &var_udpEndpointLocalAddress;
559 var_udpEndpointLocalAddress.next_variable = &var_udpEndpointLocalPort;
560 var_udpEndpointLocalPort.next_variable =
561 &var_udpEndpointRemoteAddressType;
562 var_udpEndpointRemoteAddressType.next_variable =
563 &var_udpEndpointRemoteAddress;
564 var_udpEndpointRemoteAddress.next_variable =
565 &var_udpEndpointRemotePort;
566 var_udpEndpointRemotePort.next_variable = &var_udpEndpointInstance;
567 var_udpEndpointInstance.next_variable = NULL;
568
569
570 DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_index_from_oid",
571 "called\n"));
572
573 /*
574 * parse the oid into the individual index components
575 */
576 err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
577 &var_udpEndpointLocalAddressType);
578 if (err == SNMP_ERR_NOERROR) {
579 /*
580 * copy out values
581 */
582 mib_idx->udpEndpointLocalAddressType =
583 *((u_long *) var_udpEndpointLocalAddressType.val.string);
584 /*
585 * NOTE: val_len is in bytes, udpEndpointLocalAddress_len might not be
586 */
587 if (var_udpEndpointLocalAddress.val_len >
588 sizeof(mib_idx->udpEndpointLocalAddress))
589 err = SNMP_ERR_GENERR;
590 else {
591 memcpy(mib_idx->udpEndpointLocalAddress,
592 var_udpEndpointLocalAddress.val.string,
593 var_udpEndpointLocalAddress.val_len);
594 mib_idx->udpEndpointLocalAddress_len =
595 var_udpEndpointLocalAddress.val_len /
596 sizeof(mib_idx->udpEndpointLocalAddress[0]);
597 }
598 mib_idx->udpEndpointLocalPort =
599 *((u_long *) var_udpEndpointLocalPort.val.string);
600 mib_idx->udpEndpointRemoteAddressType =
601 *((u_long *) var_udpEndpointRemoteAddressType.val.string);
602 /*
603 * NOTE: val_len is in bytes, udpEndpointRemoteAddress_len might not be
604 */
605 if (var_udpEndpointRemoteAddress.val_len >
606 sizeof(mib_idx->udpEndpointRemoteAddress))
607 err = SNMP_ERR_GENERR;
608 else {
609 memcpy(mib_idx->udpEndpointRemoteAddress,
610 var_udpEndpointRemoteAddress.val.string,
611 var_udpEndpointRemoteAddress.val_len);
612 mib_idx->udpEndpointRemoteAddress_len =
613 var_udpEndpointRemoteAddress.val_len /
614 sizeof(mib_idx->udpEndpointRemoteAddress[0]);
615 }
616 mib_idx->udpEndpointRemotePort =
617 *((u_long *) var_udpEndpointRemotePort.val.string);
618 mib_idx->udpEndpointInstance =
619 *((u_long *) var_udpEndpointInstance.val.string);
620
621
622 }
623
624 /*
625 * parsing may have allocated memory. free it.
626 */
627 snmp_reset_var_buffers(&var_udpEndpointLocalAddressType);
628
629 return err;
630 } /* udpEndpointTable_index_from_oid */
631
632
633 /*
634 *********************************************************************
635 * @internal
636 * allocate resources for a udpEndpointTable_rowreq_ctx
637 */
638 udpEndpointTable_rowreq_ctx *
639 udpEndpointTable_allocate_rowreq_ctx(void)
640 {
641 udpEndpointTable_rowreq_ctx *rowreq_ctx =
642 SNMP_MALLOC_TYPEDEF(udpEndpointTable_rowreq_ctx);
643
644 DEBUGMSGTL(("internal:udpEndpointTable:udpEndpointTable_allocate_rowreq_ctx", "called\n"));
645
646 if (NULL == rowreq_ctx) {
647 snmp_log(LOG_ERR, "Couldn't allocate memory for a "
648 "udpEndpointTable_rowreq_ctx.\n");
649 return NULL;
650 }
651
652 rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
653
654 rowreq_ctx->udpEndpointTable_data_list = NULL;
655
656
657 return rowreq_ctx;
658 } /* udpEndpointTable_allocate_rowreq_ctx */
659
660 /*
661 * @internal
662 * release resources for a udpEndpointTable_rowreq_ctx
663 */
664 void
665 udpEndpointTable_release_rowreq_ctx(udpEndpointTable_rowreq_ctx *
666 rowreq_ctx)
667 {
668 DEBUGMSGTL(("internal:udpEndpointTable:udpEndpointTable_release_rowreq_ctx", "called\n"));
669
670 netsnmp_assert(NULL != rowreq_ctx);
671
672
673 /*
674 * free index oid pointer
675 */
676 if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
677 free(rowreq_ctx->oid_idx.oids);
678
679 SNMP_FREE(rowreq_ctx);
680 } /* udpEndpointTable_release_rowreq_ctx */
681
682 /**
683 * @internal
684 * wrapper
685 */
686 static int
687 _mfd_udpEndpointTable_pre_request(netsnmp_mib_handler *handler,
688 netsnmp_handler_registration *reginfo,
689 netsnmp_agent_request_info *agtreq_info,
690 netsnmp_request_info *requests)
691 {
692 int rc;
693
694 DEBUGMSGTL(("internal:udpEndpointTable:_mfd_udpEndpointTable_pre_request", "called\n"));
695
696 if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
697 DEBUGMSGTL(("internal:udpEndpointTable",
698 "skipping additional pre_request\n"));
699 return SNMP_ERR_NOERROR;
700 }
701
702 rc = udpEndpointTable_pre_request(udpEndpointTable_if_ctx.user_ctx);
703 if (MFD_SUCCESS != rc) {
704 /*
705 * nothing we can do about it but log it
706 */
707 DEBUGMSGTL(("udpEndpointTable", "error %d from "
708 "udpEndpointTable_pre_request\n", rc));
709 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
710 }
711
712 return SNMP_ERR_NOERROR;
713 } /* _mfd_udpEndpointTable_pre_request */
714
715 /**
716 * @internal
717 * wrapper
718 */
719 static int
720 _mfd_udpEndpointTable_post_request(netsnmp_mib_handler *handler,
721 netsnmp_handler_registration *reginfo,
722 netsnmp_agent_request_info *agtreq_info,
723 netsnmp_request_info *requests)
724 {
725 udpEndpointTable_rowreq_ctx *rowreq_ctx = (udpEndpointTable_rowreq_ctx*)
726 netsnmp_container_table_row_extract(requests);
727 int rc, packet_rc;
728
729 DEBUGMSGTL(("internal:udpEndpointTable:_mfd_udpEndpointTable_post_request", "called\n"));
730
731 /*
732 * release row context, if deleted
733 */
734 if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
735 udpEndpointTable_release_rowreq_ctx(rowreq_ctx);
736
737 /*
738 * wait for last call before calling user
739 */
740 if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
741 DEBUGMSGTL(("internal:udpEndpointTable",
742 "waiting for last post_request\n"));
743 return SNMP_ERR_NOERROR;
744 }
745
746 packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
747 rc = udpEndpointTable_post_request(udpEndpointTable_if_ctx.user_ctx,
748 packet_rc);
749 if (MFD_SUCCESS != rc) {
750 /*
751 * nothing we can do about it but log it
752 */
753 DEBUGMSGTL(("udpEndpointTable", "error %d from "
754 "udpEndpointTable_post_request\n", rc));
755 }
756
757 return SNMP_ERR_NOERROR;
758 } /* _mfd_udpEndpointTable_post_request */
759
760 /**
761 * @internal
762 * wrapper
763 */
764 static int
765 _mfd_udpEndpointTable_object_lookup(netsnmp_mib_handler *handler,
766 netsnmp_handler_registration *reginfo,
767 netsnmp_agent_request_info
768 *agtreq_info,
769 netsnmp_request_info *requests)
770 {
771 int rc = SNMP_ERR_NOERROR;
772 udpEndpointTable_rowreq_ctx *rowreq_ctx = (udpEndpointTable_rowreq_ctx*)
773 netsnmp_container_table_row_extract(requests);
774
775 DEBUGMSGTL(("internal:udpEndpointTable:_mfd_udpEndpointTable_object_lookup", "called\n"));
776
777 /*
778 * get our context from mfd
779 * udpEndpointTable_interface_ctx *if_ctx =
780 * (udpEndpointTable_interface_ctx *)reginfo->my_reg_void;
781 */
782
783 if (NULL == rowreq_ctx) {
784 rc = SNMP_ERR_NOCREATION;
785 }
786
787 if (MFD_SUCCESS != rc)
788 netsnmp_request_set_error_all(requests, rc);
789 else
790 udpEndpointTable_row_prep(rowreq_ctx);
791
792 return SNMP_VALIDATE_ERR(rc);
793 } /* _mfd_udpEndpointTable_object_lookup */
794
795 /***********************************************************************
796 *
797 * GET processing
798 *
799 ***********************************************************************/
800 /*
801 * @internal
802 * Retrieve the value for a particular column
803 */
804 NETSNMP_STATIC_INLINE int
805 _udpEndpointTable_get_column(udpEndpointTable_rowreq_ctx * rowreq_ctx,
806 netsnmp_variable_list * var, int column)
807 {
808 int rc = SNMPERR_SUCCESS;
809
810 DEBUGMSGTL(("internal:udpEndpointTable:_mfd_udpEndpointTable_get_column", "called for %d\n", column));
811
812
813 netsnmp_assert(NULL != rowreq_ctx);
814
815 switch (column) {
816
817 /*
818 * udpEndpointProcess(8)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
819 */
820 case COLUMN_UDPENDPOINTPROCESS:
821 var->val_len = sizeof(u_long);
822 var->type = ASN_UNSIGNED;
823 rc = udpEndpointProcess_get(rowreq_ctx,
824 (u_long *) var->val.string);
825 break;
826
827 default:
828 snmp_log(LOG_ERR,
829 "unknown column %d in _udpEndpointTable_get_column\n",
830 column);
831 break;
832 }
833
834 return rc;
835 } /* _udpEndpointTable_get_column */
836
837 int
838 _mfd_udpEndpointTable_get_values(netsnmp_mib_handler *handler,
839 netsnmp_handler_registration *reginfo,
840 netsnmp_agent_request_info *agtreq_info,
841 netsnmp_request_info *requests)
842 {
843 udpEndpointTable_rowreq_ctx *rowreq_ctx = (udpEndpointTable_rowreq_ctx*)
844 netsnmp_container_table_row_extract(requests);
845 netsnmp_table_request_info *tri;
846 u_char *old_string;
847 void (*dataFreeHook) (void *);
848 int rc;
849
850 DEBUGMSGTL(("internal:udpEndpointTable:_mfd_udpEndpointTable_get_values", "called\n"));
851
852 netsnmp_assert(NULL != rowreq_ctx);
853
854 for (; requests; requests = requests->next) {
855 /*
856 * save old pointer, so we can free it if replaced
857 */
858 old_string = requests->requestvb->val.string;
859 dataFreeHook = requests->requestvb->dataFreeHook;
860 if (NULL == requests->requestvb->val.string) {
861 requests->requestvb->val.string = requests->requestvb->buf;
862 requests->requestvb->val_len =
863 sizeof(requests->requestvb->buf);
864 } else if (requests->requestvb->buf ==
865 requests->requestvb->val.string) {
866 if (requests->requestvb->val_len !=
867 sizeof(requests->requestvb->buf))
868 requests->requestvb->val_len =
869 sizeof(requests->requestvb->buf);
870 }
871
872 /*
873 * get column data
874 */
875 tri = netsnmp_extract_table_info(requests);
876 if (NULL == tri)
877 continue;
878
879 rc = _udpEndpointTable_get_column(rowreq_ctx, requests->requestvb,
880 tri->colnum);
881 if (rc) {
882 if (MFD_SKIP == rc) {
883 requests->requestvb->type = SNMP_NOSUCHINSTANCE;
884 rc = SNMP_ERR_NOERROR;
885 }
886 } else if (NULL == requests->requestvb->val.string) {
887 snmp_log(LOG_ERR, "NULL varbind data pointer!\n");
888 rc = SNMP_ERR_GENERR;
889 }
890 if (rc)
891 netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
892
893 /*
894 * if the buffer wasn't used previously for the old data (i.e. it
895 * was allocated memory) and the get routine replaced the pointer,
896 * we need to free the previous pointer.
897 */
898 if (old_string && (old_string != requests->requestvb->buf) &&
899 (requests->requestvb->val.string != old_string)) {
900 if (dataFreeHook)
901 (*dataFreeHook) (old_string);
902 else
903 free(old_string);
904 }
905 } /* for results */
906
907 return SNMP_ERR_NOERROR;
908 } /* _mfd_udpEndpointTable_get_values */
909
910
911 /***********************************************************************
912 *
913 * SET processing
914 *
915 ***********************************************************************/
916
917 /*
918 * SET PROCESSING NOT APPLICABLE (per MIB or user setting)
919 */
920 /***********************************************************************
921 *
922 * DATA ACCESS
923 *
924 ***********************************************************************/
925 static void _container_free(netsnmp_container *container);
926
927 /**
928 * @internal
929 */
930 static int
931 _cache_load(netsnmp_cache * cache, void *vmagic)
932 {
933 DEBUGMSGTL(("internal:udpEndpointTable:_cache_load", "called\n"));
934
935 if ((NULL == cache) || (NULL == cache->magic)) {
936 snmp_log(LOG_ERR,
937 "invalid cache for udpEndpointTable_cache_load\n");
938 return -1;
939 }
940
941 /** should only be called for an invalid or expired cache */
942 netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
943
944 /*
945 * call user code
946 */
947 return udpEndpointTable_container_load((netsnmp_container *) cache->
948 magic);
949 } /* _cache_load */
950
951 /**
952 * @internal
953 */
954 static void
955 _cache_free(netsnmp_cache * cache, void *magic)
956 {
957 netsnmp_container *container;
958
959 DEBUGMSGTL(("internal:udpEndpointTable:_cache_free", "called\n"));
960
961 if ((NULL == cache) || (NULL == cache->magic)) {
962 snmp_log(LOG_ERR,
963 "invalid cache in udpEndpointTable_cache_free\n");
964 return;
965 }
966
967 container = (netsnmp_container *) cache->magic;
968
969 _container_free(container);
970 } /* _cache_free */
971
972 /**
973 * @internal
974 */
975 static void
976 _container_item_free(void *rowreq_ctx, void *context)
977 {
978 DEBUGMSGTL(("internal:udpEndpointTable:_container_item_free",
979 "called\n"));
980
981 if (NULL == rowreq_ctx)
982 return;
983
984 udpEndpointTable_release_rowreq_ctx(rowreq_ctx);
985 } /* _container_item_free */
986
987 /**
988 * @internal
989 */
990 static void
991 _container_free(netsnmp_container *container)
992 {
993 DEBUGMSGTL(("internal:udpEndpointTable:_container_free", "called\n"));
994
995 if (NULL == container) {
996 snmp_log(LOG_ERR,
997 "invalid container in udpEndpointTable_container_free\n");
998 return;
999 }
1000
1001 /*
1002 * call user code
1003 */
1004 udpEndpointTable_container_free(container);
1005
1006 /*
1007 * free all items. inefficient, but easy.
1008 */
1009 CONTAINER_CLEAR(container, _container_item_free, NULL);
1010 } /* _container_free */
1011
1012 /**
1013 * @internal
1014 * initialize the container with functions or wrappers
1015 */
1016 void
1017 _udpEndpointTable_container_init(udpEndpointTable_interface_ctx * if_ctx)
1018 {
1019 DEBUGMSGTL(("internal:udpEndpointTable:_udpEndpointTable_container_init", "called\n"));
1020
1021 /*
1022 * cache init
1023 */
1024 if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
1025 _cache_load, _cache_free,
1026 udpEndpointTable_oid,
1027 udpEndpointTable_oid_size);
1028
1029 if (NULL == if_ctx->cache) {
1030 snmp_log(LOG_ERR, "error creating cache for udpEndpointTable\n");
1031 return;
1032 }
1033
1034 if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
1035
1036 udpEndpointTable_container_init(&if_ctx->container, if_ctx->cache);
1037 if (NULL == if_ctx->container)
1038 if_ctx->container =
1039 netsnmp_container_find("udpEndpointTable:table_container");
1040 if (NULL == if_ctx->container) {
1041 snmp_log(LOG_ERR, "error creating container in "
1042 "udpEndpointTable_container_init\n");
1043 return;
1044 }
1045 if_ctx->container->container_name = strdup("udpEndpointTable");
1046
1047 if (NULL != if_ctx->cache)
1048 if_ctx->cache->magic = (void *) if_ctx->container;
1049 } /* _udpEndpointTable_container_init */
1050
1051 /**
1052 * @internal
1053 * shutdown the container with functions or wrappers
1054 */
1055 void
1056 _udpEndpointTable_container_shutdown(udpEndpointTable_interface_ctx *
1057 if_ctx)
1058 {
1059 DEBUGMSGTL(("internal:udpEndpointTable:_udpEndpointTable_container_shutdown", "called\n"));
1060
1061 udpEndpointTable_container_shutdown(if_ctx->container);
1062
1063 _container_free(if_ctx->container);
1064
1065 } /* _udpEndpointTable_container_shutdown */
1066
1067
1068 #ifndef NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_EXTERNAL_ACCESS
1069 udpEndpointTable_rowreq_ctx *
1070 udpEndpointTable_row_find_by_mib_index(udpEndpointTable_mib_index *
1071 mib_idx)
1072 {
1073 udpEndpointTable_rowreq_ctx *rowreq_ctx;
1074 oid oid_tmp[MAX_OID_LEN];
1075 netsnmp_index oid_idx;
1076 int rc;
1077
1078 /*
1079 * set up storage for OID
1080 */
1081 oid_idx.oids = oid_tmp;
1082 oid_idx.len = sizeof(oid_tmp) / sizeof(oid);
1083
1084 /*
1085 * convert
1086 */
1087 rc = udpEndpointTable_index_to_oid(&oid_idx, mib_idx);
1088 if (MFD_SUCCESS != rc)
1089 return NULL;
1090
1091 rowreq_ctx = (udpEndpointTable_rowreq_ctx*)
1092 CONTAINER_FIND(udpEndpointTable_if_ctx.container, &oid_idx);
1093
1094 return rowreq_ctx;
1095 }
1096 #endif /* NETSNMP_FEATURE_REMOVE_UDPENDPOINTTABLE_EXTERNAL_ACCESS */