Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 1 | From c7c27ba763c613f83c1561e56448b49315c271c5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jackie Huang <jackie.huang@windriver.com> |
| 3 | Date: Wed, 6 Mar 2019 09:36:11 -0500 |
| 4 | Subject: [PATCH] Upstream: |
| 5 | http://www.mail-archive.com/bug-inetutils@gnu.org/msg02103.html |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 6 | |
| 7 | Upstream-Status: Pending |
| 8 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 9 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 10 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 11 | --- |
| 12 | ping/ping_common.h | 20 ++++++++++++++++++++ |
| 13 | 1 file changed, 20 insertions(+) |
| 14 | |
| 15 | diff --git a/ping/ping_common.h b/ping/ping_common.h |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 16 | index 65e3e60..3e84db0 100644 |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 17 | --- a/ping/ping_common.h |
| 18 | +++ b/ping/ping_common.h |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 19 | @@ -18,10 +18,14 @@ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program. If not, see `http://www.gnu.org/licenses/'. */ |
| 22 | |
| 23 | +#include <config.h> |
| 24 | + |
| 25 | #include <netinet/in_systm.h> |
| 26 | #include <netinet/in.h> |
| 27 | #include <netinet/ip.h> |
| 28 | +#ifdef HAVE_IPV6 |
| 29 | #include <netinet/icmp6.h> |
| 30 | +#endif |
| 31 | #include <icmp.h> |
| 32 | #include <error.h> |
| 33 | #include <progname.h> |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 34 | @@ -63,7 +67,12 @@ struct ping_stat |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 35 | want to follow the traditional behaviour of ping. */ |
| 36 | #define DEFAULT_PING_COUNT 0 |
| 37 | |
| 38 | +#ifdef HAVE_IPV6 |
| 39 | #define PING_HEADER_LEN (USE_IPV6 ? sizeof (struct icmp6_hdr) : ICMP_MINLEN) |
| 40 | +#else |
| 41 | +#define PING_HEADER_LEN (ICMP_MINLEN) |
| 42 | +#endif |
| 43 | + |
| 44 | #define PING_TIMING(s) ((s) >= sizeof (struct timeval)) |
| 45 | #define PING_DATALEN (64 - PING_HEADER_LEN) /* default data length */ |
| 46 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 47 | @@ -78,13 +87,20 @@ struct ping_stat |
| 48 | |
| 49 | #define PING_MIN_USER_INTERVAL (200000/PING_PRECISION) |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 50 | |
| 51 | +#ifdef HAVE_IPV6 |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 52 | /* FIXME: Adjust IPv6 case for options and their consumption. */ |
| 53 | #define _PING_BUFLEN(p, u) ((u)? ((p)->ping_datalen + sizeof (struct icmp6_hdr)) : \ |
| 54 | (MAXIPLEN + (p)->ping_datalen + ICMP_TSLEN)) |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 55 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 56 | +#else |
| 57 | +#define _PING_BUFLEN(p, u) (MAXIPLEN + (p)->ping_datalen + ICMP_TSLEN) |
| 58 | +#endif |
| 59 | + |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 60 | +#ifdef HAVE_IPV6 |
| 61 | typedef int (*ping_efp6) (int code, void *closure, struct sockaddr_in6 * dest, |
| 62 | struct sockaddr_in6 * from, struct icmp6_hdr * icmp, |
| 63 | int datalen); |
| 64 | +#endif |
| 65 | |
| 66 | typedef int (*ping_efp) (int code, |
| 67 | void *closure, |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 68 | @@ -93,13 +109,17 @@ typedef int (*ping_efp) (int code, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 69 | struct ip * ip, icmphdr_t * icmp, int datalen); |
| 70 | |
| 71 | union event { |
| 72 | +#ifdef HAVE_IPV6 |
| 73 | ping_efp6 handler6; |
| 74 | +#endif |
| 75 | ping_efp handler; |
| 76 | }; |
| 77 | |
| 78 | union ping_address { |
| 79 | struct sockaddr_in ping_sockaddr; |
| 80 | +#ifdef HAVE_IPV6 |
| 81 | struct sockaddr_in6 ping_sockaddr6; |
| 82 | +#endif |
| 83 | }; |
| 84 | |
| 85 | typedef struct ping_data PING; |