⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node-varbind-validate.m2i

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 M2I
字号:
#############################################################  -*- c -*-## generic include for XXX. Do not use directly.#### $Id: node-varbind-validate.m2i,v 1.4 2004/09/09 23:15:38 rstory Exp $#### 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## ------------## $m2c_nvv_sizeof: variable name appropriate for a sizeof() call to##                  check variable length. If NULL, no size check##                  will be done.##########################################################################@if $m2c_mark_boundary == 1@/** START code generated by $RCSfile: node-varbind-validate.m2i,v $ $Revision: 1.4 $ */@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 or is OCTET_STR, length checks are up to user@   if ($m2c_node_needlength == 1) || ("x$m2c_nvv_sizeof" eq "x")@    rc = netsnmp_check_vb_type( var, $node.type );@   else@    rc = netsnmp_check_vb_type_and_size( var, $node.type,        sizeof( $m2c_nvv_sizeof ) );@   end@##----------------------------------------------------------------------## check ENUMS##----------------------------------------------------------------------@   if $node.enums == 1@    if(SNMPERR_SUCCESS == rc) {##------------------------------------------------------@      if "$node.perltype" ne "BITS"@    /* check that the value is one of defined enums */    if( 1@         foreach $e $v enum@@            include m2c_setup_enum.m2i@ && ( *var->val.integer != $m2c_ename )@         end@ # for each        ) {        rc = SNMP_ERR_WRONGVALUE;        }##------------------------------------------------------@      else@ # BITS## {    if(var->val_len > 4) {        snmp_log(LOG_ERR,"I can not handle BITS > 4 bytes\n");        rc = SNMP_ERR_GENERR;    }    else {        u_long bits = 0;        /* check that value is within enum mask */        memcpy( &bits, var->val.string, var->val_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_nvv_func = "netsnmp_check_vb_int_range"@##@         eval $m2c_nvv_rc = "SNMP_ERR_WRONGVALUE"@@      else@@         eval $m2c_nvv_func = "netsnmp_check_vb_size_range"@##@         eval $m2c_nvv_rc = "SNMP_ERR_WRONGLENGTH"@@      end@    if(SNMPERR_SUCCESS == rc) {    /* check that the value is in the defined range(s); inefficent     * but keeps rc value knowledge in libarary where it belongs. */    if( 1@    foreach $a $b range $node@       && ((rc = $m2c_nvv_func(var, $a,$b)) != SNMP_ERR_NOERROR)@    end@     ) {        ; /* rc set in condition */    }   }@   else@    /* yyy-rks: anything else we can do here? */@   end@@end@ # not syntax specific##########################################################################@if $m2c_mark_boundary == 1@/** END code generated by $RCSfile: node-varbind-validate.m2i,v $ $Revision: 1.4 $ */@end@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -