SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-120
SNMPHOST Header File
Example 2-17. Contents of snmphosh
#ifndef _SNMPHOST_H_
#define _SNMPHOST_H_
typedef struct DEV_ENTRY_S <--1
{ short nDeviceIndex; /* index of the table */
long nDeviceType; /* Use the last digit of RFC 1514 hrDeviceType */
long nDevDescrLen; /* length of the dev desc without terminating NULL */
char* pDevDescr; /* device description padded with NULL */
long nDeviceStatus;/* Device Status */
/* The followings are device dependent */
union {
long nCpuLoad; /* Load (in %) of a processor */
long nPrinterStatus;/* Status of a printer */
long nDiskCapacity; /* capacity of a disk */
} auxInfo;
} DEV_ENTRY_T;
/* max number of devices */
#define NUM_DEV_ENTRIES 1000 <--2
static short GetHostDevices (SNMP_HOST_INT_T* host_int, <--3
DEV_ENTRY_T** ppDevTable, short devcnt, char* community,
short retrycnt, int requestid);
static short GetAuxDeviceTbl (SNMP_HOST_INT_T* host_int,
DEV_ENTRY_T* pDevTableEntry, char* community,
short retrycnt, int requestid);
static void DisplayHostDevices (DEV_ENTRY_T** ppDevTable,
short numEntries, short bBatchMode);
static DEV_ENTRY_T** InitDevTable (short nNumEntries);
static DEV_ENTRY_T* AllocateDevEntry (void);
static void SetCpuLoad (DEV_ENTRY_T* pEntry, long nLoad);
static void SetPrinterStatus (DEV_ENTRY_T* pEntry, long nStatus);
static void SetDiskCapacity (DEV_ENTRY_T* pEntry, long nCapacity);
static long GetCpuLoad (DEV_ENTRY_T* pEntry);
static long GetPrinterStatus (DEV_ENTRY_T* pEntry);
static long GetDiskCapacity (DEV_ENTRY_T* pEntry);
static short oidstring2oid (const char *name, /* name to search for */
OIDC_T *oid, /* OID buffer to fill */
short oidlen); /* length of OID buffer */
static short oidcmp2(short n1, OIDC_T *idp1, short n2, OIDC_T *idp2);
static char* dev_status_to_str (long status);
static char* prn_status_to_str (long status);
#endif /* _SNMPHOST_H_ */