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 | |
parent | f1baa4a6b4239cff069aa0b257365b12fb6ee130 (diff) | |
download | busybox-w32-ca2dc96be81440985af36c0724150498729e12a9.tar.gz busybox-w32-ca2dc96be81440985af36c0724150498729e12a9.tar.bz2 busybox-w32-ca2dc96be81440985af36c0724150498729e12a9.zip |
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>
-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 @@ | |||
122 | //usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" | 122 | //usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" |
123 | 123 | ||
124 | #include <net/if.h> | 124 | #include <net/if.h> |
125 | #if defined(__FreeBSD__) | ||
126 | # include <netinet/in.h> /* struct ip and friends */ | ||
127 | # include <netinet/ip.h> | ||
128 | #endif | ||
125 | #include <netinet/ip_icmp.h> | 129 | #include <netinet/ip_icmp.h> |
126 | #include "libbb.h" | 130 | #include "libbb.h" |
127 | #include "common_bufsiz.h" | 131 | #include "common_bufsiz.h" |
@@ -160,6 +164,40 @@ | |||
160 | # endif | 164 | # endif |
161 | #endif | 165 | #endif |
162 | 166 | ||
167 | #if defined(__FreeBSD__) | ||
168 | /** | ||
169 | * On BSD the IPv4 struct is called struct ip and instead of iXX | ||
170 | * the members are called ip_XX. One could change this code to use | ||
171 | * struct ip but that would require to define _BSD_SOURCE and that | ||
172 | * might have other complications. Instead make sure struct iphdr | ||
173 | * is present on FreeBSD. The below is taken from GLIBC. | ||
174 | * | ||
175 | * The GNU C Library is free software; you can redistribute it and/or | ||
176 | * modify it under the terms of the GNU Lesser General Public | ||
177 | * License as published by the Free Software Foundation; either | ||
178 | * version 2.1 of the License, or (at your option) any later version. | ||
179 | */ | ||
180 | struct iphdr { | ||
181 | # if BYTE_ORDER == LITTLE_ENDIAN | ||
182 | unsigned int ihl:4; | ||
183 | unsigned int version:4; | ||
184 | # elif BYTE_ORDER == BIG_ENDIAN | ||
185 | unsigned int version:4; | ||
186 | unsigned int ihl:4; | ||
187 | # endif | ||
188 | uint8_t tos; | ||
189 | uint16_t tot_len; | ||
190 | uint16_t id; | ||
191 | uint16_t frag_off; | ||
192 | uint8_t ttl; | ||
193 | uint8_t protocol; | ||
194 | uint16_t check; | ||
195 | uint32_t saddr; | ||
196 | uint32_t daddr; | ||
197 | /*The options start here. */ | ||
198 | }; | ||
199 | #endif | ||
200 | |||
163 | enum { | 201 | enum { |
164 | DEFDATALEN = 56, | 202 | DEFDATALEN = 56, |
165 | MAXIPLEN = 60, | 203 | MAXIPLEN = 60, |