SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-47
SNMPGT
int
main(int argc, char** argv)
{
SNMP_PKT_T *rcvd_pkt; <-- 5
SNMP_PKT_T *send_pkt;
EBUFFER_T ebuff; <-- 6
int rcode;
short sd;
struct sockaddr_in dest; <-- 7
struct sockaddr_in from;
int j;
int firstid, szfrom, i, oidcnt;
struct hostent *host;
u_long host_addr;
int dest_port = SNMP_REQUEST_PORT; <-- 8
char opt, *whoami, *hostname, *community="public", *oidstr[MAXOIDS]; <-- 9
int retrycnt = 0, timeout = 5, requestid = 1;
short cbTransferred;
short nFileNo;
short err = 0;
int nStatus;
char* nowaitBuf;
long lIoTag = 1;
int cbAsn1Len;
unsigned char* rcvAsn1Pdu;
int nDecodeErrorCode;
int dots = 0;/* to keep track of occurances of dots in IP address */
int byte; /* to hold the octet of IP address */
char *name;
char *ptr;
char id[20]; /* to hold part of IP address */
/* extract the command line arguments */
whoami = *argv++;
argc--;
while (( argc != 0 ) && ( **argv == '-' )) <-- 10
Example 2-4. Contents of snmpgtc (page 2 of 8)