[Olsr-dev] [PATCH v1 1/2] android: fix type punning warnings on IN6_IS_ADDR_V4MAPPED
Ferry Huberts
(spam-protected)
Fri Oct 19 18:05:53 CEST 2012
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
android/linux/olsr_netinet_in.h | 52 +++++++++++++++++++++++++++++++++++++++++
src/ipcalc.h | 4 ++++
2 files changed, 56 insertions(+)
create mode 100644 android/linux/olsr_netinet_in.h
diff --git a/android/linux/olsr_netinet_in.h b/android/linux/olsr_netinet_in.h
new file mode 100644
index 0000000..7500c80
--- /dev/null
+++ b/android/linux/olsr_netinet_in.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007, 2008, 2011
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+
+ This is a stripped copy of netinet/in.h that includes only the
+ IN6_IS_ADDR_V4MAPPED define. It is used to fix warnings on the
+ Android build.
+*/
+
+#ifndef _OLSR_NETINET_IN_H
+#define _OLSR_NETINET_IN_H 1
+
+#ifdef IN6_IS_ADDR_V4MAPPED
+ #undef IN6_IS_ADDR_V4MAPPED
+#endif
+
+
+#ifdef __GNUC__
+
+# define IN6_IS_ADDR_V4MAPPED(a) \
+ (__extension__ \
+ ({ __const struct in6_addr *__a = (__const struct in6_addr *) (a); \
+ __a->s6_addr32[0] == 0 \
+ && __a->s6_addr32[1] == 0 \
+ && __a->s6_addr32[2] == htonl (0xffff); }))
+
+#else
+
+# define IN6_IS_ADDR_V4MAPPED(a) \
+ ((((__const uint32_t *) (a))[0] == 0) \
+ && (((__const uint32_t *) (a))[1] == 0) \
+ && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
+
+#endif
+
+#endif /* _OLSR_NETINET_IN_H */
diff --git a/src/ipcalc.h b/src/ipcalc.h
index 30b8068..4dde3f4 100644
--- a/src/ipcalc.h
+++ b/src/ipcalc.h
@@ -49,6 +49,10 @@
#include <arpa/inet.h>
#include <netinet/in.h>
+#ifdef __ANDROID__
+ #include <linux/olsr_netinet_in.h>
+#endif
+
extern const struct olsr_ip_prefix ipv4_internet_route;
extern const struct olsr_ip_prefix ipv6_mappedv4_route;
extern const struct olsr_ip_prefix ipv6_internet_route;
--
1.7.11.7
More information about the Olsr-dev
mailing list