[Fwd: [Fwd: Re: Problem with sprint_realloc_iteger()]]
Rashmi M Bangera <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
i have included the sections of my code.
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.
The control does not come to get_first_data_item.It fails before that.
helper:table: Got request for handler table: base
oid:SNMPv2-SMI::transmission.7.2
SNMPv2-SMI::transmission.7.2.1.1
trace: table_helper_handler(): table.c, 464:
helper:table: oid indexes not complete: SNMPv2-SMI::transmission.7.2.1.1
trace: table_helper_handler(): table.c, 512:
helper:table: column: 1, indexes: 0trace: sprint_realloc_by_type():
mib.c, 1996:
output: sprint_realloc_by_type, type 2
trace: sprint_realloc_by_type(): mib.c, 2000:
output: ASN_INTEGER:
trace: sprint_realloc_integer(): mib.c, 1299:
output: sprint_realloc_integer
trace: sprint_realloc_integer(): mib.c, 1300:
please help me out regarding this.
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.
>>
>>case MODE_GET:
>> switch (table_info->colnum) {
>> case COLUMN_DOT3STATSINDEX:
>> {
>> long *index;
>> size_t len;
>> index = getIndex(data_context,&len);
>>
>>
>
>And what value does 'index' receive?
>There's no error checking here, and without seeing the
>'getIndex' routine, it's impossible to tell what it
>might be doing.
>
>I would definitely suggest having some debugging code
>within the getIndex routine, so you know exactly what
>values it is returning (for both 'index' and 'len').
>
>Dave
>
>