summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.pp.se>2002-01-20 19:19:45 +0000
committerThomas Habets <thomas@habets.pp.se>2002-01-20 19:19:45 +0000
commita84aa0ea2d644c1d85dec6c5932c0e00d8bd11cd (patch)
tree12c0eb664fc2ec570ab5a7145fa647786081773a
parent3dd35f2bfa3d4b0a438a136230e5ceff316cb630 (diff)
downloadarping-a84aa0ea2d644c1d85dec6c5932c0e00d8bd11cd.tar.gz
Rountrip time
-rw-r--r--README35
-rw-r--r--arping.812
-rw-r--r--arping.c49
-rw-r--r--arping.yodl2
4 files changed, 80 insertions, 18 deletions
diff --git a/README b/README
index e4a8353..7a9432f 100644
--- a/README
+++ b/README
@@ -1,8 +1,8 @@
-$Id: README 425 2001-09-09 14:43:02Z marvin $
+$Id: README 529 2002-01-20 19:19:45Z marvin $
ARP Ping
- By Marvin (marvin@rootbusters.net)
+ By Thomas Habets <thomas@habets.pp.se>
Introduction
@@ -118,6 +118,20 @@ Q: 1.01 is out, didn't you just say 1.0 was supposed to be the last one?
A: Shut up.
---
+Q: The roundtrip times are off, sometimes by milliseconds!
+
+A: I know.
+ Short answer:
+ 'ping' does the same thing. (ping from iputils-ss010824 anyway)
+
+ Long answer:
+ I can't (portably anyway) do anything other than queue a packet
+ to the network. That means I don't know exactly when it arrived. Also,
+ I can't tell when a packet arrives on the wire, only when arping gets
+ it from the kernel. Just make sure neither the network (whole segment
+ if you are hubbed, just your NIC if you are switched) nor your box is
+ loaded when you care about timing.
+---
Q: Is it OK to make arping suid root?
A: Be my guest, but if care about security *at all* you will have to restrict
@@ -126,6 +140,9 @@ A: Be my guest, but if care about security *at all* you will have to restrict
a network debugging tool, which generates low-level network packets that
ordinary users have absolutely no business generating.
+ For example, I don't protect against an ALRM signal flood, which will result
+ in a packet flood.
+
If you are honestly debugging the network then I don't see why you aren't
root already.
@@ -142,14 +159,24 @@ A: Ah, I see. A broadcast was changed to unicast, I don't know why I set it to
... Or you can run arping -s ff:ff:ff:ff:ff:ff <host>.
If this fixes it please LET ME KNOW.
---
+Q: Hey! Wasn't this Marvins program? (marvin@rootbusters.net, that is)
+ You thief!
+
+A: We are the same person.
+---
Q: Say hi to Psychad for me.
A: Will do.
---
+Misc
+----
+There, I added the stupid roundtrip time feature. Now I dare you to think of
+any other applicable features. (IPv4 only, for now)
+
License
-------
It's GPL, see the LICENSE file.
--------------------------------------------------------------------------------
-Send questions/suggestions/patches/rants/money/sparcs to marvin@rootbusters.net
+----------------------------------------------------------------------------
+Send questions/suggestions/patches/rants/money/sparcs to thomas@habets.pp.se
diff --git a/arping.8 b/arping.8
index bffb9aa..81d0340 100644
--- a/arping.8
+++ b/arping.8
@@ -38,24 +38,24 @@ Use instead of host if you want to address 255\&.255\&.255\&.255\&.
.IP
.IP "-0"
Use this option to ping with source IP address 0\&.0\&.0\&.0\&. Use this
-when you haven\'t configured your interface yet\&.
+when you haven\&'t configured your interface yet\&.
Note that this may get the MAC-ping unanswered\&.
This is an alias for -S 0\&.0\&.0\&.0\&.
.IP
.IP "-b"
Like -0 but source broadcast source address (255\&.255\&.255\&.255)\&.
-Note that this may get the arping unanswered since it\'s not normal behavior
+Note that this may get the arping unanswered since it\&'s not normal behavior
for a host\&.
.IP
.IP "-S \fIIP\fP"
Like -b and -0 but with set source address\&.
Note that this may get the arping unanswered if the target does not have
-routing to the IP\&. If you don\'t own the IP you are using, you may need to turn
+routing to the IP\&. If you don\&'t own the IP you are using, you may need to turn
on promiscious mode on the interface (with -p)\&. With this switch you can find
out what IP-address a host has without taking an IP-address yourself\&.
.IP
.IP "-T \fIIP\fP"
-Use -T as target address when pinging MACs that won\'t
+Use -T as target address when pinging MACs that won\&'t
respond to a broadcast ping but perhaps to a directed broadcast\&.
.IP
\fIExample\fP: To check the address of MAC-A, use knowledge of MAC-B and IP-B\&.
@@ -63,7 +63,7 @@ respond to a broadcast ping but perhaps to a directed broadcast\&.
$ arping -S <IP-B> -s <MAC-B> -p <MAC-A>
.IP
.IP "-p"
-Turn on promiscious mode on interface, use this if you don\'t
+Turn on promiscious mode on interface, use this if you don\&'t
"own" the MAC address you are using\&.
.IP
.IP "-s \fIMAC\fP"
@@ -90,4 +90,4 @@ instead of -S 255\&.255\&.255\&.255\&. This is libnets fault\&.
.PP
.SH "AUTHOR"
.PP
-Arping was written by Marvin <marvin@rootbusters\&.net>\&.
+Arping was written by Thomas Habets <thomas@habets\&.pp\&.se>\&.
diff --git a/arping.c b/arping.c
index 331788d..fd94798 100644
--- a/arping.c
+++ b/arping.c
@@ -1,7 +1,7 @@
/*
* arping
*
- * By marvin@rootbusters.net
+ * By Thomas Habets <thomas@habets.pp.se>
*
* ARP 'ping' utility
*
@@ -12,10 +12,10 @@
*
* Also finds out IP of specified MAC
*
- * $Id: arping.c 488 2001-12-23 13:02:41Z marvin $
+ * $Id: arping.c 529 2002-01-20 19:19:45Z marvin $
*/
/*
- * Copyright (C) 2000 Marvin (marvin@rootbusters.net)
+ * Copyright (C) 2000-2002 Thomas Habets <thomas@habets.pp.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -34,6 +34,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include <sys/time.h>
+
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif
@@ -83,6 +85,7 @@ static u_char eth_null[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static u_char eth_target[ETH_ALEN];
static u_char eth_source[ETH_ALEN]; // only used in main() but it belongs here
+static struct timeval lastpacketsent;
static const u_int ip_xmas = 0xffffffff;
static pcap_t *pcap;
@@ -186,12 +189,37 @@ static void alasend(int i)
fprintf(stderr, "libnet_write_link_layer(): error\n");
exit(1);
}
+ if (gettimeofday(&lastpacketsent, NULL)) {
+ fprintf(stderr, "arping: %s\n", strerror(errno));
+ exit(1);
+ }
alarm(1);
#if SOLARIS
signal(SIGALRM, alasend);
#endif
}
+/*
+ * NOTE: not re-entrant
+ */
+static char* tvtoda(const struct timeval *tv, const struct timeval *tv2)
+{
+ static char buf[128];
+ double f,f2;
+
+ f = tv->tv_sec + (double)tv->tv_usec / 1000000;
+ f2 = tv2->tv_sec + (double)tv2->tv_usec / 1000000;
+ f = (f2 - f) * 1000000;
+ if (f < 1000) {
+ sprintf(buf, "%.3f usec", f);
+ } else if (f < 1000000) {
+ sprintf(buf, "%.3f msec", f / 1000);
+ } else {
+ sprintf(buf, "%.3f sec", f / 1000000);
+ }
+ return buf;
+}
+
static void handlepacket(const char *unused, struct pcap_pkthdr *h,
u_char *packet)
{
@@ -201,9 +229,15 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h,
struct icmphdr *hicmp;
unsigned int c;
unsigned char *cp;
+ struct timeval recvtime;
DEBUG(printf("handlepacket()\n"));
+ if (gettimeofday(&recvtime, NULL)) {
+ fprintf(stderr, "arping: %s\n", strerror(errno));
+ exit(1);
+ }
+
eth = (struct ethhdr*)packet;
if (searchmac) {
@@ -238,8 +272,9 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h,
for (c = 0; c < ETH_ALEN-1; c++) {
printf("%.2x:", *cp++);
}
- printf("%.2x): icmp_seq=%d", *cp,
- hicmp->un.echo.sequence);
+ printf("%.2x): icmp_seq=%d time=%s", *cp,
+ hicmp->un.echo.sequence,
+ tvtoda(&lastpacketsent, &recvtime));
}
printf("\n");
}
@@ -280,9 +315,9 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h,
}
}
if (!rawoutput) {
- printf(" (%s): index=%d",
+ printf(" (%s): index=%d time=%s",
libnet_host_lookup(ip, 0),
- numrecvd);
+ numrecvd, tvtoda(&lastpacketsent, &recvtime));
}
numrecvd++;
if (!quiet) {
diff --git a/arping.yodl b/arping.yodl
index 255b205..908a451 100644
--- a/arping.yodl
+++ b/arping.yodl
@@ -77,4 +77,4 @@ manpageseealso()
manpageauthor()
- Arping was written by Marvin <marvin@rootbusters.net>.
+ Arping was written by Thomas Habets <thomas@habets.pp.se>.