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/getnetnamadr.c 146244 2005-05-15 20:15:15Z ume $"); |
28 29#include "namespace.h" 30#include "reentrant.h" 31#include <sys/param.h> 32#include <sys/socket.h> 33#include <netinet/in.h> 34#include <arpa/inet.h> 35#include <netdb.h> --- 79 unchanged lines hidden (view full) --- 115 116 rval = _nsdispatch(NULL, dtab, NSDB_NETWORKS, "getnetbyname", 117 default_src, name, ne, ned); 118 119 return (rval == NS_SUCCESS) ? 0 : -1; 120} 121 122int |
123getnetbyaddr_r(uint32_t addr, int af, struct netent *ne, 124 struct netent_data *ned) |
125{ 126 int rval; 127 128 static const ns_dtab dtab[] = { 129 NS_FILES_CB(_ht_getnetbyaddr, NULL) 130 { NSSRC_DNS, _dns_getnetbyaddr, NULL }, 131 NS_NIS_CB(_nis_getnetbyaddr, NULL) /* force -DHESIOD */ 132 { 0 } --- 27 unchanged lines hidden (view full) --- 160 if ((nd = __netdata_init()) == NULL) 161 return NULL; 162 if (getnetbyname_r(name, &nd->net, &nd->data) != 0) 163 return NULL; 164 return &nd->net; 165} 166 167struct netent * |
168#if __LONG_BIT == 64 169getnetbyaddr(u_long addr, int af) /* ABI compatibility */ 170#else 171getnetbyaddr(uint32_t addr, int af) 172#endif |
173{ 174 struct netdata *nd; 175 176 if ((nd = __netdata_init()) == NULL) 177 return NULL; |
178 if (getnetbyaddr_r((uint32_t)addr, af, &nd->net, &nd->data) != 0) |
179 return NULL; 180 return &nd->net; 181} 182 183void 184setnetent(int stayopen) 185{ 186 struct netdata *nd; --- 15 unchanged lines hidden --- |