003 File Manager
Current Path:
/usr/src/lib/libc/net
usr
/
src
/
lib
/
libc
/
net
/
📁
..
📄
Makefile.inc
(5.08 KB)
📄
Symbol.map
(2.8 KB)
📄
base64.c
(10.39 KB)
📄
byteorder.3
(2.74 KB)
📄
ether_addr.c
(5.68 KB)
📄
ethers.3
(5.85 KB)
📄
eui64.3
(6.37 KB)
📄
eui64.c
(8.3 KB)
📄
gai_strerror.3
(2.49 KB)
📄
gai_strerror.c
(3.98 KB)
📄
getaddrinfo.3
(12.12 KB)
📄
getaddrinfo.c
(70.2 KB)
📄
gethostbydns.c
(19.1 KB)
📄
gethostbyht.c
(9.04 KB)
📄
gethostbyname.3
(8.74 KB)
📄
gethostbynis.c
(6.94 KB)
📄
gethostnamadr.c
(17.01 KB)
📄
getifaddrs.3
(4.24 KB)
📄
getifaddrs.c
(8.57 KB)
📄
getifmaddrs.3
(3 KB)
📄
getifmaddrs.c
(4.79 KB)
📄
getipnodebyname.3
(10.04 KB)
📄
getnameinfo.3
(7.6 KB)
📄
getnameinfo.c
(13.68 KB)
📄
getnetbydns.c
(12 KB)
📄
getnetbyht.c
(7.18 KB)
📄
getnetbynis.c
(6.09 KB)
📄
getnetent.3
(4.36 KB)
📄
getnetnamadr.c
(10.46 KB)
📄
getproto.c
(3.87 KB)
📄
getprotoent.3
(3.78 KB)
📄
getprotoent.c
(12.22 KB)
📄
getprotoname.c
(4.25 KB)
📄
getservent.3
(4.13 KB)
📄
getservent.c
(29.69 KB)
📄
hesiod.3
(4.19 KB)
📄
hesiod.c
(12.17 KB)
📄
hosts
(1.01 KB)
📄
hosts.equiv
(53 B)
📄
if_indextoname.3
(3.94 KB)
📄
if_indextoname.c
(2.94 KB)
📄
if_nameindex.c
(4.21 KB)
📄
if_nametoindex.c
(2.84 KB)
📄
inet.3
(7.76 KB)
📄
inet6_opt_init.3
(9.07 KB)
📄
inet6_option_space.3
(2.18 KB)
📄
inet6_rth_space.3
(6.86 KB)
📄
inet6_rthdr_space.3
(2.22 KB)
📄
inet_net.3
(5.01 KB)
📄
ip6opt.c
(15.36 KB)
📄
linkaddr.3
(3.94 KB)
📄
linkaddr.c
(4.44 KB)
📄
map_v4v6.c
(3.93 KB)
📄
name6.c
(28.18 KB)
📄
netdb_private.h
(5.2 KB)
📄
networks
(310 B)
📄
nscache.c
(10.91 KB)
📄
nscachedcli.c
(14.18 KB)
📄
nsdispatch.3
(6.25 KB)
📄
nsdispatch.c
(20.3 KB)
📄
nslexer.l
(3.01 KB)
📄
nsparser.y
(3.91 KB)
📄
nss_backends.h
(2.04 KB)
📄
nss_compat.c
(7.93 KB)
📄
nsswitch.conf
(272 B)
📄
ntoh.c
(1.75 KB)
📄
protocols
(6.24 KB)
📄
rcmd.3
(8.14 KB)
📄
rcmd.c
(18.57 KB)
📄
rcmdsh.3
(3.23 KB)
📄
rcmdsh.c
(4.95 KB)
📄
recv.c
(2.22 KB)
📄
res_config.h
(299 B)
📄
resolver.3
(11.43 KB)
📄
rthdr.c
(9.7 KB)
📄
sctp_bindx.3
(3.47 KB)
📄
sctp_connectx.3
(3.44 KB)
📄
sctp_freepaddrs.3
(2.26 KB)
📄
sctp_getaddrlen.3
(2.82 KB)
📄
sctp_getassocid.3
(2.44 KB)
📄
sctp_getpaddrs.3
(3.11 KB)
📄
sctp_opt_info.3
(3.55 KB)
📄
sctp_recvmsg.3
(8.43 KB)
📄
sctp_send.3
(11.12 KB)
📄
sctp_sendmsg.3
(10.45 KB)
📄
sctp_sys_calls.c
(30.35 KB)
📄
send.c
(2.23 KB)
📄
sockatmark.3
(3.26 KB)
📄
sockatmark.c
(1.59 KB)
📄
sourcefilter.3
(6.38 KB)
📄
sourcefilter.c
(9.71 KB)
📄
vars.c
(2.07 KB)
Editing: gethostbynis.c
/*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 1994, Garrett Wollman * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <errno.h> #include <string.h> #include <stdarg.h> #include <nsswitch.h> #include <resolv.h> /* XXX */ #ifdef YP #include <rpc/rpc.h> #include <rpcsvc/yp_prot.h> #include <rpcsvc/ypclnt.h> #endif #include "netdb_private.h" #ifdef YP static int _gethostbynis(const char *name, char *map, int af, struct hostent *he, struct hostent_data *hed) { char *p, *bp, *ep; char *cp, **q; char *result; int resultlen, size, addrok = 0; char *ypbuf; res_state statp; statp = __res_state(); switch(af) { case AF_INET: size = NS_INADDRSZ; break; case AF_INET6: size = NS_IN6ADDRSZ; break; default: errno = EAFNOSUPPORT; RES_SET_H_ERRNO(statp, NETDB_INTERNAL); return (-1); } if (hed->yp_domain == (char *)NULL) if (yp_get_default_domain (&hed->yp_domain)) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); return (-1); } if (yp_match(hed->yp_domain, map, name, strlen(name), &result, &resultlen)) { RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); return (-1); } /* avoid potential memory leak */ ypbuf = alloca(resultlen + 2); bcopy(result, ypbuf, resultlen); ypbuf[resultlen] = '\0'; free(result); result = ypbuf; if ((cp = strchr(result, '\n'))) *cp = '\0'; cp = strpbrk(result, " \t"); *cp++ = '\0'; he->h_addr_list = hed->h_addr_ptrs; he->h_addr = (char *)hed->host_addr; switch (af) { case AF_INET: addrok = inet_aton(result, (struct in_addr *)hed->host_addr); if (addrok != 1) break; if (statp->options & RES_USE_INET6) { _map_v4v6_address((char *)hed->host_addr, (char *)hed->host_addr); af = AF_INET6; size = NS_IN6ADDRSZ; } break; case AF_INET6: addrok = inet_pton(af, result, hed->host_addr); break; } if (addrok != 1) { RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); return (-1); } he->h_addr_list[1] = NULL; he->h_length = size; he->h_addrtype = af; while (*cp == ' ' || *cp == '\t') cp++; bp = hed->hostbuf; ep = hed->hostbuf + sizeof hed->hostbuf; he->h_name = bp; q = he->h_aliases = hed->host_aliases; p = strpbrk(cp, " \t"); if (p != NULL) *p++ = '\0'; size = strlen(cp) + 1; if (ep - bp < size) { RES_SET_H_ERRNO(statp, NO_RECOVERY); return (-1); } strlcpy(bp, cp, ep - bp); bp += size; cp = p; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q >= &hed->host_aliases[_MAXALIASES - 1]) break; p = strpbrk(cp, " \t"); if (p != NULL) *p++ = '\0'; size = strlen(cp) + 1; if (ep - bp < size) break; strlcpy(bp, cp, ep - bp); *q++ = bp; bp += size; cp = p; } *q = NULL; return (0); } static int _gethostbynisname_r(const char *name, int af, struct hostent *he, struct hostent_data *hed) { char *map; switch (af) { case AF_INET: map = "hosts.byname"; break; default: map = "ipnodes.byname"; break; } return (_gethostbynis(name, map, af, he, hed)); } static int _gethostbynisaddr_r(const void *addr, socklen_t len, int af, struct hostent *he, struct hostent_data *hed) { char *map; char numaddr[46]; switch (af) { case AF_INET: map = "hosts.byaddr"; break; default: map = "ipnodes.byaddr"; break; } if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) return (-1); return (_gethostbynis(numaddr, map, af, he, hed)); } #endif /* YP */ int _nis_gethostbyname(void *rval, void *cb_data, va_list ap) { #ifdef YP const char *name; int af; char *buffer; size_t buflen; int *errnop, *h_errnop; struct hostent *hptr, he; struct hostent_data *hed; res_state statp; name = va_arg(ap, const char *); af = va_arg(ap, int); hptr = va_arg(ap, struct hostent *); buffer = va_arg(ap, char *); buflen = va_arg(ap, size_t); errnop = va_arg(ap, int *); h_errnop = va_arg(ap, int *); *((struct hostent **)rval) = NULL; statp = __res_state(); if ((hed = __hostent_data_init()) == NULL) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); *h_errnop = statp->res_h_errno; return (NS_NOTFOUND); } if (_gethostbynisname_r(name, af, &he, hed) != 0) { *h_errnop = statp->res_h_errno; return (NS_NOTFOUND); } if (__copy_hostent(&he, hptr, buffer, buflen) != 0) { *errnop = errno; RES_SET_H_ERRNO(statp, NETDB_INTERNAL); *h_errnop = statp->res_h_errno; return (NS_RETURN); } *((struct hostent **)rval) = hptr; return (NS_SUCCESS); #else *((struct hostent **)rval) = NULL; return (NS_UNAVAIL); #endif } int _nis_gethostbyaddr(void *rval, void *cb_data, va_list ap) { #ifdef YP const void *addr; socklen_t len; int af; char *buffer; size_t buflen; int *errnop, *h_errnop; struct hostent *hptr, he; struct hostent_data *hed; res_state statp; addr = va_arg(ap, const void *); len = va_arg(ap, socklen_t); af = va_arg(ap, int); hptr = va_arg(ap, struct hostent *); buffer = va_arg(ap, char *); buflen = va_arg(ap, size_t); errnop = va_arg(ap, int *); h_errnop = va_arg(ap, int *); *((struct hostent **)rval) = NULL; statp = __res_state(); if ((hed = __hostent_data_init()) == NULL) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); *h_errnop = statp->res_h_errno; return (NS_NOTFOUND); } if (_gethostbynisaddr_r(addr, len, af, &he, hed) != 0) { *h_errnop = statp->res_h_errno; return (NS_NOTFOUND); } if (__copy_hostent(&he, hptr, buffer, buflen) != 0) { *errnop = errno; RES_SET_H_ERRNO(statp, NETDB_INTERNAL); *h_errnop = statp->res_h_errno; return (NS_RETURN); } *((struct hostent **)rval) = hptr; return (NS_SUCCESS); #else *((struct hostent **)rval) = NULL; return (NS_UNAVAIL); #endif }
Upload File
Create Folder