summaryrefslogtreecommitdiff
path: root/usr/src/lib/libnsl
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2018-07-31 15:13:05 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2018-07-31 15:13:05 +0000
commit7cd3f4b8e082236e604a53fa1ab5dacb8d11c0c5 (patch)
tree2cf3b0977768b7a05a135733c7d58288079ee40c /usr/src/lib/libnsl
parentf72f56d9727aa3ebd6798b5f109dbd3d1670cbe5 (diff)
parente5c421abb8bd517cb6964747b9ce23066e1a1cef (diff)
downloadillumos-joyent-7cd3f4b8e082236e604a53fa1ab5dacb8d11c0c5.tar.gz
[illumos-gate merge]
commit e5c421abb8bd517cb6964747b9ce23066e1a1cef 9266 ixgbe: this statement may fall through commit 8a7aa2a592747bd90d85645126d80688e024a0e2 9673 move internet address manipulation functions to libc commit 7e3488dc6cdcb0c04e1ce167a1a3bfef83b5f2e0 9610 qede: error: left shift of negative value commit d972451485b9ccf8c5c4951e2d24f63da9ac2cc8 9609 qede: error: result of '983040 << 16' requires 37 bits to represent, but 'int' only has 32 bits commit 3df3d01f9da8be5cdd1e81a5d050c24ccc55caa9 9608 qede: error: 'free_buffer_count' may be used uninitialized in this function commit 0d7de619fa7b28e48c8e80fa26d724400f4f47a4 9607 qede: this statement may fall through commit 77b62fe435d195b5a58f123e6c5ec9c9dffdc877 9606 qede: error: this 'for' clause does not guard Conflicts: usr/src/man/man1m/route.1m usr/src/lib/libdladm/Makefile.com
Diffstat (limited to 'usr/src/lib/libnsl')
-rw-r--r--usr/src/lib/libnsl/Makefile.com10
-rw-r--r--usr/src/lib/libnsl/common/llib-lnsl18
-rw-r--r--usr/src/lib/libnsl/common/mapfile-vers35
-rw-r--r--usr/src/lib/libnsl/nss/inet_ntop.c187
-rw-r--r--usr/src/lib/libnsl/nss/inet_pton.c221
-rw-r--r--usr/src/lib/libnsl/rpc/inet_ntoa.c286
6 files changed, 27 insertions, 730 deletions
diff --git a/usr/src/lib/libnsl/Makefile.com b/usr/src/lib/libnsl/Makefile.com
index 792e1cd24f..876c3681e9 100644
--- a/usr/src/lib/libnsl/Makefile.com
+++ b/usr/src/lib/libnsl/Makefile.com
@@ -21,7 +21,7 @@
#
# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2018 Nexenta Systems, Inc. All rights reserved.
#
LIBRARY= libnsl.a
@@ -43,7 +43,7 @@ NETDIR= netdir.o
NSS= \
gethostbyname_r.o gethostent.o gethostent_r.o gethostent6.o gethostby_door.o \
getipnodeby_door.o getipnodeby.o getrpcent.o getrpcent_r.o inet_matchaddr.o \
-inet_pton.o inet_ntop.o netdir_inet.o netdir_inet_sundry.o \
+netdir_inet.o netdir_inet_sundry.o \
parse.o getauthattr.o getprofattr.o getexecattr.o getuserattr.o getauuser.o
NETSELECT= netselect.o
@@ -55,7 +55,7 @@ t_connect.o t_error.o t_free.o t_getinfo.o t_getname.o \
t_getstate.o t_listen.o t_look.o t_open.o t_optmgmt.o \
t_rcv.o t_rcvconnect.o t_rcvdis.o t_rcvrel.o t_rcvudata.o \
t_rcvuderr.o t_snd.o t_snddis.o t_sndrel.o t_sndudata.o \
-t_sndv.o t_sndreldata.o t_rcvv.o t_rcvreldata.o t_sysconf.o \
+t_sndv.o t_sndreldata.o t_rcvv.o t_rcvreldata.o t_sysconf.o \
t_sndvudata.o t_rcvvudata.o t_sync.o t_unbind.o t_strerror.o \
xti_wrappers.o
@@ -67,7 +67,7 @@ auth_des.o auth_none.o auth_sys.o auth_time.o authdes_prot.o \
authsys_prot.o can_use_af.o \
clnt_bcast.o clnt_dg.o clnt_door.o clnt_generic.o clnt_perror.o \
clnt_raw.o clnt_simple.o clnt_vc.o fdsync.o getdname.o \
-inet_ntoa.o key_call.o key_prot.o mt_misc.o \
+key_call.o key_prot.o mt_misc.o \
netname.o netnamer.o pmap_clnt.o pmap_prot.o \
rpc_callmsg.o rpc_comdata.o rpc_generic.o rpc_prot.o rpc_sel2poll.o \
rpc_soc.o rpc_td.o rpcb_clnt.o rpcb_prot.o \
@@ -83,7 +83,7 @@ SAF= checkver.o doconfig.o
YP= \
dbm.o yp_all.o yp_b_clnt.o yp_b_xdr.o yp_bind.o \
yp_enum.o yp_master.o yp_match.o yp_order.o yp_update.o \
-yperr_string.o yp_xdr.o ypprot_err.o ypupd.o \
+yperr_string.o yp_xdr.o ypprot_err.o ypupd.o \
yp_rsvd.o \
yppasswd_xdr.o
diff --git a/usr/src/lib/libnsl/common/llib-lnsl b/usr/src/lib/libnsl/common/llib-lnsl
index 46f74824eb..8a1fba5b94 100644
--- a/usr/src/lib/libnsl/common/llib-lnsl
+++ b/usr/src/lib/libnsl/common/llib-lnsl
@@ -22,8 +22,10 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- *
- * Copyright 2016 Nexenta Systems, Inc.
+ */
+
+/*
+ * Copyright 2018 Nexenta Systems, Inc.
*/
@@ -442,12 +444,6 @@ struct rpcent *getrpcent_r(struct rpcent *result, char *buffer, int buflen);
/* inet_matchaddr.c */
int inet_matchaddr(const void *, const char *);
-/* inet_ntop.c */
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
-
-/* inet_pton.c */
-int inet_pton(int af, const char *src, void *dst);
-
/* netdir_inet.c */
int _get_hostserv_inetnetdir_byname(struct netconfig *nconf,
struct nss_netdirbyname_in *args,
@@ -568,12 +564,6 @@ int setdomainname(char *domain, int len);
/* gethostname.c */
int gethostname(char *hname, int hlen);
-/* inet_ntoa.c */
-char *inet_ntoa_r(struct in_addr in, char b[]);
-char *inet_ntoa(struct in_addr in);
-in_addr_t inet_addr(const char *cp);
-in_addr_t inet_netof(struct in_addr in);
-
/* key_call.c */
int key_setsecret(const char *secretkey);
int key_secretkey_is_set(void);
diff --git a/usr/src/lib/libnsl/common/mapfile-vers b/usr/src/lib/libnsl/common/mapfile-vers
index aafb70af9f..bae1af4edc 100644
--- a/usr/src/lib/libnsl/common/mapfile-vers
+++ b/usr/src/lib/libnsl/common/mapfile-vers
@@ -18,10 +18,11 @@
#
# CDDL HEADER END
#
+
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2015 Joyent, Inc.
-# Copyright 2017 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2018 Nexenta Systems, Inc.
#
#
@@ -40,7 +41,7 @@
$mapfile_version 2
-SYMBOL_VERSION ILLUMOS_0.1 { # Illumos additions
+SYMBOL_VERSION ILLUMOS_0.1 { # illumos additions
global:
svc_tp_create_addr;
} SUNW_1.10;
@@ -52,7 +53,7 @@ SYMBOL_VERSION SUNW_1.10 { # SunOS 5.11 (Solaris 11)
SYMBOL_VERSION SUNW_1.9.1 { # SunOS 5.10 (Solaris 10 update 5)
global:
- inet_aton;
+ inet_aton { TYPE = FUNCTION; FILTER = libc.so.1 };
} SUNW_1.9;
SYMBOL_VERSION SUNW_1.9 { # SunOS 5.10 (Solaris 10)
@@ -78,8 +79,8 @@ SYMBOL_VERSION SUNW_1.7 { # SunOS 5.8 (Solaris 8)
freehostent;
getipnodebyaddr;
getipnodebyname;
- inet_ntop;
- inet_pton;
+ inet_ntop { TYPE = FUNCTION; FILTER = libc.so.1 };
+ inet_pton { TYPE = FUNCTION; FILTER = libc.so.1 };
} SUNW_1.6;
SYMBOL_VERSION SUNW_1.6 { # SunOS 5.7 (Solaris 7)
@@ -235,16 +236,16 @@ SYMBOL_VERSION SUNW_0.7 { # SunOS 5.3 (Solaris 2.3)
getrpcent;
getrpcent_r;
h_errno { FLAGS = NODIRECT };
- inet_ntoa_r;
+ inet_ntoa_r { TYPE = FUNCTION; FILTER = libc.so.1 };
key_secretkey_is_set;
maxbno;
nc_sperror;
netdir_perror;
netdir_sperror;
nextkey;
- nis_clone_object;
- nis_destroy_object;
- nis_dir_cmp;
+ nis_clone_object;
+ nis_destroy_object;
+ nis_dir_cmp;
nis_domain_of;
nis_leaf_of;
nis_leaf_of_r;
@@ -318,9 +319,9 @@ SYMBOL_VERSION SISCD_2.3 {
$endif
gethostbyaddr;
gethostbyname;
- inet_addr;
- inet_netof;
- inet_ntoa;
+ inet_addr { TYPE = FUNCTION; FILTER = libc.so.1 };
+ inet_netof { TYPE = FUNCTION; FILTER = libc.so.1 };
+ inet_ntoa { TYPE = FUNCTION; FILTER = libc.so.1 };
_null_auth;
rpc_broadcast_exp;
svc_fdset;
@@ -579,8 +580,8 @@ SYMBOL_VERSION SUNWprivate_1.1 {
__getnetnamebyuid;
__getpublickey_cached;
__getpublickey_cached_g;
- __getpublickey_flush;
- __getpublickey_flush_g;
+ __getpublickey_flush;
+ __getpublickey_flush_g;
getpublickey_g;
getsecretkey_g;
hashinc;
@@ -620,17 +621,17 @@ SYMBOL_VERSION SUNWprivate_1.1 {
__nis_get_mechanism_library;
__nis_get_mechanisms;
__nis_get_mechanism_symbol;
- nis_get_static_storage;
+ nis_get_static_storage;
__nis_gssprin2netname;
__nis_keyalg2authtype;
__nis_keyalg2mechalias;
__nis_mechalias2authtype;
__nis_mechname2alias;
- nis_read_obj;
+ nis_read_obj;
__nis_release_mechanisms;
__nis_rpc_domain;
__nis_translate_mechanism;
- nis_write_obj;
+ nis_write_obj;
__nsl_dom;
__nss2herrno;
nss_ioctl;
diff --git a/usr/src/lib/libnsl/nss/inet_ntop.c b/usr/src/lib/libnsl/nss/inet_ntop.c
deleted file mode 100644
index 28067cffa0..0000000000
--- a/usr/src/lib/libnsl/nss/inet_ntop.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "mt.h"
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <strings.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <errno.h>
-
-static const char *inet_ntop4(const uchar_t *, char *, socklen_t);
-static const char *inet_ntop6(const uchar_t *, char *, socklen_t);
-
-/*
- * char *
- * inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
- */
-const char *
-inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
- switch (af) {
- case AF_INET:
- return (inet_ntop4(src, dst, size));
- case AF_INET6:
- return (inet_ntop6(src, dst, size));
- default:
- errno = EAFNOSUPPORT;
- return (NULL);
- }
- /* NOTREACHED */
-}
-
-/*
- * const char *
- * inet_ntop4(src, dst, size)
- * format an IPv4 address, more or less like inet_ntoa()
- * return:
- * `dst' (as a const)
- * notes:
- * (1) uses no statics
- * (2) takes a uchar_t* not an in_addr as input
- */
-
-#ifdef SPRINTF_CHAR
-/* CSTYLED */
-#define SPRINTF(x) strlen(sprintf/**/x)
-#else
-#define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-static const char *
-inet_ntop4(const uchar_t *src, char *dst, socklen_t size)
-{
- static const char fmt[] = "%u.%u.%u.%u";
- char tmp[sizeof ("255.255.255.255")];
-
- if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
- errno = ENOSPC;
- return (NULL);
- }
- (void) strcpy(dst, tmp);
- return (dst);
-}
-
-/*
- * const char *
- * inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
- */
-#define INADDRSZ 4
-#define IN6ADDRSZ 16
-#define INT16SZ 2
-static const char *
-inet_ntop6(const uchar_t *src, char *dst, socklen_t size)
-{
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")], *tp;
- struct { int base, len; } best, cur;
- uint_t words[IN6ADDRSZ / INT16SZ];
- int i;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- (void) memset(words, '\0', sizeof (words));
- for (i = 0; i < IN6ADDRSZ; i++)
- words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
- best.base = -1;
- cur.base = -1;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
- if (words[i] == 0) {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- } else {
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
- }
- }
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- }
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base &&
- i < (best.base + best.len)) {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof (tmp) - (tp - tmp)))
- return (NULL);
- tp += strlen(tp);
- break;
- }
- tp += SPRINTF((tp, "%x", words[i]));
- }
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
- if ((int)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
- }
- (void) strcpy(dst, tmp);
- return (dst);
-}
diff --git a/usr/src/lib/libnsl/nss/inet_pton.c b/usr/src/lib/libnsl/nss/inet_pton.c
deleted file mode 100644
index ec94b1f5e5..0000000000
--- a/usr/src/lib/libnsl/nss/inet_pton.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "mt.h"
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <strings.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <errno.h>
-
-static int inet_pton4(const char *src, uchar_t *dst);
-static int inet_pton6(const char *src, uchar_t *dst);
-
-/*
- * int
- * inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
- * return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- * Paul Vixie, 1996. Taken from on297-gate:dns stuff
- */
-int
-inet_pton(int af, const char *src, void *dst)
-{
- switch (af) {
- case AF_INET:
- return (inet_pton4(src, dst));
- case AF_INET6:
- return (inet_pton6(src, dst));
- default:
- errno = EAFNOSUPPORT;
- return (-1);
- }
- /* NOTREACHED */
-}
-
-/*
- * int
- * inet_pton4(src, dst)
- * like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- * 1 if `src' is a valid dotted quad, else 0.
- * notice:
- * does not touch `dst' unless it's returning 1.
- *
- */
-#define INADDRSZ 4
-#define IN6ADDRSZ 16
-#define INT16SZ 2
-
-static int
-inet_pton4(const char *src, uchar_t *dst)
-{
- static const char digits[] = "0123456789";
- int saw_digit, octets, ch;
- uchar_t tmp[INADDRSZ], *tp;
-
- saw_digit = 0;
- octets = 0;
- *(tp = tmp) = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr(digits, ch)) != NULL) {
- uint_t new = *tp * 10 + (pch - digits);
-
- if (new > 255)
- return (0);
- *tp = new;
- if (!saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
- }
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
- return (0);
- *++tp = 0;
- saw_digit = 0;
- } else
- return (0);
- }
- if (octets < 4)
- return (0);
-
- (void) memcpy(dst, tmp, INADDRSZ);
- return (1);
-}
-
-
-/*
- * int
- * inet_pton6(src, dst)
- * convert presentation level address to network order binary form.
- * return:
- * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- * (1) does not touch `dst' unless it's returning 1.
- * (2) :: in a full address is silently ignored.
- * credit:
- * inspired by Mark Andrews.
- *
- */
-
-
-static int
-inet_pton6(const char *src, uchar_t *dst)
-{
- static const char xdigits_l[] = "0123456789abcdef",
- xdigits_u[] = "0123456789ABCDEF";
- uchar_t tmp[IN6ADDRSZ], *tp, *endp, *colonp;
- const char *xdigits, *curtok;
- int ch, saw_xdigit;
- uint_t val;
-
- (void) memset((tp = tmp), '\0', IN6ADDRSZ);
- endp = tp + IN6ADDRSZ;
- colonp = NULL;
- /* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
- return (0);
- curtok = src;
- saw_xdigit = 0;
- val = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
- pch = strchr((xdigits = xdigits_u), ch);
- if (pch != NULL) {
- val <<= 4;
- val |= (pch - xdigits);
- if (val > 0xffff)
- return (0);
- saw_xdigit = 1;
- continue;
- }
- if (ch == ':') {
- curtok = src;
- if (!saw_xdigit) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
- } else if (*src == '\0') {
- return (0);
- }
- if (tp + INT16SZ > endp)
- return (0);
- *tp++ = (uchar_t)(val >> 8) & 0xff;
- *tp++ = (uchar_t)val & 0xff;
- saw_xdigit = 0;
- val = 0;
- continue;
- }
- if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
- inet_pton4(curtok, tp) > 0) {
- tp += INADDRSZ;
- saw_xdigit = 0;
- break; /* '\0' was seen by inet_pton4(). */
- }
- return (0);
- }
- if (saw_xdigit) {
- if (tp + INT16SZ > endp)
- return (0);
- *tp++ = (uchar_t)(val >> 8) & 0xff;
- *tp++ = (uchar_t)val & 0xff;
- }
- if (colonp != NULL) {
- /*
- * Since some memmove()'s erroneously fail to handle
- * overlapping regions, we'll do the shift by hand.
- */
- const int n = tp - colonp;
- int i;
-
- if (tp == endp)
- return (0);
- for (i = 1; i <= n; i++) {
- endp[- i] = colonp[n - i];
- colonp[n - i] = 0;
- }
- tp = endp;
- }
- if (tp != endp)
- return (0);
- (void) memcpy(dst, tmp, IN6ADDRSZ);
- return (1);
-}
diff --git a/usr/src/lib/libnsl/rpc/inet_ntoa.c b/usr/src/lib/libnsl/rpc/inet_ntoa.c
deleted file mode 100644
index f68ed15e39..0000000000
--- a/usr/src/lib/libnsl/rpc/inet_ntoa.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-/*
- * Portions of this source code were derived from Berkeley
- * 4.3 BSD under license from the Regents of the University of
- * California.
- */
-
-/*
- * Copyright (c) 1983, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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.
- */
-
-/*
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Convert network-format internet address
- * to base 256 d.d.d.d representation.
- *
- * Reentrant interface
- */
-
-#include "mt.h"
-#include "rpc_mt.h"
-#include <errno.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-char *
-inet_ntoa_r(in, b)
- struct in_addr in;
- char b[]; /* Assumed >= 18 bytes */
-{
- char *p;
-
- p = (char *)&in;
-#define UC(b) (((int)b)&0xff)
- (void) sprintf(b, "%d.%d.%d.%d",
- UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
- return (b);
-}
-
-char *
-inet_ntoa(in)
- struct in_addr in;
-{
- char *b;
- static char b_main[18];
- static pthread_key_t ntoa_key = PTHREAD_ONCE_KEY_NP;
-
- if (thr_main())
- b = b_main;
- else if ((b = thr_get_storage(&ntoa_key, 18, free)) == NULL)
- b = b_main;
-
- return (inet_ntoa_r(in, b));
-}
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
- uint32_t val;
- int base, n;
- char c;
- unsigned int parts[4];
- unsigned int *pp = parts;
-
-
- c = *cp;
- for (;;) {
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, isdigit=decimal.
- */
- if (!isdigit(c))
- return (0);
- val = 0; base = 10;
- if (c == '0') {
- c = *++cp;
- if (c == 'x' || c == 'X')
- base = 16, c = *++cp;
- else
- base = 8;
- }
- for (;;) {
- if (isascii(c) && isdigit(c)) {
- val = (val * base) + (c - '0');
- c = *++cp;
- } else if (base == 16 && isascii(c) && isxdigit(c)) {
- val = (val << 4) |
- (c + 10 - (islower(c) ? 'a' : 'A'));
- c = *++cp;
- } else
- break;
- }
- if (c == '.') {
- /*
- * Internet format:
- * a.b.c.d
- * a.b.c (with c treated as 16 bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3)
- return (0);
- *pp++ = val;
- c = *++cp;
- } else
- break;
- }
- /*
- * Check for trailing characters.
- */
- if (c != '\0' && (!isascii(c) || !isspace(c)))
- return (0);
- /*
- * Concoct the address according to
- * the number of parts specified.
- */
- n = pp - parts + 1;
- switch (n) {
-
- case 0:
- return (0); /* initial nondigit */
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if ((val > 0xffffff) || (parts[0] > 0xff))
- return (0);
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) ||
- (parts[2] > 0xff))
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
- if (addr)
- addr->s_addr = htonl(val);
- return (1);
-}
-
-/*
- * Internet address interpretation routine.
- * All the network library routines call this
- * routine to interpret entries in the data bases
- * which are expected to be an address.
- * The value returned is in network order.
- */
-in_addr_t
-inet_addr(const char *cp)
-{
- struct in_addr val;
-
- if (inet_aton(cp, &val))
- return (val.s_addr);
- return (INADDR_NONE);
-}
-
-/*
- * Return the network number from an internet
- * address; handles class a/b/c network #'s.
- */
-uint_t
-inet_netof(struct in_addr in)
-{
- uint32_t i = ntohl(in.s_addr);
-
- if (IN_CLASSA(i))
- return ((i & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
- if (IN_CLASSB(i))
- return ((i & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
- return ((i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
-}