SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-18
Managers Supporting UDP and IPC
  while ((ptr = strchr(name, '.')) != NULL)
  {
   dots++;  /* keep track of no. of dots */
   memset(id, NULL, 20);
   strncpy(id, name, ptr - name);
   byte = atoi(id);
   if ( byte < 0 || byte > 255)
   {
   fprintf(stdout, "Invalid IP address %s\n", hname);
   return HOSTNAME_ERROR;
   }
   name = ptr + 1;
  } /* of while */
  /* if IP address contains invalid no. of dots exit */
  if ( dots < 3)
  {
   fprintf(stdout, "Invalid IP address %s\n", hname);
   return HOSTNAME_ERROR;
  }
  host_addr1 = inet_addr(hname);
  if (host_addr1 == INVALID_HOST_ADDR)
  {
  fprintf(stdout, "Invalid IP address %s\n", hname);
  return HOSTNAME_ERROR;
  }
  t2 = (char *) &host_addr1;
  host1 = host_file_gethostbyaddr (t2, 4, AF_INET); <--14
  if (host1 == NULL) <--15
  {
   return CK_REMOTE_IP;
  } else   /* IP address is defined in host file */
  {
   memset(t3, NULL, MAXNAMEBUF);
   strcat(t3, "\\");  /* returned hostname need a '\' */ <--16
   strcat(t3, host1->h_name);
   if (strlen(t3) > MAXHOSTNAME) /* hostname is assumed 8 char long */
   return CK_REMOTE_IP;
   err3 = NODENAME_TO_NODENUMBER_ (t3, (short) strlen(t3), &sysnum2); <--17
Example 2-2. Contents of snmpfsc (page 5 of 19)










