source: npl/monitoring/syn3_snmp_subagent/subagent/syn3FacilitiesTable/syn3FacilitiesTable_interface.c

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 28.1 KB
Line 
1/*
2 * Note: this file originally auto-generated by mib2c using
3 *       version : 15899 $ of $
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/* standard Net-SNMP includes */
30#include <net-snmp/net-snmp-config.h>
31#include <net-snmp/net-snmp-includes.h>
32#include <net-snmp/agent/net-snmp-agent-includes.h>
33
34/* include our parent header */
35#include "syn3FacilitiesTable.h"
36
37
38#include <net-snmp/agent/table_container.h>
39#include <net-snmp/library/container.h>
40
41#include "syn3FacilitiesTable_interface.h"
42
43#include <ctype.h>
44
45/**********************************************************************
46 **********************************************************************
47 ***
48 *** Table syn3FacilitiesTable
49 ***
50 **********************************************************************
51 **********************************************************************/
52/*
53 * SYN3-MIB::syn3FacilitiesTable is subid 1 of syn3Facilities.
54 * Its status is Current.
55 * OID: .1.3.6.1.4.1.31337.1.2.1, length: 10
56*/
57typedef struct syn3FacilitiesTable_interface_ctx_s {
58
59   netsnmp_container              *container;
60   netsnmp_cache                  *cache;
61
62   syn3FacilitiesTable_registration *      user_ctx;
63   
64   netsnmp_table_registration_info  tbl_info;
65
66   netsnmp_baby_steps_access_methods access_multiplexer;
67
68} syn3FacilitiesTable_interface_ctx;
69
70static syn3FacilitiesTable_interface_ctx syn3FacilitiesTable_if_ctx;
71
72static void _syn3FacilitiesTable_container_init(
73    syn3FacilitiesTable_interface_ctx *if_ctx);
74static void _syn3FacilitiesTable_container_shutdown(
75    syn3FacilitiesTable_interface_ctx *if_ctx);
76
77
78netsnmp_container *
79syn3FacilitiesTable_container_get( void )
80{
81    return syn3FacilitiesTable_if_ctx.container;
82}
83
84syn3FacilitiesTable_registration *
85syn3FacilitiesTable_registration_get( void )
86{
87    return syn3FacilitiesTable_if_ctx.user_ctx;
88}
89
90syn3FacilitiesTable_registration *
91syn3FacilitiesTable_registration_set( syn3FacilitiesTable_registration * newreg )
92{
93    syn3FacilitiesTable_registration * old = syn3FacilitiesTable_if_ctx.user_ctx;
94    syn3FacilitiesTable_if_ctx.user_ctx = newreg;
95    return old;
96}
97
98int
99syn3FacilitiesTable_container_size( void )
100{
101    return CONTAINER_SIZE(syn3FacilitiesTable_if_ctx.container);
102}
103
104/*
105 * mfd multiplexer modes
106 */
107static Netsnmp_Node_Handler _mfd_syn3FacilitiesTable_pre_request;
108static Netsnmp_Node_Handler _mfd_syn3FacilitiesTable_post_request;
109static Netsnmp_Node_Handler _mfd_syn3FacilitiesTable_object_lookup;
110static Netsnmp_Node_Handler _mfd_syn3FacilitiesTable_get_values;
111/**
112 * @internal
113 * Initialize the table syn3FacilitiesTable
114 *    (Define its contents and how it's structured)
115 */
116void
117_syn3FacilitiesTable_initialize_interface(syn3FacilitiesTable_registration * reg_ptr,  u_long flags)
118{
119    netsnmp_baby_steps_access_methods *access_multiplexer =
120        &syn3FacilitiesTable_if_ctx.access_multiplexer;
121    netsnmp_table_registration_info *tbl_info = &syn3FacilitiesTable_if_ctx.tbl_info;
122    netsnmp_handler_registration *reginfo;
123    netsnmp_mib_handler *handler;
124    int    mfd_modes = 0;
125
126    DEBUGMSGTL(("internal:syn3FacilitiesTable:_syn3FacilitiesTable_initialize_interface","called\n"));
127
128
129    /*************************************************
130     *
131     * save interface context for syn3FacilitiesTable
132     */
133    /*
134     * Setting up the table's definition
135     */
136    netsnmp_table_helper_add_indexes(tbl_info,
137                                  ASN_OCTET_STR, /** index: syn3FacilityName */
138                             0);
139
140    /*  Define the minimum and maximum accessible columns.  This
141        optimizes retrival. */
142    tbl_info->min_column = SYN3FACILITIESTABLE_MIN_COL;
143    tbl_info->max_column = SYN3FACILITIESTABLE_MAX_COL;
144
145    /*
146     * save users context
147     */
148    syn3FacilitiesTable_if_ctx.user_ctx = reg_ptr;
149
150    /*
151     * call data access initialization code
152     */
153    syn3FacilitiesTable_init_data(reg_ptr);
154
155    /*
156     * set up the container
157     */
158    _syn3FacilitiesTable_container_init(&syn3FacilitiesTable_if_ctx);
159    if (NULL == syn3FacilitiesTable_if_ctx.container) {
160        snmp_log(LOG_ERR,"could not initialize container for syn3FacilitiesTable\n");
161        return;
162    }
163   
164    /*
165     * access_multiplexer: REQUIRED wrapper for get request handling
166     */
167    access_multiplexer->object_lookup = _mfd_syn3FacilitiesTable_object_lookup;
168    access_multiplexer->get_values = _mfd_syn3FacilitiesTable_get_values;
169
170    /*
171     * no wrappers yet
172     */
173    access_multiplexer->pre_request = _mfd_syn3FacilitiesTable_pre_request;
174    access_multiplexer->post_request = _mfd_syn3FacilitiesTable_post_request;
175
176
177    /*************************************************
178     *
179     * Create a registration, save our reg data, register table.
180     */
181    DEBUGMSGTL(("syn3FacilitiesTable:init_syn3FacilitiesTable",
182                "Registering syn3FacilitiesTable as a mibs-for-dummies table.\n"));             
183    handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
184    reginfo = netsnmp_handler_registration_create("syn3FacilitiesTable", handler,
185                                                  syn3FacilitiesTable_oid,
186                                                  syn3FacilitiesTable_oid_size,
187                                                  HANDLER_CAN_BABY_STEP |
188                                                  HANDLER_CAN_RONLY
189                                                  );
190    if(NULL == reginfo) {
191        snmp_log(LOG_ERR,"error registering table syn3FacilitiesTable\n");
192        return;
193    }
194    reginfo->my_reg_void = &syn3FacilitiesTable_if_ctx;
195
196    /*************************************************
197     *
198     * set up baby steps handler, create it and inject it
199     */
200    if( access_multiplexer->object_lookup )
201        mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
202    if( access_multiplexer->set_values )
203        mfd_modes |= BABY_STEP_SET_VALUES;
204    if( access_multiplexer->irreversible_commit )
205        mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
206    if( access_multiplexer->object_syntax_checks )
207        mfd_modes |= BABY_STEP_CHECK_OBJECT;
208
209    if( access_multiplexer->pre_request )
210        mfd_modes |= BABY_STEP_PRE_REQUEST;
211    if( access_multiplexer->post_request )
212        mfd_modes |= BABY_STEP_POST_REQUEST;
213   
214    if( access_multiplexer->undo_setup )
215        mfd_modes |= BABY_STEP_UNDO_SETUP;
216    if( access_multiplexer->undo_cleanup )
217        mfd_modes |= BABY_STEP_UNDO_CLEANUP;
218    if( access_multiplexer->undo_sets )
219        mfd_modes |= BABY_STEP_UNDO_SETS;
220   
221    if( access_multiplexer->row_creation )
222        mfd_modes |= BABY_STEP_ROW_CREATE;
223    if( access_multiplexer->consistency_checks )
224        mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
225    if( access_multiplexer->commit )
226        mfd_modes |= BABY_STEP_COMMIT;
227    if( access_multiplexer->undo_commit )
228        mfd_modes |= BABY_STEP_UNDO_COMMIT;
229   
230    handler = netsnmp_baby_steps_handler_get(mfd_modes);
231    netsnmp_inject_handler(reginfo, handler);
232
233    /*************************************************
234     *
235     * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
236     */
237    handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
238    netsnmp_inject_handler(reginfo, handler);
239
240    /*************************************************
241     *
242     * inject container_table helper
243     */
244    handler =
245        netsnmp_container_table_handler_get(tbl_info,
246                                            syn3FacilitiesTable_if_ctx.container,
247                                            TABLE_CONTAINER_KEY_NETSNMP_INDEX);
248    netsnmp_inject_handler( reginfo, handler );
249
250    /*************************************************
251     *
252     * inject cache helper
253     */
254    if(NULL != syn3FacilitiesTable_if_ctx.cache) {
255        handler = netsnmp_cache_handler_get(syn3FacilitiesTable_if_ctx.cache);
256        netsnmp_inject_handler( reginfo, handler );
257    }
258
259    /*
260     * register table
261     */
262    netsnmp_register_table(reginfo, tbl_info);
263
264} /* _syn3FacilitiesTable_initialize_interface */
265
266/**
267 * @internal
268 * Shutdown the table syn3FacilitiesTable
269 */
270void
271_syn3FacilitiesTable_shutdown_interface(syn3FacilitiesTable_registration * reg_ptr)
272{
273    /*
274     * shutdown the container
275     */
276    _syn3FacilitiesTable_container_shutdown(&syn3FacilitiesTable_if_ctx);
277}
278
279void
280syn3FacilitiesTable_valid_columns_set(netsnmp_column_info *vc)
281{
282    syn3FacilitiesTable_if_ctx.tbl_info.valid_columns = vc;
283} /* syn3FacilitiesTable_valid_columns_set */
284
285/**
286 * @internal
287 * convert the index component stored in the context to an oid
288 */
289int
290syn3FacilitiesTable_index_to_oid(netsnmp_index *oid_idx,
291                         syn3FacilitiesTable_mib_index *mib_idx)
292{
293    int err = SNMP_ERR_NOERROR;
294   
295    /*
296     * temp storage for parsing indexes
297     */
298    /*
299     * syn3FacilityName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H
300     */
301    netsnmp_variable_list var_syn3FacilityName;
302
303    /*
304     * set up varbinds
305     */
306    memset( &var_syn3FacilityName, 0x00, sizeof(var_syn3FacilityName) );
307    var_syn3FacilityName.type = ASN_OCTET_STR;
308
309    /*
310     * chain temp index varbinds together
311     */
312    var_syn3FacilityName.next_variable =  NULL;
313
314
315    DEBUGMSGTL(("verbose:syn3FacilitiesTable:syn3FacilitiesTable_index_to_oid","called\n"));
316
317        /* syn3FacilityName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
318    snmp_set_var_value(&var_syn3FacilityName, (u_char*)&mib_idx->syn3FacilityName,
319                       mib_idx->syn3FacilityName_len * sizeof(mib_idx->syn3FacilityName[0]));
320
321
322    err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
323                           NULL, 0, &var_syn3FacilityName);
324    if(err)
325        snmp_log(LOG_ERR,"error %d converting index to oid\n", err);
326
327    /*
328     * parsing may have allocated memory. free it.
329     */
330    snmp_reset_var_buffers( &var_syn3FacilityName );
331
332    return err;
333} /* syn3FacilitiesTable_index_to_oid */
334
335/**
336 * extract syn3FacilitiesTable indexes from a netsnmp_index
337 *
338 * @retval SNMP_ERR_NOERROR  : no error
339 * @retval SNMP_ERR_GENERR   : error
340 */
341int
342syn3FacilitiesTable_index_from_oid(netsnmp_index *oid_idx,
343                         syn3FacilitiesTable_mib_index *mib_idx)
344{
345    int err = SNMP_ERR_NOERROR;
346   
347    /*
348     * temp storage for parsing indexes
349     */
350    /*
351     * syn3FacilityName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H
352     */
353    netsnmp_variable_list var_syn3FacilityName;
354
355    /*
356     * set up varbinds
357     */
358    memset( &var_syn3FacilityName, 0x00, sizeof(var_syn3FacilityName) );
359    var_syn3FacilityName.type = ASN_OCTET_STR;
360
361    /*
362     * chain temp index varbinds together
363     */
364    var_syn3FacilityName.next_variable =  NULL;
365
366
367    DEBUGMSGTL(("verbose:syn3FacilitiesTable:syn3FacilitiesTable_index_from_oid","called\n"));
368
369    /*
370     * parse the oid into the individual index components
371     */
372    err = parse_oid_indexes( oid_idx->oids, oid_idx->len,
373                             &var_syn3FacilityName );
374    if (err == SNMP_ERR_NOERROR) {
375        /*
376         * copy out values
377         */
378    /*
379     * NOTE: val_len is in bytes, syn3FacilityName_len might not be
380     */
381         if(var_syn3FacilityName.val_len > sizeof(mib_idx->syn3FacilityName))
382             err = SNMP_ERR_GENERR;
383         else {
384             memcpy(mib_idx->syn3FacilityName, var_syn3FacilityName.val.string, var_syn3FacilityName.val_len);
385             mib_idx->syn3FacilityName_len = var_syn3FacilityName.val_len / sizeof(mib_idx->syn3FacilityName[0]);
386         }
387
388
389    }
390
391    /*
392     * parsing may have allocated memory. free it.
393     */
394    snmp_reset_var_buffers( &var_syn3FacilityName );
395
396    return err;
397} /* syn3FacilitiesTable_index_from_oid */
398
399
400/* *********************************************************************
401 * @internal
402 * allocate resources for a syn3FacilitiesTable_rowreq_ctx
403 */
404syn3FacilitiesTable_rowreq_ctx *
405syn3FacilitiesTable_allocate_rowreq_ctx(void *user_init_ctx)
406{
407    syn3FacilitiesTable_rowreq_ctx *rowreq_ctx =
408                  SNMP_MALLOC_TYPEDEF(syn3FacilitiesTable_rowreq_ctx);
409
410    DEBUGMSGTL(("internal:syn3FacilitiesTable:syn3FacilitiesTable_allocate_rowreq_ctx","called\n"));
411
412    if(NULL == rowreq_ctx) {
413        snmp_log(LOG_ERR,"Couldn't allocate memory for a "
414                 "syn3FacilitiesTable_rowreq_ctx.\n");
415        return NULL;
416    }
417
418    rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
419
420    rowreq_ctx->syn3FacilitiesTable_data_list = NULL;
421
422    /*
423     * if we allocated data, call init routine
424     */
425    if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
426        if(SNMPERR_SUCCESS !=
427            syn3FacilitiesTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
428           syn3FacilitiesTable_release_rowreq_ctx(rowreq_ctx);
429           rowreq_ctx = NULL;
430        }
431    }
432
433    return rowreq_ctx;
434} /* syn3FacilitiesTable_allocate_rowreq_ctx */
435
436/*
437 * @internal
438 * release resources for a syn3FacilitiesTable_rowreq_ctx
439 */
440void
441syn3FacilitiesTable_release_rowreq_ctx(syn3FacilitiesTable_rowreq_ctx *rowreq_ctx)
442{
443    DEBUGMSGTL(("internal:syn3FacilitiesTable:syn3FacilitiesTable_release_rowreq_ctx","called\n"));
444
445    netsnmp_assert(NULL != rowreq_ctx);
446   
447    syn3FacilitiesTable_rowreq_ctx_cleanup(rowreq_ctx);
448
449    /*
450     * free index oid pointer
451     */
452    if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
453        free(rowreq_ctx->oid_idx.oids);
454
455    SNMP_FREE(rowreq_ctx);
456} /* syn3FacilitiesTable_release_rowreq_ctx */
457
458/**
459 * @internal
460 * wrapper
461 */
462static int
463_mfd_syn3FacilitiesTable_pre_request(netsnmp_mib_handler *handler,
464                            netsnmp_handler_registration *reginfo,
465                            netsnmp_agent_request_info *agtreq_info,
466                            netsnmp_request_info *requests)
467{
468    int rc;
469
470    DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_pre_request",
471                "called\n"));
472   
473    if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
474        DEBUGMSGTL(("internal:syn3FacilitiesTable",
475                    "skipping additional pre_request\n"));
476        return SNMP_ERR_NOERROR;
477    }
478       
479    rc = syn3FacilitiesTable_pre_request(syn3FacilitiesTable_if_ctx.user_ctx);
480    if (MFD_SUCCESS != rc) {
481        /*
482         * nothing we can do about it but log it
483         */
484        DEBUGMSGTL(("syn3FacilitiesTable","error %d from "
485                    "syn3FacilitiesTable_pre_request\n", rc));
486        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
487    }
488   
489    return SNMP_ERR_NOERROR;
490} /* _mfd_syn3FacilitiesTable_pre_request */
491
492/**
493 * @internal
494 * wrapper
495 */
496static int
497_mfd_syn3FacilitiesTable_post_request(netsnmp_mib_handler *handler,
498                             netsnmp_handler_registration *reginfo,
499                             netsnmp_agent_request_info *agtreq_info,
500                             netsnmp_request_info *requests)
501{
502    syn3FacilitiesTable_rowreq_ctx *rowreq_ctx =
503                  netsnmp_container_table_row_extract(requests);
504    int rc, packet_rc;
505
506    DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_post_request",
507                "called\n"));
508
509    /*
510     * release row context, if deleted
511     */
512    if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
513        syn3FacilitiesTable_release_rowreq_ctx(rowreq_ctx);
514
515    /*
516     * wait for last call before calling user
517     */
518    if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
519        DEBUGMSGTL(("internal:syn3FacilitiesTable",
520                    "waiting for last post_request\n"));
521        return SNMP_ERR_NOERROR;
522    }
523   
524    packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
525    rc = syn3FacilitiesTable_post_request(syn3FacilitiesTable_if_ctx.user_ctx,packet_rc);
526    if (MFD_SUCCESS != rc) {
527        /*
528         * nothing we can do about it but log it
529         */
530        DEBUGMSGTL(("syn3FacilitiesTable","error %d from "
531                    "syn3FacilitiesTable_post_request\n", rc));
532    }
533   
534    return SNMP_ERR_NOERROR;
535} /* _mfd_syn3FacilitiesTable_post_request */
536
537/**
538 * @internal
539 * wrapper
540 */
541static int
542_mfd_syn3FacilitiesTable_object_lookup(netsnmp_mib_handler *handler,
543                         netsnmp_handler_registration *reginfo,
544                         netsnmp_agent_request_info *agtreq_info,
545                         netsnmp_request_info *requests)
546{
547    int                    rc = SNMP_ERR_NOERROR;
548    syn3FacilitiesTable_rowreq_ctx *rowreq_ctx =
549                  netsnmp_container_table_row_extract(requests);
550   
551    DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_object_lookup","called\n"));
552
553    /*
554     * get our context from mfd
555     * syn3FacilitiesTable_interface_ctx *if_ctx =
556     *             (syn3FacilitiesTable_interface_ctx *)reginfo->my_reg_void;
557     */
558
559    if(NULL == rowreq_ctx) {
560        rc = SNMP_ERR_NOCREATION;
561    }
562
563    if (MFD_SUCCESS != rc)
564        netsnmp_request_set_error_all(requests, rc);
565    else
566        syn3FacilitiesTable_row_prep(rowreq_ctx);
567
568    return SNMP_VALIDATE_ERR(rc);
569} /* _mfd_syn3FacilitiesTable_object_lookup */
570
571/***********************************************************************
572 *
573 * GET processing
574 *
575 ***********************************************************************/
576/*
577 * @internal
578 * Retrieve the value for a particular column
579 */
580NETSNMP_STATIC_INLINE int
581_syn3FacilitiesTable_get_column( syn3FacilitiesTable_rowreq_ctx *rowreq_ctx,
582                       netsnmp_variable_list *var, int column )
583{
584    int rc = SNMPERR_SUCCESS;
585   
586    DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_get_column",
587                "called for %d\n", column));
588
589
590    netsnmp_assert(NULL != rowreq_ctx);
591
592    switch(column) {
593
594    /* (INDEX) syn3FacilityName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
595    case COLUMN_SYN3FACILITYNAME:
596    var->type = ASN_OCTET_STR;
597    /*
598     * NOTE: val_len is in bytes, syn3FacilityName_len might not be (e.g. oids)
599     */
600        if (var->val_len < (rowreq_ctx->tbl_idx.syn3FacilityName_len *
601                            sizeof(rowreq_ctx->tbl_idx.syn3FacilityName[0]))) {
602           var->val.string = malloc(rowreq_ctx->tbl_idx.syn3FacilityName_len *
603                                    sizeof(rowreq_ctx->tbl_idx.syn3FacilityName[0]));
604        }
605        var->val_len = rowreq_ctx->tbl_idx.syn3FacilityName_len * sizeof(rowreq_ctx->tbl_idx.syn3FacilityName[0]);
606        memcpy( var->val.string, rowreq_ctx->tbl_idx.syn3FacilityName, var->val_len );
607        break;
608
609    /* syn3FacilityStatus(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
610    case COLUMN_SYN3FACILITYSTATUS:
611    var->type = ASN_OCTET_STR;
612rc = syn3FacilityStatus_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
613        break;
614
615    /* syn3FacilityDescription(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
616    case COLUMN_SYN3FACILITYDESCRIPTION:
617    var->type = ASN_OCTET_STR;
618rc = syn3FacilityDescription_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
619        break;
620
621    /* syn3FacilityAck(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
622    case COLUMN_SYN3FACILITYACK:
623    var->type = ASN_OCTET_STR;
624rc = syn3FacilityAck_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
625        break;
626
627     default:
628        if (SYN3FACILITIESTABLE_MIN_COL <= column && column <= SYN3FACILITIESTABLE_MAX_COL) {
629            DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_get_column",
630                "assume column %d is reserved\n", column));
631            rc = MFD_SKIP;
632        } else {
633            snmp_log(LOG_ERR,
634                "unknown column %d in _syn3FacilitiesTable_get_column\n", column);
635        }
636        break;
637    }
638
639    return rc;
640} /* _syn3FacilitiesTable_get_column */
641
642int
643_mfd_syn3FacilitiesTable_get_values(netsnmp_mib_handler *handler,
644                         netsnmp_handler_registration *reginfo,
645                         netsnmp_agent_request_info *agtreq_info,
646                         netsnmp_request_info *requests)
647{
648    syn3FacilitiesTable_rowreq_ctx *rowreq_ctx =
649                  netsnmp_container_table_row_extract(requests);
650    netsnmp_table_request_info * tri;
651    u_char                     * old_string;
652    void                      (*dataFreeHook)(void *);
653    int                        rc;
654
655    DEBUGMSGTL(("internal:syn3FacilitiesTable:_mfd_syn3FacilitiesTable_get_values","called\n"));
656
657    netsnmp_assert(NULL != rowreq_ctx);
658   
659    for(;requests; requests = requests->next) {
660        /*
661         * save old pointer, so we can free it if replaced
662         */
663        old_string = requests->requestvb->val.string;
664        dataFreeHook = requests->requestvb->dataFreeHook;
665        if(NULL == requests->requestvb->val.string) {
666            requests->requestvb->val.string = requests->requestvb->buf;
667            requests->requestvb->val_len = sizeof(requests->requestvb->buf);
668        }
669        else if(requests->requestvb->buf == requests->requestvb->val.string) {
670            if(requests->requestvb->val_len != sizeof(requests->requestvb->buf))
671                requests->requestvb->val_len = sizeof(requests->requestvb->buf);
672        }
673
674        /*
675         * get column data
676         */
677        tri = netsnmp_extract_table_info(requests);
678        if(NULL == tri)
679            continue;
680       
681        rc = _syn3FacilitiesTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum);
682        if(rc) {
683            if(MFD_SKIP == rc) {
684                requests->requestvb->type = SNMP_NOSUCHINSTANCE;
685                rc = SNMP_ERR_NOERROR;
686            }
687        }
688        else if (NULL == requests->requestvb->val.string) {
689            snmp_log(LOG_ERR,"NULL varbind data pointer!\n");
690            rc = SNMP_ERR_GENERR;
691        }
692        if(rc)
693            netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
694
695        /*
696         * if the buffer wasn't used previously for the old data (i.e. it
697         * was allcoated memory)  and the get routine replaced the pointer,
698         * we need to free the previous pointer.
699         */
700        if(old_string && (old_string != requests->requestvb->buf) &&
701           (requests->requestvb->val.string != old_string)) {
702            if(dataFreeHook)
703                (*dataFreeHook)(old_string);
704            else
705                free(old_string);
706        }
707    } /* for results */
708
709    return SNMP_ERR_NOERROR;
710} /* _mfd_syn3FacilitiesTable_get_values */
711
712
713/***********************************************************************
714 *
715 * SET processing
716 *
717 ***********************************************************************/
718
719/*
720 * SET PROCESSING NOT APPLICABLE (per MIB or user setting)
721 */
722/***********************************************************************
723 *
724 * DATA ACCESS
725 *
726 ***********************************************************************/
727static void _container_free(netsnmp_container *container);
728
729/**
730 * @internal
731 */
732static int
733_cache_load(netsnmp_cache *cache, void *vmagic)
734{
735    DEBUGMSGTL(("internal:syn3FacilitiesTable:_cache_load","called\n"));
736
737    if((NULL == cache) || (NULL == cache->magic)) {
738        snmp_log(LOG_ERR, "invalid cache for syn3FacilitiesTable_cache_load\n");
739        return -1;
740    }
741
742    /** should only be called for an invalid or expired cache */
743    netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
744   
745    /*
746     * call user code
747     */
748    return syn3FacilitiesTable_container_load((netsnmp_container*)cache->magic);
749} /* _cache_load */
750
751/**
752 * @internal
753 */
754static void
755_cache_free(netsnmp_cache *cache, void *magic)
756{
757    netsnmp_container *container;
758
759    DEBUGMSGTL(("internal:syn3FacilitiesTable:_cache_free","called\n"));
760
761    if((NULL == cache) || (NULL == cache->magic)) {
762        snmp_log(LOG_ERR, "invalid cache in syn3FacilitiesTable_cache_free\n");
763        return;
764    }
765
766    container = (netsnmp_container*)cache->magic;
767
768    _container_free(container);
769} /* _cache_free */
770
771/**
772 * @internal
773 */
774static void
775_container_item_free(syn3FacilitiesTable_rowreq_ctx *rowreq_ctx, void *context)
776{
777    DEBUGMSGTL(("internal:syn3FacilitiesTable:_container_item_free","called\n"));
778
779    if(NULL == rowreq_ctx)
780        return;
781
782    syn3FacilitiesTable_release_rowreq_ctx(rowreq_ctx);
783} /* _container_item_free */
784
785/**
786 * @internal
787 */
788static void
789_container_free(netsnmp_container *container)
790{
791    DEBUGMSGTL(("internal:syn3FacilitiesTable:_container_free","called\n"));
792
793    if (NULL == container) {
794        snmp_log(LOG_ERR, "invalid container in syn3FacilitiesTable_container_free\n");
795        return;
796    }
797
798    /*
799     * call user code
800     */
801    syn3FacilitiesTable_container_free(container);
802   
803    /*
804     * free all items. inefficient, but easy.
805     */
806    CONTAINER_CLEAR(container,
807                    (netsnmp_container_obj_func *)_container_item_free,
808                    NULL);
809} /* _container_free */
810
811/**
812 * @internal
813 * initialize the container with functions or wrappers
814 */
815void
816_syn3FacilitiesTable_container_init(syn3FacilitiesTable_interface_ctx *if_ctx)
817{
818    DEBUGMSGTL(("internal:syn3FacilitiesTable:_syn3FacilitiesTable_container_init","called\n"));
819
820    /*
821     * cache init
822     */
823    if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
824                                         _cache_load, _cache_free,
825                                         syn3FacilitiesTable_oid,
826                                         syn3FacilitiesTable_oid_size);
827
828    if(NULL == if_ctx->cache) {
829        snmp_log(LOG_ERR, "error creating cache for syn3FacilitiesTable\n");
830        return;
831    }
832
833    if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
834
835    syn3FacilitiesTable_container_init(&if_ctx->container, if_ctx->cache);
836    if(NULL == if_ctx->container)
837        if_ctx->container = netsnmp_container_find("syn3FacilitiesTable:table_container");
838    if(NULL == if_ctx->container) {
839        snmp_log(LOG_ERR,"error creating container in "
840                 "syn3FacilitiesTable_container_init\n");
841        return;
842    }
843
844    if (NULL != if_ctx->cache)
845        if_ctx->cache->magic = (void*)if_ctx->container;
846} /* _syn3FacilitiesTable_container_init */
847
848/**
849 * @internal
850 * shutdown the container with functions or wrappers
851 */
852void
853_syn3FacilitiesTable_container_shutdown(syn3FacilitiesTable_interface_ctx *if_ctx)
854{
855    DEBUGMSGTL(("internal:syn3FacilitiesTable:_syn3FacilitiesTable_container_shutdown","called\n"));
856
857    syn3FacilitiesTable_container_shutdown(if_ctx->container);
858
859    _container_free(if_ctx->container);
860
861} /* _syn3FacilitiesTable_container_shutdown */
862
863
864syn3FacilitiesTable_rowreq_ctx *
865syn3FacilitiesTable_row_find_by_mib_index(syn3FacilitiesTable_mib_index *mib_idx)
866{
867    syn3FacilitiesTable_rowreq_ctx   *rowreq_ctx;
868    oid                      oid_tmp[MAX_OID_LEN];
869    netsnmp_index            oid_idx;
870    int                      rc;
871
872    /*
873     * set up storage for OID
874     */
875    oid_idx.oids = oid_tmp;
876    oid_idx.len = sizeof(oid_tmp)/sizeof(oid);
877
878    /*
879     * convert
880     */
881    rc = syn3FacilitiesTable_index_to_oid(&oid_idx, mib_idx);
882    if (MFD_SUCCESS != rc)
883        return NULL;
884
885    rowreq_ctx = CONTAINER_FIND(syn3FacilitiesTable_if_ctx.container, &oid_idx);
886
887    return rowreq_ctx;
888}
889
Note: See TracBrowser for help on using the repository browser.