Varbind



Summary


#include <rssnmp/snmp.h>
Function Description
rssnmp_varbind_New() Variable initializer.
rssnmp_varbind_NewSimple() Variable initializer.
rssnmp_varbind_NewCopy() Variable initializer, creates a copy of another varbind.
rssnmp_varbind_Free() Variable destructor.
rssnmp_varbind_Print() Variable print method.
rssnmp_varbind_SetValue() Sets the varbind value.
rssnmp_varbind_GetValue() Returns the variable value in string form.
rssnmp_varbind_GetValueInt() Returns the variable value in integer form.
rssnmp_varbind_GetOid() Returns variable's OID in vector form.
rssnmp_varbind_GetOidText() Returns variable's OID in text form.
rssnmp_varbind_GetType() Returns variable's type.


Initializers, destructor and print method

Synopsis

rssnmp_varbind_t rssnmp_varbind_New(int type, rssnmp_oid_t *oid, int oid_size, void *data, int data_size);

rssnmp_varbind_t rssnmp_varbind_NewSimple(int type, char *oid, char *value);

rssnmp_varbind_t rssnmp_varbind_NewCopy(rssnmp_varbind_t v);

void rssnmp_varbind_Free(rssnmp_varbind_t v);

void rssnmp_varbind_Print(rssnmp_varbind_t v, FILE *fp, char *offset);

Description

The rssnmp_varbind_New() initializer creates a new varbind based on it's type, OID (given by the oid vector and oid_size) and value (defined by data and data_size. On the other hand, the rssnmp_varbind_NewSimple initializer is, as its name suggests, a simplfied varbind initializer, with both oid and value given in strings.

Also, the rssnmp_varbind_NewCopy() creates an exact replica of its parameter, v.

Return Value

All initializers return NULL on error.



Value and OID get and set methods

Synopsis

void rssnmp_varbind_SetValue(rssnmp_varbind_t v, void *data, int datasize);

char *rssnmp_varbind_GetValue(rssnmp_varbind_t v, char *buff, int buff_size);

int rssnmp_varbind_GetValueInt(rssnmp_varbind_t v);

rssnmp_oid_t *rssnmp_varbind_GetOid(rssnmp_varbind_t v, int *oid_size);

char *rssnmp_varbind_GetOidText(rssnmp_varbind_t v, char *buff, int buff_size);

int rssnmp_varbind_GetType(rssnmp_varbind_t v);

Description

Setting the value of a varbind can be done with the rssnmp_varbind_SetValue(), in which data is the new value and datasize is its size.

To fetch its content, the rssnmp_varbind_GetValue() and rssnmp_varbind_GetValueInt() methods can be used, they return the variable value in text and integer formats, respectively. The rssnmp_varbind_GetValue() method writes the value on buff with size given by buff_size.

Variable's OID can be retrieved by rssnmp_varbind_GetOid() and rssnmp_varbind_GetOidText() methods. The first method will return a rssnmp_oid_t vector, and its size will be written in oid_size. As for the second method, the OID will be written in text format in buff, with size given by buff_size.

The rssnmp_varbind_GetType() method returns the variable type.



ASN.1 Variable Types


#define ASN_INTEGER 0x02
#define ASN_BITSTRING 0x03
#define ASN_OCTETSTRING 0x04
#define ASN_NULL 0x05
#define ASN_OID 0x06
#define ASN_NOSUCHINSTANCE 0x81