--===============1882606100==
Content-Type: multipart/alternative; boundary=Apple-Mail-1-268814415


--Apple-Mail-1-268814415
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

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
--Apple-Mail-1-268814415
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=ISO-8859-1

-khtml-line-break: after-white-space; ">Could anyone tell me what i am =
doing wrong here? I have=A0 the following piece of code, in which i test =
for the sysUpTime (ASN_TIMETICKS?) and for status of ipForwarding =
(INTEGER) and ifNumber (also INTEGER).

class=3D"khtml-block-placeholder">
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.

class=3D"khtml-block-placeholder">
This is what i do (red =
color is what matters):
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">=A0
face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">/* Manipulate the information ourselves =
*/
margin-bottom: 0px; margin-left: 0px; "> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">=A0 =A0 class=3D"Apple-style-span" color=3D"#760F50" face=3D"Monaco" =
size=3D"2"> 10px;">for
size=3D"2"> 10px;">(vars=3Dresponse->variables;vars;vars=3Dvars->next_variable) =
{
margin-bottom: 0px; margin-left: 0px; "> style=3D"white-spacere"> color=3D"#760F50" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">if
size=3D"2"> 10px;">(vars->type=3D=3DASN_OCTET_STR) {
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> color=3D"#760F50" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">char
size=3D"2"> =
*sp=3D(
face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">char class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> =
*)malloc(
face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">1 face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">+vars->val_len);
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: =
10px;">memcpy(sp,vars->val.string,vars->val_len);

>

margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">sp[vars->val_len]=3D class=3D"Apple-style-span" color=3D"#0000FF" face=3D"Monaco" =
size=3D"2"> 10px;">'\0'
size=3D"2"> 10px;">;

min-height: 14.0px"> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;">=A0
class=3D"khtml-block-placeholder">

margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" color=3D"#236E25" face=3D"Monaco" =
size=3D"2"> 10px;">/* Fill in second part of database struct =
*/
margin-bottom: 0px; margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> color=3D"#760F50" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">if
size=3D"2"> 10px;">(i=3D=3D color=3D"#0000FF" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">0
size=3D"2">) =
data->sysDescr=3Dstrdup(sp);

0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere">
class=3D"khtml-block-placeholder">

margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" color=3D"#760F50" face=3D"Monaco" =
size=3D"2"> 10px;">if
size=3D"2"> 10px;">(i=3D=3D color=3D"#0000FF" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">2
size=3D"2">) =
data->sysContact=3Dstrdup(sp);
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> color=3D"#760F50" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">if
size=3D"2"> 10px;">(i=3D=3D color=3D"#0000FF" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">3
size=3D"2">) =
data->sysName=3Dstrdup(sp);
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> style=3D"white-spacere"> color=3D"#760F50" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">if
size=3D"2"> 10px;">(i=3D=3D color=3D"#0000FF" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">4
size=3D"2">) =
data->sysLocation=3Dstrdup(sp);
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 10px/normal Monaco; =
min-height: 14px; ">

0.0px; min-height: 14.0px"> style=3D"white-spacere">
class=3D"khtml-block-placeholder">

margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">free(sp);
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">}
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
10px/normal Monaco; min-height: 14px; ">
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">if face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">(vars->type=3D=3DASN_TIMETICKS) =
{
0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">if class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" =
color=3D"#FF4B54">(i=3D=3D
class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">1 class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">) =
data->sysUpTime=3Dvars->val.integer;
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">}

0.0px 0.0px 0.0px; min-height: 14.0px"> style=3D"white-spacere"> color=3D"#FF4B54">

style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">if face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">(vars->type=3D=3DASN_INTEGER) =
{
0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">if class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" =
color=3D"#FF4B54">(i=3D=3D
class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">5 class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">) =
data->ipForwarding=3Dvars->val.integer;
IV style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">if face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">(i=3D=3D class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">6 class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: 10px;"> class=3D"Apple-style-span" color=3D"#FF4B54">) =
data->ifNumber=3Dvars->val.integer;
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; "> style=3D"white-spacere"> face=3D"Monaco" size=3D"2"> style=3D"font-size: 10px;"> color=3D"#FF4B54">}

0.0px 0.0px 0.0px; min-height: 14.0px"> style=3D"white-spacere">
class=3D"khtml-block-placeholder">

margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">}
0px; margin-bottom: 0px; margin-left: 0px; "> class=3D"Apple-tab-span" style=3D"white-spacere"> class=3D"Apple-style-span" face=3D"Monaco" size=3D"2"> class=3D"Apple-style-span" style=3D"font-size: =
10px;">}
size=3D"2"> 10px;">=A0
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">
class=3D"khtml-block-placeholder">
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.=A0
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; ">
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; ">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.
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">
class=3D"khtml-block-placeholder">
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; =
">Greetings,
margin-bottom: 0px; margin-left: 0px; ">Alef
=

--Apple-Mail-1-268814415--


--===============1882606100==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
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?p...rge&CID=DEVDEV
--===============1882606100==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders

--===============1882606100==--