SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-44
SNMPGT
10. A while loop parses all the arguments in the invocation line that are preceded by a 
minus sign (-). Any values stored override the default values assigned earlier.
11. The target host identifier is stored in hostname.
12. A for loop extracts OIDs from the invocation line.
13. The number of OIDs is stored in oidcnt to use later when binding variables to the 
request packet.
14. Two of the three fields in the socket structure are initialized. AF_INET is assigned 
to sin_family, to indicate the UDP family is internet. The destination port is stored 
in network byte order in sin_port.
15. The IP address of the target host is stored in host_addr. If the target host was 
specified by IP address in the invocation line, this value is stored directly. If the 
target host was specified by name, a gethostbyname() call is made to convert the 
name into its corresponding IP address.
16. The third field in the socket structure is assigned the value in host_addr.
17. A socket to use for packet transmission is obtained by using the TCP/IP socket_nw() 
call.
18. The Manager Services function SNMP_Create_Request() dynamically allocates 
memory for send_pkt, then initializes packet values for the packet type, the 
community name, the request ID, and the number of OIDs in the request.
19. Each OID specified in the invocation line is bound to the request packet using the 
Manager Services function SNMP_Bind_Null(). 
20. The encoded-packet buffer descriptors are initialized using the Manager Services 
function EBufferInitialize(). This function sets all the fields describing the buffer to 
0.
21. A for loop based on the retry count specified at invocation performs packet 
encoding, transmission, receipt, decoding, and resets the PDU request ID to 1 once 
the request ID reaches MAX_REQID_VALUE.
22. The Manager Services function SNMP_Encode_Packet() BER encodes the packet in 
send_pkt into memory Manager Services allocates after setting the values of the 
buffer descriptors as follows because at this point they have not been set: 
23. The common utility function print_pkt is called to print the request packet.
24. The socket structure is copied into sndbuff. This structure must be at the start of the 
transmitted packet.  Then the used contents of buffer memory is copied into sndbuff, 
207
ebuff
start_bp
next_bp
remaining










