SNMP Manager Programmer's Guide
Constructing and Interpreting Packets
SNMP Manager Programmer’s Guide–134249
5-22
SNMP_Bind_IP_Address()
function str_to_type() is used to validate whether the type specified at invocation is a 
valid SNMP data type and converts it to the Manager Services representation for it. For 
MIB-II objects, the common utility function oid_to_namerec() is used to obtain the 
Manager Services representation of the data type:
for (i = 0; i < oidcnt; i++)
{
 peertype = longform ? str_to_type(typestr[i]) : 0;
 if ((p = oid_to_namerec(&base_oid)) != 0)
 mibtype = p->type;
 else
 mibtype = 0;
 peertype = peertype ? peertype : mibtype;
The value of peertype, which holds the Manager Services representation for the SNMP 
data type for the target MIB object, is used to determine which SNMP_Bind_ function 
to call. The function SNMP_Bind_IP_Address() is called when the value of peertype is 
VT_IPADDRESS. If the IP address value was specified using dotted numeric notation, 
the TCP/IP function inet_addr() is used to convert it into binary format. If the IP 
address value was specified using a NonStop Kernel node name, the gethostbyname() 
system call is used to convert it into an IP address:
switch (peertype)
 {
 case VT_IPADDRESS:
 if (isdigit(*valstr[i]))
 {
 ipaddr = inet_addr(valstr[i]);
 } else
 {
 if ((host3 = gethostbyname(valstr[i])) ==
 (struct hostent *) 0)
 {
 fprintf(stdout, "Can not locate host %s\n",
 valstr[i]);
 fprintf(stdout, "while binding the VT_IPADDRESS\n");
 exit (2);
 }
 ipaddr = *(u_long *) host3->h_addr);
 }
 rcode = SNMP_Bind_IP_Address(send_pkt, i,
 base_oid.num_components,
 base_oid.component_list,
 (OCTET_T *)&ipaddr);
 break;










