Файловый менеджер - Редактировать - /var/www/iplanru/data/www/intesco.ru/d59ed/snmp.tar
Назад
snmp.conf 0000666 00000000325 15077015017 0006377 0 ustar 00 # # As the snmp packages come without MIB files due to license reasons, loading # of MIBs is disabled by default. If you added the MIBs you can reenable # loaging them by commenting out the following line. mibs : proc/1470/net/snmp 0000666 00000000000 15077147055 0007575 0 ustar 00 proc/1471/net/snmp 0000666 00000000000 15077147107 0007574 0 ustar 00 mib2c-data/generic-get-decl.m2i 0000666 00000002757 15077166074 0012212 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-get-decl.m2i 9366 2004-02-02 15:56:14Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 9366 $ */ @end@ ######################################################################## ## @if $m2c_get_use_temp == 1@ /* * Define temporary variable(s). If speed/efficency is an issue, * remove this code and deal with the pointer directly. * (set $@m2c_get_use_temp = 0 in your conf file to turn off) */ @ if $m2c_node_needlength == 1@ $m2c_decl * $m2c_node_lh; size_t $m2c_node_lhs; @ else@ $m2c_decl $m2c_node_lh; @ end@ @end@ @if $m2c_node_needlength == 1@ /** we should have a non-NULL pointer and enough storage */ netsnmp_assert( (NULL != $m2c_node_param_ref_name) && (NULL != *$m2c_node_param_ref_name)); netsnmp_assert( NULL != $m2c_node_param_ref_lname ); @else@ /** we should have a non-NULL pointer */ netsnmp_assert( NULL != $m2c_node_param_ref_name ); @end@ @if ($m2c_get_use_temp == 1) && ($m2c_node_needlength == 1)@ $m2c_node_lh = (* $m2c_node_param_ref_name); $m2c_node_lhs = (* $m2c_node_param_ref_lname); @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 9366 $ */ @end@ mib2c-data/m2c_setup_node.m2i 0000666 00000024244 15077166074 0012015 0 ustar 00 ############################################################# -*- c -*- ## Defaults ## $Id: m2c_setup_node.m2i 12856 2005-09-27 15:58:00Z rstory $ ######################################################################## @if "$m2c_node_name" ne "$node"@ ## if $node.accessible != 1, might be inaccessible index node @ eval $m2c_node_name = $node@ @ eval $m2c_node_skip_mapping = $m2c_table_skip_mapping@ @ eval $m2c_node_needlength = $node.needlength@ @ eval $m2c_node_get_comments = ""@ @ eval $m2c_node_set_comments = ""@ @ eval $m2c_node_skip_get = 0@ ##//how should a function handle a pointer to a buffer that is to small? @ eval $m2c_node_realloc = 0@ // 0=fail, 1=realloc, 2=malloc ######################################################################## ## fix some declarations ######################################################################## @ if $node.enums == 1@ ## @ if $m2c_node_skip_mapping == -1@ @ eval $m2c_node_skip_mapping = 0@ @ end@ ## ## validate some assumptions ## @ if ("$node.perltype" ne "INTEGER") && ("$node.perltype" ne "BITS")@ @ print "$node had enums, but isn't INTEGER or BITS! ($node.perltype)\n"@ @ exit@ @ end@ @ if $node.ranges == 1@ @ print "$node has enums and ranges!\n"@ @ exit@ @ end@ ## ## for a TC, prefix definition w/syntax to reduce collisions ## @ if $node.syntax ne $node.perltype@ @ eval $m2c_de_pfx = "${m2c_const_pfx}$node.syntax"@ @ else@ @ eval $m2c_de_pfx = "${m2c_const_pfx}$node"@ @ end@ @ if $m2c_const_lc == 0@ @ eval $m2c_de_pfx = uc($m2c_de_pfx)@ @ end@ @ if "$node.perltype" eq "BITS"@ @ eval $m2c_enum_sfx="_flag"@ @ eval $m2c_enum_mask="${m2c_de_pfx}_flag"@ @ if $m2c_const_lc == 0@ @ eval $m2c_enum_sfx = uc($m2c_enum_sfx)@ @ eval $m2c_enum_mask = uc($m2c_enum_mask)@ @ end@ @ else@ @ eval $m2c_enum_sfx=""@ @ end@ ## ## use longs for enums (w/out length) ## @ eval $m2c_decl = "u_long"@ @ eval $m2c_node_needlength = 0@ @ if "$node.perltype" eq "BITS"@ @ eval $m2c_node_skip_get = 1@ @ end@ @ else@ @ eval $m2c_decl = $node.decl@ @ end@ // enums ######################################################################## ## find max size ######################################################################## @ if $node.ranges == 1@ ## ## I do not *think* you can have both... ## @ if $node.enums == 1@ @ print "$node has enums and ranges!\n"@ @ exit@ @ end@ @ eval $m2c_node_maxlen = 0@ @ foreach $a $b range $node@ @ eval $m2c_node_maxlen = max($m2c_node_maxlen,$b)@ @ end@ @ elsif "$node.type" eq "ASN_OBJECT_ID"@ @ eval $m2c_node_maxlen = 128@ @ else@ #ranges @ eval $m2c_node_maxlen = 65535@ @ end@ #ranges ##/*#################################################################### ## set up extra params, based on if we need length ######################################################################## ## VAR_VAL : variable value. ## VAR_VAL_PTR : pointer to variable value. ## VAR_REF : variable reference. (pointer to pointer to variable value) ##*/ @ if "x$m2c_node_var_name" eq "x"@ @ eval $m2c_node_var_name="var->"@ @ end@ @ eval $m2c_node_var_val_ptr = "($m2c_decl *)${m2c_node_var_name}val.string"@ @ if $m2c_node_needlength == 1@ @ eval $m2c_XX = "($m2c_decl **)&${m2c_node_var_name}val.string,"@ @ eval $m2c_node_var_ref = "$m2c_XX &${m2c_node_var_name}val_len"@ @ eval $m2c_node_var_val = "$m2c_node_var_val_ptr, ${m2c_node_var_name}val_len"@ @ else@ @ eval $m2c_node_var_ref = "($m2c_decl *)${m2c_node_var_name}val.string"@ @ eval $m2c_node_var_val = "*($m2c_node_var_val_ptr)"@ @ end@ ## ## @ eval $m2c_node_param_val_name = "${node}_val"@ @ eval $m2c_node_param_val_lname = "${m2c_node_param_val_name}_len"@ @ eval $m2c_node_param_ref_name = "${m2c_node_param_val_name}_ptr"@ @ if $m2c_node_needlength == 1@ @ eval $m2c_node_param_val_name = "${m2c_node_param_val_name}_ptr"@ @ eval $m2c_node_param_val_lname = "${m2c_node_param_val_name}_len"@ @ eval $m2c_node_param_val_call = "${m2c_node_param_val_name}, ${m2c_node_param_val_lname}"@ @ eval $m2c_node_param_ref_name = "${m2c_node_param_ref_name}_ptr"@ @ eval $m2c_node_param_ref_lname = "${m2c_node_param_val_lname}_ptr"@ @ eval $m2c_XX = "$m2c_decl **$m2c_node_param_ref_name,"@ @ eval $m2c_node_param_ref = "$m2c_XX size_t *$m2c_node_param_ref_lname"@ @ eval $m2c_XX = "$m2c_decl *$m2c_node_param_val_name,"@ @ eval $m2c_node_param_val = "$m2c_XX size_t $m2c_node_param_val_lname"@ @ else@ @ eval $m2c_node_param_ref = "$m2c_decl * $m2c_node_param_ref_name"@ @ eval $m2c_node_param_val = "$m2c_decl $m2c_node_param_val_name"@ @ eval $m2c_node_param_val_call = "$m2c_node_param_val_name"@ ## @ end@ ## ######################################################################## ## include user overrides ######################################################################## @ include -ifexists ${m2c_defaults_dir}node-${node}.m2d@ ######################################################################## ## ######################################################################## @ if $m2c_get_use_temp == 1@ @ eval $m2c_node_lh = "temp_$node"@ @ eval $m2c_node_lhs = "temp_${node}_len"@ @ else@ @ eval $m2c_node_lh = "(* $m2c_node_param_ref_name )"@ @ eval $m2c_node_lhs = "(* $m2c_node_param_ref_lname )"@ @ end@ @ eval $m2c_ctx_lh="$m2c_node_lh"@ @ eval $m2c_ctx_lhs="$m2c_node_lhs"@ @ eval $m2c_ctx_lhu="bytes"@ @ eval $m2c_ctx_rh="${m2c_data_item}${node}"@ @ eval $m2c_ctx_rhs="${m2c_data_item}${node}_len"@ @ eval $m2c_ctx_rhu="elements"@ ######################################################################## ## ######################################################################## @ if $m2c_node_skip_mapping != 1@ @ if $m2c_node_needlength == 1@ @ eval $m2c_XX="$m2c_decl **mib_$m2c_node_param_ref_name,"@ @ eval $m2c_XX="$m2c_XX size_t *mib_$m2c_node_param_ref_lname,"@ @ eval $m2c_XX="$m2c_XX $m2c_decl *raw_$m2c_node_param_val_name,"@ @ eval $m2c_XX="$m2c_XX size_t raw_$m2c_node_param_val_lname,"@ @ eval $m2c_node_map_param="$m2c_XX int allow_realloc"@ @ else@ @ eval $m2c_XX="$m2c_decl *mib_$m2c_node_param_ref_name,"@ @ eval $m2c_node_map_param="$m2c_XX $m2c_decl raw_$m2c_node_param_val_name"@ @ end@ @ end@ ######################################################################## ## ######################################################################## @ eval $m2c_node_srh = "$m2c_node_param_val_name"@ @ eval $m2c_node_srhs = "$m2c_node_param_val_lname"@ @end@ ######################################################################## ## @eval $m2c_node_summary="$node($node.subid)/$node.syntax/$node.type/$node.decl($m2c_decl)/"@ @if $node.needlength == 0@ @ eval $m2c_node_summary="$m2c_node_summary/l"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/L"@ @end@ @if $node.noaccess == 0@ @ eval $m2c_node_summary="$m2c_node_summary/A"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/a"@ @end@ @if $node.settable == 0@ @ eval $m2c_node_summary="$m2c_node_summary/w"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/W"@ @end@ @if $node.enums == 0@ @ eval $m2c_node_summary="$m2c_node_summary/e"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/E"@ @end@ @if $node.ranges == 0@ @ eval $m2c_node_summary="$m2c_node_summary/r"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/R"@ @end@ @if $node.hasdefval == 0@ @ eval $m2c_node_summary="$m2c_node_summary/d"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/D"@ @end@ @if $node.hashint == 0@ @ eval $m2c_node_summary="$m2c_node_summary/h"@ @else@ @ eval $m2c_node_summary="$m2c_node_summary/H"@ @end@ ######################################################################## @ ifconf ${m2c_defaults_dir}node-${node}.m2d@ @ else@ @ push@ @ open ${m2c_defaults_dir}node-${node}.m2d@ @ eval $m2c_conf_comment = "##"@ @ eval $m2c_conf_comment_divider = "########################################################################"@ $m2c_conf_comment_divider $m2c_conf_comment $m2c_conf_comment mib2c node setting for $node $m2c_conf_comment $m2c_conf_comment Remove the '##' comment delimeter to change settings $m2c_conf_comment $m2c_conf_comment_divider $m2c_conf_comment Node declaration type? This is the C type to be used when $m2c_conf_comment declaring a variable to hold a value for this column. It $m2c_conf_comment is strongly recommended that you do not change this value. $m2c_conf_comment If you do, it is likely to break lots of generated code that $m2c_conf_comment you will have to fix. $m2c_conf_comment $m2c_conf_comment @eval $@m2c_decl = $m2c_decl@ $m2c_conf_comment $m2c_conf_comment_divider $m2c_conf_comment Generate/use mapping functions? Useful if the MIB defines $m2c_conf_comment a different format or enumerations than you data store uses. $m2c_conf_comment $m2c_conf_comment @eval $@m2c_node_skip_mapping = $m2c_node_skip_mapping@ $m2c_conf_comment $m2c_conf_comment_divider $m2c_conf_comment Need a length for the value? Most OCTET-STRING based values will $m2c_conf_comment need a length, most other types will not. Do not change this one $m2c_conf_comment unless you know what you are doing! You will almost certainly need $m2c_conf_comment to fix lots of generated code if you do. $m2c_conf_comment $m2c_conf_comment @eval $@m2c_node_needlength = $m2c_node_needlength@ $m2c_conf_comment $m2c_conf_comment_divider $m2c_conf_comment Skip get? Set this to 1 if you do not want to implement a value $m2c_conf_comment for this column. $m2c_conf_comment $m2c_conf_comment @eval $@m2c_node_skip_get = $m2c_node_skip_get@ $m2c_conf_comment @ if $m2c_node_needlength == 1@ $m2c_conf_comment_divider $m2c_conf_comment Allow realloc when data size exceeds length? If your data $m2c_conf_comment store for this node is a pointer allocated with one of the $m2c_conf_comment alloc family functions, you can set this to 1 to use realloc $m2c_conf_comment when a new value length exceeds the old lenght. If you are $m2c_conf_comment using a fixed size buffer, this value should be 0. $m2c_conf_comment $m2c_conf_comment @eval $@m2c_node_realloc = $m2c_node_realloc@ @ end@ @ close ${m2c_defaults_dir}node-${node}.m2d@ @ pop@ @ end@ mib2c-data/generic-source-includes.m2i 0000666 00000001471 15077166074 0013622 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-source-includes.m2i 8830 2003-09-30 13:34:57Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 8830 $ */ @end@ ######################################################################## ## /* standard Net-SNMP includes */ #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> /* include our parent header */ #include "${name}.h" ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 8830 $ */ @end@ mib2c-data/mfd-data-get.m2c 0000666 00000012133 15077166074 0011325 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: mfd-data-get.m2c 12088 2005-04-18 21:58:42Z rstory $ ######################################################################## ######################################################################## ## lower conf files get confused with multiple processing types, so ## set single options @eval $mfd_data_get_processing_type_save = "$m2c_processing_type"@ @if "$mfd_processing_types" =~ /h/@ @eval $m2c_processing_type = 'h'@ @if $m2c_create_fewer_files != 1@ @ open ${name}_data_get.h@ @ eval $hack = "Id"@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 12088 $ of $RCSfile$ * * $$hack:$ * * @file ${name}_data_get.h * * @addtogroup get * * Prototypes for get functions * * @{ */ @ eval $m2c_tmp = "$name"@ @ eval $name = "${name}_DATA_GET"@ @ include generic-header-top.m2i@ @ eval $name = "$m2c_tmp"@ @end@ // m2c_create_fewer_files @if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 12088 $ */ @end@ ######################################################################## ## /* ********************************************************************* * GET function declarations */ /* ********************************************************************* * GET Table declarations */ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ /* * indexes */ @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if $m2c_node_skip_mapping != 1@ int ${node}_map($m2c_node_map_param); @ end@ # // skip mapping @ end@ # index @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $m2c_node_skip_mapping != 1@ int ${node}_map($m2c_node_map_param); @ end@ # // skip mapping int ${node}_get( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_ref ); @ end@ // nonindex @ include generic-table-indexes-set.m2i@ @end@ // table @if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 12088 $ */ @end@ @if $m2c_create_fewer_files != 1@ @ eval $m2c_tmp = "$name"@ @ eval $name = "${name}_DATA_GET"@ @ include generic-header-bottom.m2i@ @ eval $name = "$m2c_tmp"@ /** @} */ @end@ // m2c_create_fewer_files ###################################################################### @end@ // $mfd_processing_types =~ /h/ ###################################################################### ###################################################################### ###################################################################### @if "$mfd_processing_types" =~ /c/@ @eval $m2c_processing_type = 'c'@ @if $m2c_create_fewer_files != 1@ @open ${name}_data_get.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 12088 $ of $RCSfile$ * * $$hack:$ */ @include generic-source-includes.m2i@ /** @defgroup data_get data_get: Routines to get data * * TODO:230:M: Implement $context get routines. * TODO:240:M: Implement $context mapping routines (if any). * * These routine are used to get the value for individual objects. The * row context is passed, along with a pointer to the memory where the * value should be copied. * * @{ */ @end@ // m2c_create_fewer_files @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12088 $ */ @end@ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ /* --------------------------------------------------------------------- * TODO:200:r: Implement $context data context functions. */ @ if (($m2c_data_allocate == 1) || ($m2c_undo_embed == 0)) && ("$m2c_data_context" ne "generated")@ @ include generic-data-allocate.m2i@ @ end@ ## ## do nodes ## ##// internal only? how to know how to map external? @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if $m2c_node_skip_mapping != 0@ @ next@ @ end@ @ include details-node.m2i@ @ if $m2c_report_progress == 1@ @ print | | +-> Processing index $node@ @ end@ @ include generic-value-map-func.m2i@ @ end@ # foreach column @ include generic-table-indexes-set.m2i@ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ include details-node.m2i@ @ if $node.noaccess == 1@ @ next@ # skip to next column @ end@ @ if $m2c_report_progress == 1@ @ print | | +-> Processing nonindex $node@ @ end@ @ if $m2c_node_skip_mapping == 0@ @ include generic-value-map-func.m2i@ @ end@ @ include node-get.m2i@ @ end@ # foreach column @end@ # foreach table ## /** @} */ ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12088 $ */ @end@ ######################################################################## @end@ // $mfd_processing_types =~ /c/ ## restore original processing types @eval $m2c_processing_type = "$mfd_data_get_processing_type_save"@ mib2c-data/syntax-RowStatus-get.m2i 0000666 00000004664 15077166074 0013167 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-RowStatus-get.m2i 12090 2005-04-18 22:04:52Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12090 $ */ @end@ ######################################################################## ## @include generic-get-decl.m2i@ @include generic-ctx-get.m2i@ @if $m2c_node_skip_mapping != 1@ /* * TODO:245:o: |-> Implement $context RowStatus mapping @if $mfd_code_verbose == 1@ * * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them here. @end@ */ /* * update INTERNAL_* macros defined in the header, if neccessary */ switch ($m2c_node_lh) { /* `active', which indicates that the conceptual row is available for use by the managed device */ case INTERNAL_$context.uc_$node.uc_ACTIVE: $m2c_node_lh = ROWSTATUS_ACTIVE; break; /* `notInService', which indicates that the conceptual row exists in the agent, but is unavailable for use by the managed device (see NOTE below); 'notInService' has no implication regarding the internal consistency of the row, availability of resources, or consistency with the current state of the managed device */ case INTERNAL_$context.uc_$node.uc_NOTINSERVICE: $m2c_node_lh = ROWSTATUS_NOTINSERVICE; break; /* `notReady', which indicates that the conceptual row exists in the agent, but is missing information necessary in order to be available for use by the managed device (i.e., one or more required columns in the conceptual row have not been instanciated) */ case INTERNAL_$context.uc_$node.uc_NOTREADY: $m2c_node_lh = ROWSTATUS_NOTREADY; break; default: snmp_log(LOG_ERR, "couldn't map value %ld for $node RowStatus\n", $m2c_node_lh); return SNMP_ERR_GENERR; } @end@ @include generic-get-decl-bot.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12090 $ */ @end@ mib2c-data/details-node.m2i 0000666 00000006700 15077166074 0011454 0 ustar 00 ############################################################# -*- c -*- ## Generic include for columns. Do not use directly. ## ## $Id: details-node.m2i 13790 2005-12-02 18:12:52Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 13790 $ */ @end@ ######################################################################## /*--------------------------------------------------------------------- * $node.module::$node.parent.$node * $node is subid $node.subid of $node.parent. * Its status is $node.status, and its access level is $node.access. * OID: $node.objectID * Description: $node.description * @if $m2c_node_detail == 1@ * node -- name $node * node.parent -- label of the parent $node.parent * node.objectID -- dotted full OID $node.objectID * node.commaoid -- comma separated OID $node.commaoid * node.subid -- last oid component $node.subid * node.oidlength-- length of the oid $node.oidlength * node.syntax -- node's syntax $node.syntax * node.perltype -- node's perl type $node.perltype * node.type -- node's ASN_XXX type $node.type * node.decl -- C data type $m2c_decl ($node.decl) * node.settable -- 1 if it's writable $node.settable * node.noaccess -- 1 if not-accessible $node.noaccess * node.access -- node's access type $node.access * node.status -- node's status $node.status * node.isscalar -- returns 1 if scalar $node.isscalar * node.iscolumn -- returns 1 if column $node.iscolumn * node.enums -- $node.enums * @end@ * Attributes: * accessible $node.accessible isscalar $node.isscalar enums $node.enums hasdefval $node.hasdefval * readable $node.readable iscolumn $node.iscolumn ranges $node.ranges hashint $node.hashint * settable $node.settable @if $node.hasdefval == 1@ * defval: $node.defval @end@ @if $node.hashint == 1@ * hint: $node.hint @end@ * @if $node.enums == 1@ @ eval $m2c_evals = ""@ @ eval $m2c_first = 1@ @ foreach $e $v enum@ @ if $m2c_first == 1@ @ eval $m2c_first = 0@ @ else@ @ eval $m2c_evals = "$m2c_evals,"@ @ end@ @ eval $m2c_evals = "$m2c_evals $e($v)"@ @ end@ * Enum range: $node.enumrange. Values: $m2c_evals @elsif $node.ranges == 1@ @ eval $m2c_range_max = 0@ @ eval $m2c_evals = ""@ @ eval $m2c_first = 1@ @ foreach $a $b range $node@ @ if $m2c_first == 1@ @ eval $m2c_first = 0@ @ else@ @ eval $m2c_evals = "$m2c_evals,"@ @ end@ @ if $a == $b@ @ eval $m2c_evals = "$m2c_evals $a"@ @ else@ @ eval $m2c_evals = "$m2c_evals $a - $b"@ @ end@ @ eval $m2c_range_max = max($m2c_range_max,$b)@ @ end@ * Ranges: $m2c_evals; @end@ #ranges * * Its syntax is $node.syntax (based on perltype $node.perltype) * The net-snmp type is $node.type. The C type decl is $node.decl ($m2c_decl) @if $node.needlength == 1@ @ if $node.ranges == 1@ * This data type requires a length. (Max $m2c_range_max) @ else@ * This data type requires a length. @ end@ @end@ @if $node.noaccess@ * * * * NOTE: NODE $node IS NOT ACCESSIBLE * * @end@ */ ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 13790 $ */ @end@ mib2c-data/generic-table-enums.m2c 0000666 00000003710 15077166074 0012722 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-enums.m2c 12526 2005-07-15 22:41:16Z rstory $ ######################################################################## @if $m2c_create_fewer_files != 1@ @eval $hack = "Id"@ @eval $m2c_save = "$name"@ @eval $name = "${name}_enums"@ @open ${name}.h@ /* * Note: this file originally auto-generated by mib2c using * $Id: generic-table-enums.m2c 12526 2005-07-15 22:41:16Z rstory $ * * $$hack:$ */ @include generic-header-top.m2i@ @eval $name = "$m2c_save"@ @end@ // m2c_create_fewer_files ######################################################################## @if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 12526 $ */ @end@ ## /* * NOTES on enums * ============== * * Value Mapping * ------------- * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them * below. For example, a boolean flag (1/0) is usually represented * as a TruthValue in a MIB, which maps to the values (1/2). * */ ## ## /************************************************************************* ************************************************************************* * * enum definitions for table $context * ************************************************************************* *************************************************************************/ @ foreach $node column@ @ include m2c_setup_node.m2i@ @ if $node.enums == 1@ @ include details-enums.m2i@ @ end@ @ end@ # column @if $m2c_create_fewer_files != 1@ @eval $m2c_save = "$name"@ @eval $name = "${name}_enums"@ @include generic-header-bottom.m2i@ @eval $name = "$m2c_save"@ @end@ ######################################################################## @if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 12526 $ */ @end@ mib2c-data/syntax-DateAndTime-readme.m2i 0000666 00000000440 15077166074 0013775 0 ustar 00 This column is a DataAndTime object. The local local variables year, month, day, hour, minues, seconds, deci_seconds, utc_offset_direction, utc_offset_hours and utc_offset_minutes should be set from the data context before the netsnmp_dateandtime_set_buf_from_vars function call. mib2c-data/syntax-TestAndIncr-get.m2i 0000666 00000001474 15077166074 0013366 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-TestAndIncr-get.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## @include generic-get-decl.m2i@ return MFD_SKIP; /* TODO:235:M: Remove SKIP once you've set $node data */ @include generic-ctx-get.m2i@ @include generic-get-long.m2i@ @include generic-get-decl-bot.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/mfd-interactive-setup.m2c 0000666 00000027331 15077166074 0013320 0 ustar 00 ####################################################################### ## generic include for XXX. Do not use directly. ## ## $Id: mfd-interactive-setup.m2c 16380 2007-05-17 18:06:33Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 16380 $ */ @end@ ######################################################################## @eval $m2c_temp_writable = table_is_writable($context)@ @eval $m2c_temp_create = table_has_create($context)@ @eval $m2c_temp_dependencies = $m2c_temp_writable@ @eval $m2c_temp_context_reg = "$mfd_default_context_reg"@ @eval $m2c_temp_data_context = "$mfd_default_data_context"@ @eval $m2c_temp_data_allocate = $mfd_default_data_allocate@ @eval $m2c_temp_data_cache = $mfd_default_data_cache@ @eval $m2c_temp_undo_embed = $mfd_default_undo_embed@ @eval $m2c_temp_data_init = $mfd_default_data_init@ @eval $m2c_temp_persistent = $m2c_temp_writable@ @eval $m2c_temp_table_access = "$mfd_default_table_access"@ @eval $m2c_temp_data_transient = $mfd_default_data_transient@ @eval $m2c_temp_include_examples = $mfd_default_include_examples@ @eval $m2c_temp_table_skip_mapping = $mfd_default_table_skip_mapping@ @eval $m2c_temp_table_sparse = $mfd_default_data_sparse@ @eval $m2c_temp_generate_makefile = $mfd_default_generate_makefile@ @eval $m2c_temp_generate_subagent = $mfd_default_generate_subagent@ ## @if $mfd_interactive_setup != 0@ @open -@ @ if $mfd_interactive_setup != -1@ There are no defaults for ${context}. Would you like to 1) Accept hard-coded defaults 2) Set defaults now [DEFAULT] @ eval $ans = 2@ @ prompt $ans Select your choice : @ @ else@ @ eval $ans = 2@ @ end@ @ if $ans == 1@ @ else@ ## --------------------------------------------------- @ if $m2c_temp_writable == 1@ This table has writable columns. Do you want to generate code for writeable columns, or restrict the table to read-only? 1) generate code with writeable columns [DEFAULT] 2) generate code with read-only columns @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_writable = 0@ @ eval $m2c_temp_create = 0@ @ eval $m2c_temp_dependencies = 0@ @ eval $m2c_temp_persistent = 0@ @ end@ @ end@ # writable ## --------------------------------------------------- @ if $m2c_temp_persistent == 1@ @ eval $m2c_temp_persistent = 0@ Since your table is writable, do you want to generate code to save and restore rows in the Net-SNMP persistent store? You should only use this option if the agent 'owns' the data, and doesn't get the data from an external source. 1) do not generate persistent store code [DEFAULT] 2) generate persistent store code @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_persistent = 1@ @ end@ @ end@ # persistent ## --------------------------------------------------- @ if $m2c_temp_dependencies == 1@ @ eval $m2c_temp_dependencies = 0@ Writable tables sometimes have dependencies beteen columns or with other tables. If there are no dependencies in this table, you probably do not want the extra code. 1) do not generate dependency code [DEFAULT] 2) generate dependency code @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_dependencies = 1@ @ end@ @ end@ # dependencies ## --------------------------------------------------- @ if $m2c_temp_create == 1@ This table has read-create columns. Do you want to generate code for dynamic row creation? 1) generate code for row creation [DEFAULT] 2) do not generate code for row creation @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_create = 0@ @ end@ @ end@ # create ## --------------------------------------------------- Do you want to use an existing data structure for the USER context? This would be a structure used to track data for the entire table, (similar to a global variable) not individual rows. 1) No, use $m2c_temp_context_reg [DEFAULT] 2) Yes, use my own structure @ prompt $ans Select your choice : @ @ if $ans == 2@ @ prompt $m2c_temp_context_reg Enter your USER context : @ @ end@ ## --------------------------------------------------- Do you want to use an existing data structure for the DATA context? The DATA context holds the data for each MIB column. By default, a new data structure will be created with an element for each column. 1) No, use $m2c_temp_data_context [DEFAULT] 2) Yes, use my own structure @ prompt $ans Select your choice : @ @ if $ans == 2@ Note: Do not enter a pointer type. Use the base structure name. For example, use 'struct widget', not 'struct widget *'. If you will be using pointer to the structure, select dynamic allocation in the next question. @ prompt $m2c_temp_data_context Enter your DATA context : @ @ end@ ## --------------------------------------------------- @ if "x$m2c_temp_data_context" ne "x$mfd_default_data_context"@ Do you want to allocate your '$m2c_temp_data_context' DATA context, or embed it directly? If your data is INTERNAL (controlled by the agent), you probably want embedded. If your data is EXTERNAL (controlled by another process) and you have pointers to the data, you probably want allocated. 1) directly embed structure [DEFAULT] 2) dynamically allocate structure @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_data_allocate = 1@ @ end@ @ end@ # ! default (generated) ## --------------------------------------------------- Do you need to initialize elements in the '$m2c_temp_data_context' DATA context when a new instance is created (eg default values, or other structures you are going to add that might need initialization to the row request context? (The most common reasons you might need to do this is are if you want to keep some non-MIB data for every row, or some columns have default values.) 1) no, no initialization needed 2) yes, initilization is needed [DEFAULT] @ prompt $ans Select your choice : @ @ if $ans == 1@ @ eval $m2c_temp_data_init = 0@ @ end@ ## --------------------------------------------------- Do you plan on keeping all data in the format defined by the MIB? If so, no functions will be generated to map values. If some data will be stored in a different format, the mapping functions will be generated. If your MIB has integers with enumerations, mapping functions are more likely to be needed. (e.g. A TruthValue object will hold the value 1 or 2, but a C boolean would be 1 or 0.) 1) All values will be stored as defined by the MIB [DEFAULT] 2) I need to map values to the format defined by the MIB. @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_table_skip_mapping = -1@ @ end@ ## --------------------------------------------------- Which method would you like to use to gather data about available rows? 1) container : [DEFAULT] This access method uses a netsnmp_container to store all row data in memory. This method is best for: - Internal data (maintained by the agent) - Access speed is important - Sufficient memory exists to contain all rows 2) container-cached : This access method uses a netsnmp_container to keep track of the indexes (and data, usually) for each row. This method is best for: - External data (maintained by another process/the kernel) - Access speed is important - Sufficient memory exists to contain all indexes 3) unsorted-external : This access method iterates over all of your data to find the row with the appropriate index. This method is good for - External data (maintained by another process/the kernel) - Using less memory is much more important than access speed @ prompt $ans Select your choice : @ @ if $ans == 3@ @ eval $m2c_temp_table_access = "unsorted-external"@ @ elsif $ans == 2@ @ eval $m2c_temp_table_access = "container-cached"@ @ eval $m2c_temp_data_cache = 1@ @ else@ @ eval $m2c_temp_table_access = "container-cached"@ @ eval $m2c_temp_data_cache = 0@ @ end@ ## --------------------------------------------------- When accessing your data, is your data TRANSIENT? 1) Yes. My data is TRANSIENT (e.g. a pointer to a static buffer that my be overwritten during a request) and needs to be copied during processing. 2) Yes. My data is SEMI-TRANSIENT (e.g. an allocated pointer to a copy of the data). 3) No, my data is PERSISTENT (e.g. an allocated pointer to the actual data, which is under the agent's control) ## ' @ prompt $ans Select your choice [DEFAULT=1] : @ @ if $ans == 3@ @ eval $m2c_temp_data_transient = 0@ @ elsif $ans == 2@ @ eval $m2c_temp_data_transient = 1@ @ else@ @ eval $m2c_temp_data_transient = 2@ @ end@ ## --------------------------------------------------- Do you want example code to be generated? This will generate example code for reading data from a text file. 1) generate example code [DEFAULT] 2) do not generate example code @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_include_examples = 0@ @ else@ @ eval $m2c_temp_include_examples = 1@ @ end@ ## --------------------------------------------------- Is your table sparse? A sparse table is a table where some columns might not exist for all rows. Note that if your table contains a RowStaus column and it supports createAndWait, you will need sparse table support. 1) No, all columns always exist for every row [DEFAULT] 2) Yes, my table is sparse @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_table_sparse = 1@ @ end@ ## --------------------------------------------------- Do you want a makefile and AgentX subagent source file generated? This will let you test your table without having to link it into snmpd. (You can still link it in later.) 1) do not generate makefile/AgentX code [DEFAULT] 2) generate makefile/AgentX code @ prompt $ans Select your choice : @ @ if $ans == 2@ @ eval $m2c_temp_generate_makefile = 1@ @ eval $m2c_temp_generate_subagent = 1@ @ else@ @ eval $m2c_temp_generate_makefile = 0@ @ eval $m2c_temp_generate_subagent = 0@ @ end@ @ end@ # do not use hardcoded @end@ # $mfd_interactive_setup == 1 ################################## ## ## save values ## Note: if you add a var here, add it in m2c_table_save_defaults.m2i too ## @eval $m2c_context_reg = "$m2c_temp_context_reg"@ @eval $m2c_data_allocate = $m2c_temp_data_allocate@ @eval $m2c_data_cache = $m2c_temp_data_cache@ @eval $m2c_data_context = "$m2c_temp_data_context"@ @eval $m2c_data_init = $m2c_temp_data_init@ @eval $m2c_data_transient = $m2c_temp_data_transient@ @eval $m2c_include_examples = $m2c_temp_include_examples@ @eval $m2c_irreversible_commit = $m2c_irreversible_commit@ @eval $m2c_table_access = "$m2c_temp_table_access"@ @eval $m2c_table_dependencies = $m2c_temp_dependencies@ @eval $m2c_table_persistent = $m2c_temp_persistent@ @eval $m2c_table_row_creation = $m2c_temp_create@ @eval $m2c_table_settable = $m2c_temp_writable@ @eval $m2c_table_skip_mapping = $m2c_temp_table_skip_mapping@ @eval $m2c_table_sparse = $m2c_temp_table_sparse@ @eval $mfd_generate_makefile = $m2c_temp_generate_makefile@ @eval $mfd_generate_subagent = $m2c_temp_generate_subagent@ ## ## write them back ## @include m2c_table_save_defaults.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 16380 $ */ @end@ mib2c-data/generic-table-indexes-varbind-setup.m2i 0000666 00000002752 15077166074 0016026 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-indexes-varbind-setup.m2i 10286 2004-05-18 17:35:47Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 10286 $ */ @end@ ######################################################################## ## int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ @ eval $m2c_dii_first = ""@ @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if "x$m2c_dii_first" eq "x"@ @ eval $m2c_dii_first = $node@ @ eval $m2c_dii_tmp = "var_${node}.next_variable = "@ @ else@ @ eval $m2c_dii_tmp = "$m2c_dii_tmp &var_${node}; var_${node}.next_variable = "@ @ end@ /* * $m2c_node_summary */ netsnmp_variable_list var_$node; @ end@ @ eval $m2c_dii_tmp = "$m2c_dii_tmp NULL;"@ /* * set up varbinds */ @ eval $mfd_temp = "idx_vars"@ @ foreach $node index@ @ include m2c_setup_node.m2i@ memset( &var_$node, 0x00, sizeof(var_$node) ); var_${node}.type = $node.type; @ end@ /* * chain temp index varbinds together */ $m2c_dii_tmp ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 10286 $ */ @end@ mib2c-data/syntax-RowStatus-dependencies.m2i 0000666 00000010232 15077166074 0015022 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-RowStatus-dependencies.m2i 12850 2005-09-27 15:42:43Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12850 $ */ @end@ ######################################################################## ## { /* * check RowStatus dependencies */ if (rowreq_ctx->column_set_flags & COLUMN_$node.uc_FLAG) { /* * check for valid RowStatus transition (old, new) * (Note: move transition check to $node_check_value * to catch errors earlier) */ rc = check_rowstatus_transition( ${m2c_undo_item}$node, ${m2c_data_item}$node ); if (MFD_SUCCESS != rc) return rc; @if $m2c_table_row_creation == 1@ /* * row creation requirements */ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { if (ROWSTATUS_DESTROY == ${m2c_data_item}$node) { rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; } else if (ROWSTATUS_CREATEANDGO == ${m2c_data_item}$node) { if ((rowreq_ctx->column_set_flags & $context.uc_REQUIRED_COLS) != $context.uc_REQUIRED_COLS) { DEBUGMSGTL(("${context}", "required columns missing (0x%0x != 0x%0x)\n", rowreq_ctx->column_set_flags, $context.uc_REQUIRED_COLS)); return MFD_CANNOT_CREATE_NOW; } ${m2c_data_item}$node = ROWSTATUS_ACTIVE; } } /* row creation */ else { @end@ /* * row change requirements */ /* * don't allow a destroy if any other value was changed, since * that might call data access routines with bad info. * * you may or may not require the row be notInService before it * can be destroyed. */ if (ROWSTATUS_DESTROY == ${m2c_data_item}$node) { @if $m2c_table_refcounts == 1@ if (0 != rowreq_ctx->ref_count) { DEBUGMSGTL(("$context", "can't delete row, %d references\n", rowreq_ctx->ref_count)); return MFD_NOT_VALID_NOW; } @end@ if (rowreq_ctx->column_set_flags & ~COLUMN_$node.uc_FLAG) { DEBUGMSGTL(("$context", "destroy must be only varbind for row\n")); return MFD_NOT_VALID_NOW; } rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED; } /* row destroy */ @if $m2c_table_refcounts == 1@ else if(ROWSTATUS_NOTINSERVICE == ${m2c_data_item}$node) { if (0 != rowreq_ctx->ref_count) { DEBUGMSGTL(("$context", "can't deactivate row, %d references\n", rowreq_ctx->ref_count)); return MFD_NOT_VALID_NOW; } } /* notInService */ @end@ @if $m2c_table_row_creation == 1@ } /* row change */ @end@ } else { @if $m2c_table_row_creation == 1@ /* * must have row status to create a row */ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { DEBUGMSGTL(("$context", "must use RowStatus to create rows\n")); return MFD_CANNOT_CREATE_NOW; } @else@ /* * row creation not supported */ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { DEBUGMSGTL(("$context", "row creation not supported\n")); return MFD_CANNOT_CREATE_EVER; } @end@ } /* row status not set */ ## } ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12850 $ */ @end@ mib2c-data/node-varbind-validate.m2i 0000666 00000004134 15077166074 0013242 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: node-varbind-validate.m2i 12101 2005-04-20 22:45:01Z rstory $ ## ## Tests a netsnmp_variable_list pointer (var) against known ## contstraints. If none are found, calls the user supplied funtion ## ${node}_check_value. ## ## Sets the variable rc to a SNMP_ERR. ## ## Requirements ## ------------ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12101 $ */ @end@ ######################################################################## ##---------------------------------------------------------------------- ## setup ##---------------------------------------------------------------------- @if $m2c_paranoid == 1@ netsnmp_assert(rc == SNMP_ERR_NOERROR); /* paranoia */ @end@ ##---------------------------------------------------------------------- ## syntax specific ##---------------------------------------------------------------------- @ifconf syntax-$node.syntax-varbind-validate.m2i@ @ include syntax-$node.syntax-varbind-validate.m2i@ @else@ ##---------------------------------------------------------------------- ## Check type ##---------------------------------------------------------------------- ## if not generated code, length checks are up to user @ if "$m2c_data_context" ne "generated"@ rc = netsnmp_check_vb_type( var, $node.type ); @ elsif ($m2c_node_needlength == 1) || ("$node.perltype" eq "BITS")@ rc = netsnmp_check_vb_type_and_max_size( var, $node.type, sizeof( $m2c_nvv_item$node ) ); @ else@ rc = netsnmp_check_vb_type_and_size( var, $node.type, sizeof( $m2c_nvv_item$node ) ); @ end@ @ eval $m2c_nv_val = "*var->val.integer"@ @ eval $m2c_nv_len = "var->val_len"@ @ eval $m2c_nv_str = "var->val.string"@ @ include node-validate.m2i@ @end@ # not syntax specific ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12101 $ */ @end@ mib2c-data/mfd-interface.m2c 0000666 00000146260 15077166074 0011610 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: mfd-interface.m2c 15899 2007-02-27 13:08:24Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 15899 $ */ @end@ ######################################################################## ## ######################################################################## @eval $m2c_processing_type = 'h'@ @open ${name}_interface.h@ @eval $hack = "Id"@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 15899 $ of $RCSfile$ * * $$hack:$ */ /** @ingroup interface: Routines to interface to Net-SNMP * * \warning This code should not be modified, called directly, * or used to interpret functionality. It is subject to * change at any time. * * @{ */ @include m2c-internal-warning.m2i@ ## @eval $m2c_save = "$name"@ @eval $name = "${name}_INTERFACE"@ @include generic-header-top.m2i@ @eval $name = "$m2c_save"@ #include "${name}.h" /* ******************************************************************** * Table declarations */ @foreach $table table@ @ include m2c_setup_table.m2i@ /* PUBLIC interface initialization routine */ void _${context}_initialize_interface(${context}_registration * user_ctx, u_long flags); void _${context}_shutdown_interface(${context}_registration * user_ctx); ${context}_registration * ${context}_registration_get( void ); ${context}_registration * ${context}_registration_set( ${context}_registration * newreg ); netsnmp_container *${context}_container_get( void ); int ${context}_container_size( void ); @ if $m2c_table_settable@ u_int ${context}_dirty_get( void ); void ${context}_dirty_set( u_int status ); @ end@ @ if $m2c_data_allocate == 1@ @ eval $m2c_tmp = "${context}_data *"@ @ if $m2c_data_init == 1@ @ eval $m2c_tmp = "$m2c_tmp, void *"@ @ @end@ @ elsif $m2c_data_init == 1@ @ eval $m2c_tmp = "void *"@ @ else@ @ eval $m2c_tmp = "void"@ @ end@ ${context}_rowreq_ctx * ${context}_allocate_rowreq_ctx($m2c_tmp); void ${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx); int ${context}_index_to_oid(netsnmp_index *oid_idx, ${context}_mib_index *mib_idx); int ${context}_index_from_oid(netsnmp_index *oid_idx, ${context}_mib_index *mib_idx); @ if $m2c_table_persistent == 1@ @ include mfd-persistence.m2i@ @ end@ /* * access to certain internals. use with caution! */ void ${context}_valid_columns_set(netsnmp_column_info *vc); @end@ # for each @eval $m2c_save = "$name"@ @eval $name = "${name}_INTERFACE"@ @include generic-header-bottom.m2i@ /** @} */ @eval $name = "$m2c_save"@ ######################################################################## ######################################################################## ######################################################################## ######################################################################## ######################################################################## ######################################################################## ######################################################################## ## @open ${name}_interface.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 15899 $ of $RCSfile$ * * $$hack:$ */ @include m2c-internal-warning.m2i@ @include generic-source-includes.m2i@ #include <net-snmp/agent/table_container.h> #include <net-snmp/library/container.h> #include "${name}_interface.h" #include <ctype.h> @eval $m2c_processing_type = 'i'@ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ ######################################################################## typedef struct ${context}_interface_ctx_s { netsnmp_container *container; @ if $m2c_data_cache == 1@ netsnmp_cache *cache; @ end@ ${context}_registration * user_ctx; netsnmp_table_registration_info tbl_info; netsnmp_baby_steps_access_methods access_multiplexer; @ if $m2c_table_settable@ u_int table_dirty; @ end@ } ${context}_interface_ctx; static ${context}_interface_ctx ${context}_if_ctx; static void _${context}_container_init( ${context}_interface_ctx *if_ctx); static void _${context}_container_shutdown( ${context}_interface_ctx *if_ctx); netsnmp_container * ${context}_container_get( void ) { return ${context}_if_ctx.container; } ${context}_registration * ${context}_registration_get( void ) { return ${context}_if_ctx.user_ctx; } ${context}_registration * ${context}_registration_set( ${context}_registration * newreg ) { ${context}_registration * old = ${context}_if_ctx.user_ctx; ${context}_if_ctx.user_ctx = newreg; return old; } int ${context}_container_size( void ) { return CONTAINER_SIZE(${context}_if_ctx.container); } @ if $m2c_table_settable@ u_int ${context}_dirty_get( void ) { return ${context}_if_ctx.table_dirty; } void ${context}_dirty_set( u_int status ) { DEBUGMSGTL(("${context}:${context}_dirty_set", "called. was %d, now %d\n", ${context}_if_ctx.table_dirty, status)); ${context}_if_ctx.table_dirty = status; } @end@ /* * mfd multiplexer modes */ static Netsnmp_Node_Handler _mfd_${context}_pre_request; static Netsnmp_Node_Handler _mfd_${context}_post_request; static Netsnmp_Node_Handler _mfd_${context}_object_lookup; static Netsnmp_Node_Handler _mfd_${context}_get_values; @ if $m2c_table_settable@ static Netsnmp_Node_Handler _mfd_${context}_check_objects; static Netsnmp_Node_Handler _mfd_${context}_undo_setup; static Netsnmp_Node_Handler _mfd_${context}_set_values; static Netsnmp_Node_Handler _mfd_${context}_undo_cleanup; static Netsnmp_Node_Handler _mfd_${context}_undo_values; static Netsnmp_Node_Handler _mfd_${context}_commit; static Netsnmp_Node_Handler _mfd_${context}_undo_commit; static Netsnmp_Node_Handler _mfd_${context}_irreversible_commit; @ if $m2c_table_dependencies == 1@ static Netsnmp_Node_Handler _mfd_${context}_check_dependencies; @ end@ NETSNMP_STATIC_INLINE int _${context}_undo_column( ${context}_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ); @ end@ # writable @if ($m2c_table_persistent == 1) || ($m2c_table_row_creation == 1)@ NETSNMP_STATIC_INLINE int _${context}_check_indexes(${context}_rowreq_ctx * rowreq_ctx); @end@ @ if ("$m2c_data_context" eq "generated") && (($m2c_undo_embed == 0) || ($m2c_data_allocate == 1))@ ${context}_data *${context}_allocate_data(void); @ end@ /** * @internal * Initialize the table $context * (Define its contents and how it's structured) */ void _${context}_initialize_interface(${context}_registration * reg_ptr, u_long flags) { netsnmp_baby_steps_access_methods *access_multiplexer = &${context}_if_ctx.access_multiplexer; netsnmp_table_registration_info *tbl_info = &${context}_if_ctx.tbl_info; netsnmp_handler_registration *reginfo; netsnmp_mib_handler *handler; int mfd_modes = 0; DEBUGMSGTL(("internal:${context}:_${context}_initialize_interface","called\n")); /************************************************* * * save interface context for ${context} */ /* * Setting up the table's definition */ netsnmp_table_helper_add_indexes(tbl_info, @foreach $tabledx index@ $tabledx.type, /** index: $tabledx */ @end@ 0); /* Define the minimum and maximum accessible columns. This optimizes retrival. */ tbl_info->min_column = $context.uc_MIN_COL; tbl_info->max_column = $context.uc_MAX_COL; /* * save users context */ ${context}_if_ctx.user_ctx = reg_ptr; /* * call data access initialization code */ ${context}_init_data(reg_ptr); /* * set up the container */ _${context}_container_init(&${context}_if_ctx); if (NULL == ${context}_if_ctx.container) { snmp_log(LOG_ERR,"could not initialize container for ${context}\n"); return; } /* * access_multiplexer: REQUIRED wrapper for get request handling */ access_multiplexer->object_lookup = _mfd_${context}_object_lookup; access_multiplexer->get_values = _mfd_${context}_get_values; /* * no wrappers yet */ access_multiplexer->pre_request = _mfd_${context}_pre_request; access_multiplexer->post_request = _mfd_${context}_post_request; ## @ if $m2c_table_settable@ /* * REQUIRED wrappers for set request handling */ access_multiplexer->object_syntax_checks = _mfd_${context}_check_objects; access_multiplexer->undo_setup = _mfd_${context}_undo_setup; access_multiplexer->undo_cleanup = _mfd_${context}_undo_cleanup; access_multiplexer->set_values = _mfd_${context}_set_values; access_multiplexer->undo_sets = _mfd_${context}_undo_values; /* * no wrappers yet */ access_multiplexer->commit = _mfd_${context}_commit; access_multiplexer->undo_commit = _mfd_${context}_undo_commit; access_multiplexer->irreversible_commit = _mfd_${context}_irreversible_commit; ## @ if $m2c_table_dependencies == 1@ /* * REQUIRED for tables with dependencies */ access_multiplexer->consistency_checks = _mfd_${context}_check_dependencies; @ end@ @ end@ # writable /************************************************* * * Create a registration, save our reg data, register table. */ DEBUGMSGTL(("$name:init_$context", "Registering $context as a mibs-for-dummies table.\n")); handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); reginfo = netsnmp_handler_registration_create("${context}", handler, ${context}_oid, ${context}_oid_size, HANDLER_CAN_BABY_STEP | @if $m2c_table_settable == 1@ HANDLER_CAN_RWRITE @else@ HANDLER_CAN_RONLY @end@ ); if(NULL == reginfo) { snmp_log(LOG_ERR,"error registering table ${context}\n"); return; } reginfo->my_reg_void = &${context}_if_ctx; /************************************************* * * set up baby steps handler, create it and inject it */ if( access_multiplexer->object_lookup ) mfd_modes |= BABY_STEP_OBJECT_LOOKUP; if( access_multiplexer->set_values ) mfd_modes |= BABY_STEP_SET_VALUES; if( access_multiplexer->irreversible_commit ) mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; if( access_multiplexer->object_syntax_checks ) mfd_modes |= BABY_STEP_CHECK_OBJECT; if( access_multiplexer->pre_request ) mfd_modes |= BABY_STEP_PRE_REQUEST; if( access_multiplexer->post_request ) mfd_modes |= BABY_STEP_POST_REQUEST; if( access_multiplexer->undo_setup ) mfd_modes |= BABY_STEP_UNDO_SETUP; if( access_multiplexer->undo_cleanup ) mfd_modes |= BABY_STEP_UNDO_CLEANUP; if( access_multiplexer->undo_sets ) mfd_modes |= BABY_STEP_UNDO_SETS; if( access_multiplexer->row_creation ) mfd_modes |= BABY_STEP_ROW_CREATE; if( access_multiplexer->consistency_checks ) mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; if( access_multiplexer->commit ) mfd_modes |= BABY_STEP_COMMIT; if( access_multiplexer->undo_commit ) mfd_modes |= BABY_STEP_UNDO_COMMIT; handler = netsnmp_baby_steps_handler_get(mfd_modes); netsnmp_inject_handler(reginfo, handler); /************************************************* * * inject row_merge helper with prefix rootoid_len + 2 (entry.col) */ handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); netsnmp_inject_handler(reginfo, handler); /************************************************* * * inject container_table helper */ handler = netsnmp_container_table_handler_get(tbl_info, ${context}_if_ctx.container, TABLE_CONTAINER_KEY_NETSNMP_INDEX); netsnmp_inject_handler( reginfo, handler ); @ if $m2c_data_cache == 1@ /************************************************* * * inject cache helper */ if(NULL != ${context}_if_ctx.cache) { handler = netsnmp_cache_handler_get(${context}_if_ctx.cache); netsnmp_inject_handler( reginfo, handler ); } @ end@ /* * register table */ netsnmp_register_table(reginfo, tbl_info); @if $m2c_table_persistent == 1@ /* * register config/persistence callbacks */ ${context}_container_init_persistence(${context}_if_ctx.container); @end@ } /* _${context}_initialize_interface */ /** * @internal * Shutdown the table $context */ void _${context}_shutdown_interface(${context}_registration * reg_ptr) { /* * shutdown the container */ _${context}_container_shutdown(&${context}_if_ctx); } void ${context}_valid_columns_set(netsnmp_column_info *vc) { ${context}_if_ctx.tbl_info.valid_columns = vc; } /* ${context}_valid_columns_set */ @include generic-table-indexes-to-oid.m2i@ @include generic-table-indexes-from-oid.m2i@ ######################################################################## ## @ if (($m2c_data_allocate == 1) || ($m2c_undo_embed == 0)) && ("$m2c_data_context" eq "generated")@ @ eval $m2c_gda_todo_suppress = 1@ # no todo comments @ include generic-data-allocate.m2i@ # resets suppress @ end@ ######################################################################## /* ********************************************************************* * @internal * allocate resources for a ${context}_rowreq_ctx */ ${context}_rowreq_ctx * @if $m2c_data_allocate == 1@ @ eval $m2c_tmp = "${context}_data *data"@ @ if $m2c_data_init == 1@ @ eval $m2c_tmp = "$m2c_tmp, void *user_init_ctx"@ @ end@ @elsif $m2c_data_init == 1@ @ eval $m2c_tmp = "void *user_init_ctx"@ @else@ @ eval $m2c_tmp = "void"@ @end@ ${context}_allocate_rowreq_ctx($m2c_tmp) { ${context}_rowreq_ctx *rowreq_ctx = SNMP_MALLOC_TYPEDEF(${context}_rowreq_ctx); DEBUGMSGTL(("internal:${context}:${context}_allocate_rowreq_ctx","called\n")); if(NULL == rowreq_ctx) { snmp_log(LOG_ERR,"Couldn't allocate memory for a " "${context}_rowreq_ctx.\n"); return NULL; } @if $m2c_data_allocate == 1@ else { if(NULL != data) { /* * track if we got data from user */ rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; rowreq_ctx->data = data; } else if (NULL == (rowreq_ctx->data = ${context}_allocate_data())) { SNMP_FREE(rowreq_ctx); return NULL; } } /* * undo context will be allocated when needed (in *_undo_setup) */ @end@ rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; rowreq_ctx->${context}_data_list = NULL; @if $m2c_data_init == 1@ /* * if we allocated data, call init routine */ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { if(SNMPERR_SUCCESS != ${context}_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { ${context}_release_rowreq_ctx(rowreq_ctx); rowreq_ctx = NULL; } } @end@ return rowreq_ctx; } /* ${context}_allocate_rowreq_ctx */ /* * @internal * release resources for a ${context}_rowreq_ctx */ void ${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx) { DEBUGMSGTL(("internal:${context}:${context}_release_rowreq_ctx","called\n")); netsnmp_assert(NULL != rowreq_ctx); @if $m2c_data_init == 1@ ${context}_rowreq_ctx_cleanup(rowreq_ctx); @end@ @if $m2c_data_allocate == 1@ /* * for non-transient data, don't free data we got from the user */ if ((rowreq_ctx->data) && !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) ${context}_release_data(rowreq_ctx->data); @end@ @if $m2c_undo_embed == 0@ if(rowreq_ctx->undo) ${context}_release_data(rowreq_ctx->undo); @end@ /* * free index oid pointer */ if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) free(rowreq_ctx->oid_idx.oids); SNMP_FREE(rowreq_ctx); } /* ${context}_release_rowreq_ctx */ ######################################################################## ## /** * @internal * wrapper */ static int _mfd_${context}_pre_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_pre_request", "called\n")); if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:${context}", "skipping additional pre_request\n")); return SNMP_ERR_NOERROR; } rc = ${context}_pre_request(${context}_if_ctx.user_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}","error %d from " "${context}_pre_request\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR; } /* _mfd_${context}_pre_request */ /** * @internal * wrapper */ static int _mfd_${context}_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc, packet_rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_post_request", "called\n")); /* * release row context, if deleted */ if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) ${context}_release_rowreq_ctx(rowreq_ctx); /* * wait for last call before calling user */ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:${context}", "waiting for last post_request\n")); return SNMP_ERR_NOERROR; } packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); @ if $m2c_table_settable@ if ((MFD_SUCCESS != packet_rc) && ${context}_dirty_get()) { /* * we shouldn't get here. the undo steps should also clear * the dirty flags. */ snmp_log(LOG_WARNING, "${context} dirty flag set in post_request " "but status != SUCCESS.\n"); } @ end@ rc = ${context}_post_request(${context}_if_ctx.user_ctx,packet_rc); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}","error %d from " "${context}_post_request\n", rc)); } return SNMP_ERR_NOERROR; } /* _mfd_${context}_post_request */ ######################################################################## ## @if ($m2c_table_row_creation == 1) || ($m2c_table_persistent == 1)@ /** * @internal * wrapper */ static ${table}_rowreq_ctx * _mfd_${context}_rowreq_from_index(netsnmp_index *oid_idx, int * rc_ptr) { ${context}_rowreq_ctx * rowreq_ctx; ${context}_mib_index mib_idx; int rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_rowreq_from_index", "called\n")); if (NULL == rc_ptr) rc_ptr = &rc; *rc_ptr = MFD_SUCCESS; memset(&mib_idx, 0x0, sizeof(mib_idx)); /* * try to parse oid */ *rc_ptr = ${context}_index_from_oid(oid_idx, &mib_idx); if(MFD_SUCCESS != *rc_ptr) { DEBUGMSGT(("$context", "error parsing index\n")); return NULL; } /* * allocate new context */ @ eval $m2c_tmp = ""@ @ if ($m2c_data_allocate == 1) || ($m2c_data_init == 1)@ @ eval $m2c_tmp = "NULL"@ @ if ($m2c_data_allocate == 1) && ($m2c_data_init == 1)@ @ eval $m2c_tmp = "$m2c_tmp, NULL"@ @ @end@ @ end@ rowreq_ctx = ${context}_allocate_rowreq_ctx($m2c_tmp); if (NULL == rowreq_ctx) { *rc_ptr = MFD_ERROR; return NULL; /* msg already logged */ } memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx)); /* * check indexes */ *rc_ptr = _${context}_check_indexes(rowreq_ctx); if(MFD_SUCCESS != *rc_ptr) { netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || (*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); ${context}_release_rowreq_ctx(rowreq_ctx); return NULL; } /* * copy indexes */ rowreq_ctx->oid_idx.len = oid_idx->len; memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids, oid_idx->len * sizeof(oid)); return rowreq_ctx; } /* _mfd_${context}_rowreq_from_index */ @end@ # row creation /** * @internal * wrapper */ static int _mfd_${context}_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc = SNMP_ERR_NOERROR; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_object_lookup","called\n")); /* * get our context from mfd * ${context}_interface_ctx *if_ctx = * (${context}_interface_ctx *)reginfo->my_reg_void; */ if(NULL == rowreq_ctx) { @ if $m2c_table_row_creation == 0@ rc = SNMP_ERR_NOCREATION; @ else@ netsnmp_table_request_info *tblreq_info; netsnmp_index oid_idx; tblreq_info = netsnmp_extract_table_info(requests); if(NULL == tblreq_info) { snmp_log(LOG_ERR, "request had no table info\n"); return MFD_ERROR; } /* * try create rowreq */ oid_idx.oids = tblreq_info->index_oid; oid_idx.len = tblreq_info->index_oid_len; rowreq_ctx = _mfd_${context}_rowreq_from_index(&oid_idx, &rc); if(MFD_SUCCESS == rc) { netsnmp_assert(NULL != rowreq_ctx); rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED; /* * add rowreq_ctx to request data lists */ netsnmp_container_table_row_insert(requests, (netsnmp_index*)rowreq_ctx); } @ end@ // row creation } if (MFD_SUCCESS != rc) netsnmp_request_set_error_all(requests, rc); else ${context}_row_prep(rowreq_ctx); return SNMP_VALIDATE_ERR(rc); } /* _mfd_${context}_object_lookup */ ######################################################################## ## /*********************************************************************** * * GET processing * ***********************************************************************/ /* * @internal * Retrieve the value for a particular column */ NETSNMP_STATIC_INLINE int _${context}_get_column( ${context}_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch(column) { @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ @ if $node.accessible == 1@ /* (INDEX) $m2c_node_summary */ case COLUMN_$node.uc: var->type = $node.type; @ if $m2c_node_needlength == 1@ /* * NOTE: val_len is in bytes, ${node}_len might not be (e.g. oids) */ if (var->val_len < (rowreq_ctx->tbl_idx.${node}_len * sizeof(rowreq_ctx->tbl_idx.${node}[0]))) { var->val.string = malloc(rowreq_ctx->tbl_idx.${node}_len * sizeof(rowreq_ctx->tbl_idx.${node}[0])); } var->val_len = rowreq_ctx->tbl_idx.${node}_len * sizeof(rowreq_ctx->tbl_idx.${node}[0]); memcpy( var->val.string, rowreq_ctx->tbl_idx.$node, var->val_len ); @ else@ var->val_len = sizeof($m2c_decl); (*var->val.integer) = rowreq_ctx->tbl_idx.$node; @ end@ break; @ end@ ## accessible @ end@ ## index @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.accessible == 1@ /* $m2c_node_summary */ case COLUMN_$node.uc: @ if $m2c_table_sparse == 1@ if (! (COLUMN_$node.uc_FLAG & rowreq_ctx->column_exists_flags)) { DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_column", "column %d ($node) doesn't exist\n", column)); return MFD_SKIP; } @ end@ ## use sizeof except for BITS @ if $m2c_node_needlength == 0@ @ if "$node.perltype" eq "BITS"@ { $m2c_decl mask = 0xff << ((sizeof($m2c_decl) - 1) * 8); int idx = 0; @ else@ var->val_len = sizeof($m2c_decl); @ end@ @ end@ var->type = $node.type; rc = ${node}_get(rowreq_ctx, $m2c_node_var_ref ); @ if ($m2c_node_needlength == 0) && ("$node.perltype" eq "BITS")@ /* * check for length of bits string */ var->val_len = 0; while( 0 != mask ) { ++idx; if ( *(($m2c_decl *) var->val.string) & mask ) var->val_len = idx; mask = mask >> 8; } } @ end@ break; @ end@ # accessible @ end@ # for each column default: if ($context.uc_MIN_COL <= column && column <= $context.uc_MAX_COL) { DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_column", "assume column %d is reserved\n", column)); rc = MFD_SKIP; } else { snmp_log(LOG_ERR, "unknown column %d in _${context}_get_column\n", column); } break; } return rc; } /* _${context}_get_column */ ######################################################################## ## int _mfd_${context}_get_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info * tri; u_char * old_string; void (*dataFreeHook)(void *); int rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_values","called\n")); netsnmp_assert(NULL != rowreq_ctx); @if $m2c_table_sparse == 1@ DEBUGMSGTL(("9:${context}:_mfd_${context}_get_values", "exists %p\n", (void*)rowreq_ctx->column_exists_flags)); @end@ for(;requests; requests = requests->next) { /* * save old pointer, so we can free it if replaced */ old_string = requests->requestvb->val.string; dataFreeHook = requests->requestvb->dataFreeHook; if(NULL == requests->requestvb->val.string) { requests->requestvb->val.string = requests->requestvb->buf; requests->requestvb->val_len = sizeof(requests->requestvb->buf); } else if(requests->requestvb->buf == requests->requestvb->val.string) { if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) requests->requestvb->val_len = sizeof(requests->requestvb->buf); } /* * get column data */ tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; rc = _${context}_get_column(rowreq_ctx, requests->requestvb, tri->colnum); if(rc) { if(MFD_SKIP == rc) { requests->requestvb->type = SNMP_NOSUCHINSTANCE; rc = SNMP_ERR_NOERROR; } } else if (NULL == requests->requestvb->val.string) { snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); rc = SNMP_ERR_GENERR; } if(rc) netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); /* * if the buffer wasn't used previously for the old data (i.e. it * was allcoated memory) and the get routine replaced the pointer, * we need to free the previous pointer. */ if(old_string && (old_string != requests->requestvb->buf) && (requests->requestvb->val.string != old_string)) { if(dataFreeHook) (*dataFreeHook)(old_string); else free(old_string); } } /* for results */ return SNMP_ERR_NOERROR; } /* _mfd_${context}_get_values */ ##---------------------------------------------------------------------- @if ($m2c_table_row_creation == 1) || ($m2c_table_persistent == 1)@ NETSNMP_STATIC_INLINE int _${context}_check_indexes(${context}_rowreq_ctx * rowreq_ctx) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_${context}_check_indexes","called\n")); netsnmp_assert(NULL != rowreq_ctx); ## @if $m2c_table_external_indexes != 0@ /* * check that the corresponding EXTERNAL row exists */ @ foreach $node externalindex@ @ include m2c_setup_node.m2i@ /* (INDEX) $m2c_node_summary */ rc = ${context}_${node}_check_index( rowreq_ctx ); if(MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; @ end@ # for each nonindex @end@ # external index @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ /* (INDEX) $m2c_node_summary */ @ eval $m2c_nv_val = "rowreq_ctx->tbl_idx.$node"@ @ eval $m2c_nv_len = "rowreq_ctx->tbl_idx.${node}_len"@ @ eval $m2c_nv_str = "rowreq_ctx->tbl_idx.$node"@ @ include node-validate.m2i@ if (MFD_SUCCESS != rc) return rc; rc = ${node}_check_index( rowreq_ctx ); if(MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; @ end@ # for each internalindex /* * if individual parts look ok, check them as a whole */ return ${context}_validate_index( ${context}_if_ctx.user_ctx, rowreq_ctx ); } /* _${context}_check_indexes */ @end@ # $m2c_table_row_creation ######################################################################## ## /*********************************************************************** * * SET processing * ***********************************************************************/ @if $m2c_table_settable == 0@ /* * SET PROCESSING NOT APPLICABLE (per MIB or user setting) */ @else@ /*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*/ /* * @internal * Check the syntax for a particular column */ NETSNMP_STATIC_INLINE int _${context}_check_column( ${context}_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_${context}_check_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch(column) { @ eval $m2c_nvv_item = "${m2c_context_item}tbl_idx."@ @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ /* (INDEX) $m2c_node_summary */ case COLUMN_$node.uc: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; @ end@ ## index @ eval $m2c_nvv_item = "$m2c_data_item"@ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 0@ /* $m2c_node_summary */ case COLUMN_$node.uc: rc = SNMP_ERR_NOTWRITABLE; break; @ next@ @ end@ /* $m2c_node_summary */ case COLUMN_$node.uc: @ include node-varbind-validate.m2i@ if(SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("${context}:_${context}_check_column:$node", "varbind validation failed (eg bad type or size)\n")); } else { rc = ${node}_check_value( rowreq_ctx, $m2c_node_var_val ); if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from ${node}_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; @ end@ # for each nonindex default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column %d in _${context}_check_column\n", column); } return rc; } /* _${context}_check_column */ ##---------------------------------------------------------------------- int _mfd_${context}_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info * tri; int rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_check_objects","called\n")); netsnmp_assert(NULL != rowreq_ctx); for(;requests; requests = requests->next) { /* * get column number from table request info, and check that column */ tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; rc = _${context}_check_column(rowreq_ctx, requests->requestvb, tri->colnum); if(rc) { netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); break; } } /* for results */ return SNMP_ERR_NOERROR; } /* _mfd_${context}_check_objects */ @ if $m2c_table_dependencies == 1@ /*---------------------------------------------------------------------- * * SET: check dependencies * *---------------------------------------------------------------------*/ /* * @internal * Check dependencies wrapper */ static int _mfd_${context}_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_check_dependencies","called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ${context}_check_dependencies(rowreq_ctx); if(rc){ DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_check_dependencies\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR; } /* _mfd_${context}_check_dependencies */ @end@ // dependencies /*---------------------------------------------------------------------- * * SET: Undo setup * *---------------------------------------------------------------------*/ /* * @internal * Set the value for a particular column */ NETSNMP_STATIC_INLINE int _${context}_undo_setup_column( ${context}_rowreq_ctx *rowreq_ctx, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_${context}_undo_setup_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch(column) { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 1@ /* $m2c_node_summary */ case COLUMN_$node.uc: rowreq_ctx->column_set_flags |= COLUMN_$node.uc_FLAG; rc = ${node}_undo_setup(rowreq_ctx ); break; @ end@ # settable @ end@ # for each column default: snmp_log(LOG_ERR,"unknown column %d in _${context}_undo_setup_column\n", column); break; } return rc; } /* _${context}_undo_setup_column */ ##---------------------------------------------------------------------- /** * @internal * undo setup */ int _mfd_${context}_undo_setup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_setup","called\n")); netsnmp_assert(NULL != rowreq_ctx); @if $m2c_undo_embed == 0@ /* * allocate undo context */ rowreq_ctx->undo = ${context}_allocate_data(); if(NULL == rowreq_ctx->undo) { /** msg already logged */ netsnmp_request_set_error_all(requests, SNMP_ERR_RESOURCEUNAVAILABLE); return SNMP_ERR_NOERROR; } @end@ /* * row undo setup */ rowreq_ctx->column_set_flags = 0; rc = ${context}_undo_setup(rowreq_ctx); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo_setup\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } else { /* * column undo setup */ netsnmp_table_request_info * tri; for(;requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; rc = _${context}_undo_setup_column(rowreq_ctx, tri->colnum); if(MFD_SUCCESS != rc) { DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo_setup_column\n", rc)); netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); } } /* for results */ } return SNMP_ERR_NOERROR; } /* _mfd_${context}_undo_setup */ /** * @internal * undo setup */ int _mfd_${context}_undo_cleanup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc; DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_cleanup","called\n")); /* * failed row create in early stages has no rowreq_ctx */ if (NULL == rowreq_ctx) return MFD_SUCCESS; /* * call user cleanup */ rc = ${context}_undo_cleanup(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo_cleanup\n", rc)); } @if $m2c_undo_embed == 0@ /* * release undo context, if needed */ if(rowreq_ctx->undo) { ${context}_release_data(rowreq_ctx->undo); rowreq_ctx->undo = NULL; } @end@ return SNMP_ERR_NOERROR; } /* _mfd_${context}_undo_cleanup */ /*---------------------------------------------------------------------- * * SET: Set values * *---------------------------------------------------------------------*/ /* * @internal * Set the value for a particular column */ NETSNMP_STATIC_INLINE int _${context}_set_column( ${context}_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_${context}_set_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch(column) { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 1@ /* $m2c_node_summary */ case COLUMN_$node.uc: rowreq_ctx->column_set_flags |= COLUMN_$node.uc_FLAG; rc = ${node}_set(rowreq_ctx, $m2c_node_var_val ); break; @ end@ # settable @ end@ # for each column default: snmp_log(LOG_ERR,"unknown column %d in _${context}_set_column\n", column); rc = SNMP_ERR_GENERR; break; } return rc; } /* _${context}_set_column */ ######################################################################## ## int _mfd_${context}_set_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info * tri; int rc = SNMP_ERR_NOERROR; DEBUGMSGTL(("internal:${context}:_mfd_${context}_set_values","called\n")); netsnmp_assert(NULL != rowreq_ctx); rowreq_ctx->column_set_flags = 0; for(;requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; rc = _${context}_set_column(rowreq_ctx, requests->requestvb, tri->colnum); if(MFD_SUCCESS != rc) { DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_set_column\n", rc)); netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); } } /* for results */ return SNMP_ERR_NOERROR; } /* _mfd_${context}_set_values */ /*---------------------------------------------------------------------- * * SET: commit * *---------------------------------------------------------------------*/ /** * @internal * commit the values */ int _mfd_${context}_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_commit","called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ${context}_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_commit\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { /* * if we successfully commited this row, set the dirty flag. Use the * current value + 1 (i.e. dirty = # rows changed). * this is checked in post_request... */ ${context}_dirty_set( ${context}_dirty_get() + 1 ); /* set table dirty flag */ } return SNMP_ERR_NOERROR; } int _mfd_${context}_undo_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_commit","called\n")); netsnmp_assert(NULL != rowreq_ctx); if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { u_int d = ${context}_dirty_get(); netsnmp_assert(d != 0); if(d) ${context}_dirty_set( d - 1 ); } rc = ${context}_undo_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo_commit\n", rc)); } if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { snmp_log(LOG_WARNING, "${context} row dirty flag still set after undo_commit\n"); rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; } return SNMP_ERR_NOERROR; } /* _mfd_${context}_commit */ /*---------------------------------------------------------------------- * * SET: Undo * *---------------------------------------------------------------------*/ /** * @internal * undo the value for a particular column */ NETSNMP_STATIC_INLINE int _${context}_undo_column( ${context}_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:${context}:_${context}_undo_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch(column) { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 1@ /* $m2c_node_summary */ case COLUMN_$node.uc: rc = ${node}_undo(rowreq_ctx); break; @ end@ # settable @ end@ # for each column default: snmp_log(LOG_ERR,"unknown column %d in _${context}_undo_column\n", column); break; } return rc; } /* _${context}_undo_column */ ######################################################################## ## int _mfd_${context}_undo_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info * tri; DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_values","called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ${context}_undo(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo\n", rc)); } for(;requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; rc = _${context}_undo_column(rowreq_ctx, requests->requestvb, tri->colnum); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_undo_column\n", rc)); } } /* for results */ return SNMP_ERR_NOERROR; } /* _mfd_${context}_undo_values */ /*---------------------------------------------------------------------- * * SET: irreversible commit * *---------------------------------------------------------------------*/ /** * @internal * commit irreversible actions */ int _mfd_${context}_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { @ if $m2c_irreversible_commit == 1@ int rc; @ end@ ${context}_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:${context}:_mfd_${context}_irreversible:commit","called\n")); netsnmp_assert(NULL != rowreq_ctx); @ if $m2c_irreversible_commit == 1@ rc = ${context}_irreversible_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { netsnmp_request_set_error_all(requests, SNMP_ERR_COMMITFAILED); DEBUGMSGTL(("${context}:mfd","error %d from " "${context}_irreversible_commit\n", rc)); } @ end@ /* * check for and handle row creation/deletion * and update column exist flags... */ if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { if (! (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) CONTAINER_REMOVE(${context}_if_ctx.container, rowreq_ctx); } else { if (rowreq_ctx->column_set_flags) { @if $m2c_table_sparse == 1@ DEBUGMSGTL(("internal:${context}:_mfd_irreversible_commit", "updating exists (%p) w/set (%p) = %p\n", rowreq_ctx->column_exists_flags, rowreq_ctx->column_set_flags, (rowreq_ctx->column_exists_flags | rowreq_ctx->column_set_flags))); rowreq_ctx->column_exists_flags |= rowreq_ctx->column_set_flags; @end@ # sparse rowreq_ctx->column_set_flags = 0; } @if ($m2c_table_row_creation == 1)@ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; CONTAINER_INSERT(${context}_if_ctx.container, rowreq_ctx); } @end@ # creation } return SNMP_ERR_NOERROR; } /* _mfd_${context}_irreversible_commit */ @end@ # settable /*********************************************************************** * * DATA ACCESS * ***********************************************************************/ @ include mfd-access-${m2c_table_access}-defines.m2i@ @ if $m2c_table_persistent == 1@ @ include mfd-persistence.m2i@ @ end@ ${context}_rowreq_ctx * ${context}_row_find_by_mib_index(${context}_mib_index *mib_idx) { ${context}_rowreq_ctx *rowreq_ctx; oid oid_tmp[MAX_OID_LEN]; netsnmp_index oid_idx; int rc; /* * set up storage for OID */ oid_idx.oids = oid_tmp; oid_idx.len = sizeof(oid_tmp)/sizeof(oid); /* * convert */ rc = ${context}_index_to_oid(&oid_idx, mib_idx); if (MFD_SUCCESS != rc) return NULL; rowreq_ctx = CONTAINER_FIND(${context}_if_ctx.container, &oid_idx); return rowreq_ctx; } @ if $m2c_table_refcounts == 1@ int ${context}_row_ref_increment(${context}_rowreq_ctx *rowreq_ctx) { if (NULL == rowreq_ctx) return -1; ++rowreq_ctx->ref_count; DEBUGMSGTL(("${context}:${context}_row_ref_increment", "row %p ref count is %d\n",rowreq_ctx, rowreq_ctx->ref_count)); return MFD_SUCCESS; } int ${context}_row_ref_decrement(${context}_rowreq_ctx *rowreq_ctx) { if (NULL == rowreq_ctx) return -1; if (0 == rowreq_ctx->ref_count) { snmp_log(LOG_WARNING,"attempt to decrement ref_count below 0\n"); return -2; } --rowreq_ctx->ref_count; DEBUGMSGTL(("${context}:${context}_row_ref_decrement", "row %p ref count is %d\n",rowreq_ctx, rowreq_ctx->ref_count)); return MFD_SUCCESS; } @ end@ // refcounts @end@ # foreach table ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 15899 $ */ @end@ mib2c-data/generic-ctx-set.m2i 0000666 00000002101 15077166074 0012074 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-ctx-set.m2i 12586 2005-07-25 23:25:54Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12586 $ */ @end@ ######################################################################## ## /* * TODO:461:M: |-> Set $node value. * set $node value in $m2c_data_item_base */ @if ($m2c_include_examples != 0) || ("$m2c_data_context" eq "generated")@ @ if $m2c_node_needlength == 0@ ${m2c_data_item}$node = $m2c_node_srh; @ else@ memcpy( ${m2c_data_item}$node, $m2c_node_srh, $m2c_node_srhs ); /** convert bytes to number of $m2c_decl */ ${m2c_data_item}${node}_len = $m2c_node_srhs / sizeof(${m2c_node_srh}[0]); @ end@ # need length @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12586 $ */ @end@ mib2c-data/generic-value-map-func.m2i 0000666 00000007334 15077166074 0013342 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-value-map-func.m2i 12095 2005-04-18 22:14:01Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12095 $ */ @end@ ######################################################################## ## } /** * map a value from its original native format to the MIB format. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : Any other error * * @note parameters follow the memset convention (dest, src). * * @note generation and use of this function can be turned off by re-running * mib2c after adding the following line to the file * ${m2c_defaults_dir}node-${node}.m2d : * @eval $@m2c_node_skip_mapping = 1@ * * @remark * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them here. * Otherwise, just do a direct copy. */ int ${node}_map($m2c_node_map_param) { @if $m2c_node_needlength == 1@ int converted_len; netsnmp_assert(NULL != raw_$m2c_node_param_val_name); netsnmp_assert((NULL != mib_$m2c_node_param_ref_name) && (NULL != mib_$m2c_node_param_ref_lname)); @else@ netsnmp_assert(NULL != mib_$m2c_node_param_ref_name); @end@ DEBUGMSGTL(("verbose:${context}:${node}_map","called\n")); @if $m2c_node_needlength == 1@ /* * TODO:241:r: |-> Implement $node non-integer mapping * it is hard to autogenerate code for mapping types that are not simple * integers, so here is an idea of what you might need to do. It will * probably need some tweaking to get right. */ /* * if the length of the raw data doesn't directly correspond with * the length of the mib data, set converted_len to the * space required. */ converted_len = raw_$m2c_node_param_val_lname; /* assume equal */ if((NULL == *mib_$m2c_node_param_ref_name) || (*mib_$m2c_node_param_ref_lname < converted_len)) { if(! allow_realloc) { snmp_log(LOG_ERR,"not enough space for value mapping\n"); return SNMP_ERR_GENERR; } *mib_$m2c_node_param_ref_name = realloc( *mib_$m2c_node_param_ref_name, converted_len * sizeof(**mib_$m2c_node_param_ref_name)); if(NULL == *mib_$m2c_node_param_ref_name) { snmp_log(LOG_ERR,"could not allocate memory\n"); return SNMP_ERR_GENERR; } } *mib_$m2c_node_param_ref_lname = converted_len; memcpy( *mib_$m2c_node_param_ref_name, raw_$m2c_node_param_val_name, converted_len ); ## @elsif ($node.enums == 1) && ("$node.perltype" eq "INTEGER")@ /* * TODO:241:o: |-> Implement $node enum mapping. * uses INTERNAL_* macros defined in the header files */ switch(raw_$m2c_node_param_val_name) { @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ case INTERNAL_$context.uc_$m2c_iname: *mib_$m2c_node_param_ref_name = $m2c_ename; break; @ end@ # foreach default: snmp_log(LOG_ERR, "couldn't map value %ld for $node\n", raw_$m2c_node_param_val_name ); return MFD_ERROR; } ## @else@ /* * TODO:241:o: |-> Implement $node mapping. * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them here. */ (*mib_$m2c_node_param_ref_name) = raw_$m2c_node_param_val_name; @end@ return MFD_SUCCESS; } /* ${node}_map */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12095 $ */ @end@ mib2c-data/generic-get-long.m2i 0000666 00000001125 15077166074 0012226 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-get-long.m2i 8830 2003-09-30 13:34:57Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 8830 $ */ @end@ ######################################################################## ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 8830 $ */ @end@ mib2c-data/node-validate.m2i 0000666 00000004563 15077166074 0011625 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: node-validate.m2i 12101 2005-04-20 22:45:01Z rstory $ ## ## assumes an integer rc is available and will be tested by caller ## ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12101 $ */ @end@ ######################################################################## ##---------------------------------------------------------------------- ## setup ##---------------------------------------------------------------------- @if $node.enums == 1@ ##------------------------------------------------------ @ if "$node.perltype" ne "BITS"@ /* check that the value is one of defined enums */ if( (SNMPERR_SUCCESS == rc) @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ && ( $m2c_nv_val != $m2c_ename ) @ end@ # for each ) { rc = SNMP_ERR_WRONGVALUE; } ##------------------------------------------------------ @ else@ # BITS ## { if($m2c_nv_len > 4) { snmp_log(LOG_ERR,"I can not handle BITS > 4 bytes\n"); rc = SNMP_ERR_GENERR; } else if (SNMPERR_SUCCESS == rc){ u_long bits = 0; /* check that value is within enum mask */ memcpy( &bits, $m2c_nv_str, $m2c_nv_len); if( (bits | $m2c_enum_mask) != $m2c_enum_mask) rc = SNMP_ERR_WRONGVALUE; } @ end@ ##---------------------------------------------------------------------- ## check RANGES ##---------------------------------------------------------------------- @elsif $node.ranges == 1@ @ if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ @ eval $m2c_nv_rc = "SNMP_ERR_WRONGVALUE"@ @ eval $m2c_nv_tmp = "$m2c_nv_val"@ @ else@ @ eval $m2c_nv_rc = "SNMP_ERR_WRONGLENGTH"@ @ eval $m2c_nv_tmp = "$m2c_nv_len"@ @ end@ /* check defined range(s). */ if( (SNMPERR_SUCCESS == rc) @ foreach $a $b range $node@ @ if $a == $b@ && ($m2c_nv_tmp != $a) @ else@ && (($m2c_nv_tmp < $a) || ($m2c_nv_tmp > $b)) @ end@ @ end@ ) { rc = $m2c_nv_rc; } @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12101 $ */ @end@ mib2c-data/generic-get-oid.m2i 0000666 00000001247 15077166074 0012047 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-get-oid.m2i 10598 2004-07-03 17:10:41Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 10598 $ */ @end@ ######################################################################## ## @if $m2c_node_skip_mapping == -1@ @ eval $m2c_node_skip_mapping = 0@ @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 10598 $ */ @end@ mib2c-data/node-storage.m2i 0000666 00000001332 15077166074 0011467 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: node-storage.m2i 8830 2003-09-30 13:34:57Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 8830 $ */ @end@ ######################################################################## ## @if $m2c_node_needlength == 0@ $m2c_decl $node; @else@ $m2c_decl $node[$m2c_node_maxlen]; size_t ${node}_len; @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 8830 $ */ @end@ mib2c-data/generic-table-constants.m2c 0000666 00000003123 15077166074 0013605 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-constants.m2c 12526 2005-07-15 22:41:16Z rstory $ ######################################################################## @if $m2c_create_fewer_files != 1@ @ foreach $table table@ @ include m2c_setup_table.m2i@ @ run generic-table-oids.m2c@ @ run generic-table-enums.m2c@ @ end@ # table ######################################################################## @else@ @ eval $hack = "Id"@ @ eval $m2c_save = "$name"@ @ eval $name = "${m2c_save}_constants"@ @ open ${name}.h@ /* * Note: this file originally auto-generated by mib2c using * $Id: generic-table-constants.m2c 12526 2005-07-15 22:41:16Z rstory $ * * $$hack:$ */ ######################################################################## @ if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 12526 $ */ @ end@ ######################################################################## @ include generic-header-top.m2i@ @ eval $name = "$m2c_save"@ @ foreach $table table@ @ include m2c_setup_table.m2i@ @ include generic-table-oids.m2c@ @ include generic-table-enums.m2c@ @ end@ # table @ eval $m2c_save = "$name"@ @ eval $name = "${m2c_save}_oids"@ @ include generic-header-bottom.m2i@ @ eval $name = "$m2c_save"@ ######################################################################## @ if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 12526 $ */ @ end@ @end@ // m2c_create_fewer_files mib2c-data/generic-table-indexes-set.m2i 0000666 00000010053 15077166074 0014027 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-indexes-set.m2i 14170 2006-01-26 17:02:48Z dts12 $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 14170 $ */ @end@ ######################################################################## ## @eval $gtis_tmp=""@ @foreach $node index@ @ include m2c_setup_node.m2i@ @ eval $gtis_tmp="$gtis_tmp, $m2c_node_param_val"@ @end@ # for each index ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'h'@ int ${context}_indexes_set_tbl_idx(${context}_mib_index *tbl_idx$gtis_tmp); int ${context}_indexes_set(${context}_rowreq_ctx *rowreq_ctx$gtis_tmp); @end@ // m2c_processing_type eq 'h' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'c'@ /** * set mib index(es) * * @param tbl_idx mib index structure @foreach $node index@ @ if $node.needlength == 1@ * @param ${node}_ptr * @param ${node}_ptr_len @else@ * @param ${node}_val @end@ @end@ * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error. * * @remark * This convenience function is useful for setting all the MIB index * components with a single function call. It is assume that the C values * have already been mapped from their native/rawformat to the MIB format. */ int ${context}_indexes_set_tbl_idx(${context}_mib_index *tbl_idx$gtis_tmp) { DEBUGMSGTL(("verbose:${context}:${context}_indexes_set_tbl_idx","called\n")); @foreach $node index@ @ include m2c_setup_node.m2i@ ## table indexes are not allocated pointers, so do not allow realloc here @eval $m2c_node_realloc = 0@ // fail /* $m2c_node_summary */ @ eval $m2c_ctx_lh = "tbl_idx->$node"@ @ eval $m2c_ctx_lhs = "tbl_idx->${node}_len"@ @ eval $m2c_ctx_lhu="elements"@ @ eval $m2c_ctx_rh = "$m2c_node_param_val_name"@ @ eval $m2c_ctx_rhs = "$m2c_node_param_val_lname"@ @ eval $m2c_ctx_rhu="elements"@ @ if $m2c_node_needlength == 1@ $m2c_ctx_lhs = sizeof($m2c_ctx_lh)/sizeof($m2c_ctx_lh[0]); /* max length */ @ end@ ## also, assume mapping already done @ include generic-ctx-get.m2i@ ##@ include generic-value-map.m2i@ @end@ // for each column return MFD_SUCCESS; } /* ${context}_indexes_set_tbl_idx */ /** * @internal * set row context indexes * * @param reqreq_ctx the row context that needs updated indexes * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error. * * @remark * This function sets the mib indexs, then updates the oid indexs * from the mib index. */ int ${context}_indexes_set(${context}_rowreq_ctx *rowreq_ctx$gtis_tmp) { DEBUGMSGTL(("verbose:${context}:${context}_indexes_set","called\n")); if(MFD_SUCCESS != ${context}_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx @foreach $node index@ @ include m2c_setup_node.m2i@ , $m2c_node_param_val_call @end@ # for each index )) return MFD_ERROR; /* * convert mib index to oid index */ rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); if(0 != ${context}_index_to_oid(&rowreq_ctx->oid_idx, &rowreq_ctx->tbl_idx)) { return MFD_ERROR; } return MFD_SUCCESS; } /* ${context}_indexes_set */ @end@ // m2c_processing_type eq 'c' ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 14170 $ */ @end@ mib2c-data/syntax-InetAddressType-set.m2i 0000666 00000001761 15077166074 0014272 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-InetAddressType-set.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## /* * TODO:230:o: Set $node data * set data context from $m2c_ctx_rh * * Note: if there is a corresponding InetAddress object, we don't * know if they'll be set together, or which order they will be set. * So we just accept the value here, and check that both values are * consistent in ${context}_check_dependencies(). */ @include generic-ctx-set.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/mfd-access-unsorted-external-defines.m2i 0000666 00000120227 15077166074 0016206 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: mfd-access-unsorted-external-defines.m2i 17717 2009-08-04 21:59:16Z dts12 $ ######################################################################## ## @eval $mfd_aue_wrap_param = "wrap_ctx"@ @eval $mfd_aue_wrap_param_type = "${context}_interface_ctx *"@ @eval $mfd_aue_wrap_param_decl = "$mfd_aue_wrap_param_type $mfd_aue_wrap_param"@ ## @eval $mfd_aue_param = "${context}_reg"@ @eval $mfd_aue_param_type = "${context}_registration *"@ @eval $mfd_aue_param_decl = "$mfd_aue_param_type $mfd_aue_param"@ @eval $mfd_aue_param_cmt = "$mfd_aue_param Pointer to a $mfd_aue_param_type" ## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 17717 $ */ @end@ ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'h'@ ## @if $m2c_include_examples == 1@ $example_start /* ********************************************************************* * Since we have no idea how you really access your data, we'll go with * a worst case example: a flat text file. @ if $m2c_data_transient != 2@ @ print Example code is for fully transient data. Either turn off@ @ print m2c_include_examples or set m2c_data_transient to 2.@ @ exit@ @ end@ */ #define MAX_LINE_SIZE 256 $example_end @end@ /** * loop context * * ToDo: * define loop context structure * * Since the actual loop is in the MFD handler, a loop contex parameter * is provided to help you keep track of where you are in between calls * to functions that you wrote and the master MFD handler calls. The * structure of this context is user defineable, and is defined in the * file ${table}_data_access.h. * * E.G., if your data is stored in a linked list, the obvious thing you * want to know from one function call to the next is your current * position in the linked list. Thus the easiest context to use is a * pointer within the linked list. For an array, the current index to * that array would be easiest. * * The funtion calls are actually passed a reference to the loop * context, to allow the loop context to be allocated memory. Here are * some simple examples definitions for various data formats. These * definitions are used in examples later on. * */ typedef struct ${context}_loop_context_s { /* * temporary context used during iteration */ ${context}_rowreq_ctx *rowreq_ctx; @if $m2c_include_examples == 1@ /* * this example code is based on a data source that is a * text file to be read and parsed. */ FILE *filep; char line[MAX_LINE_SIZE]; @end@ } ${context}_loop_context; /* * define a reference to the loop context * * NOTE: DO NOT ADD ITEMS TO THIS STRUCTURE! */ typedef struct ${context}_ref_loop_ctx_s { ${context}_loop_context *loop_ctx; } ${context}_ref_loop_ctx; int ${context}_loop_get_first( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref); int ${context}_loop_get_next( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref); int ${context}_loop_get_data( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref); int ${context}_loop_save_position($mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_loop_ctx *save_loop_ctx_ref, int reuse); int ${context}_loop_cleanup_context( $mfd_aue_param_decl, ${context}_ref_loop_ctx *ref); ## @end@ // m2c_processing_type eq 'h' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'i'@ /** * @internal * wrapper around clean up a loop reference */ static int _${context}_loop_cleanup_context( $mfd_aue_wrap_param_decl, ${context}_ref_loop_ctx *ref) { DEBUGMSGTL(("internal:${context}:_${context}_loop_cleanup_context","called\n")); return ${context}_loop_cleanup_context($mfd_aue_wrap_param->user_ctx, ref); } /* _${context}_loop_cleanup_context */ /** * @internal * wrapper around save position */ static int _${context}_loop_save_position( $mfd_aue_wrap_param_decl, ${context}_ref_loop_ctx *ref, ${context}_ref_loop_ctx *ref_copy, int reuse) { DEBUGMSGTL(("internal:${context}:_${context}_loop_save_position","called\n")); return ${context}_loop_save_position($mfd_aue_wrap_param->user_ctx, ref, ref_copy, reuse); } /* _${context}_loop_save_position */ /** * @internal * wrapper around user get_first to setup the index oid */ static int _${context}_loop_get_first_wrapper($mfd_aue_wrap_param_decl, ${context}_ref_loop_ctx * loop_ctx_ref, ${context}_ref_rowreq_ctx * rowreq_ctx_ref) { int rc; DEBUGMSGTL(("internal:${context}:_${context}_loop_get_first_wrapper","called\n")); rc = ${context}_loop_get_first($mfd_aue_wrap_param->user_ctx, loop_ctx_ref, rowreq_ctx_ref); /* * convert index to OID */ if(SNMPERR_SUCCESS == rc ) { netsnmp_assert((NULL != rowreq_ctx_ref) && (rowreq_ctx_ref->rowreq_ctx->oid_idx.oids == rowreq_ctx_ref->rowreq_ctx->oid_tmp)); rowreq_ctx_ref->rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx_ref->rowreq_ctx->oid_tmp); rc = ${context}_index_to_oid(&rowreq_ctx_ref->rowreq_ctx->oid_idx, &rowreq_ctx_ref->rowreq_ctx->tbl_idx); netsnmp_assert(rowreq_ctx_ref->rowreq_ctx->oid_idx.len != sizeof(rowreq_ctx_ref->rowreq_ctx->oid_tmp)); } return rc; } /* _${context}_loop_get_first_wrapper */ /** * @internal * wrapper around user get_next to setup the index oid */ static int _${context}_loop_get_next_wrapper($mfd_aue_wrap_param_decl, ${context}_ref_loop_ctx * loop_ctx_ref, ${context}_ref_rowreq_ctx * rowreq_ctx_ref) { int rc; DEBUGMSGTL(("internal:${context}:_${context}_loop_get_next_wrapper","called\n")); rc = ${context}_loop_get_next($mfd_aue_wrap_param->user_ctx, loop_ctx_ref, rowreq_ctx_ref); /* * convert index to OID */ if(SNMPERR_SUCCESS == rc ) { netsnmp_assert((NULL != rowreq_ctx_ref) && (rowreq_ctx_ref->rowreq_ctx->oid_idx.oids == rowreq_ctx_ref->rowreq_ctx->oid_tmp)); rowreq_ctx_ref->rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx_ref->rowreq_ctx->oid_tmp); rc = ${context}_index_to_oid(&rowreq_ctx_ref->rowreq_ctx->oid_idx, &rowreq_ctx_ref->rowreq_ctx->tbl_idx); netsnmp_assert(rowreq_ctx_ref->rowreq_ctx->oid_idx.len != sizeof(rowreq_ctx_ref->rowreq_ctx->oid_tmp)); } return rc; } /* _${context}_loop_get_next_wrapper */ @if $m2c_data_transient != 0@ # /** * @internal * get data wrapper to allocate context for the user */ static int _${context}_loop_get_data_wrapper($mfd_aue_wrap_param_decl, ${context}_ref_loop_ctx * loop_ctx_ref, ${context}_ref_rowreq_ctx * rowreq_ctx_ref) { // ${context}_rowreq_ctx *orig_ctx = rowreq_ctx_ref->rowreq_ctx; DEBUGMSGTL(("internal:${context}:_${context}_loop_get_data_wrapper","called\n")); return ${context}_loop_get_data($mfd_aue_wrap_param->user_ctx, loop_ctx_ref, rowreq_ctx_ref); } /* _${context}_loop_get_data_wrapper */ @end@ // transient != 0 /** * @internal * initialize the iterator container with functions or wrappers */ void _${context}_container_init(${context}_interface_ctx *if_ctx) { DEBUGMSGTL(("internal:${context}:_${context}_container_init","called\n")); if_ctx->container = netsnmp_container_iterator_get(/** registration */ if_ctx, /** compare */ NULL, /** get_first */ (Netsnmp_Iterator_Loop_Key*)_${context}_loop_get_first_wrapper, /** get_next */ (Netsnmp_Iterator_Loop_Key*)_${context}_loop_get_next_wrapper, /** get_data */ @if $m2c_data_transient != 0@ # (Netsnmp_Iterator_Loop_Data*)_${context}_loop_get_data_wrapper, @else@ NULL, @end@ /** save_pos */ (Netsnmp_Iterator_Ctx_Dup*)_${context}_loop_save_position, /** init_context */ (Netsnmp_Iterator_Ctx*)NULL, /** cleanup_context */ (Netsnmp_Iterator_Ctx*)_${context}_loop_cleanup_context, /** free_user_ctx */ NULL, /** sorted */ 0); } /* _${context}_container_init */ ## @end@ // m2c_processing_type eq 'i' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'c'@ /** * unsorted-external overview * * The unsorted external data access code works by calling a few simple * functions to get the index value for each row. Once the agent determines * which row is needed to process an incoming request, another function * is called to retrieve the data for that row. * * A simplified version of the pseudo-code looks like this: * * ${context}_loop_get_first(loop,data) * while( no_error ) { * if( best_match(data, key) * ${context}_loop_save_position(loop,pos); * ${context}_loop_get_next(loop,data) * } * ${context}_loop_get_data(pos,data) * ${context}_loop_cleanup_context(loop) */ /*********************************************************************** * * ITERATION * ***********************************************************************/ /** * get the first data index * * Summary * ------- * This function is called to initialize the iterator loop context for a * new iteration loop and return the index(es) for the first * ${context}_data in the data set. * * Note that during the loop, the only important thing is the indexes. * If access to your data is cheap/fast (e.g. you have a pointer to a * structure in memory), it would make sense to update the data here. * If, however, the accessing the data invovles more work (e.g. parsing * some other existing data, or peforming calculations to derive the data), * then you should limit yourself to setting the indexes. Extracting the * can be put off until the desired row is found. See the notes on * ${context}_loop_get_data(). * * Note that this function does not correspond to a SNMP GET pdu, and * you should return data items in whatever order they are already in. * (In fact, if your data is already ordered in the same order as the * SNMP indexes, you shouldn't be using the unsorted-access code). * * This function should update the table index (rowreq_ctx_ref->rowreq_ctx->tbl_idx) * values for the raw data (rowreq_ctx_ref->rowreq_ctx->data). * * More Details * ------------ * If there is currently no data available, return MFD_END_OF_DATA. * Otherwise, you should set rowreq_ctx_ref->rowreq_ctx and its indexes. * * rowreq_ctx_ref->rowreq_ctx will be NULL. You should allocate a new context * for this loop. [Alternatively, you could allocate one in * ${context}_loop_init_context, save it in your * ${context}_ref_loop_ctx, and use it here.] * * Once you have your context pointer, you should set the index (or indexes) * in rowreq_ctx_ref->rowreq_ctx->tbl_idx to the appropriate value for this row. [If you * use your loop_ctx_ref cleverly, you might be able to put this work in * ${context}_loop_get_next, and simply call that function.] * * @param $mfd_aue_param_cmt * @param loop_ctx_ref Pointer to your loop reference. * @param rowreq_ctx_ref Pointer to a context reference. * * @retval MFD_SUCCESS : success. * @retval MFD_END_OF_DATA : no data available * @retval MFD_ERROR : error. */ int ${context}_loop_get_first( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref) { DEBUGMSGTL(("verbose:${context}:${context}_loop_get_first","called\n")); netsnmp_assert(rowreq_ctx_ref); netsnmp_assert(loop_ctx_ref); /* * allocate memory for new structure */ loop_ctx_ref->loop_ctx = SNMP_MALLOC_TYPEDEF(${context}_loop_context); if(NULL == loop_ctx_ref->loop_ctx) return MFD_ERROR; /* * allocate a temporary context to use during iteration */ @ eval $m2c_tmp = ""@ @ if ($m2c_data_allocate == 1) || ($m2c_data_init == 1)@ @ eval $m2c_tmp = "NULL"@ @ if ($m2c_data_allocate == 1) && ($m2c_data_init == 1)@ @ eval $m2c_tmp = "$m2c_tmp, NULL"@ @ @end@ @ end@ loop_ctx_ref->loop_ctx->rowreq_ctx = ${context}_allocate_rowreq_ctx($m2c_tmp); if(NULL == loop_ctx_ref->loop_ctx->rowreq_ctx) { SNMP_FREE(loop_ctx_ref->loop_ctx); return MFD_RESOURCE_UNAVAILABLE; } /* * ToDo: * set up loop context */ @if $m2c_include_examples == 1@ $example_start /* * open our data file. */ loop_ctx_ref->loop_ctx->filep = fopen("/etc/dummy.conf", "r"); if(NULL == loop_ctx_ref->loop_ctx->filep) { return MFD_RESOURCE_UNAVAILABLE; } $example_end @end@ @ifconf ${table}_update_idx.m2i@ @ include ${table}_update_idx.m2i@ @else@ @ if $m2c_include_examples == 1@ $example_start /* * in this example, after opening the file, get next does the same thing * as get first, we let's just call get next... */ return ${context}_loop_get_next($mfd_aue_param, loop_ctx_ref, rowreq_ctx_ref); $example_end @ else@ /* * we just need the index for now. Reuse the one in the loop context's * temporary row request context. (rowreq_ctx_ref->rowreq_ctx->tbl_idx) */ rowreq_ctx_ref->rowreq_ctx = loop_ctx_ref->loop_ctx->rowreq_ctx; /* * ToDo: * set local vars for index from loop_ctx_ref->loop_ctx * this can be done in one of two ways: */ /* * 1) individually */ @ foreach $node index@ @ include m2c_setup_node.m2i@ /* * ToDo: * set rowreq_ctx_ref->rowreq_ctx->tbl_idx->$node @ if $m2c_node_needlength == 1@ * and rowreq_ctx_ref->tbl_idx->${node}_len @ end@ */ @ end@ #foreach /* * OR */ /* * 2) by calling ${context}_indexes_set() * ${context}_indexes_set(rowreq_ctx_ref->tbl_idx, @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if $m2c_node_needlength == 1@ * ${node}_ptr, ${node}_len @ else@ * $node @ end@ @ end@ # foreach index * ); */ @ end@ # example @end@ #ifconf return MFD_SUCCESS; } /* ${context}_loop_get_first */ /** * get the next data index * * Summary * ------- * This function returns the next data item in the data set. The same * caveat applies here as did above. The indexes are the important parts * during loop processing. * * Note that this function does not correspond to a SNMP GET-NEXT pdu, and * you should return data items in whatever order they are already in. * (In fact, if your data is already ordered in the same order as the * SNMP indexes, you shouldn't be using the unsorted-access code). * * More Details * ------------ * rowreq_ctx_ref->rowreq_ctx will have been set in ${context}_loop_get_first. * * If there is currently no data available, return MFD_END_OF_DATA. * Otherwise, you should set the indexes in rowreq_ctx_ref->rowreq_ctx->tbl_idx. * * You should set the index (or indexes) in rowreq_ctx_ref->rowreq_ctx->tbl_idx to the * appropriate value for this row. * * @param $mfd_aue_param_cmt * @param loop_ctx_ref Pointer to your loop reference. * @param rowreq_ctx_ref Pointer to a context reference. * * @retval MFD_SUCCESS : success. * @retval MFD_END_OF_DATA : no more data available * @retval MFD_ERROR : error. */ int ${context}_loop_get_next( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref) { DEBUGMSGTL(("verbose:${context}:${context}_loop_get_next","called\n")); netsnmp_assert(loop_ctx_ref && loop_ctx_ref->loop_ctx); netsnmp_assert(rowreq_ctx_ref); /* * we just need the index for now. Reuse the one in the loop context's * temporary row request context. (rowreq_ctx_ref->rowreq_ctx->tbl_idx) */ rowreq_ctx_ref->rowreq_ctx = loop_ctx_ref->loop_ctx->rowreq_ctx; @ if $m2c_include_examples == 1@ $example_start /* * get a line (skip blank lines) */ do { if (!fgets(loop_ctx_ref->loop_ctx->line, sizeof(loop_ctx_ref->loop_ctx->line), loop_ctx_ref->loop_ctx->filep)) { /* we're done */ fclose(loop_ctx_ref->loop_ctx->filep); loop_ctx_ref->loop_ctx->filep = NULL; } } while (loop_ctx_ref->loop_ctx->filep && (loop_ctx_ref->loop_ctx->line[0] == '\n')); /* * check for end of data */ if(NULL == loop_ctx_ref->loop_ctx->filep) return MFD_END_OF_DATA; /* * ToDo: * set local vars for index from loop_ctx_ref->loop_ctx * this can be done in one of two ways: */ /* * 1) individually */ @ foreach $node index@ @ include m2c_setup_node.m2i@ /* * ToDo: * set rowreq_ctx_ref->rowreq_ctx->tbl_idx->$node @ if $m2c_node_needlength == 1@ * and rowreq_ctx_ref->tbl_idx->${node}_len @ end@ */ @ end@ #foreach /* * OR */ /* * 2) by calling ${context}_indexes_set() * ${context}_indexes_set(rowreq_ctx_ref->tbl_idx, @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if $m2c_node_needlength == 1@ * ${node}_ptr, ${node}_len @ else@ * $node @ end@ @ end@ # foreach index * ); */ $example_end @ end@ # example return MFD_SUCCESS; } /* ${context}_loop_get_next */ /** * duplicate the current loop reference * * Summary * ------- * During loop iteration, the iterator keeps track of the row that * is the current best match. This function is called when the * current row is a better match than any previous row. * * You should save any information you need to be able to locate this row * again from the current loop context to a new loop context. * * At the end of the loop, when the best match has been found, the saved * loop context will be used to get the data for the row by calling * ${context}_loop_get_data(). @if $m2c_data_transient != 0@ # persistent * * Since your data is transient, you need to make a copy of it before * the iterator moves on to the next row. @end@ * @if $m2c_data_transient != 0@ # persistent * More Details * ------------ @ if $m2c_data_transient == 1@ # short term * Since your data is semi-TRANSIENT data, you could just keep a pointer * to the data in the loop reference. The data should then be copied in * ${context}_loop_get_data(). @ else@ # $m2c_data_transient == 2@ # copy immediately * One idea would be to copy it space allocated in the loop reference * structure. Another would be to simply have a pointer in the loop * reference structure, and allocate memory here. * @ end@ @end@ * @param $mfd_aue_param_cmt * @param loop_ctx_ref Reference to current loop context. * @param save_loop_ctx_ref Reference to a loop context for saving the current * position. If reuse is not set or * save_loop_ctx_ref->loop_ctx is NULL, allocate * a new one. If reuse is set, you may reuse the existing * loop_ctx. * @param reuse Indicates if an existing save_loop_ctx_ref->loop_ctx * may be reused. * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : error. */ int ${context}_loop_save_position($mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_loop_ctx *save_loop_ctx_ref, int reuse) { DEBUGMSGTL(("verbose:${context}:${context}_loop_save_position","called\n")); netsnmp_assert(loop_ctx_ref && save_loop_ctx_ref); /* * ToDo: * 1) allocate new loop context, unless you can reuse a previous pointer. * 2) save information for the position of loop_ctx_ref in save_loop_ctx_ref. */ if((0 == reuse) || (NULL == save_loop_ctx_ref->loop_ctx)) save_loop_ctx_ref->loop_ctx = SNMP_MALLOC_TYPEDEF(${context}_loop_context); if(NULL == save_loop_ctx_ref->loop_ctx) { snmp_log(LOG_ERR, "could not allocate memory\n"); return MFD_ERROR; } /* * if you can reuse a previously saved contex, just swap * it out with the loop iterator */ if(reuse && save_loop_ctx_ref->loop_ctx->rowreq_ctx) { ${context}_rowreq_ctx * tmp_rowreq_ctx = save_loop_ctx_ref->loop_ctx->rowreq_ctx; save_loop_ctx_ref->loop_ctx->rowreq_ctx = loop_ctx_ref->loop_ctx->rowreq_ctx; loop_ctx_ref->loop_ctx->rowreq_ctx = tmp_rowreq_ctx; } else { /* * take the current pointer */ save_loop_ctx_ref->loop_ctx->rowreq_ctx = loop_ctx_ref->loop_ctx->rowreq_ctx; /* * allocate a new context to replace the one you just took. */ @ eval $m2c_tmp = ""@ @ if ($m2c_data_allocate == 1) || ($m2c_data_init == 1)@ @ eval $m2c_tmp = "NULL"@ @ if ($m2c_data_allocate == 1) && ($m2c_data_init == 1)@ @ eval $m2c_tmp = "$m2c_tmp, NULL"@ @ @end@ @ end@ loop_ctx_ref->loop_ctx->rowreq_ctx = ${context}_allocate_rowreq_ctx($m2c_tmp); if(NULL == loop_ctx_ref->loop_ctx->rowreq_ctx) { SNMP_FREE(loop_ctx_ref->loop_ctx); return MFD_ERROR; } } @if $m2c_data_transient == 0@ # persistent /** non-TRANSIENT data: no need to copy */ @elsif $m2c_data_transient == 1@ # short term /** semi-TRANSIENT data: will copy data when index found */ /** only need to copy pertinent data from loop context */ @elsif $m2c_data_transient == 2@ # copy immediately /* * TRANSIENT data: copy all the data. */ @end@ @if $m2c_include_examples == 1@ $example_start @ if $m2c_data_transient == 1@ # short term /** save line to do that */ memcpy(save_loop_ctx_ref->loop_ctx->line, loop_ctx_ref->loop_ctx->line, sizeof(loop_ctx_ref->loop_ctx->line)); @ elsif $m2c_data_transient == 2@ # copy immediately @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ /* * ToDo: * set rowreq_ctx_ref->${m2c_data_item}$node * from the loop context */ @ end@ @ end@ $example_end @end@ # example return MFD_SUCCESS; } /* ${context}_loop_save_position */ @if $m2c_data_transient != 0@ # semi-transient /** * set ${context}_data from a data context * * Summary * ------- * At the end of the loop, when the best match has been found, the saved * loop context will be used to get the data for the row by calling * ${context}_loop_get_data(). * * You should return a fully populated row request context in * rowreq_ctx_ref->rowreq_ctx. * * More Details * ------------ * @param $mfd_aue_param_cmt * @param loop_ctx_ref pointer to your loop reference. * @param rowreq_ctx_ref pointer to a context reference. */ int ${context}_loop_get_data( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref, ${context}_ref_rowreq_ctx *rowreq_ctx_ref) { DEBUGMSGTL(("verbose:${context}:${context}_loop_get_data","called\n")); netsnmp_assert((NULL != loop_ctx_ref) && (NULL != loop_ctx_ref->loop_ctx)); netsnmp_assert(NULL != rowreq_ctx_ref); netsnmp_assert(NULL != rowreq_ctx_ref->rowreq_ctx); /* * take temporary row request context from loop context */ rowreq_ctx_ref->rowreq_ctx = loop_ctx_ref->loop_ctx->rowreq_ctx; loop_ctx_ref->loop_ctx->rowreq_ctx = NULL; /* * copy data to the data context (rowreq_ctx_ref->${m2c_data_item}) @ if $m2c_include_examples == 1@ * in loop_save_position, we saved line to do that @ end@ */ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ /* * $m2c_node_summary */ @ eval $m2c_ctx_lh = "rowreq_ctx_ref->$m2c_ctx_rh"@ @ eval $m2c_ctx_lhs = "rowreq_ctx_ref->$m2c_ctx_rhs"@ @ eval $m2c_ctx_rh = "loop_ctx_ref->loop_ctx->$node"@ @ eval $m2c_ctx_rhs = "loop_ctx_ref->loop_ctx->${node}_len"@ @ include generic-value-map.m2i@ @ end@ return MFD_SUCCESS; } /* ${context}_loop_get_data */ @end@ // if $m2c_data_transient != 0 /** * clean up a loop reference * * Summary * ------- * This function will be called once the loop iteration has completed * to release any memory or resources allocated for the loop context. * * More Details * ------------ * @param $mfd_aue_param_cmt * @param loop_ctx_ref Pointer to your loop reference. * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : error. */ int ${context}_loop_cleanup_context( $mfd_aue_param_decl, ${context}_ref_loop_ctx *loop_ctx_ref) { DEBUGMSGTL(("verbose:${context}:${context}_loop_cleanup_context","called\n")); netsnmp_assert(loop_ctx_ref); if(!loop_ctx_ref->loop_ctx) return MFD_ERROR; /* * release the row request context, if it wasn't taken */ if(loop_ctx_ref->loop_ctx->rowreq_ctx) ${context}_release_rowreq_ctx(loop_ctx_ref->loop_ctx->rowreq_ctx); /* * ToDo: * release resources */ @if $m2c_include_examples == 1@ $example_start /* * close file */ if(loop_ctx_ref->loop_ctx->filep) fclose(loop_ctx_ref->loop_ctx->filep); $example_end @end@ /* * free loop context */ free(loop_ctx_ref->loop_ctx); return MFD_SUCCESS; } /* ${context}_loop_cleanup_context */ @end@ // m2c_processing_type eq 'c' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'r'@ ## unsorted-external summary ------------------------- The unsorted-external data access code is for cases when you data is kept UNSORTED and EXTERNAL to the agent/sub-agent. This code was generated based on the following assumptions or settings: 1) The raw data for this table is UNSORTED. @if $mfd_readme_verbose != 0@ UNSORTED data is data that is not kept in the same order as the way SNMP expects the index(es) for the table to be kept. [It could very well be sorted in some other order, but for the purpose of SNMP, the order is incorrect.] If you're not sure if your data is sorted in an SNMP compliant way, its likely not. Because the raw data is unsorted, to satisfy a particular request, the entire data set must be examined to find the apropriate index. This is done via a simple loop. The MFD handler will call your get_first function and the call the get_next function repeatedly, until it returns SNMPERR_NO_VARS. @end@ 2) The raw data for this table is EXTERNAL. @if $mfd_readme_verbose != 0@ EXTERNAL data is data that is owned by some other process, device, file or mechanism. The agent must use some interface to read or modify the data. An external process may modify the data without the agent's knowledge. For example, the Net-SNMP agent implements the interface table (ifTable), which reports on network interfaces. The host operating system owns this data, and Net-SNMP must use system calls to report or manipulate the data. Examples of external data include data stored in kernel space, in files, in another non-memory shared process, and data stored in devices. @end@ 3) The raw data for this table is TRANSIENT. @if $mfd_readme_verbose != 0@ TRANSIENT data is data that may be overwritten by another funtion or process. For example, many OS functions return data in a static buffer that will be reused the next time the function is called. Because of this, we will assume that you will copy the raw data retrieved from these other sources to a generated structure for use within the Net-SNMP agent. (Don't worry, we'll help you) @end@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## The unsorted external data access code works by calling a few simple functions to get the index value for each row. Once the agent determines which row is needed to process an incoming request, another function is called to retrieve the data for that row. A simplified version of the pseudo-code looks like this: ${context}_loop_init_context(loop) ${context}_loop_get_first(loop,data) while( no_error ) { if( best_match(data, key) ${context}_loop_save_position(loop,pos); ${context}_loop_get_next(loop,data) } ${context}_loop_get_data(pos,data) ${context}_loop_cleanup_context(loop) ## ## end sync ## We will talk about each individual step below. ######################################################################## Defining context for the loop ----------------------------- ToDo : typedef ${context}_loop_context WHERE: ${table}_data_access.h @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## Since the actual loop is in the MFD handler, a loop contex parameter is provided to help you keep track of where you are in between calls to functions that you wrote and the master MFD handler calls. The structure of this context is user defineable, and is defined in the file ${table}_data_access.h. E.G., if your data is stored in a linked list, the obvious thing you want to know from one function call to the next is your current position in the linked list. Thus the easiest context to use is a pointer within the linked list. For an array, the current index to that array would be easiest. The funtion calls are actually passed a reference to the loop context, to allow the loop context to be allocated memory. Here are some simple examples definitions for various data formats. These definitions are used in examples later on. ## ## end sync ## Linked list ----------- typedef list_node ${context}_loop_context; Array ----- typedef integer ${context}_loop_context; File ---- typedef struct ${context}_loop_context_s { char * file_name; FILE * f; char line[128]; } ${context}_loop_context; @end@ ######################################################################## Initialization -------------- ToDo : Initialization FUNC : ${context}_loop_init_data WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ The ${context}_loop_init_data function will be called during startup to allow for any initialization needed for the data access routines. @end@ ######################################################################## Preparing for the loop ---------------------- ToDo : initialize loop context FUNC : ${context}_loop_init_context WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## This function will be called before the start of a new itertion over the data. The loop context that is initialized here will be passed to ${context}_loop_get_first and ${context}_loop_get_next. Set the loop context variable ref->loop_ctx so that the iteration functions (get_first and get_next) can locate the apropriate data context. ## ## end sync ## The primary purpose of the loop_init_context call is to initialize the loop context data (ref). Here are some simple examples, based on the earlier example loop contexts. Linked list ----------- ref->loop_ctx = my_table_head_ptr; Array ----- /* instead of actually allocating memory, just use the pointer */ /* as an integer */ (integer)(ref->loop_ctx) = 0; File ---- ref->loop_ctx = SNMP_MALLOC_TYPEDEF(${context}_loop_context); /* error checking here */ ref->loop_ctx->file_name = (char*) reg->mfd_user_ctx; ref->loop_ctx->f = fopen( ref->loop_ctx->file_name, "r+" ); @end@ ######################################################################## The Loop -------- ToDo : return raw data FUNC : ${context}_loop_get_first WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## This function is called to return set the index(es) for the first ${context}_data in the data set. Note that during the loop, the only important thing is the indexes. If access to your data is cheap/fast (e.g. you have a pointer to a structure in memory), it would make sense to update the data here. If, however, the accessing the data invovles more work (e.g. parsing some other existing data, or peforming calculations to derive the data), then you should limit yourslef to setting the indexes. Extracting the can be put off until the desired row is found See the notes on ${context}_loop_get_data(). Note that this function does not correspond to a SNMP GET pdu, and you should return data items in whatever order they are already in. (In fact, if your data is already ordered in the same order as the SNMP indexes, you shouldn't be using the unsorted-access code). This function should update the table index (rowreq_ctx_ref->rowreq_ctx->tbl_idx) values for the raw data (rowreq_ctx_ref->rowreq_ctx->data). ## ## end sync ## Linked list ----------- rowreq_ctx_ref->rowreq_ctx->data = loop_ctx_ref->loop_ctx; Array ----- /* assuming registration has array of pointers */ rowreq_ctx_ref->rowreq_ctx->data = reg->mfd_user_ctx[(integer)(ref->loop_ctx)]; File ---- fgets(loop_ctx_ref->loop_ctx->line, sizeof(loop_ctx_ref->loop_ctx->line), loop_ctx_ref->loop_ctx->f); rowreq_ctx_ref->rowreq_ctx->data = loop_ctx_ref->loop_ctx->line; @end@ ToDo : return raw data FUNC : ${context}_loop_get_next WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## This function returns the next data item in the data set. The same caveat applies here as did above. The indexes are the important parts during loop processing. Note that this function does not correspond to a SNMP GET-NEXT pdu, and you should return data items in whatever order they are already in. (In fact, if your data is already ordered in the same order as the SNMP indexes, you shouldn't be using the unsorted-access code). ## ## end sync ## Linked list ----------- loop_ctx_ref->loop_ctx = loop_ctx_ref->loop_ctx->next; rowreq_ctx_ref->rowreq_ctx->data = loop_ctx_ref->loop_ctx; Array ----- ++((integer)(ref->loop_ctx)); /* assuming registration has array of pointers */ rowreq_ctx_ref->rowreq_ctx->data = reg->mfd_user_ctx[(integer)(ref->loop_ctx)]; File ---- fgets(loop_ctx_ref->loop_ctx->line, sizeof(loop_ctx_ref->loop_ctx->line), loop_ctx_ref->loop_ctx->f); rowreq_ctx_ref->rowreq_ctx->data = loop_ctx_ref->loop_ctx->line; @end@ ######################################################################## Updating the Index ------------------ ToDo : update index for the raw data FUNC : ${context}_indexes_set WHERE: ${table}_data_access.c This is a convenience function for setting the index context from the native C data. Where necessary, value mapping should be done. @if $mfd_readme_verbose == 1@ This function should update the table index values (found in tbl_idx) for the given raw data. @end@ ######################################################################## Saving a position in the loop ----------------------------- ToDo : Saving a position in the loop FUNC : ${context}_loop_save_position WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## During loop iteration, the iterator keeps track of the row that is the current best match. This function is called when the current row is a better match than any previous row. You should save any information you need to be able to locate this row again from the current loop context to a new loop context. At the end of the loop, when the best match has been found, the saved loop context will be used to get the data for the row by calling ${context}_loop_get_data(). @if $m2c_data_transient != 0@ # persistent Since your data is transient, you need to make a copy of it before the iterator moves on to the next row. @end@ ## ## end sync ## @end@ ######################################################################## Returning Data For an Index --------------------------- ToDo : copy transient raw data to generated structure FUNC : ${context}_loop_get_data WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## At the end of the loop, when the best match has been found, the saved loop context will be used to get the data for the row by calling ${context}_loop_get_data(). ## ## end sync ## @end@ ######################################################################## Cleaning up after the loop -------------------------- ToDo : release any allocated memory FUNC : ${context}_loop_cleanup_context WHERE: ${table}_data_access.c @if $mfd_readme_verbose != 0@ ## ## this should be syncronized with master version of comments in ## mfd-access-unsorted-external-body.m2i You should be able to copy ## the comments here and replace " * " with " ". ## This function will be called once the loop iteration has completed to release any memory allocated for loop reference. ## ## end sync ## The purpose of the loop_cleanup_context call is to release any memory allocated for the loop context data. Here are some simple examples, based on the earlier example loop contexts. Linked list ----------- /* nothing to do */ Array ----- /* nothing to do */ File ---- free(ref->loop_ctx); @end@ ## @end@ // m2c_processing_type eq 'r ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 17717 $ */ @end@ mib2c-data/node-get.m2i 0000666 00000007300 15077166074 0010603 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: node-get.m2i 12704 2005-08-30 00:38:54Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12704 $ */ @end@ ######################################################################## ## @include m2c_setup_node.m2i@ @eval $m2c_node_realloc = 2@ // malloc /** * Extract the current value of the $node data. * * Set a value using the data context for the row. * @if $m2c_node_get_comments ne ""@ $m2c_node_get_comments * @end@ * @param rowreq_ctx * Pointer to the row request context. * @param $m2c_node_param_ref_name * Pointer to storage for a $node.decl variable @if $m2c_node_needlength == 1@ * @param $m2c_node_param_ref_lname * Pointer to a size_t. On entry, it will contain the size (in bytes) * pointed to by $node. * On exit, this value should contain the data size (in bytes). @end@ * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error @if $m2c_node_needlength == 1@ * * @note If you need more than (*$m2c_node_param_ref_lname) bytes of memory, * allocate it using malloc() and update $m2c_node_param_ref_name. * <b>DO NOT</b> free the previous pointer. * The MFD helper will release the memory you allocate. * * @remark If you call this function yourself, you are responsible * for checking if the pointer changed, and freeing any * previously allocated memory. (Not necessary if you pass * in a pointer to static memory, obviously.) @end@ */ int ${node}_get( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_ref ) { @ifconf syntax-$node.syntax-get.m2i@ @ include syntax-$node.syntax-get.m2i@ @else@ @ include generic-get-decl.m2i@ DEBUGMSGTL(("verbose:${context}:${node}_get","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the $node data. @if $m2c_node_needlength == 0@ * copy $m2c_node_lh from $m2c_data_item_base @else@ * copy $m2c_node_lh data and $m2c_node_lhs from $m2c_data_item_base @end@ */ @ if ("$m2c_data_context" eq "generated") && ($m2c_node_skip_get != 1)@ @ include generic-ctx-get.m2i@ @ else@ @ if ($m2c_node_skip_get != 1)@ /* * TODO:235:M: |-> Remove log message/SKIP once you've set $node data */ snmp_log(LOG_ERR,"${context} node $node not implemented: skipping\n"); @ end@ return MFD_SKIP; @ end@ ## ------------------------------------------------------------------ @ if $node.decl =~ /long/i@ # ASN_INTEGER ASN_COUNTER ASN_GAUGE @ include generic-get-long.m2i@ @ elsif $node.decl =~ /char/i@ # ASN_OCTET_STR ASN_OPAQUE @ include generic-get-char.m2i@ @ elsif $node.decl =~ /oid/i@ # ASN_OBJECT_ID @ include generic-get-oid.m2i@ @ elsif $node.decl =~ /U64/i@ # ASN_COUNTER64 @ include generic-get-U64.m2i@ @ else@ @ print ERROR: unknown node.decl: $node.decl@ @ exit@ @ end@ ## ------------------------------------------------------------------ @ if ($m2c_node_skip_mapping != 1) && ("$m2c_data_context" ne "generated")@ @ include generic-value-map.m2i@ @ end@ @ include generic-get-decl-bot.m2i@ // copy value out @end@ # no syntax include return MFD_SUCCESS; } /* ${node}_get */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12704 $ */ @end@ mib2c-data/generic-table-oids.m2c 0000666 00000007125 15077166074 0012535 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-oids.m2c 17548 2009-04-23 16:35:18Z hardaker $ ######################################################################## @if $m2c_create_fewer_files != 1@ @eval $hack = "Id"@ @eval $m2c_save = "$name"@ @eval $name = "${m2c_save}_oids"@ @open ${name}.h@ /* * Note: this file originally auto-generated by mib2c using * $Id: generic-table-oids.m2c 17548 2009-04-23 16:35:18Z hardaker $ * * $$hack:$ */ @include generic-header-top.m2i@ @eval $name = "$m2c_save"@ @end@ // m2c_create_fewer_files ######################################################################## @if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 17548 $ */ @end@ ## /* column number definitions for table $context */ #define $context.uc_OID $context.commaoid @eval $minv = 0xffffffff@ @eval $maxv = 0@ @eval $gto_flag_req = ""@ @eval $gto_flag_set = ""@ @eval $m2c_tmp_gto = 0@ @foreach $node column@ #define COLUMN_$node.uc $node.subid @if $node.accessible == 1@ @if ($node.settable == 1) || ($m2c_table_sparse == 1)@ @ if "x$gto_flag_set" eq "x"@ @ eval $gto_flag_set = "COLUMN_$node.uc_FLAG"@ @ else@ @ eval $gto_flag_set = "$gto_flag_set | COLUMN_$node.uc_FLAG"@ @ end@ @if $m2c_tmp_gto > 31@ #define COLUMN_$node.uc_FLAG (((uint64_t)0x1) << $m2c_tmp_gto) @else@ #define COLUMN_$node.uc_FLAG (0x1 << $m2c_tmp_gto) @end@ @eval $m2c_tmp_gto = $m2c_tmp_gto + 1@ @end@ @if ($m2c_table_row_creation == 1) && ($node.settable == 1) && ("x$node.defval" eq "x")@ @if "x$gto_flag_req" eq "x"@ @eval $gto_flag_req = "COLUMN_$node.uc_FLAG"@ @else@ @eval $gto_flag_req = "$gto_flag_req | COLUMN_$node.uc_FLAG"@ @end@ @end@ @if $node.subid < $minv@ @eval $minv = $node.subid@ @eval $minn = "COLUMN_$node.uc"@ @end@ @if $node.subid > $maxv@ @eval $maxv = $node.subid@ @eval $maxn = "COLUMN_$node.uc"@ @end@ @end@ @end@ # column #define $context.uc_MIN_COL $minn #define $context.uc_MAX_COL $maxn ## ## column_set_flags and column_exist_flags are unsigned ints, to 32 is ## the limit. Could try something with a 'long long' to see if that ## can get us to 64, or do something like FD_SET, which would let us ## be pretty unlimited. ## @if $maxn > 31@ @ print ERROR: more than 32 columns not supported yet.@ @ exit@ @end@ @ if $m2c_table_settable@ @if "x$gto_flag_set" ne "x"@ /* * TODO:405:r: Review $context.uc_SETTABLE_COLS macro. * OR together all the writable cols. */ #define $context.uc_SETTABLE_COLS ($gto_flag_set) @end@ @if $m2c_table_row_creation@ @if "x$gto_flag_req" ne "x"@ /* * TODO:405:r: Review $context.uc_REQUIRED_COLS macro. * OR together all the required rows for row creation. * default is writable cols w/out defaults. */ #define $context.uc_REQUIRED_COLS ($gto_flag_req) @end@ @end@ @ end@ # settable @if $m2c_create_fewer_files != 1@ @eval $m2c_save = "$name"@ @eval $name = "${m2c_save}_oids"@ @include generic-header-bottom.m2i@ @eval $name = "$m2c_save"@ @end@ ######################################################################## @if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 17548 $ */ @end@ mib2c-data/syntax-RowStatus-varbind-validate.m2i 0000666 00000001225 15077166074 0015612 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-RowStatus-varbind-validate.m2i 8857 2003-10-01 00:20:35Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 8857 $ */ @end@ ######################################################################## ## rc = netsnmp_check_vb_rowstatus_value(var); ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 8857 $ */ @end@ mib2c-data/m2c-internal-warning.m2i 0000666 00000002562 15077166074 0013044 0 ustar 00 /* * ********************************************************************* * ********************************************************************* * ********************************************************************* * *** *** * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** * *** *** * *** *** * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** * *** *** * *** *** * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** * *** *** * *** *** * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** * *** *** * *** *** * ********************************************************************* * ********************************************************************* * ********************************************************************* */ mib2c-data/generic-table-indexes-to-oid.m2i 0000666 00000003332 15077166074 0014431 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-indexes-to-oid.m2i 12019 2005-03-22 22:27:57Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12019 $ */ @end@ ######################################################################## ## /** * @internal * convert the index component stored in the context to an oid */ int ${context}_index_to_oid(netsnmp_index *oid_idx, ${context}_mib_index *mib_idx) { @include generic-table-indexes-varbind-setup.m2i@ DEBUGMSGTL(("verbose:${context}:${context}_index_to_oid","called\n")); @ foreach $node index@ @ include m2c_setup_node.m2i@ /* $m2c_node_summary */ @ if $m2c_node_needlength == 1@ snmp_set_var_value(&var_$node, (u_char*)&mib_idx->$node, mib_idx->${node}_len * sizeof(mib_idx->${node}[0])); @ else@ snmp_set_var_value(&var_$node, (u_char*)&mib_idx->$node, sizeof(mib_idx->$node)); @ end@ @ end@ # for each column err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, NULL, 0, &var_$m2c_dii_first); if(err) snmp_log(LOG_ERR,"error %d converting index to oid\n", err); /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_$m2c_dii_first ); return err; } /* ${context}_index_to_oid */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12019 $ */ @end@ mib2c-data/mfd-data-set.m2c 0000666 00000011675 15077166074 0011353 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: mfd-data-set.m2c 12077 2005-04-14 02:47:19Z rstory $ ######################################################################## ## lower conf files get confused with multiple processing types, so ## set single options @eval $mfd_data_set_processing_type_save = "$m2c_processing_type"@ @if "$mfd_processing_types" =~ /h/@ @eval $m2c_processing_type = 'h'@ @if $m2c_create_fewer_files != 1@ @ eval $hack = "Id"@ @open ${name}_data_set.h@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 12077 $ of $RCSfile$ * * $$hack:$ */ @eval $m2c_save = "$name"@ @eval $name = "${name}_DATA_SET"@ @include generic-header-top.m2i@ @eval $name = "$m2c_save"@ @end@ // m2c_create_fewer_files ######################################################################## @if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 12077 $ */ @end@ ## /* ********************************************************************* * SET function declarations */ /* ********************************************************************* * SET Table declarations */ @foreach $table table@ @ include m2c_setup_table.m2i@ @ if $m2c_table_settable == 0@ @ next@ # skip to next table @ end@ @ include details-table.m2i@ @ include parent-set.m2i@ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ int ${node}_check_value( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val); int ${node}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx ); int ${node}_set( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val ); int ${node}_undo( ${context}_rowreq_ctx *rowreq_ctx ); @ end@ # foreach nonindex int ${context}_check_dependencies(${context}_rowreq_ctx *ctx); @end@ # foreach table @if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 12077 $ */ @end@ @if $m2c_create_fewer_files != 1@ @eval $m2c_save = "$name"@ @eval $name = "${name}_DATA_SET"@ @include generic-header-bottom.m2i@ @eval $name = "$m2c_save"@ @end@ // m2c_create_fewer_files ###################################################################### @end@ // mfd_processing_types =~ /h/ ###################################################################### ###################################################################### ###################################################################### ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if "$mfd_processing_types" =~ /c/@ @eval $m2c_processing_type = 'c'@ @if $m2c_create_fewer_files != 1@ @open ${name}_data_set.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 12077 $ of $RCSfile$ * * $$hack:$ * */ @include generic-source-includes.m2i@ /** @defgroup data_set data_set: Routines to set data * * These routines are used to set the value for individual objects. The * row context is passed, along with the new value. * * @{ */ @end@ // m2c_create_fewer_files @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12077 $ */ @end@ ######################################################################## @foreach $table table@ @ include m2c_setup_table.m2i@ @ if $m2c_table_settable == 0@ @ next@ # skip to next table @ end@ @ include details-table.m2i@ ######################################################################## @ include parent-set.m2i@ ######################################################################## ######################################################################## /* * TODO:440:M: Implement $context node value checks. * TODO:450:M: Implement $context undo functions. * TODO:460:M: Implement $context set functions. * TODO:480:M: Implement $context commit functions. */ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 0@ @ next@ # skip to next column @ end@ @ if $m2c_report_progress == 1@ @ print | | +-> Processing nonindex $node@ @ end@ @ include details-node.m2i@ @ include node-set.m2i@ @ end@ # foreach column ######################################################################## @ if $m2c_table_dependencies == 1@ @ include parent-dependencies.m2i@ @ end@ ######################################################################## @end@ # foreach table ## ######################################################################## /** @} */ @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12077 $ */ @end@ ######################################################################## @end@ // mfd_processing_type =~ /c/ ## restore original processing types @eval $m2c_processing_type = "$mfd_data_set_processing_type_save"@ mib2c-data/syntax-COUNTER64-get.m2i 0000666 00000002323 15077166074 0012473 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-COUNTER64-get.m2i 11363 2004-10-15 00:52:14Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11363 $ */ ## } @end@ ######################################################################## ## @include generic-get-decl.m2i@ /* * TODO:231:o: |-> copy $node data. * get ${m2c_node_lh}.low and ${m2c_node_lh}.high from $m2c_data_item_base */ @if ("$m2c_data_context" eq "generated")@ ${m2c_node_lh}.high = ${m2c_data_item}${node}.high; ${m2c_node_lh}.low = ${m2c_data_item}${node}.low; @else@ return MFD_SKIP; /* TODO:235:M: |-> Remove SKIP once you've set $node data */ @end@ ## spirit of @include generic-get-decl-bot.m2i@ @if $m2c_get_use_temp == 1@ /* copy temporary value to passed parameter */ ${node}_ptr->high = ${m2c_node_lh}.high; ${node}_ptr->low = ${m2c_node_lh}.low; @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11363 $ */ @end@ mib2c-data/generic-get-char.m2i 0000666 00000003157 15077166074 0012213 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-get-char.m2i 12011 2005-03-18 23:01:44Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12011 $ */ @end@ ######################################################################## ## ## enums first @if $m2c_node_skip_mapping == -1@ @ eval $m2c_node_skip_mapping = 1@ @end@ @if ($node.enums == 1) && ("$node.perltype" eq "BITS")@ /* * TODO:242:o: update or replace BITS tests (get). * If $node data is stored in SNMP BIT order, individual * bit tests are redundant, and you can do a straight copy. If not, then * update each if condition to test the correct bit. * * NOTE WELL: setting bit '0' for: * C 0x0000001 * SNMP 0x8000000 * @ if $m2c_node_skip_mapping != 1@ * define correct bit to test for all INTERNAL_* defines in the * ${context} enum or contants header file. */ $example_start $m2c_node_lh = 0; @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ if ($m2c_ctx_rh & INTERNAL_$context.uc_$m2c_iname) { $m2c_node_lh |= $m2c_ename; } @ end@ # for each $example_end @ else@ * assuming generated code keeps $node BITS in SNMP order. */ $m2c_node_lh = @m2c_ctx_rh; @ end@ @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12011 $ */ @end@ mib2c-data/generic-get-decl-bot.m2i 0000666 00000001502 15077166074 0012757 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-get-decl-bot.m2i 9366 2004-02-02 15:56:14Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 9366 $ */ @end@ ######################################################################## ## @if $m2c_get_use_temp == 1@ /* copy temporary value to passed parameter */ (* $m2c_node_param_ref_name) = $m2c_node_lh; @ if $m2c_node_needlength == 1@ (* $m2c_node_param_ref_lname) = $m2c_node_lhs; @ end@ @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 9366 $ */ @end@ mib2c-data/syntax-InetAddress-get.m2i 0000666 00000005730 15077166074 0013414 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-InetAddress-get.m2i 11795 2005-01-06 14:49:39Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11795 $ */ @end@ ######################################################################## ## /* * TODO:231:M: |-> copy $node data. * TODO:231:M: | |-> get address type from your context pointer. */ int addressType = -1; size_t actual_size = 0; return MFD_SKIP; /* TODO:235:M: |-> Remove SKIP once you've set $node data */ switch (addressType) { case INETADDRESSTYPE_UNKNOWN: /* * An unknown address type. This value MUST be used if the value * of the InetAddress object is a zero-length string. It may also be * used to indicate an IP address which is not in one of the formats * defined below. */ actual_size = ${m2c_ctx_rhs}; break; case INETADDRESSTYPE_IPV4: /* * Represents an IPv4 network address: * octets contents encoding * 1-4 IPv4 address network-byte order */ actual_size = 4; break; case INETADDRESSTYPE_IPV6: /* * Represents an IPv6 network address: * * octets contents encoding * 1-16 IPv6 address network-byte order */ actual_size = 16; break; case INETADDRESSTYPE_IPV4Z: /* * Represents a non-global IPv4 network address together * with its zone index: * * octets contents encoding * 1-4 IPv4 address network-byte order * 5-8 zone index network-byte order */ actual_size = 8; break; case INETADDRESSTYPE_IPV6Z: /* * Represents a non-global IPv6 network address together * with its zone index: * * octets contents encoding * 1-16 IPv6 address network-byte order * 17-20 zone index network-byte order */ actual_size = 20; break; case INETADDRESSTYPE_DNS: /* * Represents a DNS domain name. The name SHOULD be fully * qualified whenever possible. */ actual_size = ${m2c_ctx_rhs}; break; default: snmp_log(LOG_ERR, "unknown InetAddressType %d for $node\n", addressType); return SNMP_ERR_GENERR; } if ( actual_size > ${m2c_ctx_lhs} ) { snmp_log(LOG_ERR, "actual size %d too big for $node\n", addressType); return SNMP_ERR_GENERR; } memcpy( ${m2c_ctx_lh}, ${m2c_ctx_rh}, actual_size); ${m2c_ctx_lhs} = actual_size; ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11795 $ */ @end@ mib2c-data/m2c_setup_table.m2i 0000666 00000003321 15077166074 0012150 0 ustar 00 ######################################################################## ## generic include for XXX. Do not use directly. ## ## $Id: m2c_setup_table.m2i 12086 2005-04-18 21:53:05Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12086 $ */ @end@ ######################################################################## ## @if "$m2c_context_name" ne "$table"@ @ eval $m2c_context_name = $table@ @ eval $context = $table@ @ if $m2c_report_progress == 1@ @ print | +-> Processing table $context@ @ end@ @ eval $m2c_context_item = "rowreq_ctx->"@ @ eval $m2c_table_external_indexes = count_external_indexes($context)@ ## @ eval $m2c_undo_embed = $mfd_default_undo_embed@ @ eval $m2c_gda_todo_suppress = 0@ # todo comments ## ## user override ## @ include ${m2c_defaults_dir}table-${context}.m2d@ ## @ eval $m2c_data_item_base = "${m2c_context_item}data"@ @ if $m2c_data_allocate == 1@ @ eval $m2c_data_item = "${m2c_data_item_base}->"@ @ else@ @ eval $m2c_data_item = "${m2c_data_item_base}."@ @ end@ @ if $m2c_table_settable == 0@ @ eval $m2c_undo_embed = 1@ @ end@ @ eval $m2c_undo_item_base = "${m2c_context_item}undo"@ @ if $m2c_undo_embed == 1@ @ eval $m2c_undo_item = "${m2c_undo_item_base}."@ @ else@ @ eval $m2c_undo_item = "${m2c_undo_item_base}->"@ @ end@ @end@ @eval $m2c_node_name = ""@ ######################################################################## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12086 $ */ @end@ mib2c-data/mfd-data-access.m2c 0000666 00000024764 15077166074 0012024 0 ustar 00 ##//######################################################### -*- c -*- ##//generic include for XXX. Do not use directly. ## ##//$Id: mfd-data-access.m2c 14170 2006-01-26 17:02:48Z dts12 $ ##//#################################################################### ##//#################################################################### ## ## lower conf files get confused with multiple processing types, so ## set single options @eval $mfd_data_access_processing_type = "$m2c_processing_type"@ @eval $m2c_processing_type = 'h'@ @open ${name}_data_access.h@ @eval $hack = "Id"@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 14170 $ of $RCSfile$ * * $$hack:$ */ @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 14170 $ */ @end@ @eval $m2c_save = "$name"@ @eval $name = "${name}_DATA_ACCESS"@ @include generic-header-top.m2i@ @eval $name = "$m2c_save"@ /* ********************************************************************* * function declarations */ /* ********************************************************************* * Table declarations */ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ ##@ eval $m2c_tmp=""@ ##@ foreach $node index@ ##@ include m2c_setup_node.m2i@ ##@ eval $m2c_tmp="$m2c_tmp, $m2c_node_param_val"@ ##@ end@ // for each index int ${context}_init_data(${context}_registration * ${context}_reg); @ include mfd-access-${m2c_table_access}-defines.m2i@ int ${context}_row_prep( ${context}_rowreq_ctx *rowreq_ctx); @ if ($m2c_table_row_creation == 1) || ($m2c_table_persistent == 1)@ int ${context}_validate_index( ${context}_registration * ${context}_reg, ${context}_rowreq_ctx *rowreq_ctx); @ foreach $node externalindex@ @ include m2c_setup_node.m2i@ int ${context}_${node}_check_index( ${context}_rowreq_ctx *rowreq_ctx ); /* external */ @ end@ # foreach externalindex @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ int ${node}_check_index( ${context}_rowreq_ctx *rowreq_ctx ); /* internal */ @ end@ # foreach internalindex @ end@ # row creation/persistent @end@ @eval $m2c_save = "$name"@ @eval $name = "${name}_DATA_ACCESS"@ @include generic-header-bottom.m2i@ @eval $name = "$m2c_save"@ ##//################################################################## ##//Do the .c file ##//################################################################## @eval $m2c_processing_type = 'c'@ @open ${name}_data_access.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 14170 $ of $RCSfile$ * * $$hack:$ */ @include generic-source-includes.m2i@ #include "${name}_data_access.h" /** @ingroup interface * @addtogroup data_access data_access: Routines to access data * * These routines are used to locate the data used to satisfy * requests. * * @{ */ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ /** * initialization for ${context} data access * * This function is called during startup to allow you to * allocate any resources you need for the data table. * * @param ${context}_reg * Pointer to ${context}_registration * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : unrecoverable error. */ int ${context}_init_data(${context}_registration * ${context}_reg) { DEBUGMSGTL(("verbose:${context}:${context}_init_data","called\n")); /* * TODO:303:o: Initialize $context data. */ @ifconf ${table}_init_data.m2i@ @ include ${table}_init_data.m2i@ @else@ @ if $m2c_include_examples == 1@ $example_start /* * if you are the sole writer for the file, you could * open it here. However, as stated earlier, we are assuming * the worst case, which in this case means that the file is * written to by someone else, and might not even exist when * we start up. So we can't do anything here. */ $example_end @ end@ return MFD_SUCCESS; @end@ #ifconf } /* ${context}_init_data */ @ include mfd-access-${m2c_table_access}-defines.m2i@ /** * prepare row for processing. * * When the agent has located the row for a request, this function is * called to prepare the row for processing. If you fully populated * the data context during the index setup phase, you may not need to * do anything. * * @param rowreq_ctx pointer to a context. * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error. */ int ${context}_row_prep( ${context}_rowreq_ctx *rowreq_ctx) { DEBUGMSGTL(("verbose:${context}:${context}_row_prep","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:390:o: Prepare row for request. * If populating row data was delayed, this is the place to * fill in the row for this request. */ return MFD_SUCCESS; } /* ${context}_row_prep */ ##//#################################################################### @ if ($m2c_table_row_creation == 1) || ($m2c_table_persistent == 1)@ /* * TODO:420:r: Implement $context index validation. */ @ foreach $node externalindex@ @ include m2c_setup_node.m2i@ @ if $m2c_report_progress == 1@ @ print | | +-> Processing index $node@ @ end@ @ include details-node.m2i@ /** * check validity of ${node} external index portion * * NOTE: this is not the place to do any checks for the sanity * of multiple indexes. Those types of checks should be done in the * ${context}_validate_index() function. * * @retval MFD_SUCCESS : the incoming value is legal * @retval MFD_ERROR : the incoming value is NOT legal */ int ${context}_${node}_check_index( ${context}_rowreq_ctx *rowreq_ctx ) { DEBUGMSGTL(("verbose:${context}:${context}_${node}_check_index","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:424:M: |-> Check $context external index $node. * check that index value in the table context (rowreq_ctx) * for the external index $node is legal. */ return MFD_SUCCESS; /* external index $node ok */ } /* ${context}_${node}_check_index */ @ end@ # foreach externalindex @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ @ if $m2c_report_progress == 1@ @ print | | +-> Processing index $node@ @ end@ @ include details-node.m2i@ /** * check validity of ${node} index portion * * @retval MFD_SUCCESS : the incoming value is legal * @retval MFD_ERROR : the incoming value is NOT legal * * @note this is not the place to do any checks for the sanity * of multiple indexes. Those types of checks should be done in the * ${context}_validate_index() function. * * @note Also keep in mind that if the index refers to a row in this or * some other table, you can't check for that row here to make * decisions, since that row might not be created yet, but may * be created during the processing this request. If you have * such checks, they should be done in the check_dependencies * function, because any new/deleted/changed rows should be * available then. * * The following checks have already been done for you: @if $node.enums == 1@ * The value is one of $m2c_evals @elsif $node.ranges == 1@ @ if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ @ eval $m2c_tmp_ns = "value"@ @ else@ @ eval $m2c_tmp_ns = "length"@ @ end@ * The $m2c_tmp_ns is in (one of) the range set(s): $m2c_evals @end@ * * If there a no other checks you need to do, simply return MFD_SUCCESS. */ int ${node}_check_index( ${context}_rowreq_ctx *rowreq_ctx ) { DEBUGMSGTL(("verbose:${context}:${node}_check_index","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:426:M: |-> Check $context index $node. * check that index value in the table context is legal. * (rowreq_ctx->tbl_index.$node) */ return MFD_SUCCESS; /* $node index ok */ } /* ${node}_check_index */ @ end@ # foreach internalindex /** * verify specified index is valid. * * This check is independent of whether or not the values specified for * the columns of the new row are valid. Column values and row consistency * will be checked later. At this point, only the index values should be * checked. * * All of the individual index validation functions have been called, so this * is the place to make sure they are valid as a whole when combined. If * you only have one index, then you probably don't need to do anything else * here. * * @note Keep in mind that if the indexes refer to a row in this or * some other table, you can't check for that row here to make * decisions, since that row might not be created yet, but may * be created during the processing this request. If you have * such checks, they should be done in the check_dependencies * function, because any new/deleted/changed rows should be * available then. * * * @param ${context}_reg * Pointer to the user registration data * @param ${context}_rowreq_ctx * Pointer to the users context. * @retval MFD_SUCCESS : success * @retval MFD_CANNOT_CREATE_NOW : index not valid right now * @retval MFD_CANNOT_CREATE_EVER : index never valid */ int ${context}_validate_index( ${context}_registration * ${context}_reg, ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:${context}:${context}_validate_index","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:430:M: |-> Validate potential $context index. */ if(1) { snmp_log(LOG_WARNING,"invalid index for a new row in the " "${context} table.\n"); /* * determine failure type. * * If the index could not ever be created, return MFD_NOT_EVER * If the index can not be created under the present circumstances * (even though it could be created under other circumstances), * return MFD_NOT_NOW. */ if(0) { return MFD_CANNOT_CREATE_EVER; } else { return MFD_CANNOT_CREATE_NOW; } } return rc; } /* ${context}_validate_index */ @ end@ # persistent/row creation @end@ ## /** @} */ ##//#################################################################### @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 14170 $ */ @end@ @eval $m2c_processing_type = "$mfd_data_access_processing_type"@ mib2c-data/syntax-InetAddress-set.m2i 0000666 00000001634 15077166074 0013427 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-InetAddress-set.m2i 9070 2003-11-04 15:32:23Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 9070 $ */ @end@ ######################################################################## ## /* * Note: if there is a corresponding InetAddressType object, we don't * know if they'll be set together, or which order they will be set. * So we just accept the value here, and check that both values are * consistent in ${context}_check_dependencies(). */ @include generic-ctx-set.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 9070 $ */ @end@ mib2c-data/syntax-StorageType-dependencies.m2i 0000666 00000001411 15077166074 0015314 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-StorageType-dependencies.m2i 11057 2004-09-10 21:39:36Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11057 $ */ @end@ ######################################################################## ## { /* * check for valid StorageType transition (old, new) */ rc = check_storage_transition( ${m2c_undo_item}$node, ${m2c_data_item}$node ); ## } ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11057 $ */ @end@ mib2c-data/generic-table-indexes.m2i 0000666 00000004370 15077166074 0013243 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-indexes.m2i 11360 2004-10-15 00:49:24Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11360 $ */ @end@ ######################################################################## ## /* * TODO:120:r: |-> Review $context mib index. * This structure is used to represent the index for $context. */ @eval $m2c_gi_others = (count_indexes($context) - 1)@ @eval $m2c_gi_len = 0@ @eval $m2c_gi_warn = 0@ typedef struct ${context}_mib_index_s { @foreach $node index@ @ include m2c_setup_node.m2i@ ##@ include details-node.m2i@ /* * $m2c_node_summary */ @ if $m2c_node_needlength == 1@ @ eval $m2c_gi_warn = 1@ @ eval $m2c_gi_maxlen = (128 - $node.oidlength - $m2c_gi_others - 1)@ @ if $m2c_node_maxlen > $m2c_gi_maxlen@ @ eval $m2c_node_maxlen = $m2c_gi_maxlen@ /** 128 - $m2c_gi_others(other indexes) - oid length($node.oidlength) = $m2c_node_maxlen */ @ end@ @ eval $m2c_gi_len = $m2c_gi_len + $m2c_node_maxlen + 1@ @ elsif "$node.type" eq "ASN_IPADDRESS"@ @ eval $m2c_gi_len = $m2c_gi_len + 4@ @ else@ @ eval $m2c_gi_len = $m2c_gi_len + 1@ @ end@ # needlength @ include node-storage.m2i@ @end@ # foreach } ${context}_mib_index; /* * TODO:121:r: | |-> Review $context max index length. * If you KNOW that your indexes will never exceed a certain * length, update this macro to that length. @ if $m2c_gi_warn == 1@ * * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! * Guessing 128 - col/entry(2) - oid len($context.oidlength) @ if $m2c_gi_len > 126@ @ eval $m2c_gi_len = 126 - $context.oidlength@ @ end@ ##@ else@ ##@ eval $m2c_gi_len = count_indexes($context)@ @ end@ */ #define MAX_${context}_IDX_LEN $m2c_gi_len ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11360 $ */ @end@ mib2c-data/generic-ctx-get.m2i 0000666 00000007032 15077166074 0012070 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-ctx-get.m2i 12865 2005-09-27 17:05:53Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12865 $ */ @end@ ######################################################################## ##/* ## This include will generate the code needed to assign data from ## a generated data context to a parameter reference. ## ## EXAMPLE (prototype generated elsewhere) ## int ## ifName_get(ifXTable_ctx * ctx, char **ifName_ptr_ptr, ## size_t * ifName_len_ptr) { ## ## ## m2c_node_lh : temp_ifName / (*ifName_ptr_ptr) ## m2c_node_lhs: temp_ifName_len / (*ifName_len_ptr); ## m2c_ctx_rh : ctx->data. ## node : ifName ## ## if (temp_ifName_len < ctx->data.ifName_len) { ## temp_ifName = malloc(ctx->data.ifName_len); ## } ## temp_ifName_len = ctx->data.ifName_len; ## memcpy(temp_ifName, ctx->data.ifName, temp_ifName_len); ##*/ @if "$m2c_data_context" ne "generated"@ /** WARNING: this code might not work for $m2c_data_context */ @end@ ##/* set up for length/copy conversions for various cases. ## length mod applies to left hand side. copy mod applies to right hand side ## ##*/ @if ("$m2c_ctx_rhu" ne "elements") && ("$m2c_ctx_rhu" ne "bytes")@ @ print Invalid rh units '$m2c_ctx_rhu'@ @ exit@ @end@ @if ("$m2c_ctx_lhu" ne "elements") && ("$m2c_ctx_lhu" ne "bytes")@ @ print Invalid lh units '$m2c_ctx_lhu'@ @ exit@ @end@ @if "$m2c_ctx_rhu" ne "$m2c_ctx_lhu"@ ##/* elements = bytes, length mod="/sizeof", copy mult="" */ @ if "$m2c_ctx_lhu" eq "elements"@ @ eval $m2c_ctx_lm = "/ sizeof($m2c_ctx_rh[0])"@ @ eval $m2c_ctx_cm = ""@ @ else@ ##/* bytes = elements, length mod="*sizeof", copy mult="sizeof" */ @ eval $m2c_ctx_lm = "* sizeof($m2c_ctx_rh[0])"@ @ eval $m2c_ctx_cm = "* sizeof($m2c_ctx_rh[0])"@ @ end@ @else@ ##/* elements = elements, length mod="", copy mult="sizeof" */ @ if "$m2c_ctx_lhu" eq "elements"@ @ eval $m2c_ctx_lm = ""@ @ eval $m2c_ctx_cm = "* sizeof($m2c_ctx_rh[0])"@ @ else@ ##/* bytes = bytes, length mod="", copy mult="" */ @ eval $m2c_ctx_lm = ""@ @ eval $m2c_ctx_cm = ""@ @ end@ @end@ @if $m2c_node_needlength == 1@ /* * make sure there is enough space for $node data */ if ((NULL == $m2c_ctx_lh) || ($m2c_ctx_lhs < ($m2c_ctx_rhs$m2c_ctx_lm))) { @ if $m2c_node_realloc == 0@ snmp_log(LOG_ERR,"not enough space for value\n"); return MFD_ERROR; @ else@ /* * allocate space for $node data */ @ if $m2c_node_realloc == 1@ $m2c_ctx_lh = realloc($m2c_ctx_lh, $m2c_ctx_rhs$m2c_ctx_cm ); @ else@ $m2c_ctx_lh = malloc($m2c_ctx_rhs$m2c_ctx_cm); @ end@ if(NULL == $m2c_ctx_lh) { snmp_log(LOG_ERR,"could not allocate memory\n"); return MFD_ERROR; } @ end@ } $m2c_ctx_lhs = $m2c_ctx_rhs$m2c_ctx_lm; memcpy( $m2c_ctx_lh, $m2c_ctx_rh, $m2c_ctx_rhs$m2c_ctx_cm ); @else@ @ if $node.decl =~ /U64/i@ # ASN_COUNTER64 ${m2c_ctx_lh}.high = ${m2c_ctx_rh}.high; ${m2c_ctx_lh}.low = ${m2c_ctx_rh}.low; @ else@ $m2c_ctx_lh = $m2c_ctx_rh; @ end@ @end@ # length ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12865 $ */ @end@ mib2c-data/mfd-top.m2c 0000666 00000042250 15077166074 0010444 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## $Id: mfd-top.m2c 14170 2006-01-26 17:02:48Z dts12 $ ######################################################################## ######################################################################## ## ## mfd function params ## @ifconf ${name}.m2d@ @ include ${name}.m2d@ @end@ ## ## set up defaults ## @foreach $table table@ @ include default-mfd-top.m2c@ # get defaults @ eval $context = $table@ ## ## set up defaults ## @ print Defaults for $table...@ @ eval $m2c_context_reg = "$mfd_default_context_reg"@ @ eval $m2c_data_allocate = $mfd_default_data_allocate@ @ eval $m2c_data_cache = $mfd_default_data_cache@ @ eval $m2c_data_context = "$mfd_default_data_context"@ @ eval $m2c_data_init = $mfd_default_data_init@ @ eval $m2c_data_transient = $mfd_default_data_transient@ @ eval $m2c_include_examples = $mfd_default_include_examples@ @ eval $m2c_irreversible_commit = 0@ @ eval $m2c_table_access = "$mfd_default_table_access"@ @ eval $m2c_table_dependencies = table_is_writable($context)@ @ eval $m2c_table_persistent = 0@ @ eval $m2c_table_row_creation = table_has_create($context)@ @ eval $m2c_table_settable = table_is_writable($context)@ @ eval $m2c_table_skip_mapping = -1@ # -1 = no default; based on type @ eval $m2c_table_sparse = 0@ @ eval $mfd_generate_makefile = $mfd_default_generate_makefile@ @ eval $mfd_generate_subagent = $mfd_default_generate_subagent@ ## ## allow for user override, or save defaults ## @ ifconf default-table-${context}.m2d@ @ print Warning: using defaults in current directory. Consider moving@ @ print them to $m2c_defaults_dir.@ @ eval $m2c_defaults_dir = "default-"@ @ end@ @ ifconf ${m2c_defaults_dir}table-${context}.m2d@ @ if $mfd_interactive_setup == 1@ @ print There are existing defaults for $context (${m2c_defaults_dir}table-${context}.m2d).@ @ prompt $ans r)econfigure or u)se existing [default=u] : @ @ if "x$ans" eq "xr"@ @ eval $mfd_interactive_setup = -1@ # already asked to overwrite @ run -again mfd-interactive-setup.m2c@ @ eval $mfd_interactive_setup = 1@ @ else@ ## ## read in old, write them back (this should add any new vars @ include ${m2c_defaults_dir}table-${context}.m2d@ @ include m2c_table_save_defaults.m2i@ @ end@ @ end@ @ else@ # no existing defaults @ ifdir defaults@ ## NOP @ else@ @ perleval my $rc = mkdir(defaults,0775); return $rc != 1 @ @ end@ @ run mfd-interactive-setup.m2c@ @ end@ # no conf file @end@ # foreach table @if $m2c_gen_table_defaults == 1@ @ exit@ @end@ @print Starting MFD code generation...@ ######################################################################## @eval $m2c_processing_type = 'h'@ @open ${name}.h@ @eval $hack = "Id"@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 14170 $ of $RCSfile$ * * $$hack:$ */ @include generic-header-top.m2i@ /** @addtogroup misc misc: Miscellaneous routines * * @{ */ @if $m2c_mark_boundary == 1@ /** START header generated by $RCSfile$ $Revision: 14170 $ */ @end@ #include <net-snmp/library/asn1.h> /* other required module components */ /* *INDENT-OFF* */ config_add_mib($name.module) config_require($name.module/${name}/${name}_interface) config_require($name.module/${name}/${name}_data_access) @if $m2c_create_fewer_files != 1@ config_require($name.module/${name}/${name}_data_get) config_require($name.module/${name}/${name}_data_set) /* *INDENT-ON* */ /* OID and column number definitions for $context */ #include "${name}_oids.h" /* enum definions */ #include "${name}_enums.h" @else@ /* *INDENT-ON* */ /* OID, column number and enum definions for $context */ #include "${name}_constants.h" @end@ // m2c_create_fewer_files /* ********************************************************************* * function declarations */ void init_$name(void); void shutdown_$context(void); /* ********************************************************************* * Table declarations */ @foreach $table table@ @ include m2c_setup_table.m2i@ @ include details-table.m2i@ /* ********************************************************************* * When you register your mib, you get to provide a generic * pointer that will be passed back to you for most of the * functions calls. * * TODO:100:r: Review all context structures */ /* * TODO:101:o: |-> Review $context registration context. */ @ if "x$m2c_context_reg" eq "x"@ @ eval $m2c_context_reg = "netsnmp_data_list"@ @ end@ typedef $m2c_context_reg ${context}_registration; @ include generic-data-context.m2i@ @ if $m2c_table_settable@ /* ********************************************************************* * TODO:115:o: |-> Review $context undo context. * We're just going to use the same data structure for our * undo_context. If you want to do something more efficent, * define your typedef here. */ typedef ${context}_data ${context}_undo_data; @ end@ @ include generic-table-indexes.m2i@ /* ********************************************************************* * TODO:130:o: |-> Review $context Row request (rowreq) context. * When your functions are called, you will be passed a * ${context}_rowreq_ctx pointer. */ typedef struct ${context}_rowreq_ctx_s { /** this must be first for container compare to work */ netsnmp_index oid_idx; ## /* xxx-rks: shrink index oid_tmp? */ oid oid_tmp[MAX_${context}_IDX_LEN]; ${context}_mib_index tbl_idx; @ if $m2c_data_allocate == 1@ @ eval $mfd_tmp = "*"@ @ else@ @ eval $mfd_tmp = " "@ @ end@ ${context}_data $mfd_tmp data; @ if $m2c_table_sparse == 1@ unsigned int column_exists_flags; /* flags for existence */ @ end@ @ if $m2c_table_settable@ @ if $m2c_undo_embed == 1@ @ eval $mfd_tmp = " "@ @ else@ @ eval $mfd_tmp = "*"@ @ end@ # embed ${context}_undo_data $mfd_tmp undo; unsigned int column_set_flags; /* flags for set columns */ @ end@ # settable /* * flags per row. Currently, the first (lower) 8 bits are reserved * for the user. See mfd.h for other flags. */ u_int rowreq_flags; @ if $m2c_table_refcounts == 1@ u_int ref_count; @ end@ /* * TODO:131:o: | |-> Add useful data to $context rowreq context. */ /* * storage for future expansion */ netsnmp_data_list *${context}_data_list; } ${context}_rowreq_ctx; typedef struct ${context}_ref_rowreq_ctx_s { ${context}_rowreq_ctx *rowreq_ctx; } ${context}_ref_rowreq_ctx; /* ********************************************************************* * function prototypes */ ## { int ${context}_pre_request(${context}_registration * user_context); int ${context}_post_request(${context}_registration * user_context, int rc); @ if $m2c_data_init == 1@ int ${context}_rowreq_ctx_init(${context}_rowreq_ctx *rowreq_ctx, void *user_init_ctx); void ${context}_rowreq_ctx_cleanup(${context}_rowreq_ctx *rowreq_ctx); @ end@ @ if "$m2c_data_context" ne "generated"@ @ if ($m2c_data_allocate == 1) || ($m2c_undo_embed == 1)@ ${context}_data * ${context}_allocate_data(void); void ${context}_release_data(${context}_data *data); @ end@ @ end@ @ if $m2c_table_settable@ @ if $m2c_table_dependencies == 1@ int ${context}_check_dependencies(${context}_rowreq_ctx * rowreq_ctx); @ end@ int ${context}_commit(${context}_rowreq_ctx * rowreq_ctx); @ if $m2c_irreversible_commit == 1@ int ${context}_irreversible_commit(${context}_rowreq_ctx * rowreq_ctx); @ end@ @ end@ # writable ${context}_rowreq_ctx * ${context}_row_find_by_mib_index(${context}_mib_index *mib_idx); @ if $m2c_table_refcounts == 1@ int ${context}_row_ref_increment(${context}_rowreq_ctx *rowreq_ctx); int ${context}_row_ref_decrement(${context}_rowreq_ctx *rowreq_ctx); @ end@ extern oid ${context}_oid[]; extern int ${context}_oid_size; @end@ # for each #include "${name}_interface.h" #include "${name}_data_access.h" @if $m2c_create_fewer_files != 1@ #include "${name}_data_get.h" #include "${name}_data_set.h" @else@ @ eval $mfd_processing_types = "h"@ @ include mfd-data-get.m2c@ @ include mfd-data-set.m2c@ @end@ // m2c_create_fewer_files /* * DUMMY markers, ignore * * TODO:099:x: ************************************************************* * TODO:199:x: ************************************************************* * TODO:299:x: ************************************************************* * TODO:399:x: ************************************************************* * TODO:499:x: ************************************************************* */ @if $m2c_mark_boundary == 1@ /** END header generated by $RCSfile$ $Revision: 14170 $ */ @end@ @include generic-header-bottom.m2i@ /** @} */ ###################################################################### ## Do the .c file ###################################################################### @eval $m2c_processing_type = 'c'@ @open ${name}.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 14170 $ of $RCSfile$ * * $$hack:$ */ /** \page MFD helper for ${name} * * \section intro Introduction * Introductory text. * */ @include generic-source-includes.m2i@ #include <net-snmp/agent/mib_modules.h> @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 14170 $ */ @end@ #include "${name}_interface.h" @foreach $table table@ @ include m2c_setup_table.m2i@ oid ${context}_oid[] = { $context.uc_OID }; int ${context}_oid_size = OID_LENGTH(${context}_oid); @ if "x$m2c_context_reg" ne "x"@ ${context}_registration ${context}_user_context; @ end@ void initialize_table_$context(void); void shutdown_table_$context(void); @end@ /** * Initializes the $name module */ void init_$name(void) { DEBUGMSGTL(("verbose:$name:init_$name","called\n")); /* * TODO:300:o: Perform $name one-time module initialization. */ /* * here we initialize all the tables we're planning on supporting */ @foreach $table table@ if (should_init("$context")) initialize_table_$context(); @end@ } /* init_$name */ /** * Shut-down the $name module (agent is exiting) */ void shutdown_$name(void) { @foreach $table table@ if (should_init("$context")) shutdown_table_$context(); @end@ } ######################################################################## ## @foreach $table table@ @ include m2c_setup_table.m2i@ /** * Initialize the table $context * (Define its contents and how it's structured) */ void initialize_table_$context(void) { ${context}_registration * user_context; u_long flags; DEBUGMSGTL(("verbose:$context:initialize_table_$context","called\n")); /* * TODO:301:o: Perform $context one-time table initialization. */ /* * TODO:302:o: |->Initialize $context user context * if you'd like to pass in a pointer to some data for this * table, allocate or set it up here. */ @ if "$m2c_context_reg" eq "netsnmp_data_list"@ /* * a netsnmp_data_list is a simple way to store void pointers. A simple * string token is used to add, find or remove pointers. */ user_context = netsnmp_create_data_list("$context", NULL, NULL); @ else@ user_context = &${context}_user_context; @ end@ /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; /* * call interface initialization code */ _${context}_initialize_interface(user_context, flags); } /* initialize_table_$context */ /** * Shutdown the table $context */ void shutdown_table_$context(void) { /* * call interface shutdown code */ _${context}_shutdown_interface(&${context}_user_context); } ######################################################################## @ if $m2c_data_init == 1@ /** * extra context initialization (eg default values) * * @param rowreq_ctx : row request context * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) * * @retval MFD_SUCCESS : no errors * @retval MFD_ERROR : error (context allocate will fail) */ int ${context}_rowreq_ctx_init(${context}_rowreq_ctx *rowreq_ctx, void *user_init_ctx) { DEBUGMSGTL(("verbose:$context:${context}_rowreq_ctx_init","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:210:o: |-> Perform extra $context rowreq initialization. (eg DEFVALS) */ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.hasdefval == 0@ @ next@ @ end@ ##------------------------------------------------------ @ if $node.needlength == 1@ /* * strings and oids are hard to handle automagically. * so all we've got for you is a hint: * * memcpy($m2c_data_item$node, $node.defval, * len($node.defval) * sizeof($m2c_data_itme$node[0]); */ @ elsif $node.enums == 1@ @ if "$node.perltype" ne "BITS"@ @ eval $m2c_tmp_mt = $node.defval@ @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ @ if $e eq $node.defval@ @ eval $m2c_tmp_mt = $m2c_ename@ @ end@ @ end@ # for each @ end@ # ! bits $m2c_data_item$node = $m2c_tmp_mt; @ elsif ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ $m2c_data_item$node = $node.defval; @ else@ /** $m2c_data_item$node = $node.defval; */ @ end@ @ end@ foreach nonindex return MFD_SUCCESS; } /* ${context}_rowreq_ctx_init */ /** * extra context cleanup * */ void ${context}_rowreq_ctx_cleanup(${context}_rowreq_ctx *rowreq_ctx) { DEBUGMSGTL(("verbose:$context:${context}_rowreq_ctx_cleanup","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:211:o: |-> Perform extra $context rowreq cleanup. */ } /* ${context}_rowreq_ctx_cleanup */ @ end@ // data_init ######################################################################## @if $m2c_table_persistent == 1@ @ include mfd-persistence.m2i@ @end@ ######################################################################## /** * pre-request callback * * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error */ int ${context}_pre_request(${context}_registration * user_context) { DEBUGMSGTL(("verbose:${context}:${context}_pre_request","called\n")); /* * TODO:510:o: Perform $context pre-request actions. */ return MFD_SUCCESS; } /* ${context}_pre_request */ /** * post-request callback * * Note: * New rows have been inserted into the container, and * deleted rows have been removed from the container and * released. * * @param user_context * @param rc : MFD_SUCCESS if all requests succeeded * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error (ignored) */ int ${context}_post_request(${context}_registration * user_context, int rc) { DEBUGMSGTL(("verbose:${context}:${context}_post_request","called\n")); /* * TODO:511:o: Perform $context post-request actions. */ @ if $m2c_table_settable@ /* * check to set if any rows were changed. */ if (${context}_dirty_get()) { /* * check if request was successful. If so, this would be * a good place to save data to its persistent store. */ if (MFD_SUCCESS == rc) { /* * save changed rows, if you haven't already */ @ if $m2c_table_persistent@ snmp_store(netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE)); @ end@ } ${context}_dirty_set(0); /* clear table dirty flag */ } @ end@ return MFD_SUCCESS; } /* ${context}_post_request */ @end@ // table ######################################################################## @if $m2c_create_fewer_files == 1@ @ eval $mfd_processing_types = "c"@ @ include mfd-data-get.m2c@ @ include mfd-data-set.m2c@ @else@ @ eval $mfd_processing_types = "chi"@ @ run mfd-data-get.m2c@ @ run mfd-data-set.m2c@ @end@ ######################################################################## /** @{ */ @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 14170 $ */ @end@ ## ######################################################################## ## ## Do support files ## ######################################################################## @run generic-table-constants.m2c@ @run mfd-interface.m2c@ @run mfd-data-access.m2c@ ## @run mfd-readme.m2c@ ## @if $mfd_generate_doxygen == 1@ @ run mfd-doxygen.m2c@ @end@ ## @if $mfd_generate_makefile == 1@ @ run mfd-makefile.m2m@ @end@ ## @if $mfd_generate_subagent == 1@ @ run subagent.m2c@ @end@ ## mib2c-data/mfd-access-container-cached-defines.m2i 0000666 00000042465 15077166074 0015721 0 ustar 00 ####################################################################### ###generic include for XXX. Do not use directly. ### ### $Id: mfd-access-container-cached-defines.m2i 14170 2006-01-26 17:02:48Z dts12 $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 14170 $ */ @end@ ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'h'@ @ if $m2c_data_cache != 1@ void ${context}_container_init(netsnmp_container **container_ptr_ptr); @ else@ /* * TODO:180:o: Review ${context} cache timeout. * The number of seconds before the cache times out */ #define $context.uc_CACHE_TIMEOUT 60 void ${context}_container_init(netsnmp_container **container_ptr_ptr, netsnmp_cache *cache); @ end@ # data cache void ${context}_container_shutdown(netsnmp_container *container_ptr); int ${context}_container_load(netsnmp_container *container); void ${context}_container_free(netsnmp_container *container); @ if $m2c_data_cache == 1@ int ${context}_cache_load(netsnmp_container *container); void ${context}_cache_free(netsnmp_container *container); @ end@ @ if $m2c_include_examples == 1@ $example_start /* ********************************************************************* * Since we have no idea how you really access your data, we'll go with * a worst case example: a flat text file. */ #define MAX_LINE_SIZE 256 $example_end @ end@ // example @end@ // m2c_processing_type eq 'h' ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'c'@ /** * container overview * */ /** * container initialization * * @param container_ptr_ptr A pointer to a container pointer. If you * create a custom container, use this parameter to return it * to the MFD helper. If set to NULL, the MFD helper will * allocate a container for you. @ if $m2c_data_cache == 1@ * @param cache A pointer to a cache structure. You can set the timeout * and other cache flags using this pointer. @ end@ * * This function is called at startup to allow you to customize certain * aspects of the access method. For the most part, it is for advanced * users. The default code should suffice for most cases. If no custom * container is allocated, the MFD code will create one for your. * @ if $m2c_data_cache == 1@ * This is also the place to set up cache behavior. The default, to * simply set the cache timeout, will work well with the default * container. If you are using a custom container, you may want to * look at the cache helper documentation to see if there are any * flags you want to set. * @ end@ * @remark * This would also be a good place to do any initialization needed * for you data source. For example, opening a connection to another * process that will supply the data, opening a database, etc. */ void @ if $m2c_data_cache != 1@ ${context}_container_init(netsnmp_container **container_ptr_ptr) @ else@ ${context}_container_init(netsnmp_container **container_ptr_ptr, netsnmp_cache *cache) @ end@ { DEBUGMSGTL(("verbose:${context}:${context}_container_init","called\n")); if (NULL == container_ptr_ptr) { snmp_log(LOG_ERR,"bad container param to ${context}_container_init\n"); return; } /* * For advanced users, you can use a custom container. If you * do not create one, one will be created for you. */ *container_ptr_ptr = NULL; @if $m2c_data_cache == 1@ if (NULL == cache) { snmp_log(LOG_ERR,"bad cache param to ${context}_container_init\n"); return; } /* * TODO:345:A: Set up $context cache properties. * * Also for advanced users, you can set parameters for the * cache. Do not change the magic pointer, as it is used * by the MFD helper. To completely disable caching, set * cache->enabled to 0. */ cache->timeout = $context.uc_CACHE_TIMEOUT; /* seconds */ @end@ } /* ${context}_container_init */ /** * container shutdown * * @param container_ptr A pointer to the container. * * This function is called at shutdown to allow you to customize certain * aspects of the access method. For the most part, it is for advanced * users. The default code should suffice for most cases. * * This function is called before ${context}_container_free(). * * @remark * This would also be a good place to do any cleanup needed * for you data source. For example, closing a connection to another * process that supplied the data, closing a database, etc. */ void ${context}_container_shutdown(netsnmp_container *container_ptr) { DEBUGMSGTL(("verbose:${context}:${context}_container_shutdown","called\n")); if (NULL == container_ptr) { snmp_log(LOG_ERR,"bad params to ${context}_container_shutdown\n"); return; } } /* ${context}_container_shutdown */ /** * load initial data * * TODO:350:M: Implement $context data load @ if $m2c_data_cache == 1@ * This function will also be called by the cache helper to load * the container again (after the container free function has been * called to free the previous contents). @ end@ * * @param container container to which items should be inserted * * @retval MFD_SUCCESS : success. * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source * @retval MFD_ERROR : other error. * * This function is called to load the index(es) (and data, optionally) * for the every row in the data set. * * @remark * While loading the data, the only important thing is the indexes. * If access to your data is cheap/fast (e.g. you have a pointer to a * structure in memory), it would make sense to update the data here. * If, however, the accessing the data invovles more work (e.g. parsing * some other existing data, or peforming calculations to derive the data), * then you can limit yourself to setting the indexes and saving any * information you will need later. Then use the saved information in * ${context}_row_prep() for populating data. * * @note * If you need consistency between rows (like you want statistics * for each row to be from the same time frame), you should set all * data here. * */ int ${context}_container_load(netsnmp_container *container) { ${context}_rowreq_ctx *rowreq_ctx; size_t count = 0; /* * temporary storage for index values */ @ foreach $node index@ @ include m2c_setup_node.m2i@ /* * $m2c_node_summary */ @ if $m2c_node_needlength == 1@ @ eval $m2c_gi_maxlen = (126 - $node.oidlength - $m2c_gi_others)@ @ if $m2c_node_maxlen > $m2c_gi_maxlen@ @ eval $m2c_node_maxlen = $m2c_gi_maxlen@ /** 128 - 1(entry) - 1(col) - $m2c_gi_others(other indexes) = $m2c_node_maxlen */ @ end@ @ end@ # needlength @ include node-storage.m2i@ @ end@ // foreach @if $m2c_include_examples == 1@ /* * this example code is based on a data source that is a * text file to be read and parsed. */ FILE *filep; char line[MAX_LINE_SIZE]; @end@ // examples DEBUGMSGTL(("verbose:${context}:${context}_container_load","called\n")); @if $m2c_include_examples == 1@ $example_start /* * open our data file. */ filep = fopen("/etc/dummy.conf", "r"); if(NULL == filep) { return MFD_RESOURCE_UNAVAILABLE; } $example_end @end@ // example /* * TODO:351:M: |-> Load/update data in the $context container. * loop over your $context data, allocate a rowreq context, * set the index(es) [and data, optionally] and insert into * the container. */ while( 1 ) { @ if $m2c_include_examples == 0@ /* * check for end of data; bail out if there is no more data */ if( 1 ) break; @ else@ $example_start /* * get a line (skip blank lines) */ do { if (!fgets(line, sizeof(line), filep)) { /* we're done */ fclose(filep); filep = NULL; } } while (filep && (line[0] == '\n')); /* * check for end of data */ if(NULL == filep) break; /* * parse line into variables */ $example_end @ end@ # example /* * TODO:352:M: | |-> set indexes in new $context rowreq context. @ eval $m2c_tmp = ""@ @ if ($m2c_data_allocate == 1) || ($m2c_data_init == 1)@ @ eval $m2c_tmp = "NULL"@ @ if ($m2c_data_allocate == 1) && ($m2c_data_init == 1)@ @ eval $m2c_tmp = "$m2c_tmp, NULL"@ * data context will be set from the first param (unless NULL, * in which case a new data context will be allocated) * the second param will be passed, with the row context, to * ${context}rowreq_ctx_init. @ else@ * data context will be set from the param (unless NULL, * in which case a new data context will be allocated) @ @end@ @ end@ */ rowreq_ctx = ${context}_allocate_rowreq_ctx($m2c_tmp); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "memory allocation failed\n"); return MFD_RESOURCE_UNAVAILABLE; } if(MFD_SUCCESS != ${context}_indexes_set(rowreq_ctx @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if $m2c_node_needlength == 1@ , $node, ${node}_len @ else@ , $node @ end@ @ end@ # foreach index )) { snmp_log(LOG_ERR,"error setting index while loading " "${context} data.\n"); ${context}_release_rowreq_ctx(rowreq_ctx); continue; } /* * TODO:352:r: | |-> populate $context data context. * Populate data context here. (optionally, delay until row prep) */ @if $m2c_data_transient == 0@ # persistent /* non-TRANSIENT data: no need to copy. set pointer to data */ @else@ /* * TRANSIENT or semi-TRANSIENT data: * copy data or save any info needed to do it in row_prep. */ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ /* * setup/save data for $node * $m2c_node_summary */ @ if "$m2c_data_context" eq "generated"@ @ eval $m2c_ctx_lh = "$m2c_ctx_rh"@ @ eval $m2c_ctx_lhs = "$m2c_ctx_rhs"@ @ eval $m2c_ctx_rh = "$node"@ @ eval $m2c_ctx_rhs = "${node}_len"@ @ include generic-value-map.m2i@ @ end@ # data_context ! generated @ end@ // for each @end@ # transient /* * insert into table container */ CONTAINER_INSERT(container, rowreq_ctx); ++count; } @if $m2c_include_examples == 1@ $example_start if(NULL != filep) fclose(filep); $example_end @end@ # example DEBUGMSGT(("verbose:${context}:${context}_container_load", "inserted %d records\n", count)); return MFD_SUCCESS; } /* ${context}_container_load */ /** * container clean up * * @param container container with all current items * * This optional callback is called prior to all * item's being removed from the container. If you * need to do any processing before that, do it here. * * @note * The MFD helper will take care of releasing all the row contexts. @ if ($m2c_data_allocate == 1) && ($m2c_data_transient == 0)@ * If you did not pass a data context pointer when allocating * the rowreq context, the one that was allocated will be deleted. * If you did pass one in, it will not be deleted and that memory * is your responsibility. @ end@ * */ void ${context}_container_free(netsnmp_container *container) { DEBUGMSGTL(("verbose:${context}:${context}_container_free","called\n")); /* * TODO:380:M: Free $context container data. */ } /* ${context}_container_free */ @end@ // m2c_processing_type eq 'c' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'i'@ @ if $m2c_data_cache == 1@ static void _container_free(netsnmp_container *container); /** * @internal */ static int _cache_load(netsnmp_cache *cache, void *vmagic) { DEBUGMSGTL(("internal:${context}:_cache_load","called\n")); if((NULL == cache) || (NULL == cache->magic)) { snmp_log(LOG_ERR, "invalid cache for ${context}_cache_load\n"); return -1; } /** should only be called for an invalid or expired cache */ netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); /* * call user code */ return ${context}_container_load((netsnmp_container*)cache->magic); } /* _cache_load */ /** * @internal */ static void _cache_free(netsnmp_cache *cache, void *magic) { netsnmp_container *container; DEBUGMSGTL(("internal:${context}:_cache_free","called\n")); if((NULL == cache) || (NULL == cache->magic)) { snmp_log(LOG_ERR, "invalid cache in ${context}_cache_free\n"); return; } container = (netsnmp_container*)cache->magic; _container_free(container); } /* _cache_free */ @ end@ # cache /** * @internal */ static void _container_item_free(${context}_rowreq_ctx *rowreq_ctx, void *context) { DEBUGMSGTL(("internal:${context}:_container_item_free","called\n")); if(NULL == rowreq_ctx) return; ${context}_release_rowreq_ctx(rowreq_ctx); } /* _container_item_free */ /** * @internal */ static void _container_free(netsnmp_container *container) { DEBUGMSGTL(("internal:${context}:_container_free","called\n")); if (NULL == container) { snmp_log(LOG_ERR, "invalid container in ${context}_container_free\n"); return; } /* * call user code */ ${context}_container_free(container); /* * free all items. inefficient, but easy. */ CONTAINER_CLEAR(container, (netsnmp_container_obj_func *)_container_item_free, NULL); } /* _container_free */ /** * @internal * initialize the container with functions or wrappers */ void _${context}_container_init(${context}_interface_ctx *if_ctx) { DEBUGMSGTL(("internal:${context}:_${context}_container_init","called\n")); @ if $m2c_data_cache == 1@ /* * cache init */ @ if 0@ if_ctx->cache = netsnmp_cache_find_by_oid(PARTNER_oid, OID_LENGTH(PARTNER_oid)); @ else@ if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ _cache_load, _cache_free, ${context}_oid, ${context}_oid_size); @ end@ // shared cache if(NULL == if_ctx->cache) { snmp_log(LOG_ERR, "error creating cache for ${context}\n"); return; } if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; ${context}_container_init(&if_ctx->container, if_ctx->cache); @ else@ /* * container init */ ${context}_container_init(&if_ctx->container); @ end@ data cache if(NULL == if_ctx->container) if_ctx->container = netsnmp_container_find("${context}:table_container"); if(NULL == if_ctx->container) { snmp_log(LOG_ERR,"error creating container in " "${context}_container_init\n"); return; } @ if $m2c_data_cache == 1@ if (NULL != if_ctx->cache) if_ctx->cache->magic = (void*)if_ctx->container; @ end@ } /* _${context}_container_init */ /** * @internal * shutdown the container with functions or wrappers */ void _${context}_container_shutdown(${context}_interface_ctx *if_ctx) { DEBUGMSGTL(("internal:${context}:_${context}_container_shutdown","called\n")); ${context}_container_shutdown(if_ctx->container); _container_free(if_ctx->container); } /* _${context}_container_shutdown */ @end@ // m2c_processing_type eq 'i' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'r'@ ## container summary ------------------------ The container data access code is for cases when you want to store your data in the agent/sub-agent. ... to be continued... @ if $m2c_data_cache == 1@ cache summary ------------------------ The container-cached data access code is for cases when you want to cache your data in the agent/sub-agent. ... to be continued... @ end@ @end@ // m2c_processing_type eq 'r' ######################################################################## ##//#################################################################### @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 14170 $ */ @end@ mib2c-data/mfd-readme.m2c 0000666 00000073471 15077166074 0011110 0 ustar 00 ######################################################################## ## generic include for XXX. Don't use directly. ## ## $Id: mfd-readme.m2c 12091 2005-04-18 22:05:47Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12091 $ */ @end@ ######################################################################## ## @open ${name}-README-FIRST.txt@ ************************************************************************ ${name} README ------------------------------------------------------------------------ This document describes the results of the mib2c code generation system using the mfd code generation template. The resulting files are documented both in this README file as well as per-table specific README files. All of the files generated by this run of mib2c will begin with the ${name} prefix. Quick Start ----------- For those interested in a quick start, to get a pseudo-todo list, try this command in directory with the generated code: grep -n "TODO:" *.[ch] | sed 's/\([^ ]*\) \(.*\)TODO\(.*\)/\3 (\1)/' | sort -n Key: :o: Optional :r: Recommended :M: Mandatory :A: Advanced users This will give you and ordered list of places in the code that you may (or must) take a closer look at). You may also want to take a look at the on-line tutorial, found here: http://www.net-snmp.org/tutorial/tutorial-5/toolkit/mfd/index.html MIBs For Dummies Overview ------------------------- The MIBs For Dummies (MFD) configuration files have been written to help SNMP novices implement SNMP MIBs. This section will be a brief introduction to some of the general concepts you should be familar with. Managed Information Base (MIB) ------------------------------ A SNMP MIB (Managed information base) is a text file that describes the syntax for some set of data objects. The MIB creates a correlation between an ASCII name for an object and a number OID (Object Identifier). The SNMP protocol communicates information using the OIDs, and the MIB allows tools to display a name, which we humans find easier to deal with. To use an analogy, a MIB is much like a menu at a restaurant. If you've ever been to a reataurant and ordered a meal, and later received a bill that simply had '#6' on it, you get the idea. The name is easier for the customers to remember, and the waiters and chefs use the number for efficency. Scalars ------- A scalar variable is a unique object in a MIB which can represent a single value. For example, the SNMP standard MIB-II defines a variable, sysContact.0, which is a string containing the contact information for the person in charge of a particular agent. Note that scalar variable always end with '.0'. Rows and Tables --------------- When a group of related attributes occur more than once, they can be grouped together in a table. A table has an index, which uniquely identifies a particular row, and data columns, which contain the attributes for that row. For example, the SNMP standard MIB-II defines a table, ifTable, which contains information on the ethernet interfaces on a system. Data Structures --------------- The code generated by the MFD configuration files has a few important structures. The Data Context ---------------- The data context structure should contain the necessary information to provide the data for the columns in a given row. As long as you can extract the data for a column for the data context, the data context can be anything you want: a pointer to an existing structure, the parameters needed for a function call or an actual copy of the data. By default, a data context structure is generated with storage for all the data in a row. Information on changing the default is presented later on in this help. The MIB Context --------------- The MIB context structure is generated with storage for all the indexes of a table. This data will be used when searching for the correct row to process for a request. The Row Request Context ----------------------- Each table will have a unique data structure for holding data during the processing of a particular row. The row request context contains the registration context (that you supply during initilization), the data context, the MIB context, the undo context (for settable tables) and other data. There is also a netsnmp_data_list, which can be used to temporary storage during processing. The Table Registration Pointer ------------------------------ During initilization, you may provide a pointer to arbitrary data for you own use. This pointer will be saved in the row request context, and is passed as a parameter to several functions. It is not required, and is provided as a way for you to access table specific data in the generated code. These files are top-level files potentially useful for all the tables: ------------------------------------------------------------------------ File : ${name}_Makefile ---------------------------------------------------------------------- Purpose : Make file for compiling a (sub)agent. This file is only useful if you don't want to compile your code directly into the Net-SNMP master agent. Editable: Optional Usage : make -f ${name}_Makefile File : ${name}_subagent.c ---------------------------------------------------------------------- Purpose : This file contains a main() function for an agent or sub-agent and is compiled using the Makefile above. Table specific README files ------------------------------------------------------------------------ Each table for which code was generated has its own README file describing the files specifically associated with each table. You should probably read these next: @foreach $table table@ @ include m2c_setup_table.m2i@ ${name}-README-${table}.txt @end@ These are miscellaneous auto-generated code files you generally shouldn't edit. They contain code that ties your code together with the Net-SNMP agent. ------------------------------------------------------------------------ @if $m2c_create_fewer_files == 1@ File : ${name}.c Purpose : Initilization for the entire module set, including the SNMP tables. @end@ File : ${name}.h Purpose : Header file for the module set. Includes config_require macros to auto-load the other code pieces when compiled into the agent. @if $m2c_create_fewer_files != 1@ File : ${name}_oids.h Purpose : C #define definitions of the tables, columns, and OIDs File : ${name}_enums.h Purpose : C #define definitions of the enumerated type values for each column of each table that requires them. @else@ File : ${name}_constants.h Purpose : C #define definitions of the tables, columns, OIDs, enumerated type values for each column of each table that requires them. @end@ File : ${name}_interface.c Purpose : MFD interface to Net-SNMP. This auto-generated code ties the functions you will fill out to the code that the agent needs. ######################################################################## @foreach $table table@ @ include m2c_setup_table.m2i@ @ open ${name}-README-${table}.txt@ ************************************************************************ ${context} README ------------------------------------------------------------------------ This readme file describes the code generated by mib2c (using the MIBs for Dummies (MFD) configuration file). The code generated was generated specifically for the following SNMP table: ${context} Your code will be called when the snmp agent receives requests for the ${context} table. The agent will start by looking for the right row in your existing data to operate on, if one exists. Configuration Variables ------------------------------------------------------------ Some variables used for code generation may be set to affect the code generation. You may override these variables by setting them in the file ${m2c_defaults_dir}table-${context}.m2d, and then re-running mib2c. m2c_table_settable (currently '$m2c_table_settable') -------------------------------------------------------- This variable determines whether or not code is generated to support MIB object which have an access of read-write or read-create. The default is set based on whether or not the table contains writable objects, but can be over-ridden. Syntax: @eval $@m2c_table_settable = 0@ m2c_table_dependencies (currently '$m2c_table_dependencies') -------------------------------------------------------- This variable determines whether or not code is generated to support checking dependencies between columns, rows or tables. The default is set based on whether or not the table contains writable objects, but can be over-ridden. Syntax: @eval $@m2c_table_dependencies = 0@ m2c_table_row_creation (currently '$m2c_table_row_creation') -------------------------------------------------------- This variable determines whether or not code is generated to support checking creation of new rows via SNMP. The default is set based on whether or not the table contains read-create objects, but can be over-ridden. Syntax: @eval $@m2c_table_row_creation = 0@ m2c_context_reg (currently '$m2c_context_reg') -------------------------------------------------------- This variable contains the structure name to typedef for the ${context}_registration. During initilization, you will provide a pointer to a structure of this type. This pointer is used as a parameter to many functions so that you have access to your registration data. The default is a netsnmp_data_list pointer, which will allow you to keep multiple pointers tagged by a text name. If you have a new or existing structure you would rather use, you can redefine this variable. To avoid regenerating code, you may also change this typedef directly in the ${table}.h header. Syntax: @eval $@m2c_context_reg = "struct my_registration_context@ m2c_data_context (currently '$m2c_data_context') -------------------------------------------------------- This variable contains the structure name to typedef for the ${context}_data. This typedef is used in the row request context structure for the table, ${context}_rowreq_ctx. The typedef in the primary table context will be used for the data and undo structure types. This structure should contain all the data needed for all the columns in the table. The default is 'generated', which will cuase a new data strcuture to be generated with data members for each column. To avoid regenerating code, you may also change this typedef directly in the ${table}.h header. Syntax: @eval $@m2c_data_context = "struct my_data_context"@ m2c_data_allocate (currently '$m2c_data_allocate') -------------------------------------------------------- This variable determines whether or not the data context (see above) requires memory to be allocated. The default generated data structure does not. If you are using a custom data context which needs to allocate memory, override this value and two additional functions will be generated: ${context}_allocate_data ${context}_release_data Syntax: @eval $@m2c_data_allocate = 1@ m2c_data_init (currently '$m2c_data_init') -------------------------------------------------------- This variable determines whether or not the data context (see above) or any other items you have added to the table context requires initialization. The default generated data structure does not. If you are using a custom data context or have added items needing initialization to the table context, override this value and two additional functions will be generated: ${context}_rowreq_ctx_init ${context}_rowreq_ctx_cleanup Syntax: @eval $m2c_data_init = 1@ m2c_table_access (currently '$m2c_table_access') ------------------------------------------------------------------ This variable determines which data interface will be use to generate code for looking up data for a given index. The default is the 'container-cached' access code, which caches the data in a netsnmp- container (usually a sorted array). Available options can be determined by checking for mib2c configuration files that begin with 'mfd-access-*'. Syntax: @eval $@m2c_table_access = '$m2c_table_access'@ m2c_include_examples (currently '$m2c_include_examples') ------------------------------------------------------------------ This variable determines whether or not to generate example code. The default is to generate example code. Syntax: @eval $@m2c_include_examples = 0@ m2c_data_transient (currently '$m2c_data_transient') ------------------------------------------------------------------ This variable determines how the generated example code deals with the data during data lookup. See the table readme file for details on how the current table access method interprets this value. In general, a value of 0 indicates persistent data, 1 indicates semi-transient and 2 indicates transient data. Syntax: @eval $@m2c_data_transient = 0@ Index(es) for the ${context} table ------------------------------------------------------------ The index(es) for the ${context} table are: @foreach $node index@ @ include m2c_setup_node.m2i@ $node: Syntax: $node.syntax DataType: $node.perltype ASN type: $node.type C-code type: $m2c_decl @end@ # foreach You should know how to set all these values from your data context, ${context}_data. ************************************************************************ ${context} File Overview ------------------------------------------------------------------------ Several files have been generated to implement the ${context} table. We'll go through these files, one by one, explaining each and letting you know which you need to edit. File: ${name}_data_access.[c|h] ------------------------------------------------------------------------ The ${name}_data_access file contains the interface to your data in its raw format. These functions are used to build the row cache or locate the row (depending on the table access method). Set MIB context ----------------- TODO : Set MIB index values FUNC : ${context}_indexes_set WHERE: ${context}_data_access.c This is a convenience function for setting the index context from the native C data. Where necessary, value mapping should be done. @if $mfd_readme_verbose == 1@ This function should update the table index values (found in tbl_idx) for the given raw data. @end@ @ eval $m2c_processing_type = 'r'@ @ include mfd-access-${m2c_table_access}-defines.m2i@ @if $m2c_create_fewer_files != 1@ File: ${name}_enums.h @else@ File: ${name}_constants.h @end@ ------------------------------------------------------------------------ This file contains macros for mapping enumeration values when the enumerated values defined by the MIB do not match the values used internally. Review this file to see if any values need to be updated. @if $m2c_create_fewer_files != 1@ File: ${name}_data_get.c @else@ File: ${name}.c; GET support @end@ ------------------------------------------------------------------------ @ if ("$m2c_data_allocate" eq "yes") && ("$m2c_data_context" ne "generated")@ Allocate data context --------------------- TODO : allocate memory for a data context FUNC : ${context}_allocate_data This function will be called to allocate memory for a data context when a new row request context is being created, or to create an undo context while processing a set request. Release data context ------- TODO : release memory allocated for a data context FUNC : ${context}_release_data This function will be called to release any resources held by a data or undo context. It will be called when a row request context is released, or during cleanup after a set request. @ end@ @ foreach $node index@ @ include m2c_setup_node.m2i@ @ if ($m2c_skip_mapping != 1)@ Map native data to MIB format ----------------------------- TODO : convert data from its native format to the format required by the MIB FUNC : ${node}_map This function should map between the native format of the node data to the format or values required by the MIB. For example, a C boolean value for a MIB node with the TruthValue syntax needs to map the value C false(0) to TruthValue false(2). @ end@ #// skip mapping @ end@ // foreach index @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if ($m2c_skip_mapping != 1)@ Map native data to MIB format ----------------------------- TODO : convert data from its native format to the format required by the MIB FUNC : ${node}_map This function should map between the native format of the node data to the format or values required by the MIB. For example, a C boolean value for a MIB node with the TruthValue syntax needs to map the value C false(0) to TruthValue false(2). @ end@ #// skip mapping Get data for column ------------------- TODO : retrieve column data from raw data FUNC : ${node}_get @ ifconf syntax-$node.syntax-readme.m2i@ @ include syntax-$node.syntax-readme.m2i@ @ elsif ($node.enums == 1) && ("$node.perltype" eq "BITS")@ Since this column has enumerated BITS, you should update or replace the IS_SET_* macros to properly determine whether or not a particular bit should be set. @ end@ @ end@ @if $m2c_create_fewer_files != 1@ File: ${name}_data_set.c @else@ File: ${name}.c; SET support @end@ ------------------------------------------------------------------------ @if $m2c_table_settable == 0@ This table does not support set requests. @else@ This code was generated based on the following assumptions or settings: @ if $m2c_table_dependencies == 1@ 1) None of the values for this table have DEPENDENCIES on other objects. @ else@ 1) Some of the values for this table have DEPENDENCIES on other objects. @ end@ @ if $mfd_readme_verbose != 0@ DEPENDENCIES on other objects complicates SET request processing. When one or more columns in a table depend on another object (in the same table, or in another table), a DEPENDENCY exists. For example, if you have a table that determine a color with three columns (red, green and blue) that define the percentage of each primary color, the total for the three columns must equal 100 percent. So, in addition to checking that each colums has a valid value between 0 and 100, the total of all three columns must equal 100. Set $@m2c_table_dependencies = 0 in ${m2c_defaults_dir}table-${table}.m2d and regenerate code if this assumption is incorrect. @ end@ @if $m2c_table_row_creation == 1@ 2) This table supports ROW CREATION. @else@ 2) This table does not support ROW CREATION. @end@ @if $mfd_readme_verbose != 0@ Supporting ROW CREATION allows new rows to be created via SNMP requests. @end@ @if $m2c_table_row_creation == 1@ To support row creation, the index component of an incoming set request must be validated. A funciton is generated for each individual index component, and another for validating all the index components together. @ foreach $node externalindex@ @ include m2c_setup_node.m2i@ Validate external index ----------------------- TODO : validate the specified external index component FUNC : ${context}_${node}_check_index @ end@ # foreach externalindex @ foreach $node internalindex@ @ include m2c_setup_node.m2i@ Validate index component ------------------------ TODO : validate the specified index component FUNC : ${node}_check_index @ end@ Validate index -------------- TODO : check that all index components are valid FUNC : ${context}_validate_index @end@ @ if $m2c_table_dependencies == 1@ Check dependencies ------------------ TODO : check that all dependencies have been satisfied FUNC : ${context}_check_dependencies This function will be called after all the individual columns have been set to their new values. Check for any dependencies between rows or tables in this function. @ end@ Undo setup ---------- TODO : save data for undo FUNC : ${context}_undo_setup This function will be called before the individual undo_setup functions are called. This is where you should save any undo information which is not directly related to a particular column. This function will only be called once per row. After this function is called, any column which is being set will have its individual node undo_setup function called. @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 0@ @ next@ # skip to next column @ end@ Check value for column ---------------------- TODO : perform additional validations on values for a set request FUNC : ${node}_check_value The generated code will automatically validate incoming requests against all the requirements specified by the syntax of the MIB. However, it is often the case that additional requirements are specified in the description of a MIB object. Those type of validations should be checked in this function. Undo setup for column --------------------- TODO : save the value for column FUNC : ${node}_undo_setup After the table level undo setup function has been called, the individual node undo setup functions will be called for columns which are being set. Set value for column -------------------- TODO : set the value for column FUNC : ${node}_set After all the validations have been passed, this function will be called to set the new value. Undo value for column --------------------- TODO : undo set for column FUNC : ${node}_undo If an error occurs after a column has been set, this function will be called to undo the set and restore the previous state. @ end@ # nonindex Commit changes -------------- TODO : commit changes FUNC : ${context}_commit After all values have been set, the commit function will be called. @ if $m2c_irreversible_commit == 1@ Commit irreversible changes --------------------------- FUNC: ${context}_irreversible_commit This special mode is reserved for committing changes which can not be undone. (e.g. launching a rocket). It is called after all normal commits have succeeded. @ end@ @end@ # settable ************************************************************************ ${context} Reference ------------------------------------------------------------------------ Function flow ---------------------------------------------------- To give you the general idea of how the functions flow works, this example flow is from a complete table implementation. NOTE: Depending on your configuration, some of the functions used in the examples below may not have been generated for the ${context} table. Conversely, the examples below may not include some functions that were generated for the ${context} table. To watch the flow of the ${context} table, use the following debug tokens: snmp_agent helper:table:req ${context} verbose:${context} internal:${context} e.g. snmpd -f -Le -D${context},verbose:${context},internal:${context} @if $m2c_create_fewer_files == 1@ @ eval $tmp_mfd_rm_set = "xxx.c"@ @ eval $tmp_mfd_rm_get = "xxx.c"@ @else@ @ eval $tmp_mfd_rm_set = "xxx_data_set.c"@ @ eval $tmp_mfd_rm_get = "xxx_data_get.c"@ @end@ Initialization -------------------------------- init_xxxTable: called xxx.c initialize_table_xxxTable xxx.c _xxxTable_initialize_interface xxx_interface.c xxxTable_init_data xxx_data_access.c _xxxTable_container_init xxx_interface.c xxxTable_container_init xxx_data_access.c GET Request -------------------------------- _cache_load xxx_interface.c xxxTable_cache_load xxx_data_access.c xxxTable_allocate_rowreq_ctx xxx_interface.c xxxTable_allocate_data $tmp_mfd_rm_get xxxTable_rowreq_ctx_init $tmp_mfd_rm_get xxxTable_indexes_set $tmp_mfd_rm_get xxxTable_indexes_set_tbl_idx $tmp_mfd_rm_get xxxTable_pre_request _mfd_xxxTable_object_lookup xxx_interface.c xxxTable_row_prep xxx_data_access.c _mfd_xxxTable_get_values xxx_interface.c _mfd_xxxTable_get_column xxx_interface.c yyy_get $tmp_mfd_rm_get xxxTable_post_request GETNEXT Request -------------------------------- _cache_load ... xxxTable_pre_request ... _mfd_xxxTable_object_lookup ... _mfd_xxxTable_get_values ... xxxTable_post_request ... SET Request: success -------------------------------- _cache_load ... xxxTable_pre_request _mfd_xxxTable_object_lookup ... _mfd_xxxTable_check_objects xxx_interface.c _xxxTable_check_column xxx_interface.c yyy_check_value $tmp_mfd_rm_set _mfd_xxxTable_undo_setup xxx_interface.c xxxTable_allocate_data ... xxxTable_undo_setup xxx_interface.c _xxxTable_undo_setup_column xxx_interface.c yyy_undo_setup $tmp_mfd_rm_set _mfd_xxxTable_set_values xxx_interface.c _xxxTable_set_column xxx_interface.c yyy_set $tmp_mfd_rm_set _mfd_xxxTable_check_dependencies xxx_interface.c xxxTable_check_dependencies $tmp_mfd_rm_set _mfd_xxxTable_commit xxx_interface.c xxxTable_commit $tmp_mfd_rm_set _mfd_xxxTable_undo_cleanup xxx_interface.c xxxTable_undo_cleanup $tmp_mfd_rm_set xxxTable_release_data ... xxxTable_post_request ... SET Request: row creation -------------------------------- _cache_load ... xxxTable_pre_request _mfd_xxxTable_object_lookup ... xxxTable_index_from_oid xxx_interface.c xxxTable_allocate_rowreq_ctx ... ... _xxxTable_check_indexes xxx_interface.c yyy_check_index $tmp_mfd_rm_set xxxTable_validate_index $tmp_mfd_rm_set _mfd_xxxTable_check_objects ... _xxxTable_check_column ... yyy_check_value ... _xxxTable_check_column ... yyy_check_value ... _mfd_xxxTable_undo_setup ... _mfd_xxxTable_set_values ... _mfd_xxxTable_check_dependencies ... _mfd_xxxTable_commit ... _mfd_xxxTable_undo_cleanup ... xxxTable_post_request ... SET Resuest: value error -------------------------------- _cache_load ... xxxTable_pre_request ... _mfd_xxxTable_object_lookup ... _mfd_xxxTable_check_objects ... _xxxTable_check_column ... yyy_check_value ... ERROR:"yyy value not supported" xxxTable_post_request ... SET Request: commit failure -------------------------------- _cache_load ... xxxTable_pre_request ... _mfd_xxxTable_object_lookup ... _mfd_xxxTable_check_objects ... _mfd_xxxTable_undo_setup ... _mfd_xxxTable_set_values ... _mfd_xxxTable_check_dependencies ... _mfd_xxxTable_commit ... xxxTable_commit ... ERROR: bad rc -1 _mfd_xxxTable_undo_commit xxx_interface.c xxxTable_undo_commit $tmp_mfd_rm_set _mfd_xxxTable_undo_values xxx_interface.c _xxxTable_undo_column xxx_interface.c yyy_undo $tmp_mfd_rm_set _mfd_xxxTable_undo_cleanup ... xxxTable_post_request ... Row release (user initiated) -------------------------------- xxxTable_release_rowreq_ctx xxx_interface.c xxxTable_rowreq_ctx_cleanup $tmp_mfd_rm_get xxxTable_release_data $tmp_mfd_rm_get Table / column details ---------------------------------------------------- @ include details-table.m2i@ @ foreach $node column@ @ include m2c_setup_node.m2i@ @ include details-node.m2i@ @ end@ @end@ # foreach table ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12091 $ */ @end@ mib2c-data/generic-data-allocate.m2i 0000666 00000003247 15077166074 0013214 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-data-allocate.m2i 11948 2005-02-25 22:36:30Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11948 $ */ @end@ ######################################################################## ## /* * ${context}_allocate_data * * Purpose: create new ${context}_data. */ ${context}_data * ${context}_allocate_data(void) { @if $m2c_gda_todo_suppress != 1@ /* * TODO:201:r: |-> allocate memory for the $context data context. */ @end@ @if $m2c_data_context != "generated"@ /** this might not be right for $m2c_data_context */ @end@ ${context}_data *rtn = SNMP_MALLOC_TYPEDEF(${context}_data); DEBUGMSGTL(("verbose:${context}:${context}_allocate_data","called\n")); if(NULL == rtn) { snmp_log(LOG_ERR, "unable to malloc memory for new " "${context}_data.\n"); } return rtn; } /* ${context}_allocate_data */ /* * ${context}_release_data * * Purpose: release ${context} data. */ void ${context}_release_data(${context}_data *data) { DEBUGMSGTL(("verbose:${context}:${context}_release_data","called\n")); @if $m2c_gda_todo_suppress != 1@ /* * TODO:202:r: |-> release memory for the $context data context. */ @end@ free(data); } /* ${context}_release_data */ @eval $m2c_gda_todo_suppress = 0@ # reset ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11948 $ */ @end@ mib2c-data/default-mfd-top.m2c 0000666 00000010361 15077166074 0012064 0 ustar 00 ######################################################################## ## ## DEFAULTS (no blank lines allowed) ## ######################################################################## ## mark boundarys @if "x$m2c_mark_boundary" eq "x"@ @ eval $m2c_mark_boundary = 0@ @end@ ## @if "x$mfd_readme_verbose" eq "x"@ @ eval $mfd_readme_verbose = 1@ @end@ @if "x$m2c_create_fewer_files" eq "x"@ @ eval $m2c_create_fewer_files = 0@ @end@ @if "x$mfd_processing_types" eq "x"@ @ eval $mfd_processing_types = "#"@ @end@ @if "x$m2c_code_verbose" eq "x"@ @ eval $m2c_code_verbose = 0@ @end@ @if "x$m2c_defaults_dir" eq "x"@ @ eval $m2c_defaults_dir = "defaults/"@ @end@ ######################################################################## ## enum constants upper or lower case? (NODE_NAME vs node_name) @if "x$m2c_const_lc" eq "x"@ @ eval $m2c_const_lc = 0@ @end@ ## ######################################################################## ## prefix for all enums (NODE_NAME vs XYZ_NODE_NAME) @if "x$m2c_const_pfx" eq "x"@ @ eval $m2c_const_pfx = ""@ # or "XYZ_" @end@ ## ######################################################################## ## use temporary values in get routines, or direct pointers? @if "x$m2c_get_use_temp" eq "x"@ @ eval $m2c_get_use_temp = 0@ @end@ ## ######################################################################## ######################################################################## ## ## CODING STYLE ## ######################################################################## ######################################################################## ## allow for different style enums (#define vs const) @if "x$m2c_const_dcl" eq "x"@ @ eval $m2c_const_dcl = "#define"@ # or "const int" @end@ @if "m2c_const_del" eq "x"@ @ eval $m2c_const_del = ""@ # or "=" @end@ @if "x$m2c_const_sfx" eq "x"@ @ eval $m2c_const_sfx = ""@ # or ";" @end@ ## ## set defaults for mfd ## @if "x$user_mfd_default_table_access" eq "x" @ @ eval $mfd_default_table_access = "container-cached"@ @else@ @ eval $mfd_default_table_access = "$user_mfd_default_table_access"@ @end@ ## @if "x$user_mfd_default_table_skip_mapping" eq "x" @ @ eval $mfd_default_table_skip_mapping = 1@ @else@ @ eval $mfd_default_table_skip_mapping = $user_mfd_default_table_skip_mapping@ @end@ ## @if "x$user_mfd_default_data_context" eq "x" @ @ eval $mfd_default_data_context = "generated"@ @else@ @ eval $mfd_default_data_context = "$user_mfd_default_data_context"@ @end@ ## @if "x$user_mfd_default_context_reg" eq "x" @ @ eval $mfd_default_context_reg = "netsnmp_data_list"@ @else@ @ eval $mfd_default_context_reg = "$user_mfd_default_context_reg"@ @end@ ## @if "x$user_mfd_default_data_allocate" eq "x" @ @ eval $mfd_default_data_allocate = 0@ @else@ @ eval $mfd_default_data_allocate = $user_mfd_default_data_allocate@ @end@ ## @if "x$user_mfd_default_data_cache" eq "x" @ @ eval $mfd_default_data_cache = 1@ @else@ @ eval $mfd_default_data_cache = $user_mfd_default_data_cache@ @end@ ## @if "x$user_mfd_default_data_sparse" eq "x" @ @ eval $mfd_default_data_sparse = 0@ @else@ @ eval $mfd_default_data_sparse = $user_mfd_default_data_sparse@ @end@ @if "x$user_mfd_default_undo_embed" eq "x" @ @ eval $mfd_default_undo_embed = 0@ @else@ @ eval $mfd_default_undo_embed = $user_mfd_default_undo_embed@ @end@ ## @if "x$user_mfd_default_data_init" eq "x" @ @ eval $mfd_default_data_init = 1@ @else@ @ eval $mfd_default_data_init = $user_mfd_default_data_init@ @end@ ## @if "x$user_mfd_default_data_transient" eq "x" @ @ eval $mfd_default_data_transient = 2@ # TRANSIENT @else@ @ eval $mfd_default_data_transient = $user_mfd_default_data_transient@ @end@ ## @if "x$user_mfd_default_include_examples" eq "x" @ @ eval $mfd_default_include_examples = 1@ @else@ @ eval $mfd_default_include_examples = $user_mfd_default_include_examples@ @end@ @if "x$m2c_data_cache" eq "x"@ @ eval $m2c_data_cache = 0@ @end@ ## @if "x$user_mfd_default_generate_makefile" eq "x" @ @ eval $mfd_default_generate_makefile = 0@ @else@ @ eval $mfd_default_generate_makefile = $user_mfd_default_generate_makefile@ @end@ @if "x$user_mfd_default_generate_subagent" eq "x" @ @ eval $mfd_default_generate_subagent = 0@ @else@ @ eval $mfd_default_generate_subagent = $user_mfd_default_generate_subagent@ @end@ mib2c-data/parent-set.m2i 0000666 00000034505 15077166074 0011172 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: parent-set.m2i 12851 2005-09-27 15:43:39Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12851 $ */ @end@ ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'h'@ int ${context}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx); int ${context}_undo_cleanup( ${context}_rowreq_ctx *rowreq_ctx); int ${context}_undo( ${context}_rowreq_ctx *rowreq_ctx); int ${context}_commit( ${context}_rowreq_ctx *rowreq_ctx); int ${context}_undo_commit( ${context}_rowreq_ctx *rowreq_ctx); @ if $m2c_irreversible_commit == 1@ int ${context}_irreversible_commit( ${context}_rowreq_ctx *rowreq_ctx); @ end@ @end@ // m2c_processing_type eq 'h' ######################################################################## ##//#################################################################### ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @if $m2c_processing_type eq 'c'@ ## ## MASTER COPY OF THIS FLOWCHART IS IN agent/helpers/baby_steps.c ## /* * NOTE: if you update this chart, please update the versions in * local/mib2c-conf.d/parent-set.m2i * agent/mibgroup/helpers/baby_steps.c * while you're at it. */ /* *********************************************************************** * Baby Steps Flow Chart (2004.06.05) * * * * +--------------+ +================+ U = unconditional path * * |optional state| ||required state|| S = path for success * * +--------------+ +================+ E = path for error * *********************************************************************** * * +--------------+ * | pre | * | request | * +--------------+ * | U @if $m2c_table_row_creation == 1@ * +-------------+ +==============+ * | row |f|<-------|| object || * | create |1| E || lookup || * +-------------+ +==============+ * E | | S | S * | +------------------>| * | +==============+ * | E || check || * |<---------------|| values || @else@ * +==============+ * +----------------|| object || * | E || lookup || * | +==============+ * | | S * | +==============+ * | E || check || * |<---------------|| values || @end@ # row creation * | +==============+ * | | S * | +==============+ * | +<-------|| undo || * | | E || setup || * | | +==============+ * | | | S * | | +==============+ * | | || set ||-------------------------->+ * | | || value || E | * | | +==============+ | * | | | S | * | | +--------------+ | * | | | check |-------------------------->| * | | | consistency | E | * | | +--------------+ | * | | | S | * | | +==============+ +==============+ | * | | || commit ||-------->|| undo || | * | | || || E || commit || | * | | +==============+ +==============+ | * | | | S U |<--------+ * | | +--------------+ +==============+ * | | | irreversible | || undo || * | | | commit | || set || * | | +--------------+ +==============+ * | | | U U | * | +-------------->|<------------------------+ * | +==============+ * | || undo || * | || cleanup || * | +==============+ * +---------------------->| U @if $m2c_table_row_creation == 1@ * | * (err && f1)------------------->+ * | | * +--------------+ +--------------+ * | post |<--------| row | * | request | U | release | * +--------------+ +--------------+ @else@ * +--------------+ * | post | * | request | * +--------------+ @end@ # row creation * */ ##---------------------------------------------------------------------- /** * Setup up context with information needed to undo a set request. * * This function will be called before the individual node undo setup * functions are called. If you need to do any undo setup that is not * related to a specific column, you can do it here. * @if $m2c_undo_embed == 0@ @ if $m2c_data_init == 1@ * Note that the undo context has been allocated with * ${context}_allocate_data(), but may need extra * initialization similar to what you may have done in * ${context}_rowreq_ctx_init(). @ end@ @end@ * Note that an individual node's undo_setup function will only be called * if that node is being set to a new value. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in the node's undo_setup * function, so it won't be done unless it is necessary. * * @param rowreq_ctx * Pointer to the table context (${context}_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */ int ${context}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:${context}:${context}_undo_setup","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:451:M: |-> Setup $context undo. * set up $context undo information, in preparation for a set. * Undo storage is in ${m2c_ctx_lh}* */ return rc; } /* ${context}_undo_setup */ /** * Undo a set request. * * This function will be called before the individual node undo * functions are called. If you need to do any undo that is not * related to a specific column, you can do it here. * * Note that an individual node's undo function will only be called * if that node is being set to a new value. * * If there is anything specific to a particular column (e.g. releasing * memory for a string), you should do that setup in the node's undo * function, so it won't be done unless it is necessary. * * @param rowreq_ctx * Pointer to the table context (${context}_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */ int ${context}_undo( ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:${context}:${context}_undo","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:451:M: |-> $context undo. * $context undo information, in response to a failed set. * Undo storage is in ${m2c_ctx_lh}* */ return rc; } /* ${context}_undo_setup */ /** * Cleanup up context undo information. * * This function will be called after set/commit processing. If you * allocated any resources in undo_setup, this is the place to release * those resources. * * This function is called regardless of the success or failure of the set * request. If you need to perform different steps for cleanup depending * on success or failure, you can add a flag to the rowreq_ctx. * * @param rowreq_ctx * Pointer to the table context (${context}_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */ int ${context}_undo_cleanup( ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:${context}:${context}_undo_cleanup","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:452:M: |-> Cleanup $context undo. * Undo storage is in ${m2c_ctx_lh}* */ return rc; } /* ${context}_undo_cleanup */ ##---------------------------------------------------------------------- /** * commit new values. * * At this point, you should have done everything you can to ensure that * this commit will not fail. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in @if $m2c_create_fewer_files != 1@ * ${context}_oids.h. @else@ * ${context}.h. @end@ * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param ${context}_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */ int ${context}_commit( ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:${context}:${context}_commit","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * save flags, then clear until we actually do something */ save_flags = rowreq_ctx->column_set_flags; rowreq_ctx->column_set_flags = 0; /* * commit $context data * 1) check the column's flag in save_flags to see if it was set. * 2) clear the flag when you handle that column * 3) set the column's flag in column_set_flags if it needs undo * processing in case of a failure. */ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if $node.settable == 0@ @ next@ @ end@ if (save_flags & COLUMN_$node.uc_FLAG) { save_flags &= ~COLUMN_$node.uc_FLAG; /* clear $node */ /* * TODO:482:o: |-> commit column $node. */ rc = -1; if(-1 == rc) { snmp_log(LOG_ERR,"$context column $node commit failed\n"); } else { /* * set flag, in case we need to undo $node */ rowreq_ctx->column_set_flags |= COLUMN_$node.uc_FLAG; } } @ end@ # foreach $node /* * if we successfully commited this row, set the dirty flag. */ if (MFD_SUCCESS == rc) { rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; } if (save_flags) { snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags); return MFD_ERROR; } return rc; } /* ${context}_commit */ /** * undo commit new values. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in @if $m2c_create_fewer_files != 1@ * ${context}_oids.h. @else@ * ${context}.h. @end@ * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param ${context}_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */ int ${context}_undo_commit( ${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:${context}:${context}_undo_commit","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:485:M: |-> Undo $context commit. * check the column's flag in rowreq_ctx->column_set_flags to see * if it was set during commit, then undo it. * * eg: if (rowreq_ctx->column_set_flags & COLUMN_$node.uc_FLAG) {} */ /* * if we successfully un-commited this row, clear the dirty flag. */ if (MFD_SUCCESS == rc) { rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; } return rc; } /* ${context}_undo_commit */ @if $m2c_irreversible_commit == 1@ ##---------------------------------------------------------------------- /** * perform commit actions that are not reversible * * THERE IS NO ATTEMPT AT RECOVERY FOR ERRORS FROM THIS STATE! * * @param ${context}_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : other error */ int ${context}_irreversible_commit( ${context}_rowreq_ctx *rowreq_ctx) { int rc; DEBUGMSGTL(("verbose:${context}:${context}_irreversible_commit","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * TODO:495:o: Irreversible $context commit. */ ##$example_start ##$example_end return MFD_SUCCESS; } /* ${context}_irreversible_commit */ @end@ // irreversable commit ## ######################################################################## @end@ // m2c_processing_type eq 'c' ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12851 $ */ @end@ mib2c-data/node-set.m2i 0000666 00000017161 15077166074 0010625 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: node-set.m2i 11991 2005-03-04 20:10:14Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11991 $ */ @end@ ######################################################################## ## ##---------------------------------------------------------------------- /** * Check that the proposed new value is potentially valid. * * @param rowreq_ctx * Pointer to the row request context. * @param $m2c_node_param_val_name * A $node.decl containing the new value. @ if $m2c_node_needlength == 1@ * @param $m2c_node_param_val_lname * The size (in bytes) of the data pointed to by $m2c_node_param_val_name @ end@ * * @retval MFD_SUCCESS : incoming value is legal * @retval MFD_NOT_VALID_NOW : incoming value is not valid now * @retval MFD_NOT_VALID_EVER : incoming value is never valid * * This is the place to check for requirements that are not * expressed in the mib syntax (for example, a requirement that * is detailed in the description for an object). * @if ("$m2c_data_context" ne "generated") && ($m2c_node_needlength == 1)@ * Since you aren't using a generated data context, you also need to * check the length, to make sure you don't overflow your storage space. * @end@ * You should check that the requested change between the undo value and the * new value is legal (ie, the transistion from one value to another * is legal). * *@note * This check is only to determine if the new value * is \b potentially valid. This is the first check of many, and * is one of the simplest ones. * *@note * this is not the place to do any checks for values * which depend on some other value in the mib. Those * types of checks should be done in the * ${context}_check_dependencies() function. * * The following checks have already been done for you: * The syntax is $node.type @if ("$m2c_data_context" eq "generated") && ($m2c_node_needlength == 1)@ * The length is < sizeof($m2c_data_item$node). @end@ @if $node.enums == 1@ * The value is one of $m2c_evals @elsif $node.ranges == 1@ @ if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ @ eval $m2c_tmp_ns = "value"@ @ else@ @ eval $m2c_tmp_ns = "length"@ @ end@ * The $m2c_tmp_ns is in (one of) the range set(s): $m2c_evals @end@ * * If there a no other checks you need to do, simply return MFD_SUCCESS. * @ if $mfd_code_verbose == 1@ @ if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ * For example, an object with the syntax INTEGER(0..500) will * have already been checked for a value between 0 and 500. But * if the description also specifies that the value must be an * even number, you would enforce that requirement here. If and odd * numer is set, return MFD_NOT_VALID_EVER. If the description also * specified that changed must be made in single steps of 2, then a set * to change the value 10 to an even value other than 8 or 12 should * return MFD_NOT_VALID_NOW. @ else@ * For example, and object with the syntax DisplayString(0..40) * will have already been checked for a length between 0 and 40. * But if the description also specified that the value must * be all uppercase letters, you would enforce that requirement here * by returning MFD_NOT_VALID_EVER for a set containing lowercase * letters. If the description also specified that the value can not * change by more than one letter at a time, an attempt to change * "ABBY" to "ANNIE" should return MFD_NOT_VALID_NOW. @ end@ * @ end@ */ int ${node}_check_value( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val) { DEBUGMSGTL(("verbose:${context}:${node}_check_value","called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); @if $m2c_node_needlength == 1@ netsnmp_assert(NULL != $m2c_node_param_val_name); @end@ /* * TODO:441:o: |-> Check for valid $node value. */ return MFD_SUCCESS; /* $node value not illegal */ } /* ${node}_check_value */ ##---------------------------------------------------------------------- /** * Save old value information * * @param rowreq_ctx * Pointer to the table context (${context}_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. * * This function will be called after the table level undo setup function * ${context}_undo_setup has been called. * *@note * this function will only be called if a new value is set for this column. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in this function, so it * won't be done unless it is necessary. */ int ${node}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx) { DEBUGMSGTL(("verbose:${context}:${node}_undo_setup","called\n")); @ifconf syntax-$node.syntax-undo-setup.m2i@ @ include syntax-$node.syntax-undo-setup.m2i@ @else@ /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:455:o: |-> Setup $node undo. */ @ eval $m2c_ctx_lh = "${m2c_undo_item}${node}"@ @ eval $m2c_ctx_lhs = "${m2c_undo_item}${node}_len"@ @ eval $m2c_ctx_rh = "${m2c_data_item}${node}"@ @ eval $m2c_ctx_rhs = "${m2c_data_item}${node}_len"@ @ include generic-ctx-copy.m2i@ @end@ return MFD_SUCCESS; } /* ${node}_undo_setup */ ##---------------------------------------------------------------------- /** * Set the new value. * @if $m2c_node_set_comments ne ""@ $m2c_node_set_comments * @end@ * @param rowreq_ctx * Pointer to the users context. You should know how to * manipulate the value from this object. * @param $m2c_node_param_val_name * A $node.decl containing the new value. @ if $m2c_node_needlength == 1@ * @param $m2c_node_param_val_lname * The size (in bytes) of the data pointed to by $m2c_node_param_val_name @ end@ */ int ${node}_set( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val ) { @ifconf syntax-$node.syntax-set.m2i@ @ include syntax-$node.syntax-set.m2i@ @else@ DEBUGMSGTL(("verbose:${context}:${node}_set","called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); @if $m2c_node_needlength == 1@ netsnmp_assert(NULL != $m2c_node_param_val_name); @end@ @ if $m2c_node_skip_mapping != 1@ @ include generic-value-map-reverse.m2i@ @ else@ @ include generic-ctx-set.m2i@ @ end@ @end@ # no syntax include return MFD_SUCCESS; } /* ${node}_set */ ##---------------------------------------------------------------------- /** * undo the previous set. * @if $m2c_node_undo_comments ne ""@ $m2c_node_undo_comments * @end@ * @param rowreq_ctx * Pointer to the users context. */ int ${node}_undo( ${context}_rowreq_ctx *rowreq_ctx) { @ifconf syntax-$node.syntax-undo.m2i@ @ include syntax-$node.syntax-undo.m2i@ @else@ DEBUGMSGTL(("verbose:${context}:${node}_undo","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:456:o: |-> Clean up $node undo. */ @ eval $m2c_ctx_rh = "${m2c_undo_item}${node}"@ @ eval $m2c_ctx_rhs = "${m2c_undo_item}${node}_len"@ @ eval $m2c_ctx_lh = "${m2c_data_item}${node}"@ @ eval $m2c_ctx_lhs = "${m2c_data_item}${node}_len"@ @ include generic-ctx-copy.m2i@ @end@ # no syntax include return MFD_SUCCESS; } /* ${node}_undo */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11991 $ */ @end@ mib2c-data/syntax-DateAndTime-get.m2d 0000666 00000000477 15077166074 0013324 0 ustar 00 ## ## @eval $m2c_node_needlength = 0@ @eval $m2c_decl = "u_char *"@ ## @eval $m2c_node_proto_parms = "u_char * ${node}"@ ## @eval $m2c_node_proto_comments = "$m2c_node_proto_comments * Param: ${node}\n"@ @eval $m2c_node_proto_comments = "$m2c_node_proto_comments * Pointer to storage for a DateAndTime value\n"@ mib2c-data/subagent.m2c 0000666 00000013470 15077166074 0010710 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## $Id: subagent.m2c 15795 2007-01-25 22:07:06Z tanders $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 15795 $ */ @end@ ######################################################################## ## @if 0@ @open ${name}_subagent.h@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 15795 $ of $RCSfile$ */ @include generic-header-top.m2i@ @include generic-header-bottom.m2i@ @end@ ###################################################################### ## Do the .c file ###################################################################### @open ${name}_subagent.c@ /* * Note: this file originally auto-generated by mib2c using * version $Revision: 15795 $ of $RCSfile$ */ @include generic-source-includes.m2i@ #include <signal.h> static int keep_running; static RETSIGTYPE stop_server(int a) { keep_running = 0; } static void usage(void) { printf("usage: $name [-D<tokens>] [-f] [-L] [-M] [-H] [LISTENING ADDRESSES]\n" "\t-f Do not fork() from the calling shell.\n" "\t-DTOKEN[,TOKEN,...]\n" "\t\tTurn on debugging output for the given TOKEN(s).\n" "\t\tWithout any tokens specified, it defaults to printing\n" "\t\tall the tokens (which is equivalent to the keyword 'ALL').\n" "\t\tYou might want to try ALL for extremely verbose output.\n" "\t\tNote: You can't put a space between the -D and the TOKENs.\n" "\t-H\tDisplay a list of configuration file directives\n" "\t\tunderstood by the agent and then exit.\n" "\t-M\tRun as a normal SNMP Agent instead of an AgentX sub-agent.\n" "\t-x ADDRESS\tconnect to master agent at ADDRESS (default /var/agentx/master).\n" "\t-L\tDo not open a log file; print all messages to stderr.\n"); exit(0); } int main (int argc, char **argv) { int agentx_subagent=1; /* change this if you want to be a SNMP master agent */ /* Defs for arg-handling code: handles setting of policy-related variables */ int ch; extern char *optarg; int dont_fork = 0, use_syslog = 0; char *agentx_socket = NULL; while ((ch = getopt(argc, argv, "D:fHLMx:")) != EOF) switch(ch) { case 'D': debug_register_tokens(optarg); snmp_set_do_debugging(1); break; case 'f': dont_fork = 1; break; case 'H': netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1); init_agent("$name"); /* register our .conf handlers */ init_$name(); init_snmp("$name"); fprintf(stderr, "Configuration directives understood:\n"); read_config_print_usage(" "); exit(0); case 'M': agentx_subagent = 0; break; case 'L': use_syslog = 0; /* use stderr */ break; case 'x': agentx_socket = optarg; break; default: fprintf(stderr,"unknown option %c\n", ch); usage(); } if (optind < argc) { int i; /* * There are optional transport addresses on the command line. */ DEBUGMSGTL(("snmpd/main", "optind %d, argc %d\n", optind, argc)); for (i = optind; i < argc; i++) { char *c, *astring; if ((c = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_PORTS))) { astring = malloc(strlen(c) + 2 + strlen(argv[i])); if (astring == NULL) { fprintf(stderr, "malloc failure processing argv[%d]\n", i); exit(1); } sprintf(astring, "%s,%s", c, argv[i]); netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_PORTS, astring); SNMP_FREE(astring); } else { netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_PORTS, argv[i]); } } DEBUGMSGTL(("snmpd/main", "port spec: %s\n", netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_PORTS))); } /* we're an agentx subagent? */ if (agentx_subagent) { /* make us a agentx client. */ netsnmp_enable_subagent(); if (NULL != agentx_socket) netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, agentx_socket); } snmp_disable_log(); if (use_syslog) snmp_enable_calllog(); else snmp_enable_stderrlog(); /* daemonize */ if(!dont_fork) { int rc = netsnmp_daemonize(1,!use_syslog); if(rc) exit(-1); } /* initialize tcp/ip if necessary */ SOCK_STARTUP; /* initialize the agent library */ init_agent("$name"); /* init $name mib code */ init_$name(); /* read ${name}.conf files. */ init_snmp("$name"); /* If we're going to be a snmp master agent, initial the ports */ if (!agentx_subagent) init_master_agent(); /* open the port to listen on (defaults to udp:161) */ /* In case we recevie a request to stop (kill -TERM or kill -INT) */ keep_running = 1; signal(SIGTERM, stop_server); signal(SIGINT, stop_server); /* you're main loop here... */ while(keep_running) { /* if you use select(), see snmp_select_info() in snmp_api(3) */ /* --- OR --- */ agent_check_and_process(1); /* 0 == don't block */ } /* at shutdown time */ snmp_shutdown("$name"); SOCK_CLEANUP; exit(0); } ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 15795 $ */ @end@ mib2c-data/syntax-InetAddressType-get.m2i 0000666 00000002033 15077166074 0014247 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-InetAddressType-get.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## @include generic-get-decl.m2i@ @include generic-ctx-get.m2i@ /* the ${context}_rowreq_ctx->data pointer should be pointer to the data you supplied during the data lookup, so you should know how to determine the InetAddressType from this pointer. */ return MFD_SKIP; /* TODO:235:M: |-> Remove SKIP once you've set $node data */ @include generic-value-map.m2i@ @include generic-get-decl-bot.m2i@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/generic-value-map.m2i 0000666 00000002665 15077166074 0012413 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-value-map.m2i 11593 2004-12-10 14:46:09Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11593 $ */ @end@ ######################################################################## ## } @if $m2c_node_skip_mapping == 1@ /** no mapping */ @ include generic-ctx-get.m2i@ @else@ // mapping /* * TODO:246:r: |-> Define $node mapping. * Map values between raw/native values and MIB values * @ if $m2c_node_needlength == 1@ * if(MFD_SUCCESS != * ${node}_map(&$m2c_ctx_lh, &$m2c_ctx_lhs, * $m2c_ctx_rh, $m2c_ctx_rhs, $m2c_node_realloc)) { * return MFD_ERROR; * } */ @ include generic-ctx-get.m2i@ ## @ elsif ($node.enums == 1) && ("$node.perltype" eq "INTEGER")@ ## * enums usually need mapping. */ if(MFD_SUCCESS != ${node}_map(&${m2c_ctx_lh}, ${m2c_ctx_rh} )) { return MFD_ERROR; } @ else@ // enums * Integer based value can usually just do a direct copy. */ @ include generic-ctx-get.m2i@ @ end@ @end@ // mapping ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11593 $ */ @end@ mib2c-data/generic-ctx-copy.m2i 0000666 00000002100 15077166074 0012252 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-ctx-copy.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## /* @if $m2c_node_needlength == 1@ * copy $node and ${node}_len data @else@ * copy $node data @end@ * set ${m2c_ctx_lh} from ${m2c_ctx_rh} */ @if ($m2c_include_examples != 0) || ("$m2c_data_context" eq "generated")@ @ if $m2c_node_needlength == 0@ ${m2c_ctx_lh} = ${m2c_ctx_rh}; @ else@ memcpy( ${m2c_ctx_lh}, ${m2c_ctx_rh}, (${m2c_ctx_rhs} * sizeof(${m2c_ctx_lh}[0]))); ${m2c_ctx_lhs} = ${m2c_ctx_rhs}; @ end@ # need length @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/generic-table-indexes-from-oid.m2i 0000666 00000004327 15077166074 0014757 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-table-indexes-from-oid.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## /** * extract ${context} indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int ${context}_index_from_oid(netsnmp_index *oid_idx, ${context}_mib_index *mib_idx) { @include generic-table-indexes-varbind-setup.m2i@ DEBUGMSGTL(("verbose:${context}:${context}_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_$m2c_dii_first ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ @ eval $m2c_node_name = ""@ # purge node name to re-eval $m2c_node_var_name @ foreach $node index@ @ eval $m2c_node_var_name = "var_${node}."@ @ include m2c_setup_node.m2i@ @ if $m2c_node_needlength == 1@ /* * NOTE: val_len is in bytes, ${node}_len might not be */ if(var_${node}.val_len > sizeof(mib_idx->$node)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->${node}, var_${node}.val.string, var_${node}.val_len); mib_idx->${node}_len = var_${node}.val_len / sizeof(mib_idx->${node}[0]); } @ else@ mib_idx->$node = $m2c_node_var_val; @ end@ @ end@ # foreach @ eval $m2c_node_var_name = ""@ #reset custom name @ eval $m2c_node_name = ""@ # purge node name to re-eval $m2c_node_var_name } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_$m2c_dii_first ); return err; } /* ${context}_index_from_oid */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/syntax-DateAndTime-get.m2i 0000666 00000004230 15077166074 0013320 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: syntax-DateAndTime-get.m2i 12079 2005-04-14 02:52:09Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12079 $ */ @end@ ######################################################################## ## /* temporary storage for date. If you have any of this data available directly, use it instead. */ int year, month, day, hour, minutes, seconds, deci_seconds; int rc, utc_offset_direction, utc_offset_hours, utc_offset_minutes; /** we should have a pointer and enough storage */ netsnmp_assert( (NULL != $m2c_node_param_ref_name) && (NULL != *$m2c_node_param_ref_name)); netsnmp_assert( (NULL != $m2c_node_param_ref_lname) && ((* $m2c_node_param_ref_lname) >= 11)); /* * TODO:231:o: |-> copy $node data. * get the date from your context pointer. */ return MFD_SKIP; /* TODO:234:M: |-> Remove SKIP once you've set $node data */ year = 0; /* 0..65536 */ month = 0; /* 1..12 */ day = 0; /* 1..31 */ hour = 0; /* 0..23 */ minutes = 0; /* 0..59 */ seconds = 0; /* 0..60 (60 indicates a leap-second) */ deci_seconds = 0; /* 0..9 */ /* setting utc offset is optional. Leave the values as is if you want to exclude this information. */ utc_offset_direction = 0; /* -1, +1 */ utc_offset_hours = -1; /* 0..13 */ utc_offset_minutes = -1; /* 0..59 */ /* call convenience function to set data */ rc = netsnmp_dateandtime_set_buf_from_vars(*$m2c_node_param_ref_name, $m2c_node_param_ref_lname, year, month, day, hour, minutes, seconds, deci_seconds, utc_offset_direction, utc_offset_hours, utc_offset_minutes ); if(rc != SNMP_ERR_NOERROR) return rc; ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12079 $ */ @end@ mib2c-data/mfd-makefile.m2m 0000666 00000010132 15077166074 0011423 0 ustar 00 ####################################################### -*- Makefile -*- ## $Id: mfd-makefile.m2m 12577 2005-07-25 15:37:02Z dts12 $ ## ######################################################################## ## @strict token off@ @ifconf ${name}_Makefile@ @ print ${name}_Makefile exists, skipping@ @else@ @ if "x$m2c_create_fewer_files" eq "x"@ @ eval $m2c_create_fewer_files = 0@ @ end@ @ open ${name}_Makefile@ @ ifconf ${name}_Makefile.m2m@ @ include ${name}_Makefile.m2m@ @ else@ ######################################################################## @ if $m2c_mark_boundary == 1@ # START code generated by $RCSfile$ $Revision: 12577 $ @ end@ ######################################################################## CC=gcc TABLE_PREFIX=${name} @ if "$mfd_netsnmp_dir" ne ""@ NETSNMPDIR=$mfd_netsnmp_dir NETSNMPCONFIG=$(NETSNMPDIR)/net-snmp-config @ else@ NETSNMPCONFIG=net-snmp-config @ end@ @ if "$mfd_netsnmp_dir" ne ""@ # Assuming we're linking against a Net-SNMP build tree (which may or # may not be the same as the source tree) and not an installed package. # Note: to do this we REQUIRE gnu-make. NETSNMPBASECFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags) NETSNMPINCLUDES := $(shell $(NETSNMPCONFIG) --build-includes $(NETSNMPDIR)) # base flags after build/src include, in case it has /usr/local/include NETSNMPCFLAGS=$(NETSNMPINCLUDES) $(NETSNMPBASECFLAGS) NETSNMPBASELIBS := $(shell $(NETSNMPCONFIG) --base-agent-libs) NETSNMPEXTLIBS := $(shell $(NETSNMPCONFIG) --external-agent-libs) NETSNMPLIBDIRS := $(shell $(NETSNMPCONFIG) --build-lib-dirs $(NETSNMPDIR)) NETSNMPLIBDEPS := $(shell $(NETSNMPCONFIG) --build-lib-deps $(NETSNMPDIR)) LIB_DEPS=$(NETSNMPLIBDEPS) LIBS=$(NETSNMPLIBDIRS) -Wl,-Bstatic $(NETSNMPBASELIBS) -Wl,-Bdynamic $(NETSNMPEXTLIBS) @ else@ # uncomment this if you have GNU make #NETSNMPCFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags) #NETSNMPLIBS := $(shell $(NETSNMPCONFIG) --agent-libs) NETSNMPCFLAGS=`$(NETSNMPCONFIG) --base-cflags` NETSNMPLIBS=`$(NETSNMPCONFIG) --agent-libs` LIBS=$(NETSNMPLIBS) @ end@ STRICT_FLAGS = -Wall -Wstrict-prototypes CFLAGS=-I. $(NETSNMPCFLAGS) $(STRICT_FLAGS) USER_SRCS = \ @ if $m2c_create_fewer_files != 1@ $(TABLE_PREFIX)_data_get.c \ $(TABLE_PREFIX)_data_set.c \ @ end@ $(TABLE_PREFIX)_data_access.c SRCS = $(USER_SRCS) \ $(TABLE_PREFIX).c \ $(TABLE_PREFIX)_subagent.c \ $(TABLE_PREFIX)_interface.c USER_OBJS = \ @ if $m2c_create_fewer_files != 1@ $(TABLE_PREFIX)_data_get.o \ $(TABLE_PREFIX)_data_set.o \ @ end@ $(TABLE_PREFIX)_data_access.o OBJS = $(USER_OBJS) \ $(TABLE_PREFIX).o \ $(TABLE_PREFIX)_subagent.o \ $(TABLE_PREFIX)_interface.o TARGETS=$(TABLE_PREFIX) .SUFFIXES: .SUFFIXES: .c .o .deps all: $(TARGETS) user: $(USER_OBJS) $(TARGETS): $(LIB_DEPS) $(TABLE_PREFIX): $(OBJS) $(TABLE_PREFIX)_Makefile $(CC) -o $(TABLE_PREFIX) $(OBJS) $(LIBS) clean: rm -f $(OBJS) $(TARGETS) @if "$mfd_netsnmp_dir" ne ""@ $(TABLE_PREFIX).deps $(TABLE_PREFIX)_subagent.deps $(TABLE_PREFIX)_interface.deps: $(TABLE_PREFIX)_Makefile $(TABLE_PREFIX)_data_access.deps: $(TABLE_PREFIX)_Makefile @if $m2c_create_fewer_files != 1@ $(TABLE_PREFIX)_data_get.deps: $(TABLE_PREFIX)_Makefile $(TABLE_PREFIX)_data_set.deps: $(TABLE_PREFIX)_Makefile @end@ %.deps : %.c \@echo "Generating makefile $\@ ..." \@set -e; $(CC) -M $(COPTS) $(CFLAGS) $(CPPFLAGS) $< \ | sed 's/\($*\)\.o[ :]*/\1.o $\@ : /g' > $\@; \ [ -s $\@ ] || $(RM) $(RMFLAGS) $\@ include $(TABLE_PREFIX).deps include $(TABLE_PREFIX)_subagent.deps include $(TABLE_PREFIX)_interface.deps include $(TABLE_PREFIX)_data_access.deps @ if $m2c_create_fewer_files != 1@ include $(TABLE_PREFIX)_data_get.deps include $(TABLE_PREFIX)_data_set.deps @ end@ @end@ ######################################################################## @ if $m2c_mark_boundary == 1@ # END code generated by $RCSfile$ $Revision: 12577 $ @ end@ @ end@ # not including ${name}_Makefile.m2m @ close ${name}_Makefile@ @end@ # no existing makefile mib2c-data/generic-header-top.m2i 0000666 00000001251 15077166074 0012542 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-header-top.m2i 8830 2003-09-30 13:34:57Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 8830 $ */ @end@ ######################################################################## ## #ifndef $name.uc_H #define $name.uc_H #ifdef __cplusplus extern "C" { #endif ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 8830 $ */ @end@ mib2c-data/details-enums.m2i 0000666 00000005255 15077166074 0011662 0 ustar 00 ############################################################# -*- c -*- ## generic include for enums. Do not use directly. ## ## $Id: details-enums.m2i 12011 2005-03-18 23:01:44Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12011 $ */ @end@ ######################################################################## @ifconf $node.syntax.m2i@ @ include $node.syntax.m2i@ @else@ ## ## Generating enums ## ## Examples: ## ## enums syntax perltype net-snmp type cdecl m2c_decl ## ----- -------- -------- ------------- ----- ------- ## 1 SomeTC BITS ASN_OCTET_STR char u_long ## 1 INTEGER INTEGER ASN_INTEGER long u_long ## 1 RowStatus INTEGER ASN_INTEGER long u_long ## /************************************************************* * constants for enums for the MIB node * $node ($node.syntax / $node.type) * * since a Textual Convention may be referenced more than once in a * MIB, protect againt redefinitions of the enum values. */ ## #ifndef ${m2c_de_pfx}_ENUMS #define ${m2c_de_pfx}_ENUMS @ eval $m2c_mask=""@ @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ @ if "$node.perltype" eq "BITS"@ @ if $v > 31@ @ print ** ACK! I cannot handle BITS longer than 4 bytes!@ @ exit@ @ end@ @ if "x$m2c_mask" eq "x"@ @ eval $m2c_mask="$m2c_ename"@ @ else@ @ eval $m2c_mask="$m2c_mask | $m2c_ename"@ @ end@ $m2c_const_dcl $m2c_ename $m2c_const_del (1 << (31-$v)) $m2c_const_sfx @ else@ $m2c_const_dcl $m2c_ename $m2c_const_del $v $m2c_const_sfx @ end@ @ end@ # for each #endif /* ${m2c_de_pfx}_ENUMS */ @ if "$node.perltype" eq "BITS"@ $m2c_const_dcl $m2c_enum_mask $m2c_const_del ($m2c_mask) @ end@ @ if ($m2c_node_skip_mapping != 1) && ($node.enums == 1)@ /* * TODO:140:o: Define your interal representation of $node enums. * (used for value mapping; see notes at top of file) */ @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ @ if ("$node.perltype" ne "BITS")@ $m2c_const_dcl INTERNAL_$context.uc_$m2c_iname $m2c_const_del $v $m2c_const_sfx @ else@ $m2c_const_dcl INTERNAL_$context.uc_$m2c_iname $m2c_const_del (0x01 << $v) $m2c_const_sfx @ end@ @ end@ // foreach @ end@ // skip mapping / enums @end@ # ! syntax include ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12011 $ */ @end@ mib2c-data/generic-data-context.m2i 0000666 00000003106 15077166074 0013106 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-data-context.m2i 11300 2004-10-08 23:39:17Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11300 $ */ @end@ ######################################################################## ## /**********************************************************************/ /* * TODO:110:r: |-> Review ${context} data context structure. * This structure is used to represent the data for $context. */ ## @if "$m2c_data_context" eq "generated"@ /* * This structure contains storage for all the columns defined in the * $context. */ typedef struct ${context}_data_s { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ /* * $m2c_node_summary */ @ if $m2c_node_needlength == 0@ $m2c_decl $node; @ else@ $m2c_decl $node[$m2c_node_maxlen]; size_t ${node}_len; /* # of $m2c_decl elements, not bytes */ @ end@ @ end@ # foreach nonindex } ${context}_data; @elsif "$m2c_data_context" eq "unknown"@ /* * update typedef to correct pointer type. * (or add @eval $@m2c_data_context = "TYPE"@ and regenerate code) */ typedef void ${context}_data; @else@ typedef $m2c_data_context ${context}_data; @end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11300 $ */ @end@ mib2c-data/generic-header-bottom.m2i 0000666 00000001226 15077166074 0013246 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-header-bottom.m2i 11068 2004-09-14 02:29:16Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11068 $ */ @end@ ######################################################################## ## #ifdef __cplusplus } #endif #endif /* $name.uc_H */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11068 $ */ @end@ mib2c-data/m2c_table_save_defaults.m2i 0000666 00000010675 15077166074 0013647 0 ustar 00 ####################################################################### ## generic include for XXX. Do not use directly. ## ## $Id: m2c_table_save_defaults.m2i 12577 2005-07-25 15:37:02Z dts12 $ ######################################################################## ## ## ## Note: if you add a var here, add it in mfd-interactive-setup.m2c too ## ## @open ${m2c_defaults_dir}table-${context}.m2d@ @eval $m2c_tmp_cc = "##"@ @eval $tmp_cc = ""@ # hack to prevet mib2c eval $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc mib2c Table setting for $context $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc User context structure type $m2c_tmp_cc $tmp_cc@eval $@m2c_context_reg = "$m2c_context_reg"@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Allocate data structure in row structure? (vs embedd) $m2c_tmp_cc $tmp_cc@eval $@m2c_data_allocate = $m2c_data_allocate@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate code to cache data? $m2c_tmp_cc $tmp_cc@eval $@m2c_data_cache = $m2c_data_cache@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Data context structure type $m2c_tmp_cc $tmp_cc@eval $@m2c_data_context = "$m2c_data_context"@ [generated|NAME] $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate function to initialize row context when created? $m2c_tmp_cc $tmp_cc@eval $@m2c_data_init = $m2c_data_init@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Persistence of data context $m2c_tmp_cc // 0:persistent, 1:semi-transient, 2:transient $m2c_tmp_cc $tmp_cc@eval $@m2c_data_transient = $m2c_data_transient@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Include some example code? $m2c_tmp_cc $tmp_cc@eval $@m2c_include_examples = $m2c_include_examples@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate code for irreversible_commit mode? $m2c_tmp_cc $tmp_cc@eval $@m2c_irreversible_commit = $m2c_irreversible_commit@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Data access method $m2c_tmp_cc $tmp_cc@eval $@m2c_table_access = "$m2c_table_access"@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate row dependency function? $m2c_tmp_cc $tmp_cc@eval $@m2c_table_dependencies = $m2c_table_dependencies@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate data store/restore functions for persistent storage? $m2c_tmp_cc $tmp_cc@eval $@m2c_table_persistent = $m2c_table_persistent@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate code for dynamic row creation? $m2c_tmp_cc $tmp_cc@eval $@m2c_table_row_creation = $m2c_table_row_creation@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate code for settable objects? $m2c_tmp_cc $tmp_cc@eval $@m2c_table_settable = $m2c_table_settable@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Skip mapping between data context and MIB formats? $m2c_tmp_cc // 0:generate maps, 1:skip maps, -1:skip unless enum/oid $m2c_tmp_cc $tmp_cc@eval $@m2c_table_skip_mapping = $m2c_table_skip_mapping@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate code for sparse tables? $m2c_tmp_cc $tmp_cc@eval $@m2c_table_sparse = $m2c_table_sparse@ $m2c_tmp_cc $m2c_tmp_cc ######################################################################## $m2c_tmp_cc $m2c_tmp_cc Generate Makefile/AgentX code? $m2c_tmp_cc $tmp_cc@eval $@mfd_generate_makefile = $mfd_generate_makefile@ $tmp_cc@eval $@mfd_generate_subagent = $mfd_generate_subagent@ $m2c_tmp_cc @close ${m2c_defaults_dir}table-${context}.m2d@ mib2c-data/details-table.m2i 0000666 00000002073 15077166074 0011615 0 ustar 00 ############################################################# -*- c -*- ## generic include for tables. Do not use directly. ## ## $Id: details-table.m2i 12023 2005-03-24 00:42:15Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12023 $ */ @end@ ######################################################################## /********************************************************************** ********************************************************************** *** *** Table $context *** ********************************************************************** **********************************************************************/ /* * $context.module::$context is subid $context.subid of $context.parent. * Its status is $context.status. * OID: $context.objectID, length: $context.oidlength */ ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12023 $ */ @end@ mib2c-data/mfd-doxygen.m2c 0000666 00000004603 15077166074 0011317 0 ustar 00 ######################################################################## @foreach $table table@ @ ifconf ${context}_doxygen.conf @ print "${context}_doxygen.conf exists, skipping.@ @ else@ @ include m2c_setup_table.m2i@ @ open ${context}_doxygen.conf@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = ${context} # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 0.1 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = docs #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = . # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. FILE_PATTERNS = *.c *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = @ end@ # conf file exists @end@ # foreach table mib2c-data/m2c_setup_enum.m2i 0000666 00000002010 15077166074 0012017 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: m2c_setup_enum.m2i 11987 2005-03-04 19:58:28Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11987 $ */ @end@ ######################################################################## ## ## the iname enum should be unique per column, so always use node name ## @ if $m2c_const_lc == 1@ @ eval $m2c_ename = "${m2c_de_pfx}_${e}${m2c_enum_sfx}"@ @ eval $m2c_iname = "${m2c_const_pfx}${node}_${e}${m2c_enum_sfx}"@ @ else@ @ eval $m2c_ename = "${m2c_de_pfx}_$e.uc${m2c_enum_sfx}"@ @ eval $m2c_iname = "${m2c_const_pfx}$node.uc_$e.uc${m2c_enum_sfx}"@ @ end@ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11987 $ */ @end@ mib2c-data/generic-value-map-reverse.m2i 0000666 00000003077 15077166074 0014062 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: generic-value-map-reverse.m2i 12587 2005-07-25 23:26:53Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 12587 $ */ @end@ ######################################################################## ## /* * TODO:245:o: |-> Implement $node reverse mapping. * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them here. */ @if ($node.enums == 1)@ $example_start @ if ("$node.perltype" eq "BITS")@ $m2c_ctx_rh = 0; @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ if ($m2c_node_srh & $m2c_ename) { $m2c_ctx_rh |= INTERNAL_$context.uc_$m2c_iname; } @ end@ # for each @ elsif ("$node.perltype" eq "INTEGER")@ switch($m2c_node_srh) { @ foreach $e $v enum@ @ include m2c_setup_enum.m2i@ case $m2c_ename: $m2c_ctx_rh = INTERNAL_$context.uc_$m2c_iname; break; @ end@ # foreach default: snmp_log(LOG_ERR, "couldn't reverse map value %ld for $node\n", $m2c_node_srh ); return SNMP_ERR_GENERR; } @ end@ # integers/bits $example_end @else@ @ include generic-ctx-set.m2i@ @end@ # enums ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 12587 $ */ @end@ mib2c-data/parent-dependencies.m2i 0000666 00000003732 15077166074 0013023 0 ustar 00 ############################################################# -*- c -*- ## generic include for XXX. Do not use directly. ## ## $Id: parent-dependencies.m2i 11989 2005-03-04 20:02:42Z rstory $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 11989 $ */ @end@ # ; ######################################################################## ## /** * check dependencies * * This is useful for for tables which have dependencies between columns * (or rows, or tables). For example, two columns allocating a percentage * of something add up 100%. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in @if $m2c_create_fewer_files != 1@ * ${context}_oids.h. @else@ * ${context}.h. @end@ * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @retval MFD_SUCCESS all the changes to the row are legal * @retval MFD_ERROR one or more changes are not legal * * (see README-table-${table} if you don't have dependencies) */ int ${context}_check_dependencies(${context}_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; DEBUGMSGTL(("internal:${context}:${context}_check_dependencies","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:470:o: Check $context row dependencies. * check that all new value are legal and consistent with each other */ ## } @foreach $node nonindex@ @ ifconf syntax-$node.syntax-dependencies.m2i@ @ include syntax-$node.syntax-dependencies.m2i@ if ( MFD_SUCCESS != rc ) return rc; @ end@ @end@ # for each ## { return rc; } /* ${context}_check_dependencies */ ## ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 11989 $ */ @end@ mib2c-data/mfd-persistence.m2i 0000666 00000036007 15077166074 0012177 0 ustar 00 ######################################################################## ## generic include for XXX. Do not use directly. ## $Id: mfd-persistence.m2i 15990 2007-03-23 09:19:51Z dts12 $ ######################################################################## @if $m2c_mark_boundary == 1@ /** START code generated by $RCSfile$ $Revision: 15990 $ */ @end@ ######################################################################## @if $m2c_processing_type eq 'h'@ /* ********************************************************************* * Persistent declarations */ /* * persistence */ #define LINE_TERM_CHAR '$' void ${context}_container_init_persistence( netsnmp_container * container ); int ${context}_container_should_save(${context}_rowreq_ctx * rowreq_ctx); @end@ // m2c_processing_type eq 'h' ###################################################################### ###################################################################### ###################################################################### @if $m2c_processing_type eq 'c'@ /************************************************************ * the *_should_save routine is called to determine if a row * should be stored persistently. * * Note that this is not a 'dirty' check (i.e. if a row has changed), * but a check for volatile rows that should not be saved between * restarts. * * return 1 if the row should be stored * return 0 if the row should not be stored */ int ${context}_container_should_save(${context}_rowreq_ctx * rowreq_ctx) { @ foreach $node column@ @ if "$node.syntax" eq "StorageType"@ @ include m2c_setup_node.m2i@ if (SNMP_STORAGE_VOLATILE == $m2c_ctx_rh ) return 0; @ end@ @ end@ return 1; /* save the row */ } @end@ // m2c_processing_type eq 'h' ###################################################################### ###################################################################### ###################################################################### @if $m2c_processing_type eq 'i'@ /*********************************************************************** * * PERSISTENCE * ***********************************************************************/ static int _${context}_container_save_rows(int majorID, int minorID, void *serverarg, void *clientarg); static void _${context}_container_row_restore(const char *token, char *buf); static int _${context}_container_row_save( ${context}_rowreq_ctx *rowreq_ctx, void *type); static char * _${context}_container_col_restore( ${context}_rowreq_ctx *rowreq_ctx, u_int col, char* buf); static char * _${context}_container_col_save( ${context}_rowreq_ctx *rowreq_ctx, u_int col, char* buf); static char row_token[] = "${context}"; /************************************************************ * *_init_persistence should be called from the main table * init routine. * * If your table depends on rows in another table, * you should register your callback after the other table, * which should ensure the rows on which you depend are saved * (and re-created) before the dependent rows. */ void ${context}_container_init_persistence( netsnmp_container * container ) { int rc; register_config_handler(NULL, row_token, _${context}_container_row_restore, NULL, NULL); rc = snmp_register_callback( SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, _${context}_container_save_rows, container); if( rc != SNMP_ERR_NOERROR ) snmp_log(LOG_ERR, "error registering for STORE_DATA callback " "in _${context}_container_init_persistence\n"); } static int _${context}_container_save_rows(int majorID, int minorID, void *serverarg, void *clientarg) { char sep[] = "##############################################################"; char buf[] = "#\n" "# $context persistent data\n" "#"; char *type = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE); read_config_store((char*)type, sep); read_config_store((char*)type, buf); /* * save all rows */ CONTAINER_FOR_EACH((netsnmp_container*)clientarg, (netsnmp_container_obj_func*)_${context}_container_row_save, type); read_config_store((char*)type, sep); read_config_store((char*)type, "\n"); /* * never fails */ return SNMPERR_SUCCESS; } /************************************************************ * _${context}_container_row_save */ static int _${context}_container_row_save( ${context}_rowreq_ctx *rowreq_ctx, void *type) { /* * Allocate space for a line with all data for a row. An * attempt is made to come up with a default maximum size, but * there is no guarantee it will be enough. It probably will be, * unless you are dealing with large values or you have external * indexes. * * 1) allocate space for each column. Comment out columns you don't * intend to save. You may also need to add room for any non- * column data you want to store. Remeber, data will be stored in * ASCII form, so you need to allow for that. Here are some * general guidelines: * * Object ID : 12 * len [ASCII len of max int + 1 for .] * Octet String: (2 * len) + 2 [2 ASCII chars per byte + "0x"] * Integers : 12 [ASCII len for smallest negative number] * * 2) You also need to allocate space for the row index. This will * be stored as an OID, which means that Octet Strings need to * be treated a little differently. Specifically, you will need * (4 * len) + 4 [3 ASCII chars per byte + 1 for ., + 4 for len]. * * 3) Also, remeber to add space for the identifier and seperator * characters (for example, each column is prefixed by the * column number and a semicolon. To allow for the maximum * column values, 12 bytes [11 for oid + 1 for ':'] per * column are added). */ /** xxx: add storage for external index(s)! */ #define MAX_ROW_SIZE (sizeof(row_token) + 1 + \ @ if $ext_index != 0@ ( 12 * 128 ) + /* external interfaces - max 128 subids */ \ @ end@ @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ @ if ($node.settable == 1)@ @ if "$node.type" eq "ASN_OBJECT_ID"@ ( ( 12 * sizeof(${m2c_ctx_rh}) ) + 3 ) + /* $node.type */ \ @ elsif "$node.type" eq "ASN_OCTET_STR"@ ( ( 2 * sizeof(${m2c_ctx_rh}) ) + 3 ) + /* $node.type */ \ @ else@ ( 12 ) + /* $node.type $node */ \ @ end@ @ end@ @ end@ ( $table.uc_MAX_COL * 12 ) + /* column num prefix + : */ \ 2 /* LINE_TERM_CHAR + \n */ ) char buf[MAX_ROW_SIZE], *pos = buf, *max = &buf[MAX_ROW_SIZE-1]; char *tmp; int i; if (${context}_container_should_save(rowreq_ctx) == 0) { return SNMP_ERR_NOERROR; } /* * build the line */ pos += sprintf(pos, "%s ", row_token); pos = read_config_save_objid(pos, rowreq_ctx->oid_idx.oids, rowreq_ctx->oid_idx.len); if(NULL == pos) { snmp_log(LOG_ERR,"error saving ${context} row " "to persistent file\n"); return SNMP_ERR_GENERR; } *pos++ = ' '; if(pos > max) { snmp_log(LOG_ERR,"error saving ${context} row " "to persistent file (too long)\n"); return SNMP_ERR_GENERR; } /* * add each column */ for(i = $table.uc_MIN_COL; i <= $table.uc_MAX_COL; ++i ) { if ((0x1 << (i-1)) & ~$context.uc_SETTABLE_COLS) continue; tmp = pos; pos = _${context}_container_col_save(rowreq_ctx, i, pos); if(NULL == pos) pos = tmp; else *pos++ = ' '; if(pos > max) { snmp_log(LOG_ERR,"error saving ${context} row " "to persistent file (too long)\n"); return SNMP_ERR_GENERR; } } /* * if you have non-column data, add it here */ /* * store the line */ pos += sprintf(pos, "%c", LINE_TERM_CHAR); if(pos > max) { snmp_log(LOG_ERR,"error saving ${context} row " "to persistent file (too long)\n"); return SNMP_ERR_GENERR; } read_config_store((char*)type, buf); DEBUGMSGTL(("internal:${context}:_${context}_container_row_save", "saving line '%s'\n", buf)); return SNMP_ERR_NOERROR; } static void _${context}_container_row_restore(const char *token, char *buf) { ${context}_rowreq_ctx * rowreq_ctx; netsnmp_index index; oid tmp_oid[ MAX_${context}_IDX_LEN]; u_int col = 0, found = 0; if (strncmp(token, row_token, sizeof(row_token)) != 0) { snmp_log(LOG_ERR, "unknown token in _${context}_container_row_restore\n"); return; } DEBUGMSGTL(("internal:${context}:_${context}_container_row_restore", "parsing line '%s'\n", buf)); /* * pull out index and create default row */ index.oids = tmp_oid; index.len = OID_LENGTH(tmp_oid); buf = read_config_read_objid(buf, &index.oids, &index.len); if (NULL == buf) { snmp_log(LOG_ERR, "error reading row index in " "_${context}_container_row_restore\n"); return; } rowreq_ctx = _mfd_${context}_rowreq_from_index( &index, NULL ); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "error creating row index in " "_${context}_container_row_restore\n"); return; } /* * loop through and get each column */ buf = skip_white(buf); while ( (NULL != buf) && isdigit(*buf) ) { /* * extract column, skip ':' */ col = (u_int)strtol(buf, &buf, 10); if (NULL == buf) break; if (*buf != ':') { buf = NULL; break; } ++buf; /* skip : */ /* * parse value */ DEBUGMSGTL(("_${context}_container_row_restore", "parsing column %d\n", col)); buf = _${context}_container_col_restore( rowreq_ctx, col, buf ); ++found; } if (0 == found) { snmp_log(LOG_ERR, "error parsing ${context} row; no columns found\n"); ${context}_release_rowreq_ctx( rowreq_ctx ); return; } /* * if you added any non-column data, this is where * you should handle it. */ /* * if the pointer is NULL and we didn't reach the * end of the line, something went wrong. Log message, * delete the row and bail. */ if ((buf == NULL) || (*buf != LINE_TERM_CHAR)) { snmp_log(LOG_ERR, "error parsing ${context} row around column %d\n", col); ${context}_release_rowreq_ctx( rowreq_ctx ); return; } DEBUGMSGTL(("internal:${context}:_${context}_container_row_restore", "inserting row\n")); /* * copy oid index and insert row */ rowreq_ctx->oid_idx.len = index.len; memcpy(rowreq_ctx->oid_idx.oids, index.oids, index.len * sizeof(oid)); CONTAINER_INSERT(${context}_if_ctx.container, rowreq_ctx); } /************************************************************ * _${context}_container_col_save */ static char * _${context}_container_col_save( ${context}_rowreq_ctx *rowreq_ctx, u_int col, char* buf) { if( ( NULL == rowreq_ctx ) || ( NULL == buf )) { snmp_log(LOG_ERR, "bad parameter in " "_${context}_container_col_save\n"); return NULL; } DEBUGMSGTL(("internal:${context}:_${context}_container_col_save", "processing column %d\n", col)); /* * prefix with column number, so we don't ever depend on * order saved. */ buf += sprintf(buf, "%u:", col); /* * save data for the column */ switch(col) { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ case COLUMN_$node.uc: /** $node.syntax = $node.type */ @ if $m2c_node_needlength == 1@ @ if "$node.type" eq "ASN_OBJECT_ID"@ buf = read_config_save_objid(buf, ${m2c_ctx_rh}, ${m2c_ctx_rhs} ); @ else@ # "$node.type" eq "ASN_OCTET_STR"@ buf = read_config_save_octet_string(buf, ${m2c_ctx_rh}, ${m2c_ctx_rhs} ); @ end@ @ elsif "$node.type" eq "ASN_INTEGER"@ buf += sprintf(buf,"%ld",${m2c_ctx_rh}); @ else@ buf += sprintf(buf,"%lu",${m2c_ctx_rh}); @ end@ break; @ end@ # for each default: /** We shouldn't get here */ snmp_log(LOG_ERR, "unknown column %d in " "_${context}_container_col_save\n", col); return NULL; } return buf; } /************************************************************ * _${context}_container_col_restore */ static char * _${context}_container_col_restore( ${context}_rowreq_ctx *rowreq_ctx, u_int col, char* buf) { size_t len; if( ( NULL == rowreq_ctx ) || ( NULL == buf )) { snmp_log(LOG_ERR, "bad parameter in " "_${context}_container_col_restore\n"); return NULL; } DEBUGMSGTL(("verbose:${context}:_${context}_container_col_restore", "processing column %d\n", col)); /* * restore data for the column */ switch(col) { @ foreach $node nonindex@ @ include m2c_setup_node.m2i@ case COLUMN_$node.uc: /** $node.syntax = $node.type */ @ if $m2c_node_needlength == 1@ ${m2c_ctx_rhs} = sizeof(${m2c_ctx_rh}); buf = read_config_read_memory($node.type,buf, (char*)&${m2c_ctx_rh}, (size_t*)&${m2c_ctx_rhs} ); @ if "$node.type" eq "ASN_OBJECT_ID"@ ${m2c_ctx_rhs} /= sizeof(oid); @ end@ @ else@ len = sizeof(${m2c_ctx_rh}); @ if "$node.type" eq "ASN_OCTET_STR"@ # BITS @ eval $m2c_tmp = "ASN_INTEGER"@ @ else@ @ eval $m2c_tmp = $node.type@ @ end@ buf = read_config_read_memory($m2c_tmp, buf, (char*)&${m2c_ctx_rh}, &len); @ end@ @ if $m2c_table_sparse == 1@ if (NULL != buf) rowreq_ctx->column_exists_flags |= COLUMN_$node.uc_FLAG; @ end@ # table sparse break; @ end@ # foreach col default: /** We shouldn't get here */ snmp_log(LOG_ERR, "unknown column %d in " "_${context}_container_col_restore\n", col); return NULL; } return buf; } ## @end@ // $m2c_processing_type eq 'i' ######################################################################## @if $m2c_mark_boundary == 1@ /** END code generated by $RCSfile$ $Revision: 15990 $ */ @end@ snmpconf-data/snmp-data/snmpconf-config 0000666 00000000027 15077166074 0014213 0 ustar 00 forconffile: snmp.conf snmpconf-data/snmp-data/output 0000666 00000006021 15077166074 0012465 0 ustar 00 title Output style options description This section allows you to control how the output of the description various commands will be formated token logTimestamp info Should timestamps be shown on the output info arguments: (1|yes|true|0|no|false) question 1 Should timestamps be shown on the output validanswer 1 ^(1|yes|true|0|no|false)$ token printNumericEnums info Print enums numericly or textually info command line equivelent: -Oe question 1 Print enums numericly info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ token printNumericOids info Print OIDs numericly or textually info command line equivelent: -On question 1 Print enums numericly info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ token dontBreakdownOids info When OIDs contain a index to a table, they are broken info into the displayable pieces and shown to you. info For example the oid vacmSecurityModel.0.3.119.101.115 info is nicely broken down by info default and the string hidden in the oid is shown info to you as vacmSecurityModel.0."wes". This token and the -Ob info option diables this feature and displays it as info vacmSecurityModel.0.3.119.101.115 again. info command line equivelent: -Ob info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ question 1 Disable the breaking-down of OIDs? token escapeQuotes info Should the quotation marks in broken down oids be escaped info If you want to cut and paste oids that have been broken down info into indexes and strings, this will put a backslash in front of them info so your shell will pass them rather than interpret them. info arguments: (1|yes|true|0|no|false) question 1 Should the quotation marks in broken down oids be escaped validanswer 1 ^(1|yes|true|0|no|false)$ token quickPrinting info Make the output simple for quick parsing info This option removes the equal sign and value identifies leaving info just the oid and the value on the output for easier parsing in scripts info command line equivelent: -Oq info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ question 1 Make the output simple for quick parsing token numericTimeticks info Print timeticks as a number and not a time-string info command line equivelent: info arguments: (1|yes|true|0|no|false) question 1 Print timeticks as a number and not a time-string validanswer 1 ^(1|yes|true|0|no|false)$ token suffixPrinting info Shorten OIDs printed to the screen info possible values: info - 0: UCD-style. OIDs are displayed like: info - system.sysUpTime.0 info - 1: deletes all by the last symbolic part of the OID: info - system.sysUpTime.0 becomes sysUpTime.0 info - 2: is a variant of this, adding the name of the MIB info - that defined this object: info - system.sysUpTime.0 becomes SNMPv2-MIB::sysUpTime.0 info - (This is the default with net-snmp v5) info command line equivelent: 0 = -Ou, 1 = -Os, 2 = -OS info arguments: (1|2) question 1 Shorten OIDs (0|1|2) validanswer 1 ^(0|1|2)$ snmpconf-data/snmp-data/mibs 0000666 00000004237 15077166074 0012066 0 ustar 00 title Textual mib parsing description This section controls the textual mib parser. Textual description mibs are parsed in order to convert OIDs, enumerated description lists, and ... to and from textual representations description and numerical representations. token mibdirs info Specifies directories to be searched for mibs. info Adding a '+' sign to the front of the argument appends the new info directory to the list of directories already being searched. info arguments: [+]directory[:directory...] question 1 Enter the list of directories to search through for mibs token mibs info Specifies a list of mibs to be searched for and loaded. info Adding a '+' sign to the front of the argument appends the new info mib name to the list of mibs already being searched for. info arguments: [+]mibname[:mibname...] question 1 Enter the list of mibs to read token mibfile info Loads a particular mib file from a particualar path info arguments: /path/to/mibfile question 1 Enter the mib file name to read token showMibErrors info Should errors in mibs be displayed when the mibs are loaded question 1 Should errors in mibs be displayed when the mibs are loaded info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ token mibWarningLevel info Should warnings about mibs be displayed when the mibs are loaded question 1 Should warnings about mibs be displayed when the mibs are loaded info arguments: 1|2 validanswer 1 ^(1|2)$ token strictCommentTerm info Be strict about about mib comment termination. info Strictly follow comment rules about parsing mibs. info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ question 1 Be strict about about mib comment termination token mibAllowUnderline info Should underlines be allowed in mib symbols (illegal) info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ question 1 Should underlines be allowed in mib symbols token mibReplaceWithLatest info Force replacement of older mibs with known updated ones question 1 Force replacement of older mibs with known updated ones info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ snmpconf-data/snmp-data/debugging 0000666 00000003147 15077166074 0013066 0 ustar 00 title Debugging output options description This section allows debugging output of various kinds to description be turned on or off. token doDebugging info Turns debugging output on or off (0|1) info arguments: (0|1) question 1 Turn debugging on (0|1) validanswer 1 ^(0|1)$ token debugTokens info Debugging tokens specify which lines of debugging info output you'd actually like to see. Each section of code is most info likely instrumented with a particular "tag". So, to see that tag you info would specify it here. Specifying a tag will match against all info tags that begin with that prefix, so the tag "test" will match info "test_function" and "test_something" and... info There are a few special tokens as well: info - ALL: turns on all the tokens (which generates lots of output) info - trace: prints 'trace' lines showing source code files and info - line numbers as they're traversed. info - dump: Nicely breaks down packets as they're parsed or sent out. info command line equivelent: -Dtoken[,token...] info arguments: token[,token...] question 1 Enter the tokens (comma seperated) you wish to see output for token dumpPacket info Print packets as they are received or sent info arguments: (1|yes|true|0|no|false) info command line equivelent: -d validanswer 1 ^(1|yes|true|0|no|false)$ question 1 Print packets as they are received or sent token noTokenWarnings info Silence warnings about unknown tokens in configuration files question 1 Silence warnings about unknown tokens in configuration files info arguments: (1|yes|true|0|no|false) validanswer 1 ^(1|yes|true|0|no|false)$ snmpconf-data/snmp-data/authopts 0000666 00000005427 15077166074 0013005 0 ustar 00 title Default Authentication Options description This section defines the default authentication description information. Setting these up properly in your description ~/.snmp/snmp.conf file will greatly reduce the amount of description command line arguments you need to type (especially for snmpv3). token defaultPort info The default port number to use info This token specifies the default port number you want packets to info be sent to and received from. info override: with -p on the command line. info arguments: portnum question 1 Enter the default port number to use token defVersion info The default snmp version number to use. info override: with -v on the command line. info arguments: 1|2c|3 question 1 Enter the default snmp version number to use (1|2c|3) validanswer 1 ^(1|2c|3)$ token defCommunity info The default snmpv1 and snmpv2c community name to use when needed. info If this is specified, you don't need to include the community info name as an argument to the snmp applications. info override: with -c on the command line. info arguments: communityname question 1 Enter the default community name to use token defSecurityName info The default snmpv3 security name to use when using snmpv3 info override: with -u on the command line. info arguments: securityname question 1 Enter the default security name to use token defContext info The default snmpv3 context name to use info override: with -n on the command line. info arguments: contextname question 1 Enter the default context name to use token defSecurityLevel info The default snmpv3 security level to use info override: with -l on the command line. info arguments: noAuthNoPriv|authNoPriv|authPriv question 1 Enter the default privacy pass phrase to use validanswer 1 ^(noAuthNoPriv|authNoPriv|authPriv|nanp|anp|ap)$ token defAuthType info The default snmpv3 authentication type name to use info override: with -a on the command line. info arguments: authtype question 1 Enter the default authentication type to use (MD5|SHA) validanswer 1 ^(MD5|SHA)$ token defAuthPassphrase info The default snmpv3 authentication pass phrase to use info Note: It must be at least 8 characters long. info override: with -A on the command line. info arguments: passphrase question 1 Enter the default authentication pass phrase to use token defPrivType info The default snmpv3 privacy (encryption) type name to use info override: with -x on the command line. info arguments: privtype question 1 Enter the default privacy type to use (DES|AES) validanswer 1 ^(DES|AES)$ token defPrivPassphrase info The default snmpv3 privacy pass phrase to use info Note: It must be at least 8 characters long. info override: with -X on the command line. info arguments: passphrase question 1 Enter the default privacy pass phrase to use proc/1203/net/snmp 0000666 00000000000 15077166153 0007567 0 ustar 00 proc/7600/net/snmp 0000666 00000000000 15077257076 0007603 0 ustar 00 proc/873/net/snmp 0000666 00000000000 15077257377 0007534 0 ustar 00 proc/1500/net/snmp 0000666 00000000000 15077271105 0007561 0 ustar 00 proc/589/net/snmp 0000666 00000000000 15077273222 0007523 0 ustar 00 proc/549/net/snmp 0000666 00000000000 15077273231 0007517 0 ustar 00 proc/1210/net/snmp 0000666 00000000000 15077275266 0007573 0 ustar 00 proc/1118/net/snmp 0000666 00000000000 15077275341 0007574 0 ustar 00 proc/1110/net/snmp 0000666 00000000000 15077275342 0007565 0 ustar 00 proc/3594/net/snmp 0000666 00000000000 15077275414 0007607 0 ustar 00 proc/1457/net/snmp 0000666 00000000000 15077313674 0007604 0 ustar 00 proc/31600/net/snmp 0000666 00000000000 15077313762 0007653 0 ustar 00 proc/528/net/snmp 0000666 00000000000 15077313775 0007524 0 ustar 00 proc/688/net/snmp 0000666 00000000000 15077314043 0007520 0 ustar 00 proc/1/net/snmp 0000666 00000000000 15077347003 0007335 0 ustar 00
| ver. 1.4 |
Github
|
.
| PHP 5.4.45-1~dotdeb+6.1 | Генерация страницы: 0.03 |
proxy
|
phpinfo
|
Настройка