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 accessfunctions 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, intcolumn);
/** 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 originallyauto-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 editedby hand.
* modify the exampletable_checkfns_local.[ch] filesinsead so that you
* can regenerate this one as mib2c improvements aremade.
********************************************************************/
/* standardheaders */
#include
#include
#includeexampletable_checkfns.h
#includeexampletable_checkfns_local.h
#includeexampletable_enums.h
/** decides if anincoming value for the monset mib node is legal.
* @param type theincoming 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 wewere called legally */
if (!val)
return snmp_err_generr;
/** check the incoming typefor correctness */
if (type !=asn_integer)
return snmp_err_wrongtype;
ret =snmp_err_noerror;
/** looks ok, call thelocal version of the same function. */
returncheck_monset_local(type, val, val_len, old_val, old_val_len);
}
6.3.6 exampletable_checkfns.h/*exampletable_checkfns.h*/
/*
* note: this file originallyauto-generated by mib2c using
* : mib2c.iterate.conf,v5.6 2003/02/20 00:52:07 hardaker exp $
*/
/***********************************************************************
* this file is auto-generated and should not be editedby hand.
* modify the exampletable_checkfns_local.[ch] filesinsead.
* (so that you can regenerate this one as mib2cimprovements are made)
***********************************************************************/
#ifndefexampletable_checkfns_h
#defineexampletable_checkfns_h
/** make sure we loadthe functions that you can modify */
config_require(exampletable_checkfns_local)
/* thesefunctions are designed to check incoming values for
columns in theexampletable table for legality with respect to
datatype andvalue.
*/
int check_monset(inttype, 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 originallyauto-generated by mib2c using
* :mib2c.check_values_local.conf,v 5.2 2004/05/04 23:34:56 hardaker exp $
*/
/* standardheaders */
#include
#include
#includeexampletable_checkfns.h
#includeexampletable_enums.h
/** decides if anincoming value for the monset mib node is legal, from a local implementationspecific viewpoint.
* @param type theincoming 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(inttype, long *val, size_t val_len, long *old_val, size_t old_val_len) {
/** xxx: you may want to checkaspects of the new value that
were notcovered by the automatic checks by the parent function. */
/** xxx: you make want tocheck that the requested change from
theold value to the new value is legal (ie, the transistion
fromone value to another is legal */
/** if everything looks ok,return snmp_err_noerror */
returnsnmp_err_noerror;
}
6.3.8 exampletable_checkfns_local.h/*exampletable_checkfns_local.h*/
/*
* note: this file originallyauto-generated by mib2c using
* : :mib2c.check_values_local.conf,v 5.2 2004/05/04 23:34:56 hardaker exp $
*
*/
#ifndefexampletable_checkfns_h
#defineexampletable_checkfns_h
/* thesefunctions are designed to check incoming values for
columns in theexampletable table for legality with respect to
datatype andvalue according to local conventions. you should modify
them asappropriate. they will be calledfrom parent check_value
functions thatare auto-generated using mib2c and the parent functions
should not bemodified.
*/
int check_monset_local(inttype, 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-generatedby mib2c using
* : mib2c.column_defines.conf,v 5.1 2002/05/08 05:42:47 hardaker exp $
*/
#ifndefexampletable_columns_h
#defineexampletable_columns_h
/* column numberdefinitions for table exampletable */
#definecolumn_machinenumber 1
#definecolumn_machinestatus 2
#definecolumn_checktime 3
#definecolumn_monset 4
#endif /*exampletable_columns_h */
6.3.10 exampletable_enums.h/* exampletable_enums.h*/
/*
* note: this file originallyauto-generated by mib2c using
* : mib2c.column_enums.conf,v 5.2 2003/02/22 04:09:25 hardaker exp $
*/
#ifndefexampletable_enums_h
#defineexampletable_enums_h
#endif /*exampletable_enums_h */
6.4 自定义mib文件mymib.txtmymib definitions::=begin
imports
enterprises,object-type,integer32,timeticks
fromsnmpv2-smi
textual-convention, displaystring from snmpv2-tc;
foxmailobject identifier::={enterprises 310}
secondcounterobject-type
syntaxinteger32
accessread-write
statusmandatory
description this is a oneminute counter from year 1970.1.1.0:0 to now
::={foxmail1}
weektime object-type
syntax timeticks
access read-only
status mandatory
description recording taday's time and the day sorts in theweek
::={foxmail 2}
exampletable object-type
syntaxsequence of exampleentry
max-access not-accessible
statuscurrent
description
a list of interface entries. the number of entries is
given by the value of examplenumber.
::={ foxmail 3 }
exampleentryobject-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 interfacesub-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)
userindexobject-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 valuefor 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 }
userstatusobject-type
syntax displaystring
max-access read-only
status current
description
machine status .
::={ exampleentry 2 }
checktimeobject-type
syntax timeticks
max-access read-only
status current
description
machine status checking time.
::={ exampleentry 3 }
monsetobject-type
syntaxinteger32
max-accessread-write
statuscurrent
description
an example to use set function.
::={exampleentry 4}
end
