diff options
Diffstat (limited to 'lib/libc/inet')
-rw-r--r-- | lib/libc/inet/Makefile.inc | 11 | ||||
-rw-r--r-- | lib/libc/inet/Symbol.map | 36 | ||||
-rw-r--r-- | lib/libc/inet/inet_addr.c | 31 | ||||
-rw-r--r-- | lib/libc/inet/inet_cidr_pton.c | 22 | ||||
-rw-r--r-- | lib/libc/inet/inet_lnaof.c | 19 | ||||
-rw-r--r-- | lib/libc/inet/inet_makeaddr.c | 17 | ||||
-rw-r--r-- | lib/libc/inet/inet_net_ntop.c | 33 | ||||
-rw-r--r-- | lib/libc/inet/inet_net_pton.c | 53 | ||||
-rw-r--r-- | lib/libc/inet/inet_neta.c | 17 | ||||
-rw-r--r-- | lib/libc/inet/inet_netof.c | 19 | ||||
-rw-r--r-- | lib/libc/inet/inet_network.c | 27 | ||||
-rw-r--r-- | lib/libc/inet/inet_ntoa.c | 17 | ||||
-rw-r--r-- | lib/libc/inet/inet_ntop.c | 50 | ||||
-rw-r--r-- | lib/libc/inet/inet_pton.c | 32 | ||||
-rw-r--r-- | lib/libc/inet/nsap_addr.c | 13 |
15 files changed, 244 insertions, 153 deletions
diff --git a/lib/libc/inet/Makefile.inc b/lib/libc/inet/Makefile.inc new file mode 100644 index 0000000..0e6cc39 --- /dev/null +++ b/lib/libc/inet/Makefile.inc @@ -0,0 +1,11 @@ +# $FreeBSD$ + +# inet sources +.PATH: ${.CURDIR}/inet + +SRCS+= inet_addr.c inet_cidr_ntop.c inet_cidr_pton.c inet_lnaof.c \ + inet_makeaddr.c inet_net_ntop.c inet_net_pton.c inet_neta.c \ + inet_netof.c inet_network.c inet_ntoa.c inet_ntop.c \ + inet_pton.c nsap_addr.c + +SYM_MAPS+= ${.CURDIR}/inet/Symbol.map diff --git a/lib/libc/inet/Symbol.map b/lib/libc/inet/Symbol.map new file mode 100644 index 0000000..13d1f47 --- /dev/null +++ b/lib/libc/inet/Symbol.map @@ -0,0 +1,36 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.0 { + __inet_addr; + __inet_aton; + inet_addr; + inet_aton; + __inet_cidr_ntop; + __inet_cidr_pton; + __inet_lnaof; + inet_lnaof; + __inet_makeaddr; + inet_makeaddr; + __inet_net_ntop; + inet_net_ntop; + __inet_net_pton; + inet_net_pton; + __inet_neta; + inet_neta; + __inet_netof; + inet_netof; + __inet_network; + inet_network; + __inet_ntoa; + inet_ntoa; + __inet_ntop; + inet_ntop; + __inet_pton; + inet_pton; + __inet_nsap_addr; + __inet_nsap_ntoa; + inet_nsap_addr; + inet_nsap_ntoa; +}; diff --git a/lib/libc/inet/inet_addr.c b/lib/libc/inet/inet_addr.c index c95622d..4a8b80f 100644 --- a/lib/libc/inet/inet_addr.c +++ b/lib/libc/inet/inet_addr.c @@ -10,10 +10,6 @@ * 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. @@ -70,8 +66,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static const char rcsid[] = "$Id: inet_addr.c,v 1.4.18.1 2005/04/27 05:00:52 sra Exp $"; +static const char rcsid[] = "$Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -85,11 +83,11 @@ static const char rcsid[] = "$Id: inet_addr.c,v 1.4.18.1 2005/04/27 05:00:52 sra #include "port_after.h" -/*% +/* * Ascii internet address interpretation routine. * The value returned is in network order. */ -u_long +in_addr_t /* XXX should be struct in_addr :( */ inet_addr(const char *cp) { struct in_addr val; @@ -98,7 +96,7 @@ inet_addr(const char *cp) { return (INADDR_NONE); } -/*% +/* * 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. @@ -179,22 +177,22 @@ inet_aton(const char *cp, struct in_addr *addr) { */ n = pp - parts + 1; switch (n) { - case 1: /*%< a -- 32 bits */ + case 1: /* a -- 32 bits */ break; - case 2: /*%< a.b -- 8.24 bits */ + case 2: /* a.b -- 8.24 bits */ if (val > 0xffffffU) return (0); val |= parts[0] << 24; break; - case 3: /*%< a.b.c -- 8.8.16 bits */ + case 3: /* a.b.c -- 8.8.16 bits */ if (val > 0xffffU) return (0); val |= (parts[0] << 24) | (parts[1] << 16); break; - case 4: /*%< a.b.c.d -- 8.8.8.8 bits */ + case 4: /* a.b.c.d -- 8.8.8.8 bits */ if (val > 0xffU) return (0); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); @@ -205,4 +203,11 @@ inet_aton(const char *cp, struct in_addr *addr) { return (1); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_addr +__weak_reference(__inet_addr, inet_addr); +#undef inet_aton +__weak_reference(__inet_aton, inet_aton); diff --git a/lib/libc/inet/inet_cidr_pton.c b/lib/libc/inet/inet_cidr_pton.c index b55e3ea..3089eb9 100644 --- a/lib/libc/inet/inet_cidr_pton.c +++ b/lib/libc/inet/inet_cidr_pton.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.5.18.1 2005/04/27 05:00:53 sra Exp $"; +static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.2.2.1.8.2 2004/03/17 00:29:46 marka Exp $"; #endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -27,7 +29,7 @@ static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.5.18.1 2005/04/27 05:00:5 #include <arpa/nameser.h> #include <arpa/inet.h> -#include <isc/assertions.h> +#include <assert.h> #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -49,7 +51,7 @@ static int inet_cidr_pton_ipv6 __P((const char *src, u_char *dst, static int getbits(const char *, int ipv6); -/*% +/* * int * inet_cidr_pton(af, src, dst, *bits) * convert network address from presentation to network format. @@ -92,7 +94,7 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, int *pbits, int ipv6) { tmp = 0; do { n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); + assert(n >= 0 && n <= 9); tmp *= 10; tmp += n; if (tmp > 255) @@ -204,7 +206,7 @@ inet_cidr_pton_ipv6(const char *src, u_char *dst, int *pbits) { inet_cidr_pton_ipv4(curtok, tp, &bits, 1) == 0) { tp += NS_INADDRSZ; saw_xdigit = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } if (ch == '/') { bits = getbits(src, 1); @@ -256,22 +258,20 @@ getbits(const char *src, int ipv6) { int bits = 0; char *cp, ch; - if (*src == '\0') /*%< syntax */ + if (*src == '\0') /* syntax */ return (-2); do { ch = *src++; cp = strchr(digits, ch); - if (cp == NULL) /*%< syntax */ + if (cp == NULL) /* syntax */ return (-2); bits *= 10; bits += cp - digits; - if (bits == 0 && *src != '\0') /*%< no leading zeros */ + if (bits == 0 && *src != '\0') /* no leading zeros */ return (-2); - if (bits > (ipv6 ? 128 : 32)) /*%< range error */ + if (bits > (ipv6 ? 128 : 32)) /* range error */ return (-2); } while (*src != '\0'); return (bits); } - -/*! \file */ diff --git a/lib/libc/inet/inet_lnaof.c b/lib/libc/inet/inet_lnaof.c index 70ac409..9e419f7 100644 --- a/lib/libc/inet/inet_lnaof.c +++ b/lib/libc/inet/inet_lnaof.c @@ -10,10 +10,6 @@ * 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. @@ -34,6 +30,8 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -43,16 +41,16 @@ static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; #include "port_after.h" -/*% +/* * Return the local network address portion of an * internet address; handles class a/b/c network * number formats. */ -u_long +in_addr_t inet_lnaof(in) struct in_addr in; { - register u_long i = ntohl(in.s_addr); + in_addr_t i = ntohl(in.s_addr); if (IN_CLASSA(i)) return ((i)&IN_CLASSA_HOST); @@ -62,4 +60,9 @@ inet_lnaof(in) return ((i)&IN_CLASSC_HOST); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_lnaof +__weak_reference(__inet_lnaof, inet_lnaof); diff --git a/lib/libc/inet/inet_makeaddr.c b/lib/libc/inet/inet_makeaddr.c index c56cb3e..2f6998d 100644 --- a/lib/libc/inet/inet_makeaddr.c +++ b/lib/libc/inet/inet_makeaddr.c @@ -10,10 +10,6 @@ * 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. @@ -34,6 +30,8 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -43,13 +41,13 @@ static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; #include "port_after.h" -/*% +/* * Formulate an Internet address from network + host. Used in * building addresses stored in the ifnet structure. */ struct in_addr inet_makeaddr(net, host) - u_long net, host; + in_addr_t net, host; { struct in_addr a; @@ -65,4 +63,9 @@ inet_makeaddr(net, host) return (a); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_makeaddr +__weak_reference(__inet_makeaddr, inet_makeaddr); diff --git a/lib/libc/inet/inet_net_ntop.c b/lib/libc/inet/inet_net_ntop.c index a1ac243..1c95df5 100644 --- a/lib/libc/inet/inet_net_ntop.c +++ b/lib/libc/inet/inet_net_ntop.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3.18.2 2006/06/20 02:51:32 marka Exp $"; +static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.1.2.1.8.2 2006/06/20 02:53:07 marka Exp $"; #endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -39,12 +41,12 @@ static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3.18.2 2006/06/20 02:51:32 # define SPRINTF(x) ((size_t)sprintf x) #endif -static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits, - char *dst, size_t size)); -static char * inet_net_ntop_ipv6 __P((const u_char *src, int bits, - char *dst, size_t size)); +static char * inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, + size_t size); +static char * inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, + size_t size); -/*% +/* * char * * inet_net_ntop(af, src, bits, dst, size) * convert network number from network to presentation format. @@ -73,7 +75,7 @@ inet_net_ntop(af, src, bits, dst, size) } } -/*% +/* * static char * * inet_net_ntop_ipv4(src, bits, dst, size) * convert IPv4 network number from network to presentation format. @@ -148,7 +150,7 @@ inet_net_ntop_ipv4(src, bits, dst, size) return (NULL); } -/*% +/* * static char * * inet_net_ntop_ipv6(src, bits, fakebits, dst, size) * convert IPv6 network number from network to presentation format. @@ -159,7 +161,7 @@ inet_net_ntop_ipv4(src, bits, dst, size) * pointer to dst, or NULL if an error occurred (check errno). * note: * network byte order assumed. this means 192.5.5.240/28 has - * 0x11110000 in its fourth octet. + * 0b11110000 in its fourth octet. * author: * Vadim Kogan (UCB), June 2001 * Original version (IPv4) by Paul Vixie (ISC), July 1996 @@ -191,7 +193,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) { *cp++ = ':'; *cp = '\0'; } else { - /* Copy src to private buffer. Zero host part. */ + /* Copy src to private buffer. Zero host part. */ p = (bits + 7) / 8; memcpy(inbuf, src, p); memset(inbuf + p, 0, 16 - p); @@ -207,7 +209,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) { words = (bits + 15) / 16; if (words == 1) words = 2; - + /* Find the longest substring of zero's */ zero_s = zero_l = tmp_zero_s = tmp_zero_l = 0; for (i = 0; i < (words * 2); i += 2) { @@ -268,7 +270,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) { if (strlen(outbuf) + 1 > size) goto emsgsize; strcpy(dst, outbuf); - + return (dst); emsgsize: @@ -276,4 +278,9 @@ emsgsize: return (NULL); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_net_ntop +__weak_reference(__inet_net_ntop, inet_net_ntop); diff --git a/lib/libc/inet/inet_net_pton.c b/lib/libc/inet/inet_net_pton.c index d3de33b..3d9650c 100644 --- a/lib/libc/inet/inet_net_pton.c +++ b/lib/libc/inet/inet_net_pton.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 sra Exp $"; +static const char rcsid[] = "$Id: inet_net_pton.c,v 1.4.2.1.8.2 2004/03/17 00:29:47 marka Exp $"; #endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -27,7 +29,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 #include <arpa/nameser.h> #include <arpa/inet.h> -#include <isc/assertions.h> +#include <assert.h> #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -42,7 +44,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 # define SPRINTF(x) ((size_t)sprintf x) #endif -/*% +/* * static int * inet_net_pton_ipv4(src, dst, size) * convert IPv4 network number from presentation to network format. @@ -73,12 +75,12 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { if (size <= 0U) goto emsgsize; dirty = 0; - src++; /*%< skip x or X. */ + src++; /* skip x or X. */ while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) { if (isupper(ch)) ch = tolower(ch); n = strchr(xdigits, ch) - xdigits; - INSIST(n >= 0 && n <= 15); + assert(n >= 0 && n <= 15); if (dirty == 0) tmp = n; else @@ -90,7 +92,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { dirty = 0; } } - if (dirty) { /*%< Odd trailing nybble? */ + if (dirty) { /* Odd trailing nybble? */ if (size-- <= 0U) goto emsgsize; *dst++ = (u_char) (tmp << 4); @@ -101,7 +103,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { tmp = 0; do { n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); + assert(n >= 0 && n <= 9); tmp *= 10; tmp += n; if (tmp > 255) @@ -126,11 +128,11 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { if (ch == '/' && isascii((unsigned char)(src[0])) && isdigit((unsigned char)(src[0])) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /*%< Skip over the /. */ + ch = *src++; /* Skip over the /. */ bits = 0; do { n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); + assert(n >= 0 && n <= 9); bits *= 10; bits += n; } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); @@ -149,15 +151,15 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) { goto enoent; /* If no CIDR spec was given, infer width from net class. */ if (bits == -1) { - if (*odst >= 240) /*%< Class E */ + if (*odst >= 240) /* Class E */ bits = 32; - else if (*odst >= 224) /*%< Class D */ + else if (*odst >= 224) /* Class D */ bits = 8; - else if (*odst >= 192) /*%< Class C */ + else if (*odst >= 192) /* Class C */ bits = 24; - else if (*odst >= 128) /*%< Class B */ + else if (*odst >= 128) /* Class B */ bits = 16; - else /*%< Class A */ + else /* Class A */ bits = 8; /* If imputed mask is narrower than specified octets, widen. */ if (bits < ((dst - odst) * 8)) @@ -200,11 +202,11 @@ getbits(const char *src, int *bitsp) { pch = strchr(digits, ch); if (pch != NULL) { - if (n++ != 0 && val == 0) /*%< no leading zeros */ + if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += (pch - digits); - if (val > 128) /*%< range */ + if (val > 128) /* range */ return (0); continue; } @@ -231,16 +233,16 @@ getv4(const char *src, u_char *dst, int *bitsp) { pch = strchr(digits, ch); if (pch != NULL) { - if (n++ != 0 && val == 0) /*%< no leading zeros */ + if (n++ != 0 && val == 0) /* no leading zeros */ return (0); val *= 10; val += (pch - digits); - if (val > 255) /*%< range */ + if (val > 255) /* range */ return (0); continue; } if (ch == '.' || ch == '/') { - if (dst - odst > 3) /*%< too many octets? */ + if (dst - odst > 3) /* too many octets? */ return (0); *dst++ = val; if (ch == '/') @@ -253,7 +255,7 @@ getv4(const char *src, u_char *dst, int *bitsp) { } if (n == 0) return (0); - if (dst - odst > 3) /*%< too many octets? */ + if (dst - odst > 3) /* too many octets? */ return (0); *dst++ = val; return (1); @@ -322,7 +324,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) { tp += NS_INADDRSZ; saw_xdigit = 0; ipv4 = 1; - break; /*%< '\\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } if (ch == '/' && getbits(src, &bits) > 0) break; @@ -378,7 +380,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) { return (-1); } -/*% +/* * int * inet_net_pton(af, src, dst, size) * convert network number from presentation to network format. @@ -404,4 +406,9 @@ inet_net_pton(int af, const char *src, void *dst, size_t size) { } } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_net_pton +__weak_reference(__inet_net_pton, inet_net_pton); diff --git a/lib/libc/inet/inet_neta.c b/lib/libc/inet/inet_neta.c index bc3b601..872ad48 100644 --- a/lib/libc/inet/inet_neta.c +++ b/lib/libc/inet/inet_neta.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra Exp $"; +static const char rcsid[] = "$Id: inet_neta.c,v 1.1.206.1 2004/03/09 08:33:33 marka Exp $"; #endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -38,10 +40,10 @@ static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra # define SPRINTF(x) ((size_t)sprintf x) #endif -/*% +/* * char * * inet_neta(src, dst, size) - * format a u_long network number into presentation format. + * format an in_addr_t network number into presentation format. * return: * pointer to dst, or NULL if an error occurred (check errno). * note: @@ -51,7 +53,7 @@ static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra */ char * inet_neta(src, dst, size) - u_long src; + in_addr_t src; char *dst; size_t size; { @@ -86,4 +88,9 @@ inet_neta(src, dst, size) return (NULL); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_neta +__weak_reference(__inet_neta, inet_neta); diff --git a/lib/libc/inet/inet_netof.c b/lib/libc/inet/inet_netof.c index c228e3d..8f3ff63 100644 --- a/lib/libc/inet/inet_netof.c +++ b/lib/libc/inet/inet_netof.c @@ -10,10 +10,6 @@ * 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. @@ -34,6 +30,8 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -43,15 +41,15 @@ static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93"; #include "port_after.h" -/*% +/* * Return the network number from an internet * address; handles class a/b/c network #'s. */ -u_long +in_addr_t inet_netof(in) struct in_addr in; { - register u_long i = ntohl(in.s_addr); + in_addr_t i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); @@ -61,4 +59,9 @@ inet_netof(in) return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_netof +__weak_reference(__inet_netof, inet_netof); diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c index 4758a00..2194411 100644 --- a/lib/libc/inet/inet_network.c +++ b/lib/libc/inet/inet_network.c @@ -10,10 +10,6 @@ * 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. @@ -34,6 +30,8 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -44,19 +42,19 @@ static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; #include "port_after.h" -/*% +/* * Internet network address interpretation routine. * The library routines call this routine to interpret * network numbers. */ -u_long +in_addr_t inet_network(cp) - register const char *cp; + const char *cp; { - register u_long val, base, n, i; - register char c; - u_long parts[4], *pp = parts; - int digit; + in_addr_t val, base, n; + char c; + in_addr_t parts[4], *pp = parts; + int i, digit; again: val = 0; base = 10; digit = 0; @@ -103,4 +101,9 @@ again: return (val); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_network +__weak_reference(__inet_network, inet_network); diff --git a/lib/libc/inet/inet_ntoa.c b/lib/libc/inet/inet_ntoa.c index 1d566be..1b3ec0f 100644 --- a/lib/libc/inet/inet_ntoa.c +++ b/lib/libc/inet/inet_ntoa.c @@ -10,10 +10,6 @@ * 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. @@ -33,8 +29,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1.352.1 2005/04/27 05:00:54 sra Exp $"; +static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1 2001/03/29 06:31:38 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -48,7 +46,7 @@ static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1.352.1 2005/04/27 05:00:54 sr #include "port_after.h" -/*% +/* * Convert network-format internet address * to base 256 d.d.d.d representation. */ @@ -61,4 +59,9 @@ inet_ntoa(struct in_addr in) { return (ret); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_ntoa +__weak_reference(__inet_ntoa, inet_ntoa); diff --git a/lib/libc/inet/inet_ntop.c b/lib/libc/inet/inet_ntop.c index 9ab38bc..48c2efe 100644 --- a/lib/libc/inet/inet_ntop.c +++ b/lib/libc/inet/inet_ntop.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $"; +static const char rcsid[] = "$Id: inet_ntop.c,v 1.1.2.1.8.2 2005/11/03 23:08:40 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -35,19 +37,13 @@ static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 mar #include "port_after.h" -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -/*% +/* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size)); -static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size)); +static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size); +static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size); /* char * * inet_ntop(af, src, dst, size) @@ -58,11 +54,8 @@ static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size)); * Paul Vixie, 1996. */ const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; +inet_ntop(int af, const void * __restrict src, char * __restrict dst, + socklen_t size) { switch (af) { case AF_INET: @@ -88,19 +81,18 @@ inet_ntop(af, src, dst, size) * Paul Vixie, 1996. */ static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop4(const u_char *src, char *dst, socklen_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; + int l; - if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) { + l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); + if (l <= 0 || (socklen_t) l >= size) { errno = ENOSPC; return (NULL); } - strcpy(dst, tmp); + strlcpy(dst, tmp, size); return (dst); } @@ -111,10 +103,7 @@ inet_ntop4(src, dst, size) * Paul Vixie, 1996. */ static const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop6(const u_char *src, char *dst, socklen_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough @@ -185,7 +174,7 @@ inet_ntop6(src, dst, size) tp += strlen(tp); break; } - tp += SPRINTF((tp, "%x", words[i])); + tp += sprintf(tp, "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == @@ -196,7 +185,7 @@ inet_ntop6(src, dst, size) /* * Check for overflow, copy, and we're done. */ - if ((size_t)(tp - tmp) > size) { + if ((socklen_t)(tp - tmp) > size) { errno = ENOSPC; return (NULL); } @@ -204,4 +193,9 @@ inet_ntop6(src, dst, size) return (dst); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_ntop +__weak_reference(__inet_ntop, inet_ntop); diff --git a/lib/libc/inet/inet_pton.c b/lib/libc/inet/inet_pton.c index 66b4c6a..44d9c61 100644 --- a/lib/libc/inet/inet_pton.c +++ b/lib/libc/inet/inet_pton.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 marka Exp $"; +static const char rcsid[] = "$Id: inet_pton.c,v 1.2.206.2 2005/07/28 07:43:18 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" #include <sys/param.h> @@ -30,13 +32,13 @@ static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 mar #include <errno.h> #include "port_after.h" -/*% +/* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4 __P((const char *src, u_char *dst)); -static int inet_pton6 __P((const char *src, u_char *dst)); +static int inet_pton4(const char *src, u_char *dst); +static int inet_pton6(const char *src, u_char *dst); /* int * inet_pton(af, src, dst) @@ -50,10 +52,7 @@ static int inet_pton6 __P((const char *src, u_char *dst)); * Paul Vixie, 1996. */ int -inet_pton(af, src, dst) - int af; - const char *src; - void *dst; +inet_pton(int af, const char * __restrict src, void * __restrict dst) { switch (af) { case AF_INET: @@ -78,9 +77,7 @@ inet_pton(af, src, dst) * Paul Vixie, 1996. */ static int -inet_pton4(src, dst) - const char *src; - u_char *dst; +inet_pton4(const char *src, u_char *dst) { static const char digits[] = "0123456789"; int saw_digit, octets, ch; @@ -133,9 +130,7 @@ inet_pton4(src, dst) * Paul Vixie, 1996. */ static int -inet_pton6(src, dst) - const char *src; - u_char *dst; +inet_pton6(const char *src, u_char *dst) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; @@ -188,7 +183,7 @@ inet_pton6(src, dst) inet_pton4(curtok, tp) > 0) { tp += NS_INADDRSZ; seen_xdigits = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } return (0); } @@ -220,4 +215,9 @@ inet_pton6(src, dst) return (1); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_pton +__weak_reference(__inet_pton, inet_pton); diff --git a/lib/libc/inet/nsap_addr.c b/lib/libc/inet/nsap_addr.c index d8fe87c..27d44ba 100644 --- a/lib/libc/inet/nsap_addr.c +++ b/lib/libc/inet/nsap_addr.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: nsap_addr.c,v 1.3.18.2 2005/07/28 07:38:08 marka Exp $"; +static const char rcsid[] = "$Id: nsap_addr.c,v 1.2.206.2 2005/07/28 07:43:18 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -108,4 +110,11 @@ inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) { return (start); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <arpa/inet.h>. + */ +#undef inet_nsap_addr +__weak_reference(__inet_nsap_addr, inet_nsap_addr); +#undef inet_nsap_ntoa +__weak_reference(__inet_nsap_ntoa, inet_nsap_ntoa); |