o Stop abusing MD headers with non-MD types.
o Hide nonstandard functions and types in <netinet/in.h> when _POSIX_SOURCE is defined. o Add some missing types (required by POSIX.1-200x) to <netinet/in.h>. o Restore vendor ID from Rev 1.1 in <netinet/in.h> and make use of new __FBSDID() macro. o Fix some miscellaneous issues in <arpa/inet.h>. o Correct final argument for the inet_ntop() function (POSIX.1-200x). o Get rid of the namespace pollution from <sys/types.h> in <arpa/inet.h>. Reviewed by: fenner Partially submitted by: bde
This commit is contained in:
parent
60363fb9f7
commit
de2656d0ed
@ -60,12 +60,44 @@
|
||||
|
||||
/* External definitions for functions in inet(3), addr2ascii(3) */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/ansi.h>
|
||||
|
||||
struct in_addr;
|
||||
#ifndef _IN_ADDR_T_DECLARED_
|
||||
typedef __uint32_t in_addr_t;
|
||||
#define _IN_ADDR_T_DECLARED_
|
||||
#endif
|
||||
|
||||
#ifndef _IN_PORT_T_DECLARED_
|
||||
typedef _uint16_t in_port_t;
|
||||
#define _IN_PORT_T_DECLARED_
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
/*
|
||||
* XXX socklen_t is used by a POSIX.1-200x interface, but not required by
|
||||
* POSIX.1-200x.
|
||||
*/
|
||||
#ifdef _BSD_SOCKLEN_T_
|
||||
typedef _BSD_SOCKLEN_T_ socklen_t;
|
||||
#undef _BSD_SOCKLEN_T_
|
||||
#endif
|
||||
|
||||
#ifndef _STRUCT_IN_ADDR_DECLARED
|
||||
struct in_addr {
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
#define _STRUCT_IN_ADDR_DECLARED
|
||||
#endif
|
||||
|
||||
/* XXX all new diversions!! argh!! */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define inet_addr __inet_addr
|
||||
#define inet_aton __inet_aton
|
||||
#define inet_lnaof __inet_lnaof
|
||||
@ -80,11 +112,21 @@ struct in_addr;
|
||||
#define inet_ntop __inet_ntop
|
||||
#define inet_nsap_addr __inet_nsap_addr
|
||||
#define inet_nsap_ntoa __inet_nsap_ntoa
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
__BEGIN_DECLS
|
||||
in_addr_t inet_addr __P((const char *));
|
||||
char *inet_ntoa __P((struct in_addr));
|
||||
const char *inet_ntop __P((int, const void *, char *, socklen_t));
|
||||
int inet_pton __P((int, const char *, void *));
|
||||
/*
|
||||
* XXX missing: ntohl() family.
|
||||
*/
|
||||
|
||||
/* Nonstandard functions. */
|
||||
#ifndef _POSIX_SOURCE
|
||||
int ascii2addr __P((int, const char *, void *));
|
||||
char *addr2ascii __P((int, const void *, int, char *));
|
||||
in_addr_t inet_addr __P((const char *));
|
||||
int inet_aton __P((const char *, struct in_addr *));
|
||||
in_addr_t inet_lnaof __P((struct in_addr));
|
||||
struct in_addr inet_makeaddr __P((in_addr_t, in_addr_t));
|
||||
@ -93,11 +135,9 @@ in_addr_t inet_netof __P((struct in_addr));
|
||||
in_addr_t inet_network __P((const char *));
|
||||
char *inet_net_ntop __P((int, const void *, int, char *, size_t));
|
||||
int inet_net_pton __P((int, const char *, void *, size_t));
|
||||
char *inet_ntoa __P((struct in_addr));
|
||||
int inet_pton __P((int, const char *, void *));
|
||||
const char *inet_ntop __P((int, const void *, char *, size_t));
|
||||
u_int inet_nsap_addr __P((const char *, u_char *, int));
|
||||
char *inet_nsap_ntoa __P((int, const u_char *, char *));
|
||||
unsigned inet_nsap_addr __P((const char *, unsigned char *, int));
|
||||
char *inet_nsap_ntoa __P((int, const unsigned char *, char *));
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_INET_H_ */
|
||||
#endif /* !_ARPA_INET_H_ */
|
||||
|
@ -62,7 +62,7 @@
|
||||
.Ft char *
|
||||
.Fn inet_ntoa "struct in_addr in"
|
||||
.Ft const char *
|
||||
.Fn inet_ntop "int af" "const void *src" "char *dst" "size_t size"
|
||||
.Fn inet_ntop "int af" "const void *src" "char *dst" "socklen_t size"
|
||||
.Ft int
|
||||
.Fn inet_pton "int af" "const char *src" "void *dst"
|
||||
.Ft struct in_addr
|
||||
|
@ -15,9 +15,12 @@
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char rcsid[] = "$FreeBSD$";
|
||||
static char rcsid[] = "$Id: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@ -28,15 +31,17 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SPRINTF(x) ((size_t)sprintf x)
|
||||
#define SPRINTF(x) ((socklen_t)sprintf x)
|
||||
|
||||
/*
|
||||
* 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 __P((const u_char *src, char *dst,
|
||||
socklen_t size));
|
||||
static const char *inet_ntop6 __P((const u_char *src, char *dst,
|
||||
socklen_t size));
|
||||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
@ -51,7 +56,7 @@ inet_ntop(af, src, dst, size)
|
||||
int af;
|
||||
const void *src;
|
||||
char *dst;
|
||||
size_t size;
|
||||
socklen_t size;
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
@ -80,7 +85,7 @@ static const char *
|
||||
inet_ntop4(src, dst, size)
|
||||
const u_char *src;
|
||||
char *dst;
|
||||
size_t size;
|
||||
socklen_t size;
|
||||
{
|
||||
static const char fmt[] = "%u.%u.%u.%u";
|
||||
char tmp[sizeof "255.255.255.255"];
|
||||
@ -103,7 +108,7 @@ static const char *
|
||||
inet_ntop6(src, dst, size)
|
||||
const u_char *src;
|
||||
char *dst;
|
||||
size_t size;
|
||||
socklen_t size;
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
@ -182,7 +187,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);
|
||||
}
|
||||
|
@ -49,8 +49,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ int /* clock() */
|
||||
#define _BSD_CLOCKID_T_ int /* clock_gettime()... */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -49,8 +49,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ int /* clock() */
|
||||
#define _BSD_CLOCKID_T_ int /* clockid_t */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -48,8 +48,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ unsigned long /* clock()... */
|
||||
#define _BSD_CLOCKID_T_ int /* clock_gettime()... */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -49,8 +49,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ int /* clock() */
|
||||
#define _BSD_CLOCKID_T_ int /* clockid_t */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -228,12 +228,27 @@
|
||||
*/
|
||||
#define IPPORT_RESERVEDSTART 600
|
||||
|
||||
#define IPPORT_MAX 65535
|
||||
|
||||
#ifndef _IN_ADDR_T_DECLARED_
|
||||
typedef __uint32_t in_addr_t;
|
||||
#define _IN_ADDR_T_DECLARED_
|
||||
#endif
|
||||
|
||||
#ifndef _IN_PORT_T_DECLARED_
|
||||
typedef __uint16_t in_port_t;
|
||||
#define _IN_PORT_T_DECLARED_
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internet address (a structure for historical reasons)
|
||||
*/
|
||||
#ifndef _STRUCT_IN_ADDR_DECLARED
|
||||
struct in_addr {
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
#define _STRUCT_IN_ADDR_DECLARED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definitions of bits in internet address integers.
|
||||
|
@ -48,8 +48,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ int /* clock() */
|
||||
#define _BSD_CLOCKID_T_ int /* clockid_t */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -49,8 +49,6 @@
|
||||
*/
|
||||
#define _BSD_CLOCK_T_ int /* clock() */
|
||||
#define _BSD_CLOCKID_T_ int /* clock_gettime()... */
|
||||
#define _BSD_IN_ADDR_T_ __uint32_t /* inet(3) functions */
|
||||
#define _BSD_IN_PORT_T_ __uint16_t
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */
|
||||
#define _BSD_RUNE_T_ _BSD_CT_RUNE_T_ /* rune_t (see below) */
|
||||
|
@ -124,7 +124,7 @@ typedef u_int32_t dev_t; /* device number */
|
||||
|
||||
/*
|
||||
* XXX: Deprecated;
|
||||
* byteorder(3) functions now defined in <apra/inet.h>.
|
||||
* byteorder(3) functions now defined in <arpa/inet.h>.
|
||||
*/
|
||||
#include <machine/endian.h>
|
||||
|
||||
@ -138,16 +138,16 @@ typedef _BSD_CLOCKID_T_ clockid_t;
|
||||
#undef _BSD_CLOCKID_T_
|
||||
#endif
|
||||
|
||||
/* XXX: Deprecated; now defined in <apra/inet.h>. */
|
||||
#ifdef _BSD_IN_ADDR_T_
|
||||
typedef _BSD_IN_ADDR_T_ in_addr_t;
|
||||
#undef _BSD_IN_ADDR_T_
|
||||
/* XXX: Deprecated; now defined in <arpa/inet.h>. */
|
||||
#ifndef _IN_ADDR_T_DECLARED_
|
||||
typedef __uint32_t in_addr_t;
|
||||
#define _IN_ADDR_T_DECLARED_
|
||||
#endif
|
||||
|
||||
/* XXX: Deprecated; now defined in <apra/inet.h>. */
|
||||
#ifdef _BSD_IN_PORT_T_
|
||||
typedef _BSD_IN_PORT_T_ in_port_t;
|
||||
#undef _BSD_IN_PORT_T_
|
||||
/* XXX: Deprecated; now defined in <arpa/inet.h>. */
|
||||
#ifndef _IN_PORT_T_DECLARED_
|
||||
typedef __uint16_t in_port_t;
|
||||
#define _IN_PORT_T_DECLARED_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
|
Loading…
x
Reference in New Issue
Block a user