gethost.c revision 145510
1148330Snetchild/* $NetBSD$ */ 2148330Snetchild 3148330Snetchild#include "ipf.h" 4148330Snetchild 5148330Snetchildint gethost(name, hostp) 6148330Snetchildchar *name; 7148330Snetchildu_32_t *hostp; 8148330Snetchild{ 9148330Snetchild struct hostent *h; 10148330Snetchild struct netent *n; 11148330Snetchild u_32_t addr; 12148330Snetchild 13148330Snetchild if (!strcmp(name, "test.host.dots")) { 14148543Snetchild *hostp = htonl(0xfedcba98); 15148543Snetchild return 0; 16148330Snetchild } 17167699Sdelphij 18167699Sdelphij if (!strcmp(name, "<thishost>")) 19167137Sbms name = thishost; 20167137Sbms 21166981Sru h = gethostbyname(name); 22166981Sru if (h != NULL) { 23166668Sbrueffer if ((h->h_addr != NULL) && (h->h_length == sizeof(addr))) { 24166668Sbrueffer bcopy(h->h_addr, (char *)&addr, sizeof(addr)); 25166389Srafan *hostp = addr; 26166389Srafan return 0; 27166389Srafan } 28166308Sphk } 29166308Sphk 30166246Speter n = getnetbyname(name); 31166246Speter if (n != NULL) { 32166246Speter *hostp = (u_32_t)htonl(n->n_net & 0xffffffff); 33166246Speter return 0; 34166246Speter } 35164796Spiso return -1; 36164796Spiso} 37164796Spiso