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