|
-------- Original Message --------
getIndex method is as follows. long* getIndex(void *data_context,int *len) { udata *ud = data_context; *len = sizeof(ud->ifindex); return &ud->ifindex; } structure udata contains all the interface details fetched from ioctl call in get_first_data_item().Currently i am trying for only one interface,so i am returning NULL in get_next_data_item. dot3StatsTable_get_first_data_point(void **my_loop_context, void **my_data_context, netsnmp_variable_list * put_index_data, netsnmp_iterator_info *mydata) { const char *itfName = "eth0"; ldata *ld; ld = SNMP_MALLOC_TYPEDEF(ldata); long index; if(!ld) return NULL; strncpy(ifr.ifr_name,itfName,5); ifr.ifr_name[4]= '\0'; ld->sockdesc = socket(AF_INET, SOCK_DGRAM, 0); if(ld->sockdesc < 0) { return NULL; } ld->status = ioctl(ld->sockdesc,SIOCDEVPRIVATE,&ifr); if(ld->status < 0) { DEBUGMSGTL(("output","ioctl Error:SIOCDEVPRIVATE\n")); return NULL; } ld->es = (struct estats*)ifr.ifr_data; ld->status = ioctl(ld->sockdesc,SIOCGIFINDEX,&ifr); if(ld->status < 0) { DEBUGMSGTL(("output","ioctl Error:SIOCGIFINDEX \n")); return NULL; } ld->ifindex = (long)ifr.ifr_ifindex; snmp_set_var_value(put_index_data,(u_char *)&ld->ifindex,sizeof(long)); close(ld->sockdesc); ld->sockdesc = 0; *my_loop_context = ld; return put_index_data; } i am using context convert function to copy contents of structure ldata to udata. Dave Shield wrote: On Wed, 2006-03-15 at 12:11 +0530, Rashmi M Bangera wrote:The problem is, when i use snmptable command, the code fails at sprintf() statement in the sprint_realloc_integer() function. |
