NET-SNMP服务端添加自定义节点.doc

NET-SNMP服务端添加自定义节点.doc

ID:58821123

大小:171.00 KB

页数:11页

时间:2020-10-25

NET-SNMP服务端添加自定义节点.doc_第1页
NET-SNMP服务端添加自定义节点.doc_第2页
NET-SNMP服务端添加自定义节点.doc_第3页
NET-SNMP服务端添加自定义节点.doc_第4页
NET-SNMP服务端添加自定义节点.doc_第5页
资源描述:

《NET-SNMP服务端添加自定义节点.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、NET-SNMP服务端添加自定义节点编译生成.c和.h文件后,只是一个mib节点文件模板。1代码修改:blue.h/**Note:thisfileoriginallyauto-generatedbymib2cusing*:mib2c.old-api.conf144762006-04-1817:36:51Zhardaker$*/#ifndefBLUE_H#defineBLUE_H/**functiondeclarations*/voidinit_blue(void);FindVarMethodvar_blue;W

2、riteMethodwrite_bluenum;#endif/*BLUE_H*/我们会发现生成的C文件,其实只是一个模版。其中功能实现的地方,以及某些关键地方都留了空,并且有较为详细的英文注释。只需要修改两处即可通过编译,其余部分可根据情况决定是否修改,以及如何修改。blue.c/**Note:thisfileoriginallyauto-generatedbymib2cusing*:mib2c.old-api.conf144762006-04-1817:36:51Zhardaker$*/#include

3、t-snmp/net-snmp-config.h>#include#include#include"blue.h"/**blue_variables_oid:*thisisthetopleveloidthatwewanttoregisterunder.This*isessentiallyaprefix,withthesuffixappearinginthe*variab

4、lebelow.*/oidblue_variables_oid[]={1,3,6,1,4,1,1,1};/**variable4blue_variables:*thisvariabledefinesfunctioncallbacksandtypereturninformation*forthebluemibsection*/structvariable7blue_variables[]={/**magicnumber,variabletype,ro/rw,callbackfn,L,oidsuffix*/#def

5、ineBLUENUM1{BLUENUM,ASN_INTEGER,RWRITE,var_blue,1,{4}},};/**(L=lengthoftheoidsuffix)*//**Initializesthebluemodule*/voidinit_blue(void){DEBUGMSGTL(("blue","Initializing"));/**registerourselveswiththeagenttohandleourmibtree*/REGISTER_MIB("blue",blue_variable

6、s,variable4,blue_variables_oid);/**placeanyotherinitializationjunkyouneedhere*/}/**var_blue():*Thisfunctioniscalledeverytimetheagentgetsarequestfor*ascalarvariablethatmightbefoundwithinyourmibsection*registeredabove.Itisuptoyoutodotherightthingand*returnthec

7、orrectvalue.*Youshouldalsocorrectthevalueof"var_len"ifnecessary.**Pleaseseethedocumentationformoreinformationaboutwriting*moduleextensions,andcheckouttheexamplesintheexamples*andmibIIdirectories.*/unsignedchar*var_blue(structvariable*vp,oid*name,size_t*lengt

8、h,intexact,size_t*var_len,WriteMethod**write_method){/**variableswemayuselater*/staticlonglong_ret;staticu_longulong_ret;staticunsignedcharstring[SPRINT_MAX_LEN];staticoidobjid[MAX_OID_LEN];stat

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。