DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

varbind(SLIB)


varbind -- Operations on Variable Bindings

Syntax

cc ... -lsnmp

#include <snmp/snmp.h>

void free_varbind_list(vbl_ptr) VarBindList *vbl_ptr;

short link_varbind(pdu_ptr, vbl_ptr); Pdu *pdu_ptr; /* ptr to PDU header allocated by make_pdu */ VarBindList *vbl_ptr; /* ptr to VarBindList created by make_varbind */

short link_varbind_list(pdu_ptr, vbl_ptr); Pdu *pdu_ptr; /* ptr. to PDU header alloc'ed by make_pdu */ VarBindList *vbl_ptr; /* ptr. to VarBindList created by make_varbind */

VarBindList * make_varbind(oid_ptr, type, ul_value, sl_value, os_value, \ oid_value, c64_value) OID oid_ptr; short type; /* variable type: INTEGER_TYPE, COUNTER_TYPE, etc. */ unsigned long ul_value; /* COUNTER_TYPE, GAUGE_TYPE, etc. values */ long sl_value; /* INTEGER_TYPE values */ OctetString *os_value; /* OCTET_PRIM_TYPE, BITSTRING_TYPE, etc. values */ OID oid_value; /* OBJECT_ID_TYPE value */ Counter64 *c64_value; /* COUNTER64_TYPE value */

#include <snmp/snmp.h> #include <snmp/snmpuser.h>

short print_varbind_list(vbl_ptr) VarBindList *vbl_ptr; /* ptr to a VarBindList to be printed out */

Description

free_varbind_list frees all memory associated with the variable bindings, including the name and the value of each one of them.

link_varbind completes a PDU, created by a call to make_pdu(SLIB), by adding the VarBindList entry created by a call to make_varbind(SLIB). link_varbind should be called exactly once for each vbl_ptr being associated with the PDU as this association is used to reclaim memory when the PDU is freed.

link_varbind_list appends a list of variable bindings to a PDU structure. It invokes the link_varbind routine repeatedly (once for each variable binding in the list) to accomplish this task. The arguments supplied to this function are pointers to a PDU (pdu_ptr) and a list of variable bindings (vbl_ptr) that need to be added to the PDU (1st argument).

make_varbind is called to create a VarBindList entry to be strung onto a PDU. It returns a pointer to a malloc'ed data structure of the type VarBind. Usually, this pointer is then used in a call to link_varbind to associate this VarBindList with a PDU. The structure is freed when the PDU is freed with a call to free_pdu(SLIB).

A VarBindList is a variable-value binding. It binds the name, the type, and the value of a variable into one construct. The current list of SNMP types and the value type associated with each is:


COUNTER_TYPE
uses ul_value

GAUGE_TYPE
uses ul_value

INTEGER_TYPE
uses sl_value

UINTEGER_TYPE
uses ul_value

TIME_TICKS_TYPE
uses ul_value

OBJECT_ID_TYPE
uses oid_value

OCTET_PRIM_TYPE
uses os_value

IP_ADDR_PRIM_TYPE
uses os_value

OPAQUE_PRIM_TYPE
uses os_value

COUNTER64_TYPE
uses c64_value

NULL_TYPE
no passed value needed

print_varbind_list prints out the contents of a VarBindList in a human readable form. This is a quick user interface for printing out the SNMP responses in simple SNMP utilities. If the PDU structure is pointed to by *pdu_ptr, the call is:

print_varbind_list(pdu_ptr->var_bind_list)

See also

octetstring(SLIB), oid(SLIB), snmp_authentication(SLIB), snmp_pdu(SLIB)

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003