commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-88-gd24743


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-88-gd247431
Date: Wed, 09 May 2012 21:36:55 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d2474314ec95d196af43aae5484e4a2c6073308d (commit)
       via  81e97053dad454b70a50f09b0e988fdd6e20e904 (commit)
      from  24f0cb0538cef541153a999aee72867794abba14 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d2474314ec95d196af43aae5484e4a2c6073308d


commit d2474314ec95d196af43aae5484e4a2c6073308d
Author: Mats Erik Andersson <address@hidden>
Date:   Wed May 9 03:28:35 2012 +0200

    ping, ping6: Time-to-live, hoplimit.

diff --git a/ChangeLog b/ChangeLog
index 4553d9b..ec999ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2012-05-09  Mats Erik Andersson  <address@hidden>
 
+       ping: Options `--mask' and `--ttl'.
+
+       * ping/ping.c (ttl): New variable.
+       (ARG_TTL): New enumeration value.
+       (argp_options): Add long option `mask' as synomym to `address'.
+       New long option `ttl'.
+       (parse_opt) <ARG_TTL>: New case.
+       (main): If `ttl > 0', set value for sockopt IP_TTL.
+       (*decode_typ): Add check for `mask'.
+
+       ping6: Option `--hoplimit'.
+
+       * ping/ping6.c (hoplimit): New variable.
+       (ARG_HOPLIMIT): New enumeration value.
+       (argp_options): New long option `hoplimit'.
+       (parse_opt) <ARG_HOPLIMIT>: New case.
+       (main): If `hoplimit > 0', set value for sockopt IPV6_UNICAST_HOPS.
+
+       * doc/inetutils.texi (ping invocation): Updates, corrections.
+
+2012-05-09  Mats Erik Andersson  <address@hidden>
+
        Discriminate UTC from non-UTC time stamps.
 
        * ping/ping_common.c (is_normed_time, ping_cvt_time): New fcns.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index dc1b6a1..08cba61 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -470,26 +470,40 @@ ping address@hidden@dots{}] @address@hidden
 @c Options controlling ICMP request types:
 @c       --address              Send ICMP_ADDRESS packets (root only)
 @c       --echo                 Send ICMP_ECHO packets (default)
address@hidden       --mask                 Same as --address
 @c       --timestamp            Send ICMP_TIMESTAMP packets
 @c   -t, --type=TYPE            Send TYPE packets
 @table @option
 @item --address
 @opindex --address
-Send ICMP_ADDRESS packets.
+Send ICMP_ADDRESS packets, thus requesting the address netmask
+being in use by the targetted host.
 
 @item --echo
 @opindex --echo
 Send ICMP_ECHO requests (default).
 
address@hidden --mask
address@hidden --mask
+Identical to @option{--address}.
+
 @item --timestamp
 @opindex --timestamp
-Send ICMP_TIMESTAMP packets.
-
address@hidden -t @var{type}
+Send ICMP_TIMESTAMP packets, thereby requesting a timed response
+from the targetted host.  In successful cases three time values
+will be returned.  All are expected to state the number of
+milliseconds since midnight UTC.  The first, @samp{icmp_otime},
+contains the original time for sending the request.  Then,
address@hidden, is the time of reception by the target, and
+finally, @samp{icmp_ttime}, is the time for transmitting an answer
+back to the originator.
+
address@hidden -t @var{type}
 @itemx address@hidden
 @opindex --type
 @opindex -t
-Send TYPE packets.
+Send @var{type} packets.  Accepted values are @samp{address},
address@hidden, @samp{mask}, and @samp{timestamp}.
 @end table
 
 @c Options valid for all request types:
@@ -498,9 +512,11 @@ Send TYPE packets.
 @c   -i, --interval=NUMBER      Wait NUMBER seconds between sending each packet
 @c   -n, --numeric              Do not resolve host addresses
 @c   -r, --ignore-routing       Send directly to a host on an attached network
address@hidden       --ttl=NUMBER           Set specified time-to-live on packet
+
 @table @option
 @item -c @var{n}
address@hidden address@hidden
address@hidden address@hidden
 @opindex -c
 @opindex --count
 Stop after sending (and receiving) @var{n} ECHO_RESPONSE packets.
@@ -535,6 +551,11 @@ attached network.  If the host is not on a 
directly-attached network,
 an error is returned.  This option can be used to ping a local host
 through an interface that has no route through it (e.g., after the
 interface was dropped by @command{routed}).
+
address@hidden address@hidden
address@hidden --ttl
+Set the specified number @var{n} as value of time-to-live when
+transmitting packets.  Acceptable values are 1 to 255, inclusive.
 @end table
 
 @c Options valid for --echo requests:
@@ -557,7 +578,7 @@ packets are being dropped.  Only the super-user may use 
this option.
 This can be very hard on a network and should be used with caution.
 
 @item -l @var{n}
address@hidden address@hidden
address@hidden address@hidden
 @opindex -l
 @opindex --preload
 If @var{n} is specified, ping sends that many packets as fast as
diff --git a/ping/ping.c b/ping/ping.c
index b82f557..740f8fd 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -64,6 +64,7 @@ size_t interval;
 size_t data_length = PING_DATALEN;
 unsigned options;
 unsigned long preload = 0;
+int ttl = 0;
 int timeout = -1;
 int linger = MAXWAIT;
 int (*ping_type) (char *hostname) = ping_echo;
@@ -87,7 +88,8 @@ enum {
   ARG_ECHO = 256,
   ARG_ADDRESS,
   ARG_TIMESTAMP,
-  ARG_ROUTERDISCOVERY
+  ARG_ROUTERDISCOVERY,
+  ARG_TTL,
 };
 
 static struct argp_option argp_options[] = {
@@ -96,6 +98,7 @@ static struct argp_option argp_options[] = {
   {"address", ARG_ADDRESS, NULL, 0, "send ICMP_ADDRESS packets (root only)",
    GRP+1},
   {"echo", ARG_ECHO, NULL, 0, "send ICMP_ECHO packets (default)", GRP+1},
+  {"mask", ARG_ADDRESS, NULL, 0, "same as --address", GRP+1},
   {"timestamp", ARG_TIMESTAMP, NULL, 0, "send ICMP_TIMESTAMP packets", GRP+1},
   {"type", 't', "TYPE", 0, "send TYPE packets", GRP+1},
   /* This option is not yet fully implemented, so mark it as hidden. */
@@ -111,6 +114,7 @@ static struct argp_option argp_options[] = {
   {"numeric", 'n', NULL, 0, "do not resolve host addresses", GRP+1},
   {"ignore-routing", 'r', NULL, 0, "send directly to a host on an attached "
    "network", GRP+1},
+  {"ttl", ARG_TTL, "N", 0, "specify N as time-to-live", GRP+1},
   {"verbose", 'v', NULL, 0, "verbose output", GRP+1},
   {"timeout", 'w', "N", 0, "stop after N seconds", GRP+1},
   {"linger", 'W', "N", 0, "number of seconds to wait for response", GRP+1},
@@ -223,6 +227,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       ping_type = decode_type ("router");
       break;
 
+    case ARG_TTL:
+      ttl = ping_cvt_number (arg, 255, 0);
+      break;
+
     case ARGP_KEY_NO_ARGS:
       argp_error (state, "missing host operand");
 
@@ -273,6 +281,11 @@ main (int argc, char **argv)
   if (options & OPT_INTERVAL)
     ping_set_interval (ping, interval);
 
+  if (ttl > 0)
+    if (setsockopt (ping->ping_fd, IPPROTO_IP, IP_TTL,
+                   &ttl, sizeof (ttl)) < 0)
+      error (0, errno, "setsockopt(IP_TTL)");
+
   init_data_buffer (patptr, pattern_len);
 
   while (argc--)
@@ -296,6 +309,8 @@ int (*decode_type (const char *arg)) (char *hostname)
     ping_type = ping_timestamp;
   else if (strcasecmp (arg, "address") == 0)
     ping_type = ping_address;
+  else if (strcasecmp (arg, "mask") == 0)
+    ping_type = ping_address;
 #if 0
   else if (strcasecmp (arg, "router") == 0)
     ping_type = ping_router;
diff --git a/ping/ping6.c b/ping/ping6.c
index 4f7d041..8358e7b 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -57,6 +57,7 @@ size_t count = DEFAULT_PING_COUNT;
 size_t interval;
 int socket_type;
 int timeout = -1;
+int hoplimit = 0;
 static unsigned int options;
 static unsigned long preload = 0;
 
@@ -73,11 +74,16 @@ const char *program_authors[] = {
        NULL
 };
 
+enum {
+  ARG_HOPLIMIT = 256,
+};
+
 static struct argp_option argp_options[] = {
 #define GRP 0
   {NULL, 0, NULL, 0, "Options valid for all request types:", GRP},
   {"count", 'c', "NUMBER", 0, "stop after sending NUMBER packets", GRP+1},
   {"debug", 'd', NULL, 0, "set the SO_DEBUG option", GRP+1},
+  {"hoplimit", ARG_HOPLIMIT, "N", 0, "specify N as hop-limit", GRP+1},
   {"interval", 'i', "NUMBER", 0, "wait NUMBER seconds between sending each "
    "packet", GRP+1},
   {"numeric", 'n', NULL, 0, "do not resolve host addresses", GRP+1},
@@ -162,6 +168,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       data_length = ping_cvt_number (arg, PING_MAX_DATALEN, 1);
       break;
 
+    case ARG_HOPLIMIT:
+      hoplimit = ping_cvt_number (arg, 255, 0);
+      break;
+
     case ARGP_KEY_NO_ARGS:
       argp_error (state, "missing host operand");
 
@@ -211,6 +221,11 @@ main (int argc, char **argv)
   if (options & OPT_INTERVAL)
     ping_set_interval (ping, interval);
 
+  if (hoplimit > 0)
+    if (setsockopt (ping->ping_fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
+                   &hoplimit, sizeof (hoplimit)) < 0)
+      error (0, errno, "setsockopt(IPV6_HOPLIMIT)");
+
   init_data_buffer (patptr, pattern_len);
 
   while (argc--)

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=81e97053dad454b70a50f09b0e988fdd6e20e904


commit 81e97053dad454b70a50f09b0e988fdd6e20e904
Author: Mats Erik Andersson <address@hidden>
Date:   Wed May 9 02:02:20 2012 +0200

    ping: Identify UTC time stamps.

diff --git a/ChangeLog b/ChangeLog
index 739dfb7..4553d9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-05-09  Mats Erik Andersson  <address@hidden>
+
+       Discriminate UTC from non-UTC time stamps.
+
+       * ping/ping_common.c (is_normed_time, ping_cvt_time): New fcns.
+       * ping/ping_common.h (is_normed_time, ping_cvt_time): New prototypes.
+       * ping/ping_timestamp.c (print_timestamp): New variable TIMESTR.
+       Call ping_cvt_time() to generate strings for three time values.
+       [options & OPT_VERBOSE]: Print time difference if both of
+       `icmp->icmp_otime' and `icmp->icmp_ttime' are UTC-based.
+
+       * ping/ping_common.h (_PING_BUFLEN):  Really replace the
+       parameter name `USE_IPV6' by the neutral name `u'.
+
 2012-05-08  Mats Erik Andersson  <address@hidden>
 
        Critical package errors in size and allocation.
diff --git a/ping/ping_common.c b/ping/ping_common.c
index bd6d65d..58bb22f 100644
--- a/ping/ping_common.c
+++ b/ping/ping_common.c
@@ -140,6 +140,28 @@ nsqrt (double a, double prec)
 }
 
 int
+is_normed_time (n_time t)
+{
+  /* A set MSB indicates non-normalised time standard.  */
+  return (t & (1UL << 31)) ? 0 : 1;
+}
+
+const char *
+ping_cvt_time (char *buf, size_t buflen, n_time t)
+{
+  n_time t_red;
+
+  t_red = t & ((1UL << 31) - 1);
+
+  if (is_normed_time (t))
+    snprintf (buf, buflen, "%u", t_red);
+  else
+    snprintf (buf, buflen, "<%u>", t_red);
+
+  return buf;
+}
+
+int
 _ping_setbuf (PING * p, bool use_ipv6)
 {
   if (!p->ping_buffer)
diff --git a/ping/ping_common.h b/ping/ping_common.h
index 2c8c796..ee86a00 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -67,7 +67,7 @@ struct ping_stat
 } while (0)
 
 /* FIXME: Adjust IPv6 case for options and their consumption.  */
-#define _PING_BUFLEN(p, USE_IPV6) ((USE_IPV6)? ((p)->ping_datalen + sizeof 
(struct icmp6_hdr)) : \
+#define _PING_BUFLEN(p, u) ((u)? ((p)->ping_datalen + sizeof (struct 
icmp6_hdr)) : \
                                   (MAXIPLEN + (p)->ping_datalen + ICMP_TSLEN))
 
 typedef int (*ping_efp6) (int code, void *closure, struct sockaddr_in6 * dest,
@@ -146,6 +146,8 @@ double nabs (double a);
 double nsqrt (double a, double prec);
 
 size_t ping_cvt_number (const char *optarg, size_t maxval, int allow_zero);
+int is_normed_time (n_time t);
+const char * ping_cvt_time (char *buf, size_t buflen, n_time t);
 
 void init_data_buffer (unsigned char *pat, int len);
 
diff --git a/ping/ping_timestamp.c b/ping/ping_timestamp.c
index 2c50192..c0c22e6 100644
--- a/ping/ping_timestamp.c
+++ b/ping/ping_timestamp.c
@@ -93,15 +93,30 @@ print_timestamp (int dupflag, void *closure,
                 struct sockaddr_in *dest, struct sockaddr_in *from,
                 struct ip *ip, icmphdr_t * icmp, int datalen)
 {
+  char timestr[16];
+
   printf ("%d bytes from %s: icmp_seq=%u", datalen,
          inet_ntoa (*(struct in_addr *) &from->sin_addr.s_addr),
          ntohs (icmp->icmp_seq));
   if (dupflag)
     printf (" (DUP!)");
   printf ("\n");
-  printf ("icmp_otime = %u\n", ntohl (icmp->icmp_otime));
-  printf ("icmp_rtime = %u\n", ntohl (icmp->icmp_rtime));
-  printf ("icmp_ttime = %u\n", ntohl (icmp->icmp_ttime));
+  printf ("icmp_otime = %s\n",
+         ping_cvt_time (timestr, sizeof (timestr),
+                        ntohl (icmp->icmp_otime)));
+  printf ("icmp_rtime = %s\n",
+         ping_cvt_time (timestr, sizeof (timestr),
+                        ntohl (icmp->icmp_rtime)));
+  printf ("icmp_ttime = %s\n",
+         ping_cvt_time (timestr, sizeof (timestr),
+                        ntohl (icmp->icmp_ttime)));
+
+  if ((options & OPT_VERBOSE)
+      && is_normed_time (ntohl (icmp->icmp_otime))
+      && is_normed_time (ntohl (icmp->icmp_otime)))
+    printf ("difference = %d ms\n",
+           ntohl (icmp->icmp_ttime) - ntohl (icmp->icmp_otime));
+
   return;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   36 ++++++++++++++++++++++++++++++++++++
 doc/inetutils.texi    |   35 ++++++++++++++++++++++++++++-------
 ping/ping.c           |   17 ++++++++++++++++-
 ping/ping6.c          |   15 +++++++++++++++
 ping/ping_common.c    |   22 ++++++++++++++++++++++
 ping/ping_common.h    |    4 +++-
 ping/ping_timestamp.c |   21 ++++++++++++++++++---
 7 files changed, 138 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]