This is a discussion on Re: How to GET a COUNTER32 variable ???? within the SNMP Users forums, part of the Networking and Network Related category; On Mon, 2005-05-16 at 18:59, Gemma S=E1nchez wrote: > Now, I need to GET the value ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Mon, 2005-05-16 at 18:59, Gemma S=E1nchez wrote:
> Now, I need to GET the value of this variable from my program, so I hav= e=20 > write the next piece of code: >=20 > peticion =3D snmp_pdu_create(SNMP_MSG_GET); > snmp_add_null_var(peticion, aeIndLibre_oid, OID_LENGTH(aeIndLibre_oid)= ); And what is the value of 'aeIndLibre_oid' ? In particular, is it { ....., 1 } (the OID of the aeIndLibre object) or { ....., 1, 0 } (the OID of the aeIndLibre *instance*) ? > auxint =3D snmp_synch_response(sesionAgente, peticion, &respuesta); > auxint =3D *(respuesta->variables->val.integer); Do you have some sort of religious object to checking return codes? First you ought to check the result of 'snmp_synch_response' to make sure that sending the request worked (auxint =3D=3D STAT_SUCCESS). Then you ought to check the 'errstat' field of the response PDU, to make sure that the agent sent back the expected answer. *Then* (and only then) can you look at the 'variables' list. > Obviously, I must not use the field "integer" in the union "netsnmp_var= data"=20 > to get the value of my variable aeIndLibre, because it is not an intege= r,=20 Wrong. Counter32 is based on the ASN.1 INTEGER type, so *does* use the 'val.integer' field. But you'll need to cast this to an unsigned 32-bit integer value. i.e. u_long c32_value =3D *(ulong*)respuesta->variables->val.integer; But you *must* check that the request succeeded before trying to extract this value. Dave ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/...net-snmp-users |