Could anyone tell me what i am doing wrong here? I have the following piece of code, in which i test for the sysUpTime (ASN_TIMETICKS?) and for status of ipForwarding (INTEGER) and ifNumber (also INTEGER).

I guessed the ASN values, but i get a match so i assume they are right. Now, i looked in the /usr/include/net-snmp/library/snmp-api.h and looked up the value of 'vars->val.integer' and 'vars- >val.string'. The first is a pointer to long and the second is a u_char pointer. So i declared those same types in my struct.

This is what i do (red color is what matters):
 /* Manipulate the information ourselves */
    for(vars=response->variables;vars;vars=vars->next_variable) {
        if(vars->type==ASN_OCTET_STR) {
                char *sp=(char *)malloc(1+vars->val_len);
                memcpy(sp,vars->val.string,vars->val_len);
                sp[vars->val_len]='\0';
        
                /* Fill in second part of database struct */
                if(i==0) data->sysDescr=strdup(sp);
                
                if(i==2) data->sysContact=strdup(sp);
                if(i==3) data->sysName=strdup(sp);
                if(i==4) data->sysLocation=strdup(sp);

        
                free(sp);
                }

        if(vars->type==ASN_TIMETICKS) {
        if(i==1) data->sysUpTime=vars->val.integer;
        }
        
        if(vars->type==ASN_INTEGER) {
        if(i==5) data->ipForwarding=vars->val.integer;
        if(i==6) data->ifNumber=vars->val.integer;
        }
        
                        }
        }

However, i get some number in my long * (like 218232) which definitately doesn't match up with uptime. This also goes for the integers. I don't know what i'm doing wrong, i'm just exchanging the pointers.

thanks for any help. Oh, whilst i'm at it, does anyone know if there is a mib value that you can read to get the subnetmask value? I can't seem to find it.

Greetings,
Alef
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to