




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 象棋知识培训教案课件
- 2025年安防产品购销合同书标准范本
- 2025版人工智能产业融资合作协议合同范本
- 2025大连二手房地产抵押贷款服务合同
- 2025年度生态农业产品店铺装修补贴及农产品直销合同
- 2025不锈钢玻璃地弹门工程环保验收及排放合同
- 2025版融资租赁合同违约责任及处理办法
- 2025版智能物流国内货物公路运输服务合同模板
- 请假条说课课件
- 2025制片合同产品样本
- 2025年秋新北师大版数学三年级上册全册教学设计
- 2025-2026人教版(2024)物理九年级全册教学进度表
- 义务教育质量监测学校成绩分析报告
- 2025版房地产抵押按揭续贷合同
- 2025年秋季小学四年级上册语文教学计划及教学进度表
- 北京市西城区2024-2025学年七年级下学期期末道德与法治试题(解析版)
- 2025年广东省高考化学试题(含答案解析)
- 【2025秋新版】三年级上册语文生字组词
- 《智能建造概论》高职完整全套教学课件
- 2025年中小学教师师德师风考试题库及答案
- 节能环保供货保证措施
评论
0/150
提交评论