[rtems commit] libnetworking: Import current <arpa/inet.h>

Sebastian Huber sebh at rtems.org
Tue Jun 28 13:20:03 UTC 2016


Module:    rtems
Branch:    master
Commit:    4c02385d8fa3110e4208e2cb8cb2d04d630cf85e
Changeset: http://git.rtems.org/rtems/commit/?id=4c02385d8fa3110e4208e2cb8cb2d04d630cf85e

Author:    Christian Mauderer <Christian.Mauderer at embedded-brains.de>
Date:      Fri Jun 24 08:52:48 2016 +0200

libnetworking: Import current <arpa/inet.h>

Import the <arpa/inet.h> from current FreeBSD.  Necessary due to changes
in <netinet/in.h>.  Remove BSD hack from <arpa/inet.h>.

Clean up problems with htonl().  These functions are defined in
<arpa/inet.h>.  This lead to some problems because they are defined in
<rtems/endian.h> too.  Add NTOHL, ... to
<rtems/rtems_bsdnet_internal.h>.

---

 c/src/lib/libbsp/arm/atsam/network/if_atsam.c      |  2 -
 c/src/lib/libbsp/m68k/csb360/network/network.c     |  1 -
 c/src/lib/libbsp/m68k/mvme167/network/network.c    |  1 -
 .../powerpc/beatnik/network/porting/if_xxx_rtems.c |  1 -
 .../lib/libbsp/powerpc/haleakala/network/network.c |  1 -
 .../libbsp/powerpc/tqm8xx/network/network_fec.c    |  1 -
 .../libbsp/powerpc/tqm8xx/network/network_scc.c    |  1 -
 cpukit/libnetworking/arpa/inet.h                   | 71 +++++++++++++---------
 cpukit/libnetworking/arpa/nameser_compat.h         |  2 +-
 cpukit/libnetworking/rtems/mkrootfs.c              |  2 +-
 cpukit/libnetworking/rtems/mkrootfs.h              |  2 +-
 cpukit/libnetworking/rtems/rtems_bsdnet_internal.h | 26 +++++++-
 cpukit/libnetworking/rtems/rtems_dhcp_failsafe.c   |  2 -
 cpukit/libnetworking/rtems/rtems_glue.c            |  3 +-
 cpukit/libnetworking/rtems/rtems_showifstat.c      |  1 -
 cpukit/libnetworking/rtems/rtems_showroute.c       |  2 -
 16 files changed, 73 insertions(+), 46 deletions(-)

diff --git a/c/src/lib/libbsp/arm/atsam/network/if_atsam.c b/c/src/lib/libbsp/arm/atsam/network/if_atsam.c
index 3693ef1..3397405 100644
--- a/c/src/lib/libbsp/arm/atsam/network/if_atsam.c
+++ b/c/src/lib/libbsp/arm/atsam/network/if_atsam.c
@@ -59,8 +59,6 @@
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 
-#include <arpa/inet.h>
-
 #include <dev/mii/mii.h>
 
 /*
diff --git a/c/src/lib/libbsp/m68k/csb360/network/network.c b/c/src/lib/libbsp/m68k/csb360/network/network.c
index fa0fa94..8abba2a 100644
--- a/c/src/lib/libbsp/m68k/csb360/network/network.c
+++ b/c/src/lib/libbsp/m68k/csb360/network/network.c
@@ -38,7 +38,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 /*
  * Number of interfaces supported by this driver
diff --git a/c/src/lib/libbsp/m68k/mvme167/network/network.c b/c/src/lib/libbsp/m68k/mvme167/network/network.c
index 2ab09da..f5b8e33 100644
--- a/c/src/lib/libbsp/m68k/mvme167/network/network.c
+++ b/c/src/lib/libbsp/m68k/mvme167/network/network.c
@@ -66,7 +66,6 @@
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
-#include <arpa/inet.h>
 
 #include "uti596.h"
 
diff --git a/c/src/lib/libbsp/powerpc/beatnik/network/porting/if_xxx_rtems.c b/c/src/lib/libbsp/powerpc/beatnik/network/porting/if_xxx_rtems.c
index fe15f97..cbb83a1 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/network/porting/if_xxx_rtems.c
+++ b/c/src/lib/libbsp/powerpc/beatnik/network/porting/if_xxx_rtems.c
@@ -27,7 +27,6 @@
 
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
-#include <arpa/inet.h>
 
 #include <net/if_media.h>
 
diff --git a/c/src/lib/libbsp/powerpc/haleakala/network/network.c b/c/src/lib/libbsp/powerpc/haleakala/network/network.c
index 4b89286..e8731cb 100644
--- a/c/src/lib/libbsp/powerpc/haleakala/network/network.c
+++ b/c/src/lib/libbsp/powerpc/haleakala/network/network.c
@@ -34,7 +34,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 #include <ppc4xx/ppc405gp.h>
 #include <ppc4xx/ppc405ex.h>
diff --git a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
index f066a0e..11018ea 100644
--- a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
+++ b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
@@ -67,7 +67,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 /*
  * Number of interfaces supported by this driver
diff --git a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_scc.c b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_scc.c
index 5909b02..133dc0f 100644
--- a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_scc.c
+++ b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_scc.c
@@ -63,7 +63,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 /*
  * Number of interfaces supported by this driver
diff --git a/cpukit/libnetworking/arpa/inet.h b/cpukit/libnetworking/arpa/inet.h
index 6ea7e70..91e3a82 100644
--- a/cpukit/libnetworking/arpa/inet.h
+++ b/cpukit/libnetworking/arpa/inet.h
@@ -51,24 +51,34 @@
 
 /*%
  *	@(#)inet.h	8.1 (Berkeley) 6/2/93
- * $FreeBSD: src/include/arpa/inet.h,v 1.33 2010/07/06 03:48:46 maxim Exp $
+ *	$Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
+ * $FreeBSD: head/include/arpa/inet.h 269867 2014-08-12 12:36:06Z ume $
  */
 
-
 #ifndef _ARPA_INET_H_
 #define	_ARPA_INET_H_
 
 /* External definitions for functions in inet(3). */
 
 #include <sys/cdefs.h>
-#include <rtems/bsdnet/_types.h>
+#include <sys/_types.h>
 
 /* Required for byteorder(3) functions. */
-#include <rtems/endian.h>
+#include <machine/endian.h>
 
 #define	INET_ADDRSTRLEN		16
 #define	INET6_ADDRSTRLEN	46
 
+#ifndef _UINT16_T_DECLARED
+typedef	__uint16_t	uint16_t;
+#define	_UINT16_T_DECLARED
+#endif
+
+#ifndef _UINT32_T_DECLARED
+typedef	__uint32_t	uint32_t;
+#define	_UINT32_T_DECLARED
+#endif
+
 #ifndef _IN_ADDR_T_DECLARED
 typedef	uint32_t	in_addr_t;
 #define	_IN_ADDR_T_DECLARED
@@ -79,6 +89,13 @@ typedef	uint16_t	in_port_t;
 #define	_IN_PORT_T_DECLARED
 #endif
 
+#if __BSD_VISIBLE
+#ifndef _SIZE_T_DECLARED
+typedef	__size_t	size_t;
+#define	_SIZE_T_DECLARED
+#endif
+#endif
+
 /*
  * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
  * POSIX.1-2001.
@@ -95,32 +112,17 @@ struct in_addr {
 #define	_STRUCT_IN_ADDR_DECLARED
 #endif
 
-#if !defined(__rtems__)	/* RTEMS -- Why rename these? */
-/* XXX all new diversions!! argh!! */
-#if __BSD_VISIBLE
-#define	inet_addr		__inet_addr
-#define	inet_aton		__inet_aton
-#define	inet_lnaof		__inet_lnaof
-#define	inet_makeaddr		__inet_makeaddr
-#define	inet_neta		__inet_neta
-#define	inet_netof		__inet_netof
-#define	inet_network		__inet_network
-#define	inet_net_ntop		__inet_net_ntop
-#define	inet_net_pton		__inet_net_pton
-#define	inet_cidr_ntop		__inet_cidr_ntop
-#define	inet_cidr_pton		__inet_cidr_pton
-#define	inet_ntoa		__inet_ntoa
-#define	inet_ntoa_r		__inet_ntoa_r
-#define	inet_pton		__inet_pton
-#define	inet_ntop		__inet_ntop
-#define	inet_nsap_addr		__inet_nsap_addr
-#define	inet_nsap_ntoa		__inet_nsap_ntoa
-#endif /* __BSD_VISIBLE */
-#endif /* __rtems__ */
-
 __BEGIN_DECLS
+#ifndef _BYTEORDER_PROTOTYPED
+#define	_BYTEORDER_PROTOTYPED
+uint32_t	 htonl(uint32_t);
+uint16_t	 htons(uint16_t);
+uint32_t	 ntohl(uint32_t);
+uint16_t	 ntohs(uint16_t);
+#endif
+
 in_addr_t	 inet_addr(const char *);
-char		*inet_ntoa(struct in_addr);
+/*const*/ char	*inet_ntoa(struct in_addr);
 const char	*inet_ntop(int, const void * __restrict, char * __restrict,
 		    socklen_t);
 int		 inet_pton(int, const char * __restrict, void * __restrict);
@@ -134,9 +136,22 @@ in_addr_t	 inet_netof(struct in_addr);
 in_addr_t	 inet_network(const char *);
 char		*inet_net_ntop(int, const void *, int, char *, size_t);
 int		 inet_net_pton(int, const char *, void *, size_t);
+char		*inet_ntoa_r(struct in_addr, char *buf, socklen_t size);
+char		*inet_cidr_ntop(int, const void *, int, char *, size_t);
+int		 inet_cidr_pton(int, const char *, void *, int *);
 unsigned	 inet_nsap_addr(const char *, unsigned char *, int);
 char		*inet_nsap_ntoa(int, const unsigned char *, char *);
 #endif /* __BSD_VISIBLE */
 __END_DECLS
 
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define	_BYTEORDER_FUNC_DEFINED
+#define	htonl(x)	__htonl(x)
+#define	htons(x)	__htons(x)
+#define	ntohl(x)	__ntohl(x)
+#define	ntohs(x)	__ntohs(x)
+#endif
+
 #endif /* !_ARPA_INET_H_ */
+
+/*! \file */
diff --git a/cpukit/libnetworking/arpa/nameser_compat.h b/cpukit/libnetworking/arpa/nameser_compat.h
index b38e42a..8fcceaa 100644
--- a/cpukit/libnetworking/arpa/nameser_compat.h
+++ b/cpukit/libnetworking/arpa/nameser_compat.h
@@ -40,7 +40,7 @@
 
 #define	__BIND		19950621	/* (DEAD) interface version stamp. */
 
-#include <rtems/endian.h>
+#include <sys/endian.h>
 
 #if !defined(BYTE_ORDER) || \
     (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
diff --git a/cpukit/libnetworking/rtems/mkrootfs.c b/cpukit/libnetworking/rtems/mkrootfs.c
index ccdebaf..aaf670b 100644
--- a/cpukit/libnetworking/rtems/mkrootfs.c
+++ b/cpukit/libnetworking/rtems/mkrootfs.c
@@ -36,10 +36,10 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <rtems/mkrootfs.h>
 #include <rtems/libio.h>
+#include <rtems/endian.h>
 
 /*
  * A table a list of names and their modes.
diff --git a/cpukit/libnetworking/rtems/mkrootfs.h b/cpukit/libnetworking/rtems/mkrootfs.h
index 648b711..8bd4436 100644
--- a/cpukit/libnetworking/rtems/mkrootfs.h
+++ b/cpukit/libnetworking/rtems/mkrootfs.h
@@ -21,7 +21,7 @@
 #ifndef _RTEMS_MKROOTFS_H
 #define _RTEMS_MKROOTFS_H
 
-#include <arpa/inet.h> /* in_addr_t */
+#include <sys/types.h> /* in_addr_t */
 
 #include <rtems.h>
 
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index 7ede2c6..10a1f62 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
@@ -31,6 +31,7 @@ typedef	__uintptr_t		vm_size_t;
 /* make sure we get the network versions of these */
 #include <machine/types.h>
 #include <machine/param.h>
+#include <machine/endian.h>
 #include <sys/cdefs.h>
 
 #include <sys/time.h>
@@ -105,7 +106,30 @@ typedef	int		boolean_t;
 #define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))	/* create dev_t */
 #endif
 
-#include <rtems/endian.h>
+#ifndef _BYTEORDER_PROTOTYPED
+#define	_BYTEORDER_PROTOTYPED
+__BEGIN_DECLS
+__uint32_t	 htonl(__uint32_t);
+__uint16_t	 htons(__uint16_t);
+__uint32_t	 ntohl(__uint32_t);
+__uint16_t	 ntohs(__uint16_t);
+__END_DECLS
+#endif
+
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define	_BYTEORDER_FUNC_DEFINED
+#define	htonl(x)	__htonl(x)
+#define	htons(x)	__htons(x)
+#define	ntohl(x)	__ntohl(x)
+#define	ntohs(x)	__ntohs(x)
+#endif /* !_BYTEORDER_FUNC_DEFINED */
+
+#define NTOHS(x) (x) = ntohs(x)
+#define HTONS(x) (x) = htons(x)
+#define NTOHL(x) (x) = ntohl(x)
+#define HTONL(x) (x) = htonl(x)
+
+in_addr_t	 inet_addr(const char *);
 
 typedef quad_t          rlim_t;         /* resource limit */
 typedef	u_int32_t	fixpt_t;	/* fixed point number */
diff --git a/cpukit/libnetworking/rtems/rtems_dhcp_failsafe.c b/cpukit/libnetworking/rtems/rtems_dhcp_failsafe.c
index c491ad9..46a411b 100644
--- a/cpukit/libnetworking/rtems/rtems_dhcp_failsafe.c
+++ b/cpukit/libnetworking/rtems/rtems_dhcp_failsafe.c
@@ -71,8 +71,6 @@ struct  proc;                   /* Unused parameter of some functions. */
 #include <net/if_var.h>         /* for in_var.h */
 #include <netinet/in_var.h>     /* for in_aliasreq */
 #include <sys/sockio.h>         /* for ioctl definitions */
-#include <arpa/inet.h>          /* for inet_addr, inet_ntop */
-
 
 static int network_fail_timeout = RTEMS_DHCP_FAILSAFE_NETWORK_FAIL_TIMEOUT;
 static int network_down_time = RTEMS_DHCP_FAILSAFE_NETWORK_DOWN_TIME;
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index e9b371f..4081be8 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -30,7 +30,6 @@
 #include <net/route.h>
 #include <netinet/in.h>
 #include <vm/vm.h>
-#include <arpa/inet.h>
 
 #include <net/netisr.h>
 #include <net/route.h>
@@ -830,6 +829,8 @@ rtems_bsdnet_log (int priority, const char *fmt, ...)
  * IP header checksum routine for processors which don't have an inline version
  */
 
+struct ip;
+
 u_int in_cksum_hdr(const struct ip *);
 
 u_int
diff --git a/cpukit/libnetworking/rtems/rtems_showifstat.c b/cpukit/libnetworking/rtems/rtems_showifstat.c
index 50be6c8..2e06a8c 100644
--- a/cpukit/libnetworking/rtems/rtems_showifstat.c
+++ b/cpukit/libnetworking/rtems/rtems_showifstat.c
@@ -15,7 +15,6 @@
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <rtems/rtems_bsdnet.h>
 
diff --git a/cpukit/libnetworking/rtems/rtems_showroute.c b/cpukit/libnetworking/rtems/rtems_showroute.c
index 44b4c3b..30545d2 100644
--- a/cpukit/libnetworking/rtems/rtems_showroute.c
+++ b/cpukit/libnetworking/rtems/rtems_showroute.c
@@ -19,8 +19,6 @@
 
 #include <netinet/in.h>
 
-#include <arpa/inet.h>
-
 /*
  * We'll use the application versions of realloc and free.
  */




More information about the vc mailing list