[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

o_number, o_integer, o_string, o_igeneric, o_generic, o_specific, or o_ipaddr Subroutine

Purpose

Encodes values retrieved from the Management Information Base (MIB) into the specified variable binding.

Library

SNMP Library (libsnmp.a)

Syntax

#include <isode/snmp/objects.h>
#include <isode/pepsy/SNMP-types.h>
#include <sys/types.h>
#include <netinet/in.h>
int o_number (oi, v, number)
OI oi;
register struct type_SNMP_VarBind *v;
int number;
#define o_integer (oi, v, number) o_number ((oi), (v), (number))
int o_string (oi, v, base, len)
OI oi;
register struct type_SNMP_VarBind *v;
char *base;
int len;
int o_igeneric (oi, v, offset)
OI oi;
register struct type_SNMP_VarBind *v;
int offset;
int o_generic (oi, v, offset)
OI oi;
register struct type_SNMP_VarBind *v;
int offset;
int o_specific (oi, v, value)
OI oi;
register struct type_SNMP_VarBind *v;
caddr_t value;
int o_ipaddr (oi, v, netaddr)
OI oi;
register struct type_SNMP_VarBind *v;
struct sockaddr_in *netaddr;

Description

The o_number subroutine assigns a number retrieved from the MIB to the variable binding used to request it. Once an MIB value has been retrieved, the value must be stored in the binding structure associated with the variable requested. The o_number subroutine places the integer number into the v parameter, which designates the binding for the variable. The value parameter type is defined by the oi parameter and is used to specify the encoding subroutine that stores the value. The oi parameter references a specific MIB variable and should be the same as the variable specified in the v parameter. The encoding functions are defined for each type of variable and are contained in the object identifier (OI) structure.

The o_integer macro is defined in the /usr/include/snmp/objects.h file. This macro casts the number parameter as an integer. Use the o_integer macro for types that are not integers but have integer values.

The o_string subroutine assigns a string that has been retrieved for a MIB variable to the variable binding used to request the string. Once a MIB variable has been retrieved, the value is stored in the binding structure associated with the variable requested. The o_string subroutine places the string, specified with the base parameter, into the variable binding in the v parameter. The length of the string represented in the base parameter equals the value of the len parameter. The length is used to define how much of the string is copied in the binding parameter of the variable. The value parameter type is defined by the oi parameter and is used to specify the encoding subroutine that stores the value. The oi parameter references a specific MIB variable and should be the same as the variable specified in the v parameter. The encoding subroutines are defined for each type of variable and are contained in the OI structure.

The o_generic and o_igeneric subroutines assign results that are already in the customer's MIB database. These two subroutines do not retrieve values from any other source. These subroutines check whether the MIB database has information on how and what to encode as the value. The o_generic and o_igeneric subroutines also ensure that the variable requested is an instance. If the variable is an instance, the subroutines encode the value and return OK. The subroutine has an added set of return codes. If there is not any information about the variable, the subroutine returns NOTOK on a get_next request and int_SNMP_error__status_noSuchName for the get and set requests. The difference between the o_generic and the o_igeneric subroutine is that the o_igeneric subroutine provides a method for users to define a generic subroutine.

The o_specific subroutine sets the binding value for a MIB variable with the value in a character pointer. The o_specific subroutine ensures that the data-encoding procedure is defined. The encode subroutine is always checked by all of the o_ subroutines. The o_specific subroutine returns the normal values.

The o_ipaddr subroutine sets the binding value for variables that are network addresses. The o_ipaddr subroutine uses the sin_addr field of the sockaddr_in structure to get the address. The subroutine does the normal checking and returns the results like the rest of the subroutines.

Parameters

oi Contains the OI data structure for the variable whose value is to be recorded into the binding structure.
v Specifies the variable binding parameter, which is of type type_SNMP_VarBind. The v parameter contains a name and a value field. The value field contents are supplied by the o_ subroutines.
number Contains an integer to store in the value field of the v (variable bind) parameter.
base Points to the character string to store in the value field of the v parameter.
len Designates the length of the integer character string to copy. The character string is described by the base parameter.
offset Contains an integer value of the current type of request, for example:
type_SNMP_PDUs_get__next__request
value Contains a character pointer to a value.
netaddr Points to a sockaddr_in structure. The subroutine only uses the sin_addr field of this structure.

Return Values

The return values for these subroutines are:

int_SNMP_error__status_genErr Indicates an error occurred when setting the v parameter value.
int_SNMP_error__status_noErr Indicates no errors found.

Implementation Specifics

These subroutines are part of the SNMP Application Programming Interface in the TCP/IP facility.

Related Information

List of Network Manager Programming References.

SNMP Overview for Programmers, and Working with Management Information Base (MIB) Variables in AIX Version 4.3 Communications Programming Concepts.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]