NAME
snmp_var_new, snmp_var_clone, snmp_var_free, snmp_var_EncodeVarBind, snmp_var_DecodeVarBind - SNMP Variable List Operations

SYNOPSIS
cc [ flag ... ] file ... -lsnmp [ library ... ]

#include <sys/types.h>
#include <snmp/snmp.h>

struct variable_list *snmp_var_new(oid * Name, int NameLen);

struct variable_list *snmp_var_clone(struct variable_list * Src);

void snmp_var_free(struct variable_list * Ptr);

u_char *snmp_var_EncodeVarBind(u_char * Buf, int * BufLenP, struct variable_list * VarList, int Version);

u_char *snmp_var_DecodeVarBind(u_char * Buf, int * BufLenP, struct variable_list ** VarListP, int Version);

STRUCTURE
The variable_list structure is:
    struct variable_list *next_variable;	/* Next variable, or NULL */
    oid		*name;			/* OID of variable */
    int		name_length;		/* OID Length */
    u_char		type;			/* ASN type of variable */
    union {					/* value of variable */
    	int	*integer;
    	u_char	*string;
    	oid	*objid;
    } val;
    int		val_len;		/* Length of variable data */

DESCRIPTION
snmp_var_new() creates a new variable_list structure representing the OID Name of length NameLen. If Name is NULL, the name oid will be empty.

snmp_var_clone() copies the variable_list structure pointed to by Src. If the next_variable pointer is filled in, it is copied as well, so both the original and the clone point to the same next variable_list.

snmp_var_free() frees the variable_list pointed to by Ptr. It does nothing to the variable_list pointed to by next_variable.

snmp_var_EncodeVarBind() and snmp_var_DecodeVarBind() encode and decode the variable_list structure into/out of the buffer pointed to by Buf. BufLenP points to the length of space remaining in Buf. Upon successful completion, these functions return a pointer to the next available byte in Buf and adjusts BufLenP to reflect the amount of space left in the buffer after the encoding / decoding. Version indicates what version of SNMP encoding should be used. At this time, this is ignored.

RETURN VALUES
Upon error, all functions (except snmp_var_free() ) return NULL. Otherwise, the return value is as describe above.

ERRORS
If any of these return unsuccessfully, snmp_api_error() will be set.

NOTES
ASN parsing errors are counted and available via snmpInASNParseErrs(3).