SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-65
Indexed Trap Generator
Example 2-13. Indexed Trap Generator Main Program and Next and Locator
Functions (page 1 of 5)
#include "tdmporth"
#pragma nowarn (93)
#include "syspubh"
#include "fdH"
#include "mgmtpubH"
#include "locatorH"
<-- 1
#include "portpubH"
#include "tdmtimeH"
/*************************************************************************
* This program simulates an application which tracks information
* representing some number of cards, each with a certain number
* of ports.
************************************************************************/
#define CARDS 4
<-- 2
#define PORTS 3
/* Define the structure of a table entry.
* The card and port elements serve as the MIB indexes for this
* kind of table. The "interesting" management information here
* is represented by the "ratio" element. In a real application,
* there would presumably by a number of other elements of interest. */
struct mytable
<-- 3
{
unsigned int card; /* 1-based card number */
INTEGER port; /* 1-based port in card */
DisplayString ratio; /* some computed data */
char ratio_space[20];
};
/* master context. this contains the tables this program is responsible
* for. The "mytable" structure is represents the table of interest
* to management. A real application might have multiple tables, as
* well as non-tabular information. */
struct master
<-- 4
{
INTEGER current_card; /* for trap generation */
INTEGER current_port; /* for trap generation */
INTEGER card_count; /* number of cards */
INTEGER port_count; /* number of ports */
struct mytable i[CARDS][PORTS];
} master;
static READONLY char prompt[] = "To cause a trap, enter card, port: ";
<-- 5
/* include the access methods generated by the mib compiler */
#include "tbltrapH" /* compiler output */
#include <stdioh>
<-- 6