gethostbynis.c (145724) | gethostbynis.c (145728) |
---|---|
1/*- 2 * Copyright (c) 1994, Garrett Wollman 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1994, Garrett Wollman 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: head/lib/libc/net/gethostbynis.c 145724 2005-04-30 19:28:31Z ume $"); | 27__FBSDID("$FreeBSD: head/lib/libc/net/gethostbynis.c 145728 2005-04-30 20:07:01Z ume $"); |
28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <arpa/inet.h> 33#include <arpa/nameser.h> 34#include <netdb.h> 35#include <stdio.h> --- 9 unchanged lines hidden (view full) --- 45#include <rpcsvc/yp_prot.h> 46#include <rpcsvc/ypclnt.h> 47#endif 48#include "netdb_private.h" 49 50#ifdef YP 51static int 52_gethostbynis(const char *name, char *map, int af, struct hostent *he, | 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <arpa/inet.h> 33#include <arpa/nameser.h> 34#include <netdb.h> 35#include <stdio.h> --- 9 unchanged lines hidden (view full) --- 45#include <rpcsvc/yp_prot.h> 46#include <rpcsvc/ypclnt.h> 47#endif 48#include "netdb_private.h" 49 50#ifdef YP 51static int 52_gethostbynis(const char *name, char *map, int af, struct hostent *he, |
53 struct hostent_data *hed, int mapped) | 53 struct hostent_data *hed) |
54{ 55 char *p, *bp, *ep; 56 char *cp, **q; 57 char *result; 58 int resultlen, size, addrok = 0; 59 char ypbuf[YPMAXRECORD + 2]; 60 61 switch(af) { --- 34 unchanged lines hidden (view full) --- 96 *cp++ = '\0'; 97 he->h_addr_list = hed->h_addr_ptrs; 98 he->h_addr = (char *)hed->host_addr; 99 switch (af) { 100 case AF_INET: 101 addrok = inet_aton(result, (struct in_addr *)hed->host_addr); 102 if (addrok != 1) 103 break; | 54{ 55 char *p, *bp, *ep; 56 char *cp, **q; 57 char *result; 58 int resultlen, size, addrok = 0; 59 char ypbuf[YPMAXRECORD + 2]; 60 61 switch(af) { --- 34 unchanged lines hidden (view full) --- 96 *cp++ = '\0'; 97 he->h_addr_list = hed->h_addr_ptrs; 98 he->h_addr = (char *)hed->host_addr; 99 switch (af) { 100 case AF_INET: 101 addrok = inet_aton(result, (struct in_addr *)hed->host_addr); 102 if (addrok != 1) 103 break; |
104 if (mapped) { | 104 if (_res.options & RES_USE_INET6) { |
105 _map_v4v6_address((char *)hed->host_addr, 106 (char *)hed->host_addr); 107 af = AF_INET6; 108 size = NS_IN6ADDRSZ; 109 } 110 break; 111 case AF_INET6: 112 addrok = inet_pton(af, result, hed->host_addr); --- 54 unchanged lines hidden (view full) --- 167 switch (af) { 168 case AF_INET: 169 map = "hosts.byname"; 170 break; 171 default: 172 map = "ipnodes.byname"; 173 break; 174 } | 105 _map_v4v6_address((char *)hed->host_addr, 106 (char *)hed->host_addr); 107 af = AF_INET6; 108 size = NS_IN6ADDRSZ; 109 } 110 break; 111 case AF_INET6: 112 addrok = inet_pton(af, result, hed->host_addr); --- 54 unchanged lines hidden (view full) --- 167 switch (af) { 168 case AF_INET: 169 map = "hosts.byname"; 170 break; 171 default: 172 map = "ipnodes.byname"; 173 break; 174 } |
175 return _gethostbynis(name, map, af, he, hed, 176 _res.options & RES_USE_INET6); | 175 return _gethostbynis(name, map, af, he, hed); |
177} 178 179static int 180_gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he, 181 struct hostent_data *hed) 182{ 183 char *map; 184 char numaddr[46]; 185 186 switch (af) { 187 case AF_INET: 188 map = "hosts.byaddr"; 189 break; 190 default: 191 map = "ipnodes.byaddr"; 192 break; 193 } 194 if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) 195 return -1; | 176} 177 178static int 179_gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he, 180 struct hostent_data *hed) 181{ 182 char *map; 183 char numaddr[46]; 184 185 switch (af) { 186 case AF_INET: 187 map = "hosts.byaddr"; 188 break; 189 default: 190 map = "ipnodes.byaddr"; 191 break; 192 } 193 if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) 194 return -1; |
196 return _gethostbynis(numaddr, map, af, he, hed, 0); | 195 return _gethostbynis(numaddr, map, af, he, hed); |
197} 198#endif /* YP */ 199 200/* XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*() */ 201struct hostent * 202_gethostbynisname(const char *name, int af) 203{ 204#ifdef YP --- 77 unchanged lines hidden --- | 196} 197#endif /* YP */ 198 199/* XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*() */ 200struct hostent * 201_gethostbynisname(const char *name, int af) 202{ 203#ifdef YP --- 77 unchanged lines hidden --- |