- 论坛徽章:
- 0
|
我在开发agent方面碰到了一些问题,希望能得到一些帮助.
非常感谢花费时间阅读.
我阅读了 用NET-SNMP软件包开发简单客户端代理.
我读了 <<用net-snmp软件包开发简单客户代理>> 这个文章.其中display_time.c 并没有关于 set的代码.
看了example.{c,h}这个文件,里面有 write的模块,但是有地方看不明白.请您指教一下.具体代码如下.
这个是我的 代码. 我想让我的 set的值 进入essidvar 这个变量中. 但是不知道如何把 set的值通过什么方式传入进去.请指教.
非常感谢了.占用您宝贵的时间.- int essidvar = 8;
- var_wlanSettingTable ( struct variable *vp,
- oid *name,
- size_t *length,
- int exact,
- size_t *var_len,
- WriteMethod ** write_method )
- {
- DEBUGMSGTL(("cpxwlanmib", "var_wlanSettingTable entered\n"));
- char *ptr=NULL;
- if (header_generic(vp, name, length, exact, var_len, write_method) ==
- MATCH_FAILED)
- return NULL;
- //printf("SUNBIN:enter var_wlanSettingTable \n");
- switch ( vp->magic ){
-
- case SSID:
- if(strcmp(SNMPconfGetSectionKey("sys","wlan0","MODE"), "0") == 0)
- ptr = SNMPconfGetSectionKey("sys","wlan0","ESSID");
- else
- ptr = SNMPconfGetSectionKey("sys","wlan0","RESSID");
- *var_len=strlen(ptr);
- *write_method = write_cpxwlanmib;
- return (u_char *) ptr;
- return NULL;
- }
- }
- //我的写函数
- int write_cpxwlanmib(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)
- {/*
- * Define an arbitrary maximum permissible value
- */
- #define MAX_ESSIDVAR 100
- static char intval;
- static char old_intval;
-
- static char tmp[50];
- switch (action) {
- case ACTION:
- /*
- * Set the variable as requested.
- * Note that this may need to be reversed,
- * so save any information needed to do this.
- */
- //old_intval = example_int;
- // old_intval = SNMPconfGetSectionKey("sys","wlan0","RESSID");
- // example_int = intval;
- essidvar = intval;
- sprintf(tmp,"iwconfig ath1 essid eth%d",[color=Red]essidvar[/color]);
- system(tmp);
- break;
- case UNDO:
- .....
- case COMMIT:
- ......
- break;
- }
- return SNMP_ERR_NOERROR;
- }
复制代码 |
|