[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-inetutils] ping/ping6 removing common code, patch - 5
From: |
Rakesh Pandit |
Subject: |
[bug-inetutils] ping/ping6 removing common code, patch - 5 |
Date: |
Tue, 7 Oct 2008 21:31:59 +0530 |
Hello list,
I have again started fixing things in ping/ping6. For last set I
patches I have corrected the ChangeLog and have included suggestion
like:
1. Using USE_IPV6 in place of IS_PING6
2. Use ping_sockaddr in place of address
Corrected ChangeLog is:
2008-10-07 Rakesh Pandit <address@hidden>
* ping/ping_impl.h, ping/ping.h, ping/ping_common.h,
ping/ping6.h (ping_stat, PEV_RESPONSE, PEV_DUPLICATE, PEV_NOECHO,
PING_INTERVAL, PING_CKTABSIZE, MAXWAIT, OPT_FLOOD, OPT_INTERVAL,
OPT_NUMERIC, OPT_QUIET, OPT_RROUTE, OPT_VERBOSE, PING_TIMING,
PING_HEADER_LEN, PING_DATALEN): Moved all these common macros and
structures from ping_impl.h , ping6.h and ping_ping.h to
ping_common.h. Removed PING_INTERVAL.
* ping/ping6.c (ping_run): Used PING_SET_INTERVAL similar to
libping.c and used PING_DEFAULT_INTERVAL in place of PING_INTERVAL.
* ping/libping.c (ping_set_datalen): Removed.
* ping/libping.c, ping/ping_common.c (_ping_freebuf, ping_unset_data):
Moved _ping_freebuf, ping_unset_data from libping.c to ping_common.c
* ping/ping6.c (ping_run): Free memory with call to ping_unset_data.
2008-10-06 Rakesh Pandit <address@hidden>
* ping/libping.c, ping/ping_common.c, ping/ping_common.h
(ping_set_count, ping_set_sockopt, ping_set_interval):
Moved functions from libping.c to ping_common.c and made
corresponding entries in ping_common.h
* ping/ping6.c (main): Used ping_set_interval, ping_set_sockopt,
ping_set_count in place of directly modifying struct p.
2008-10-06 Rakesh Pandit <address@hidden>
* ping/ping_common.h, ping/ping.c, ping/ping_address.c,
ping/ping_echo.c, ping/ping_router.c, ping/ping_timestamp.c,
ping/libping.c: Added common headers from ping related
files (ping.c, ping_address.c, ping_echo.c, ping_router.c,
ping_timestamp.c, libping.c) and ping6.c to ping/ping_common.h.
* ping/ping.h, ping/ping6.h, ping/ping_common.h (ping_data,
ping_efp): Moved ping_data, ping_efp from ping.h & ping6.h
to ping_common.h
* ping/libping.c, ping/ping6.c, ping/ping_common.c (_ping_setbuf,
ping_set_data): Moved _ping_setbuf and ping_set_data from libping.c
& ping6.c to ping_common.c
* ping/ping_common.h (ping_address, event, ping_data): Introduced new
unions ping_address and event in ping_common.h. Replaced ping efp
handler(ping_efp/ping_efp6) with event union and socket
address(sockaddr_in/
sockaddr_in6) with ping_address union.
* ping/ping_common.h (_PING_BUFLEN, _ping_setbuf, ping_set_data): New
arg
use_ipv6 and all callers changed.
2008-10-06 Rakesh Pandit <address@hidden>
* libicmp/Makefile.am (libicmp_a_SOURCES): Removed libping.c
and ping.h
* ping/Makefile.am (ping_SOURCES): Added libping.c and ping.h
2008-10-06 Rakesh Pandit <address@hidden>
* ping/ping6.c (is_root, count, interval, socket_type):
New global variables count, interval & socket_type, similar to ping.c
Initialize to is_root and count to false and DEFAULT_PING_COUNT
respectively.
* ping/ping6.c (parse_opt): Replaced ping structure usage with global
variables.
* ping/ping6.c (main): Assigned parsed values to ping structure.
Top most ChangeLog is for latest patch with this mail.
Last four ChangeLog entries are for patches in following mails:
http://lists.gnu.org/archive/html/bug-inetutils/2008-08/msg00060.html
http://lists.gnu.org/archive/html/bug-inetutils/2008-08/msg00058.html
http://lists.gnu.org/archive/html/bug-inetutils/2008-08/msg00057.html
http://lists.gnu.org/archive/html/bug-inetutils/2008-08/msg00052.html
--
rakesh
Latest Patch:
diff -u --recursive inetutils.org/ping/libping.c inetutils/ping/libping.c
--- inetutils.org/ping/libping.c 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/libping.c 2008-10-07 17:15:24.000000000 +0530
@@ -38,7 +38,6 @@
#include "ping.h"
-static void _ping_freebuf (PING * p);
static size_t _ping_packetsize (PING * p);
size_t
@@ -107,34 +106,6 @@
p->ping_type = type;
}
-void
-ping_set_datalen (PING * p, size_t len)
-{
- _ping_freebuf (p);
- p->ping_datalen = len;
-}
-
-void
-_ping_freebuf (PING * p)
-{
- if (p->ping_buffer)
- {
- free (p->ping_buffer);
- p->ping_buffer = NULL;
- }
- if (p->ping_cktab)
- {
- free (p->ping_cktab);
- p->ping_cktab = NULL;
- }
-}
-
-void
-ping_unset_data (PING * p)
-{
- _ping_freebuf (p);
-}
-
int
ping_xmit (PING * p)
{
diff -u --recursive inetutils.org/ping/ping6.c inetutils/ping/ping6.c
--- inetutils.org/ping/ping6.c 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping6.c 2008-10-07 17:16:27.000000000 +0530
@@ -282,10 +282,7 @@
intvl.tv_usec = 10000;
}
else
- {
- intvl.tv_sec = ping->ping_interval;
- intvl.tv_usec = 0;
- }
+ PING_SET_INTERVAL (intvl, ping->ping_interval);
gettimeofday (&last, NULL);
send_echo (ping);
@@ -354,6 +351,9 @@
gettimeofday (&last, NULL);
}
}
+
+ ping_unset_data (ping);
+
if (finish)
return (*finish) ();
return 0;
@@ -732,7 +732,7 @@
p->ping_fd = fd;
p->ping_count = DEFAULT_PING_COUNT;
- p->ping_interval = PING_INTERVAL;
+ p->ping_interval = PING_DEFAULT_INTERVAL;
p->ping_datalen = sizeof (struct icmp6_hdr);
/* Make sure we use only 16 bits in this field, id for icmp is a u_short. */
p->ping_ident = ident & 0xFFFF;
diff -u --recursive inetutils.org/ping/ping6.h inetutils/ping/ping6.h
--- inetutils.org/ping/ping6.h 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping6.h 2008-10-07 17:01:34.000000000 +0530
@@ -19,33 +19,6 @@
#include "ping_common.h"
-struct ping_stat
-{
- double tmin; /* minimum round trip time */
- double tmax; /* maximum round trip time */
- double tsum; /* sum of all times, for doing average */
- double tsumsq; /* sum of all times squared, for std. dev. */
-};
-
-#define PEV_RESPONSE 0
-#define PEV_DUPLICATE 1
-#define PEV_NOECHO 2
-
-#define PING_INTERVAL 1
-#define PING_CKTABSIZE 128
-
-#define MAXWAIT 10 /* max seconds to wait for response */
-
-#define OPT_FLOOD 0x001
-#define OPT_INTERVAL 0x002
-#define OPT_NUMERIC 0x004
-#define OPT_QUIET 0x008
-#define OPT_RROUTE 0x010
-#define OPT_VERBOSE 0x020
-
-#define PING_TIMING(s) (s >= PING_HEADER_LEN)
-#define PING_HEADER_LEN sizeof (struct timeval)
-#define PING_DATALEN (64 - PING_HEADER_LEN) /* default data length */
#define PING_MAX_DATALEN (65535 - sizeof (struct icmp6_hdr))
#define USE_IPV6 1
diff -u --recursive inetutils.org/ping/ping_common.c
inetutils/ping/ping_common.c
--- inetutils.org/ping/ping_common.c 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping_common.c 2008-10-07 17:13:55.000000000 +0530
@@ -33,6 +33,8 @@
extern unsigned char *data_buffer;
extern size_t data_length;
+static void _ping_freebuf (PING * p);
+
size_t
ping_cvt_number (const char *optarg, size_t maxval, int allow_zero)
{
@@ -194,3 +196,23 @@
ping->ping_interval = interval;
}
+void
+_ping_freebuf (PING * p)
+{
+ if (p->ping_buffer)
+ {
+ free (p->ping_buffer);
+ p->ping_buffer = NULL;
+ }
+ if (p->ping_cktab)
+ {
+ free (p->ping_cktab);
+ p->ping_cktab = NULL;
+ }
+}
+
+void
+ping_unset_data (PING * p)
+{
+ _ping_freebuf (p);
+}
diff -u --recursive inetutils.org/ping/ping_common.h
inetutils/ping/ping_common.h
--- inetutils.org/ping/ping_common.h 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping_common.h 2008-10-07 17:13:35.000000000 +0530
@@ -25,8 +25,44 @@
#include <stdbool.h>
+
+#define MAXWAIT 10 /* max seconds to wait for response */
+
+#define OPT_FLOOD 0x001
+#define OPT_INTERVAL 0x002
+#define OPT_NUMERIC 0x004
+#define OPT_QUIET 0x008
+#define OPT_RROUTE 0x010
+#define OPT_VERBOSE 0x020
+
+struct ping_stat
+{
+ double tmin; /* minimum round trip time */
+ double tmax; /* maximum round trip time */
+ double tsum; /* sum of all times, for doing average */
+ double tsumsq; /* sum of all times squared, for std. dev. */
+};
+
+#define PEV_RESPONSE 0
+#define PEV_DUPLICATE 1
+#define PEV_NOECHO 2
+
+#define PING_CKTABSIZE 128
+
#define DEFAULT_PING_COUNT 4
+#define PING_TIMING(s) (s >= PING_HEADER_LEN)
+#define PING_HEADER_LEN sizeof (struct timeval)
+#define PING_DATALEN (64 - PING_HEADER_LEN) /* default data length */
+
+#define PING_DEFAULT_INTERVAL 1000 /* Milliseconds */
+#define PING_PRECISION 1000 /* Millisecond precision */
+
+#define PING_SET_INTERVAL(t,i) do {\
+ (t).tv_sec = (i)/PING_PRECISION;\
+ (t).tv_usec = ((i)%PING_PRECISION)*(1000000/PING_PRECISION) ;\
+} while (0)
+
/* Not sure about this step*/
#define _PING_BUFLEN(p, use_ipv6) ((use_ipv6)? ((p)->ping_datalen +
sizeof (struct icmp6_hdr)) : \
((p)->ping_datalen + sizeof (icmphdr_t)))
@@ -93,3 +129,5 @@
void ping_set_count (PING * ping, size_t count);
void ping_set_sockopt (PING * ping, int opt, void *val, int valsize);
void ping_set_interval (PING * ping, size_t interval);
+void ping_unset_data (PING * p);
+
diff -u --recursive inetutils.org/ping/ping.h inetutils/ping/ping.h
--- inetutils.org/ping/ping.h 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping.h 2008-10-07 17:15:31.000000000 +0530
@@ -19,19 +19,8 @@
#include "ping_common.h"
-#define PEV_RESPONSE 0
-#define PEV_DUPLICATE 1
-#define PEV_NOECHO 2
#define USE_IPV6 0
-#define PING_DEFAULT_INTERVAL 1000 /* Milliseconds */
-#define PING_PRECISION 1000 /* Millisecond precision */
-#define PING_CKTABSIZE 128
-#define PING_SET_INTERVAL(t,i) do {\
- (t).tv_sec = (i)/PING_PRECISION;\
- (t).tv_usec = ((i)%PING_PRECISION)*(1000000/PING_PRECISION) ;\
-} while (0)
-
#define _C_BIT(p,bit) (p)->ping_cktab[(bit)>>3] /* byte in ck array */
#define _C_MASK(bit) (1 << ((bit) & 0x07))
@@ -46,7 +35,5 @@
int ping_set_dest (PING * ping, char *host);
int ping_set_pattern (PING * p, int len, u_char * pat);
void ping_set_event_handler (PING * ping, ping_efp fp, void *closure);
-void ping_set_datalen (PING * p, size_t len);
-void ping_unset_data (PING * p);
int ping_recv (PING * p);
int ping_xmit (PING * p);
diff -u --recursive inetutils.org/ping/ping_impl.h inetutils/ping/ping_impl.h
--- inetutils.org/ping/ping_impl.h 2008-10-07 11:08:53.000000000 +0530
+++ inetutils/ping/ping_impl.h 2008-10-07 14:09:05.000000000 +0530
@@ -1,27 +1,5 @@
-#define MAXWAIT 10 /* max seconds to wait for response */
-
-#define OPT_FLOOD 0x001
-#define OPT_INTERVAL 0x002
-#define OPT_NUMERIC 0x004
-#define OPT_QUIET 0x008
-#define OPT_RROUTE 0x010
-#define OPT_VERBOSE 0x020
-
-#define PING_TIMING(s) (s >= PING_HEADER_LEN)
-#define PING_HEADER_LEN sizeof (struct timeval)
-#define PING_DATALEN (64 - PING_HEADER_LEN) /* default data length */
#define PING_MAX_DATALEN (65535 - MAXIPLEN - MAXICMPLEN)
-struct ping_stat
-{
- double tmin; /* minimum round trip time */
- double tmax; /* maximum round trip time */
- double tsum; /* sum of all times, for doing average */
- double tsumsq; /* sum of all times squared, for std. dev. */
-};
-
-
-
extern unsigned options;
extern PING *ping;
extern u_char *data_buffer;
Suggestions or comments ?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-inetutils] ping/ping6 removing common code, patch - 5,
Rakesh Pandit <=