文档详情

snmp源码分析.doc

发布:2015-09-21约1.42万字共13页下载文档
文本预览下载声明
#include net-snmp/net-snmp-config.h #include net-snmp/net-snmp-includes.h #include net-snmp/agent/net-snmp-agent-includes.h #if HAVE_STDLIB_H #include stdlib.h #endif #if TIME_WITH_SYS_TIME # ifdef WIN32 # include sys/timeb.h # else # include sys/time.h # endif # include time.h #else # if HAVE_SYS_TIME_H # include sys/time.h # else # include time.h # endif #endif #include util_funcs.h 包含自己的头文件 #include Display_time.h #define EXAMPLE_STR_LEN 300 #define EXAMPLE_STR_DEFAULT life the universe and everything int???????????? example_int = 42; char??????????? example_str[EXAMPLE_STR_LEN]; void??????????? example_parse_config_exampleint(const char *token, char *cptr); void??????????? example_parse_config_examplestr(const char *token, char *cptr); void??????????? example_free_config_exampleint(void); void??????????? example_free_config_examplestr(void); 这个数组的类型是struct variableN, 其中N是这个数组中OID号的最长的数, 即:结构体最后一个成员(这个成员是个数组)定义了MIB Tree OID的底层数字。 ??? N定义了MIB Tree OID的底层的层数(也就是这个数组的长度)。 ??? 所有有效的N数字都定义在了agent/var_struct.h文件中。 struct variableN类型成员的说明: ??? 1):FoxmailINT:这个magic number是在自己的头文件Display_time.h中宏定义, ??? ??? ??? ??? ?????? 这个参数被用来传递给CallBack 例程,用来决定那个object被查询。 ??? 2):ASN_INTEGER:这个参数说明了object的类型,所有有效的类型在snmp_impl.h文件中列表说明。 ??? 3):RONLY:这个参数说明了object是否能够被set。 ??? 4):var_foxmail:当有object被查询时,这个CallBack 例程被调用。 ??? ??? ??? ??? ??? 一般的情况下,同一个文件中的所有的object使用相同的allBack 例程。 ??? 5):1:MIB Tree OID的底层数字的层数。(这个数字决定了struct variableN中的N) ??? 6):{1}:MIB Tree OID的底层数字。 struct variable2 example_variables[] = { ??? {EXAMPLESTRING, ASN_OCTET_STR, RONLY, var_example, 1, {1}}, ??? {EXAMPLEINTEGER, ASN_INTEGER, RWRITE, var_example, 2, {2, 1}}, ??? {EXAMPLEOBJECTID, ASN_OBJECT_ID, RONLY, var_example, 2, {2, 2}}, ??? {EXAMPLETIMETICKS, ASN_TIMETICKS, RONLY, var_example, 1, {3}}, ??? {EXAMPLEIPADDRESS, ASN_IPADDRESS, RONLY, var_example, 1, {4}}, ??? {EXAMPLECOUNTER, ASN_COUNTER, RONLY, var_example, 1, {5}}, ??? {EXAMPLEGAUGE, ASN_GAUGE, RONLY, var_example, 1, {6}}, ??? {EXAMPLETRIGGE
显示全部
相似文档