[PATCH 22/27] libnetworking: Clean up problems with htonl(), ...

Christian Mauderer christian.mauderer at embedded-brains.de
Fri Jun 24 09:38:41 UTC 2016


From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>

These functions are defined in <arpa/inet.h>. This lead to some problems
because they are defined in <rtems/endian.h> too.
---
 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 | 21 ++++++++++++++++++++-
 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 --
 8 files changed, 25 insertions(+), 10 deletions(-)

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..7237b91 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,25 @@ 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 */
+
+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.
  */
-- 
1.8.4.5




More information about the devel mailing list