* Given a hostname, fills up a (static) struct sockaddr_in with * the address of the host and returns a pointer to the * structure. */
| 298 | * structure. |
| 299 | */ |
| 300 | static struct sockaddr_in * |
| 301 | getaddr(char *host) |
| 302 | { |
| 303 | #ifndef FSTACK |
| 304 | struct hostent *hp; |
| 305 | #endif |
| 306 | static struct sockaddr_in reply; |
| 307 | |
| 308 | bzero(&reply, sizeof(reply)); |
| 309 | reply.sin_len = sizeof(reply); |
| 310 | reply.sin_family = AF_INET; |
| 311 | reply.sin_addr.s_addr = inet_addr(host); |
| 312 | if (reply.sin_addr.s_addr == INADDR_NONE) { |
| 313 | #ifndef FSTACK |
| 314 | if (!(hp = gethostbyname(host))) { |
| 315 | xo_warnx("%s: %s", host, hstrerror(h_errno)); |
| 316 | return (NULL); |
| 317 | } |
| 318 | bcopy((char *)hp->h_addr, (char *)&reply.sin_addr, |
| 319 | sizeof reply.sin_addr); |
| 320 | #else |
| 321 | warnx("reply.sin_addr.s_addr == INADDR_NONE"); |
| 322 | #endif |
| 323 | } |
| 324 | return (&reply); |
| 325 | } |
| 326 | |
| 327 | /* |
| 328 | * Returns true if the type is a valid one for ARP. |