SNMP Subagent Programmer's Guide
Indexed Trap Generator
2-68 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
/*************************************************************************
* locate_entry - locate a table entry
************************************************************************/
Void *
locate_entry(Void *ctxt, <--
19
Void **indices,
int op)
{
struct master *dir = (struct master *) ctxt;
INTEGER card_index;
INTEGER port_index;
Void *result;
if (op == LOCATE_TRAP) <--
20
{
indices[0] = &dir->current_card;
indices[1] = &dir->current_port;
}
card_index = *((long *) (indices[0]));
port_index = *((long *) (indices[1]));
/* Make sure the index is in range */
if ((card_index > dir->card_count) || <--
21
(card_index <= 0) ||
(port_index > dir->port_count) ||
(port_index <= 0))
{
return(NULL);
}
/* adjust for 0-based indexing */
card_index--; <--
22
port_index--;
/* find the table entry */
result = ((Void *) &dir->i[card_index][port_index]); <--
23
return(result);
}
Example 2-13. Indexed Trap Generator Main Program and Next and Locator
Functions (page 4 of 5)