DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

snmpio_api(SLIB)


snmpio_api -- network I/O and timestamp routines for SNMP management applications

Syntax

cc ... -lsnmpio

#include <snmp/snmpio.h>

int initialize_io(program_name, name, sin); char *program_name; char *name; struct sockaddr_in *sin;

int init_trap_endpoint();

int send_request(fd, dst, out_packet, out_packet_len); int fd; struct sockaddr_in *dst; u_char *out_packet; long out_packet_len; int get_response(fd, src, in_packet, in_packet_len, timeout); int fd; struct sockaddr_in *src; u_char *in_packet; long *in_packet_len; int timeout;

void close_up(fd); int fd;

long make_req_id();

Description

The routines on this manual page provide an application programming interface to the &osr SNMP agent for SNMP management applications wishing to communicate with the agent.

initialize_io( ) opens a UDP end-point for communication between the SNMP management application invoking it and an SNMP agent. program_name specifies the name of the invoking SNMP management application. name specifies the host name or IP address of the machine where the agent resides. The address and port of the remote entity (presumably where the agent is running) are stored in the various fields of the variable sin (pointer to struct sockaddr_in). This routine returns the file descriptor associated with the UDP end-point, which is used later by the management application to send/receive SNMP messages. Among other things, initialize_io( ) also sets up the signal handler to handle SIGALRM. If this routine fails for any reason, the management application exits.

init_trap_endpoint( ) is invoked by any application that is interested in monitoring traps destined for this entity. This routine opens a UDP endpoint and binds it to the port 162 (see services(SFF)).

send_request( ) is invoked by any application interested in sending an SNMP request to another SNMP entity. The fd argument references the UDP end-point opened by initialize_io( ). and dst points to the structure containing the address and port information of the remote SNMP entity. out_packet points to the buffer containing the SNMP request (a serialized SNMP message) to be sent to the remote entity. out_packet_len should contain the length of the packet being sent.

get_response( ) is invoked by an application expecting a response from an agent to which it sent an SNMP request. It uses the file descriptor fd to receive the SNMP response from the agent. The second argument, src< points to an address structure and will contain the address of the entity generating this packet.

The response from the remote entity and its length are returned in the arguments in_packet (a buffer supplied by the application) and in_packet_len, respectively, which can be accessed later by the application.

The final argument, timeout, specifies the maximum amount of time which the application will wait for a response before re-trying/exiting. If get_response( ) fails to receive a response within a pre-determined interval (set by the application using the argument timeout) it returns with a TIMEOUT. The management application may retry the operation if it so chooses.

close_up( ) is invoked by a management application when it exits (error or otherwise) to close the file descriptor fd associated with the UDP end-point.

make_req_id( ) generates and returns a positive number using the current value of the time of day. This number is used by SNMP applications in the ``request-id'' field of the PDU which they generate.

Return values

If successful, send_request( ) returns OK (0); if unsuccessful, it returns NOTOK (-1). If successful, get_response( ) returns RECEIVED(2); if unsuccessful, it returns TIMEOUT(1) or ERROR(-1).

See also

services(SFF), snmp_pdu(SLIB), snmp_authentication(SLIB)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003