diff options
author | Thomas Habets <thomas@habets.pp.se> | 2000-07-31 02:42:02 +0000 |
---|---|---|
committer | Thomas Habets <thomas@habets.pp.se> | 2000-07-31 02:42:02 +0000 |
commit | 9bf1bffb9b8580e0d06add304ba803fb53e033d3 (patch) | |
tree | a827ef634d61c4acaa729da3f3b78f66923bfcb9 /arping.c | |
parent | 63834bf1a2a58853397b4192b65b65836b43836a (diff) | |
download | arping-9bf1bffb9b8580e0d06add304ba803fb53e033d3.tar.gz |
added broadcast eth ping
Diffstat (limited to 'arping.c')
-rw-r--r-- | arping.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -12,7 +12,7 @@ * * Also finds out IP of specified MAC * - * $Id: arping.c 74 2000-07-05 23:19:38Z marvin $ + * $Id: arping.c 90 2000-07-31 02:42:02Z marvin $ */ /* * Copyright (C) 2000 Marvin (marvin@nss.nu) @@ -46,7 +46,6 @@ u_char eth_target[ETH_ALEN]; u_int ip_xmas = 0xffffffff; - pcap_t *pcap; struct bpf_program bpf_prog; struct in_addr net,mask; @@ -83,7 +82,7 @@ void alasend(int i) if (searchmac) { libnet_build_icmp_echo(ICMP_ECHO, /* type */ 0, /* code */ - 4321, /* id */ + (short)random(), /* id */ htons(numsent-1), /* seq */ NULL, /* pointer to payload */ 0, /* payload length */ @@ -157,9 +156,12 @@ void handlepacket(const char *unused, struct pcap_pkthdr *h, u_char *packet) hicmp = (struct icmphdr*)((char*)hip + sizeof(struct iphdr)); if ((htons(hicmp->type) == ICMP_ECHOREPLY) - && !memcmp(eth->h_source, eth_target, ETH_ALEN) - && !memcmp(eth->h_dest, mymac->ether_addr_octet, - ETH_ALEN)) { + && ( + (!memcmp(eth->h_source, eth_target, ETH_ALEN) + || !memcmp(eth_target, eth_xmas, ETH_ALEN)) + ) + && !memcmp(eth->h_dest, mymac->ether_addr_octet, + ETH_ALEN)) { u_char *cp = eth->h_source; if (!rawoutput) { printf("%d bytes from ", h->len); |