diff options
author | Alex Samorukov <samm@os2.kiev.ua> | 2021-01-04 01:31:11 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-01-04 13:28:28 +0100 |
commit | ca2dc96be81440985af36c0724150498729e12a9 (patch) | |
tree | 6519260526cb558d4e54eeef0d3b13406af1cb09 /networking | |
parent | f1baa4a6b4239cff069aa0b257365b12fb6ee130 (diff) | |
download | busybox-ca2dc96be81440985af36c0724150498729e12a9.tar.gz |
Fix ping build on the FreeBSD
- Define iphdr structure to build busybox/ping
- Add missing includes
Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ping.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/networking/ping.c b/networking/ping.c index c4a15e06e..86d8088de 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -122,6 +122,10 @@ //usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" #include <net/if.h> +#if defined(__FreeBSD__) +# include <netinet/in.h> /* struct ip and friends */ +# include <netinet/ip.h> +#endif #include <netinet/ip_icmp.h> #include "libbb.h" #include "common_bufsiz.h" @@ -160,6 +164,40 @@ # endif #endif +#if defined(__FreeBSD__) +/** + * On BSD the IPv4 struct is called struct ip and instead of iXX + * the members are called ip_XX. One could change this code to use + * struct ip but that would require to define _BSD_SOURCE and that + * might have other complications. Instead make sure struct iphdr + * is present on FreeBSD. The below is taken from GLIBC. + * + * 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. + */ +struct iphdr { +# if BYTE_ORDER == LITTLE_ENDIAN + unsigned int ihl:4; + unsigned int version:4; +# elif BYTE_ORDER == BIG_ENDIAN + unsigned int version:4; + unsigned int ihl:4; +# endif + uint8_t tos; + uint16_t tot_len; + uint16_t id; + uint16_t frag_off; + uint8_t ttl; + uint8_t protocol; + uint16_t check; + uint32_t saddr; + uint32_t daddr; + /*The options start here. */ +}; +#endif + enum { DEFDATALEN = 56, MAXIPLEN = 60, |