VxWorks Reference Manual : Libraries
snmpIoLib - default transport routines for SNMP
snmpIoInit( ) - initialization routine for SNMP transport endpoint
snmpIoWrite( ) - write a packet to the transport
snmpIoClose( ) - close the transport endpoint.
snmpIoMain( ) - main SNMP I/O routine
snmpIoTrapSend( ) - send a standard SNMP or MIB-II trap
snmpIoCommunityValidate( ) - sample community validation routine
snmpdMemoryAlloc( ) - allocate memory for the SNMP agent
snmpdMemoryFree( ) - free memory allocated by the SNMP agent
This module implements the SNMP v1/v2c transport-dependent routines.
snmpdIoLib.h
snmpIoInit( ) - initialization routine for SNMP transport endpoint
STATUS snmpIoInit (void)
This is the routine to be called to initialize the transport endpoint used by the SNMP agent. This routine is invoked from snmpIoMain( ). This implementation is for a socket based system. It will also call the masterIoInit( ) routine to create the IPC mechanism for the master agent.
snmpSocket
ERROR if unable to create bound socket else OK.
snmpIoLib, snmpIoMain( )
snmpIoWrite( ) - write a packet to the transport
void snmpIoWrite ( void * pSocket, /* Socket descriptor for SNMP */ char * pBuf, /* Encoded SNMP packet */ int bufSize, /* Size of the packet */ void * pRemote, /* Remote address of manager */ void * pLocal /* Local address */ )
This routine writes a datagram to the socket. The routine calls sendto( ) with flags always set to 0. The local parameter is not used in this case, but exists for conformance with our transport-independent interface.
N/A
snmpIoLib, sendto( ) <(VxWorks Reference Manual) >
snmpIoClose( ) - close the transport endpoint.
void snmpIoClose (void)
This routine is invoked to deallocate the transport endpoint. It is invoked from the task deletion hook and also from snmpdExit( ).
N/A
snmpIoMain( ) - main SNMP I/O routine
void snmpIoMain (void)
This routine is invoked by the agent after it has successsfully completed the preliminary initializations. In this routine, the user is required to initialize the transport endpoint and the views, and then complete initialization of the agent by calling snmpdInitFinish( ). Any configuration required for snmpIoTrapSend( ) must be done before calling snmpdInitFinish( ) since it will be invoked in there. Any hooks that are required by the user must be passed to snmpdInitFinish( ). The transport endpoint must be initialized before snmpdInitFinish( ) is called; the main loop is then invoked. Before calling snmpIoBody( ), the routine which waits on the socket, it calls snmpMonitorSpawn( ) which spawns the master-agent task.
This routine should never return, except on failure.
snmpIoTrapSend( ) - send a standard SNMP or MIB-II trap
void snmpIoTrapSend ( int trapType, /* Type of the trap */ int trapSpecific /* User defined specifics */ )
This routine sends a standard SNMP or MIB-II trap message to the network. It is called by the SNMP agent at startup (to indicate a cold start) and when interface states change. It takes two arguments: trapType, the trap type, and trapSpecific, the user-defined specifics on this trap.
The agent designer must rewrite this according to specific transport needs.
N/A
snmpIoCommunityValidate( ) - sample community validation routine
int snmpIoCommunityValidate ( SNMP_PKT_T * pPkt, /* ptr to snmp pkt */ SNMPADDR_T * pRemoteAddr, /* remote address */ SNMPADDR_T * pLocalAddr /* local address */ )
This routine is used to set up the view-index field in the SNMP packet. This product is shipped with defaults such that the "priv" community is allowed to set variables, and the "pub" community is allowed to get variables.
The agent designer is required to write this function according to the design of the application.
0 if the community is acceptable, otherwise 1.
snmpdMemoryAlloc( ) - allocate memory for the SNMP agent
void * snmpdMemoryAlloc ( size_t size /* size of memory to be allocated */ )
This routine allocates memory for the SNMP agent. The required size of the block is passed in size. This memory must be deallocated later with snmpdMemoryFree( ).
a pointer to the allocated buffer on success, otherwise NULL.
snmpdMemoryFree( ) - free memory allocated by the SNMP agent
void snmpdMemoryFree ( void * pBuf /* buffer to free */ )
This routine deallocates memory which was previously allocated by the SNMP agent with snmpdMemoryAlloc( ).
N/A