diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2013-06-28 11:00:35 +0900 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-07-08 10:39:12 -0700 |
commit | 71bc0fdb98f55fd0559ea6e2e8fe94248cb0c3dd (patch) | |
tree | 54a40fb25a331d2881f0dc0cb78b916509965a3d | |
parent | 5b5689b1f8769d2e631ebf9ea2b8b77dd4883531 (diff) | |
download | ping-71bc0fdb98f55fd0559ea6e2e8fe94248cb0c3dd.tar.gz |
Make ping6 compile.
With these changes, ping6 compiles and runs in the normal raw
socket mode which requires root privileges.
(cherry-pick of d06ff8674fa66847aadb1c96602e8cdb7450a655.)
Bug: 9469682
Change-Id: Iee62f73c94e403e6f52ce0aeff583ee3952fb717
-rw-r--r-- | Android.mk | 11 | ||||
-rw-r--r-- | in6_flowlabel.h | 4 | ||||
-rw-r--r-- | ping6.c | 14 | ||||
-rw-r--r-- | ping6_niquery.h | 13 | ||||
-rw-r--r-- | ping_common.c | 2 |
5 files changed, 41 insertions, 3 deletions
@@ -3,5 +3,14 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= ping.c ping_common.c LOCAL_MODULE := ping -LOCAL_CFLAGS := -DWITHOUT_IFADDRS +LOCAL_CFLAGS := -DWITHOUT_IFADDRS -Wno-sign-compare +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_CFLAGS := -DWITHOUT_IFADDRS -Wno-sign-compare +LOCAL_SRC_FILES := ping6.c ping_common.c +LOCAL_MODULE := ping6 +LOCAL_MODULE_TAGS := debug +LOCAL_C_INCLUDES := external/openssl/include +LOCAL_SHARED_LIBRARIES := libcrypto include $(BUILD_EXECUTABLE) diff --git a/in6_flowlabel.h b/in6_flowlabel.h new file mode 100644 index 0000000..9a27397 --- /dev/null +++ b/in6_flowlabel.h @@ -0,0 +1,4 @@ +/* The in6_flowlabel.h file in the iputils distribution exists to provide + * kernel flowlabel API definitions that are not in the userspace headers + * because they are linux-specific. It's not needed on Android because Android + * exposes the kernel definitions to userspace directly . */ @@ -112,6 +112,20 @@ char copyright[] = #define BIT_SET(nr, addr) do { ((__u32 *)(addr))[(nr) >> 5] |= (1U << ((nr) & 31)); } while(0) #define BIT_TEST(nr, addr) do { (__u32 *)(addr))[(nr) >> 5] & (1U << ((nr) & 31)); } while(0) +/* ICMP6_FILTER is defined in linux/icmpv6.h, which we can't include because it + * defines struct icmp6_filter, also defined in netinet/icmp6.h. Also, undefine + * the ICMP6_FILTER_XXX macros, because the ones provided by netinet/icmp6.h + * don't work on Linux - http://b/9671560 . */ +#ifdef ANDROID +#define ICMP6_FILTER 1 +#undef ICMP6_FILTER_WILLPASS +#undef ICMP6_FILTER_WILLBLOCK +#undef ICMP6_FILTER_SETPASS +#undef ICMP6_FILTER_SETBLOCK +#undef ICMP6_FILTER_SETPASSALL +#undef ICMP6_FILTER_SETBLOCKALL +#endif + #ifndef ICMP6_FILTER_WILLPASS #define ICMP6_FILTER_WILLPASS(type, filterp) \ (BIT_TEST((type), filterp) == 0) diff --git a/ping6_niquery.h b/ping6_niquery.h index fa6624a..85dd94c 100644 --- a/ping6_niquery.h +++ b/ping6_niquery.h @@ -2,6 +2,19 @@ #define NI_NONCE_SIZE 8 +/* On Android, the ni_xxx macros are already provided by netinet/icmp6.h. + * Undefine them here to avoid "ni_xxx redefined" compiler warnings. GCC + * provides no way to suppress these except by completely disabling all + * preprocessor warnings. + */ +#ifdef ANDROID +#undef ni_type +#undef ni_code +#undef ni_cksum +#undef ni_qtype +#undef ni_flags +#endif + /* Node Information Query */ struct ni_hdr { struct icmp6_hdr ni_u; diff --git a/ping_common.c b/ping_common.c index 5d00a69..2bdd6f9 100644 --- a/ping_common.c +++ b/ping_common.c @@ -697,7 +697,6 @@ void setup(int icmp_sock) setitimer(ITIMER_REAL, &it, NULL); } -#ifndef ANDROID if (isatty(STDOUT_FILENO)) { struct winsize w; @@ -706,7 +705,6 @@ void setup(int icmp_sock) screen_width = w.ws_col; } } -#endif } void main_loop(int icmp_sock, __u8 *packet, int packlen) |