ホームページ >データベース >mysql チュートリアル >用NET-SNMP软件包开发简单客户端代理(6)

用NET-SNMP软件包开发简单客户端代理(6)

WBOY
WBOYオリジナル
2016-06-07 15:30:581142ブラウズ

6.3.4 ExampleTable_access.h /*ExampleTable_access.h*/ /* * Note: this file originally auto-generated by mib2c using * :mib2c.access_functions.conf,v 1.9 2004/10/14 12:57:33 dts12 Exp $ */ #ifndef EXAMPLETABLE_ACCESS_H #define EXAMPLETABLE_

6.3.4       ExampleTable_access.h

/*ExampleTable_access.h*/

/*

 * Note: this file originally auto-generated by mib2c using

 *        : mib2c.access_functions.conf,v 1.9 2004/10/14 12:57:33 dts12 Exp $

 */

#ifndef EXAMPLETABLE_ACCESS_H

#define EXAMPLETABLE_ACCESS_H

 

/** User-defined data access functions for data in table ExampleTable */

/** row level accessors */

Netsnmp_First_Data_Point  ExampleTable_get_first_data_point;

Netsnmp_Next_Data_Point   ExampleTable_get_next_data_point;

int ExampleTable_commit_row(void **my_data_context, int new_or_del);

void * ExampleTable_create_data_context(netsnmp_variable_list *index_data, int column);

 

/** column accessors */

      long *get_MachineNumber(void *data_context, size_t *ret_len);

      char *get_MachineStatus(void *data_context, size_t *ret_len);

      u_long *get_CheckTime(void *data_context, size_t *ret_len);

      long *get_MonSet(void *data_context, size_t *ret_len);

      int set_MonSet(void *data_context, long *val, size_t val_len);

 

#endif /* EXAMPLETABLE_ACCESS_H */

 

6.3.5       ExampleTable_checkfns.c

/*ExampleTable_checkfns.c*/

/*

 * Note: this file originally auto-generated by mib2c using

 *        : mib2c.check_values.conf,v 1.8 2004/01/12 00:43:45 rstory Exp $

 */

 

/********************************************************************

 *                       NOTE   NOTE   NOTE

 *   This file is auto-generated and SHOULD NOT BE EDITED by hand.

 *   Modify the ExampleTable_checkfns_local.[ch] files insead so that you

 *   can regenerate this one as mib2c improvements are made.

 ********************************************************************/

 

/* standard headers */

#include

#include

#include "ExampleTable_checkfns.h"

#include "ExampleTable_checkfns_local.h"

#include "ExampleTable_enums.h"

 

/** Decides if an incoming value for the MonSet mib node is legal.

 *  @param type    The incoming data type.

 *  @param val     The value to be checked.

 *  @param val_len The length of data stored in val (in bytes).

 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.

 */

    int

    check_MonSet(int type, long *val, size_t val_len,

             long *old_val, size_t old_val_len) {

 

    int ret;

 

    /** Check to see that we were called legally */

      if (!val)

        return SNMP_ERR_GENERR;

 

    /** Check the incoming type for correctness */

      if (type != ASN_INTEGER)

        return SNMP_ERR_WRONGTYPE;

 

       ret = SNMP_ERR_NOERROR;

 

 

    /** looks ok, call the local version of the same function. */

      return check_MonSet_local(type, val, val_len, old_val, old_val_len);

    }

6.3.6       ExampleTable_checkfns.h

/*ExampleTable_checkfns.h*/

/*

 * Note: this file originally auto-generated by mib2c using

 *        : mib2c.iterate.conf,v 5.6 2003/02/20 00:52:07 hardaker Exp $

 */

 

/***********************************************************************

 *   This file is auto-generated and SHOULD NOT BE EDITED by hand.

 *   Modify the ExampleTable_checkfns_local.[ch] files insead.

 *   (so that you can regenerate this one as mib2c improvements are made)

 ***********************************************************************/

#ifndef EXAMPLETABLE_CHECKFNS_H

#define EXAMPLETABLE_CHECKFNS_H

 

/** make sure we load the functions that you can modify */

config_require(ExampleTable_checkfns_local)

 

/* these functions are designed to check incoming values for

columns in the ExampleTable table for legality with respect to

datatype and value.

 */

 

      int check_MonSet(int type, long *val, size_t val_len, long *old_val, size_t old_val_len);

 

#endif /* EXAMPLETABLE_CHECKFNS_H */

 

6.3.7       ExampleTable_checkfns_local.c

/*ExampleTable_checkfns_local.c*/

/*

 * Note: this file originally auto-generated by mib2c using

 *        : mib2c.check_values_local.conf,v 5.2 2004/05/04 23:34:56 hardaker Exp $

 */

 

/* standard headers */

#include

#include

#include "ExampleTable_checkfns.h"

#include "ExampleTable_enums.h"

 

/** Decides if an incoming value for the MonSet mib node is legal, from a local implementation specific viewpoint.

 *  @param type    The incoming data type.

 *  @param val     The value to be checked.

 *  @param val_len The length of data stored in val (in bytes).

 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.

 */

    int

    check_MonSet_local(int type, long *val, size_t val_len, long *old_val, size_t old_val_len) {

 

    /** XXX: you may want to check aspects of the new value that

       were not covered by the automatic checks by the parent function. */

 

    /** XXX: you make want to check that the requested change from

        the old value to the new value is legal (ie, the transistion

        from one value to another is legal */

     

    /** if everything looks ok, return SNMP_ERR_NOERROR */

      return SNMP_ERR_NOERROR;

    }

6.3.8       ExampleTable_checkfns_local.h

/*ExampleTable_checkfns_local.h*/

/*

 * Note: this file originally auto-generated by mib2c using

 *        : : mib2c.check_values_local.conf,v 5.2 2004/05/04 23:34:56 hardaker Exp $

 *

 */

#ifndef EXAMPLETABLE_CHECKFNS_H

#define EXAMPLETABLE_CHECKFNS_H

 

/* these functions are designed to check incoming values for

columns in the ExampleTable table for legality with respect to

datatype and value according to local conventions.  You should modify

them as appropriate.  They will be called from parent check_value

functions that are auto-generated using mib2c and the parent functions

should NOT be modified.

 */

 

    int check_MonSet_local(int type, long *val, size_t val_len, long *old_val, size_t old_val_len);

 

#endif /* EXAMPLETABLE_CHECKFNS_H */

 

6.3.9       ExampleTable_columns.h

/* ExampleTable_columns.h*/

/*

 * Note: this file originally auto-generated by mib2c using

 *  : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker Exp $

 */

#ifndef EXAMPLETABLE_COLUMNS_H

#define EXAMPLETABLE_COLUMNS_H

 

/* column number definitions for table ExampleTable */

       #define COLUMN_MACHINENUMBER        1

       #define COLUMN_MACHINESTATUS          2

       #define COLUMN_CHECKTIME           3

       #define COLUMN_MONSET         4

#endif /* EXAMPLETABLE_COLUMNS_H */

6.3.10   ExampleTable_enums.h

/* ExampleTable_enums.h*/

/*

 * Note: this file originally auto-generated by mib2c using

 *  : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker Exp $

 */

#ifndef EXAMPLETABLE_ENUMS_H

#define EXAMPLETABLE_ENUMS_H

 

#endif /* EXAMPLETABLE_ENUMS_H */

6.4 自定义mib文件MyMib.txt

MyMIB DEFINITIONS::=BEGIN

       IMPORTS     

              enterprises,OBJECT-TYPE,Integer32,TimeTicks

                     FROM SNMPv2-SMI

       TEXTUAL-CONVENTION,  DisplayString FROM SNMPv2-TC;

       foxmail OBJECT IDENTIFIER::={enterprises 310}

       SecondCounter OBJECT-TYPE

              SYNTAX Integer32

              ACCESS read-write

              STATUS mandatory

                DESCRIPTION "This is a one minute counter from year 1970.1.1.0:0 to now"

              ::={foxmail 1}

 

       WeekTime OBJECT-TYPE

              SYNTAX TimeTicks

              ACCESS read-only

              STATUS mandatory

                DESCRIPTION "Recording taday's time and the day sorts in the week"

              ::={foxmail 2}

 

       ExampleTable        OBJECT-TYPE

              SYNTAX SEQUENCE OF ExampleEntry

              MAX-ACCESS  not-accessible

              STATUS current

              DESCRIPTION

            "A list of interface entries.  The number of entries is

            given by the value of ExampleNumber."

                  ::= { foxmail 3 }

 

       ExampleEntry OBJECT-TYPE

                  SYNTAX      ExampleEntry

                  MAX-ACCESS  not-accessible

                  STATUS      current

                  DESCRIPTION

            "An entry containing management information applicable to a

            particular interface."

                  INDEX   { UserIndex }

                  ::= { ExampleTable 1 }

 

       ExampleEntry ::=

                  SEQUENCE {

                             UserIndex           InterfaceIndex,

                             UserStatus           DisplayString,

                             CheckTime               TimeTicks,

                            MonSet                  Integer32

                            }     

 

  InterfaceIndex ::= TEXTUAL-CONVENTION

    DISPLAY-HINT "d"

    STATUS       current

    DESCRIPTION

            "A unique value, greater than zero, for each interface or

            interface sub-layer in the managed system.  It is

            recommended that values are assigned contiguously starting

            from 1.  The value for each interface sub-layer must remain

            constant at least from one re-initialization of the entity's

            network management system to the next re-initialization."

    SYNTAX       Integer32 (1..2147483647)

 

 

       UserIndex OBJECT-TYPE

                  SYNTAX      InterfaceIndex

              MAX-ACCESS  read-only

              STATUS      current

                  DESCRIPTION

            "A unique value, greater than zero, for each interface.  It

            is recommended that values are assigned contiguously

            starting from 1.  The value for each interface sub-layer

            must remain constant at least from one re-initialization of

            the entity's network management system to the next re-

            initialization."

                ::= { ExampleEntry 1 }

 

       UserStatus OBJECT-TYPE

                  SYNTAX      DisplayString

                  MAX-ACCESS  read-only

                  STATUS      current

                  DESCRIPTION

            "machine status ."

                  ::= { ExampleEntry 2 }

 

       CheckTime OBJECT-TYPE

                  SYNTAX      TimeTicks

                  MAX-ACCESS  read-only

                  STATUS      current

                  DESCRIPTION

            "machine status checking time."

                  ::= { ExampleEntry 3 }

 

       MonSet OBJECT-TYPE

              SYNTAX Integer32

              MAX-ACCESS read-write

              STATUS current

              DESCRIPTION

             "An example to use set function."

              ::={ ExampleEntry 4}

END

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。