SNMP Configuration and Management Manual

Trap Multiplexer Subagent/Manager
SNMP Configuration and Management Manual424777-006
12-60
Application Source Code
Input : pointer to spi_buffer and distributor file number
Return : None
*/
void getevent_loop(char* spi_buf, short distr) <-- 10
{
char* event_buf; /* pointer to event data */
short byteoffset, i;
zspi_ddl_int2_def t_version; /* trap version */ <-- 11
zspi_ddl_int2_def t_generic; /* generic trap number */
zspi_ddl_int2_def t_specific; /* specific trap number */
zspi_ddl_int2_def t_timeticks; /* timeticks */
zspi_ddl_int_def t_varbind_count; /* number of var binds */
zspi_ddl_enum_def t_varbind_datatype; /* data type of each var bind */
zspi_ddl_char_def t_null = 0;
zspi_ddl_int2_def t_integer;
zspi_ddl_int2_def t_counter;
zspi_ddl_int2_def t_gauge;
short evt_num;
unsigned char trap_buf[ZEMS_VAL_BUFLEN];
ztmx_val_ssid_def tmpssid;
char t_buffer[1024]; /* temp buffer for string manipulation */
char* pt_buffer = t_buffer; /* pointer to the temp buffer */
short len;
short ibuflen = ZEMS_VAL_BUFLEN;
/* malloc memory for the event buffer */
event_buf = malloc (ZEMS_VAL_BUFLEN); <-- 12
if (event_buf == NULL)
DEBUG();
setmem (trap_buf,sizeof(trap_buf),0); /* initialise the trap buffer */
/* begin an infinite loop that collects and displays events */
while (1)
{
/* initialize spi_buf for getevent spi command */
spi_err = SSINIT((short*)spi_buf, /* buffer */ <-- 13
ZEMS_VAL_BUFLEN, /* buffer length */
(short*)&emsssid, /* ssid */
ZSPI_VAL_CMDHDR, /* header-type */
ZEMS_CMD_GETEVENT); /* command */
if (spi_err != ZSPI_ERR_OK)
DEBUG();
/* send getevent command to distributor */
printf ("\n\nWaiting for the next Event.....\n\n");
send_spi_cmd (spi_buf, distr); <-- 14
/* Extract the event into the buffer */
spi_err = SSGETTKN ((short*) spi_buf, <-- 15
ZEMS_TKN_EVENT,
event_buf,
1);
if (spi_err != ZSPI_ERR_OK)
DEBUG();
Example 12-3. Sample Application Source Code (page 5 of 14)