O_octet – Compaq AAR04BCTE User Manual

Page 91

Advertising
background image

eSNMP API Routines

o_octet

o_octet

Loads an octet value into the VARBIND structure with the appropriate type. This
function does not allocate the VARBIND structure.

Format

int o_octet ( VARBIND *vb,

OBJECT *obj,
unsigned long value );

Arguments

vb

A pointer to the VARBIND structure that is supposed to receive the data.

If the original value in the vb field is not null, this routine attempts to free it. So
if you dynamically allocate memory or issue the

malloc

command to allocate your

own VARBIND structure, fill the structure with zeros before using it.

obj

A pointer to the OBJECT structure for the MIB variable associated with the OID
in the VARBIND structure.

value

The value to be inserted into the VARBIND structure.

The real type as defined in the object structure must be one of the following;
otherwise, an error is returned.

ESNMP_TYPE_OCTET_STRING

Octet string (ASN.1)

ESNMP_TYPE_IpAddress

Implicit octet string (4) (in octet form,
network byte order)

ESNMP_TYPE_DisplayString

DisplayString (textual convention)

ESNMP_TYPE_Opaque

Implicit octet string

Return Values

ESNMP_MTHD_noError

The routine completed successfully.

ESNMP_MTHD_genErr

An error occurred.

Example

#include <esnmp.h>
#include "ip_tbl.h"

<-- for ipNetToMediaEntry_type definition

VARBIND

*vb

= method->varbind;

OBJECT

*object

= method->object;

ipNetToMediaEntry_type *data;
:
: assume buffer and structure member assignments occur here
:
switch(arg) {

case I_atPhysAddress:
return o_octet(vb, object, &data->ipNetToMediaPhysAddress);

eSNMP API Routines 5–33

Advertising