已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
NET-SNMP服务端添加自定义节点编译生成.c和.h文件后,只是一个mib节点文件模板。1 代码修改:blue.h/* * Note: this file originally auto-generated by mib2c using * : mib2c.old-api.conf 14476 2006-04-18 17:36:51Z hardaker $ */#ifndef BLUE_H#define BLUE_H/* * function declarations */void init_blue(void);FindVarMethod var_blue;WriteMethod write_bluenum;#endif /* BLUE_H */我们会发现生成的C文件,其实只是一个模版。其中功能实现的地方,以及某些关键地方都留了空,并且有较为详细的英文注释。只需要修改两处即可通过编译,其余部分可根据情况决定是否修改,以及如何修改。blue.c/* * Note: this file originally auto-generated by mib2c using * : mib2c.old-api.conf 14476 2006-04-18 17:36:51Z hardaker $ */#include #include #include #include blue.h/* * blue_variables_oid: * this is the top level oid that we want to register under. This * is essentially a prefix, with the suffix appearing in the * variable below. */oid blue_variables_oid = 1, 3, 6, 1, 4, 1, 1, 1 ;/* * variable4 blue_variables: * this variable defines function callbacks and type return information * for the blue mib section */struct variable7 blue_variables = /* * magic number , variable type , ro/rw , callback fn , L, oidsuffix */#define BLUENUM1 BLUENUM, ASN_INTEGER, RWRITE, var_blue, 1, 4,;/* * (L = length of the oidsuffix) */* Initializes the blue module */voidinit_blue(void) DEBUGMSGTL(blue, Initializingn); /* * register ourselves with the agent to handle our mib tree */ REGISTER_MIB(blue, blue_variables, variable4, blue_variables_oid); /* * place any other initialization junk you need here */* * var_blue(): * This function is called every time the agent gets a request for * a scalar variable that might be found within your mib section * registered above. It is up to you to do the right thing and * return the correct value. * You should also correct the value of var_len if necessary. * * Please see the documentation for more information about writing * module extensions, and check out the examples in the examples * and mibII directories. */unsigned char *var_blue(struct variable *vp, oid * name, size_t *length, int exact, size_t *var_len, WriteMethod * write_method) /* * variables we may use later */ static long long_ret; static u_long ulong_ret; static unsigned char stringSPRINT_MAX_LEN; static oid objidMAX_OID_LEN; static struct counter64 c64; if (header_generic(vp, name, length, exact, var_len, write_method) = MATCH_FAILED) return NULL; /* * this is where we do the value assignments for the mib results. */ switch (vp-magic) case BLUENUM: *write_method = write_bluenum; VAR = VALUE; /* XXX */ /* 编译 时 此两处会报错。注释此行 return (u_char *) & VAR; /* 修改完毕可正常编译安装 将&VAR修 default: /* 改为固定值 ERROR_MSG(); return NULL;intwrite_bluenum(int action, u_char * var_val, u_char var_val_type, size_t var_val_len, u_char * statP, oid * name, size_t name_len) long value; int size; switch (action) case RESERVE1: if (var_val_type != ASN_INTEGER) fprintf(stderr, write to blue not ASN_INTEGERn); return SNMP_ERR_WRONGTYPE; if (var_val_len sizeof(long) fprintf(stderr, write to blue: bad lengthn); return SNMP_ERR_WRONGLENGTH; break; case RESERVE2: size = var_val_len; value = *(long *) var_val; break; case FREE: /* * Release any resources that have been allocated */ break; case ACTION: /* * The variable has been stored in value for you to use, * and you have just been asked to do something with it. * Note that anything done here must be reversable in the UNDO case */ break; case UNDO: /* * Back out any changes made in the ACTION case */ break; case COMMIT: /* * Things are working well, so its now safe to make the change * permanently. Make sure that anything done here cant fail! */ break; return SNMP_ERR_NOERROR;2 mib的
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年浙江金华科贸职业技术学院单招职业适应性测试题库附答案
- 2026年安徽矿业职业技术学院单招职业倾向性测试必刷测试卷附答案
- 2026年郑州电子商务职业学院单招职业倾向性考试必刷测试卷必考题
- 2025青海时代新能源科技有限公司专场招聘笔试历年参考题库附带答案详解
- 2025重庆忠县畅达建设投资有限公司招聘专业人员1人笔试历年参考题库附带答案详解
- 2025辽宁葫芦岛市兴城市城建交通集团有限公司招聘5人笔试历年参考题库附带答案详解
- 2026年江西水利职业学院单招职业适应性考试题库新版
- 2026年重庆城市职业学院单招职业技能测试题库附答案
- 2026年四川工业科技学院单招职业倾向性测试题库新版
- 2025福建莆田国企秀屿区石南轮渡有限公司招聘16名职务船员笔试历年参考题库附带答案详解
- 充电桩备案申请书
- 全国中小学“学宪法、讲宪法”知识素养竞赛题库及答案
- 单位涉密人员保密审查表
- 国家职业技术技能标准 5-05-05-01 农机驾驶操作员 2024年版
- MOOC 食品营养学-福建农林大学 中国大学慕课答案
- 【S药业有限公司期间费用管理探究15000字(论文)】
- 写作-写景如在眼前 课件 2024年高教版(2023)中职语文基础模块上册
- 中国人寿收展基本法课件
- 变电运维管理规定(试行)第3分册组合电器运维细则
- (完整word版)英语四级单词大全
- 铁路局技术和统计科QC小组降低电梯故障发生率确保旅客人身安全成果汇报
评论
0/150
提交评论