From 922ef94eefd55ca25df7ce7c98ac7c87134aa982 Mon Sep 17 00:00:00 2001 From: Oyvind Albrigtsen Date: Tue, 4 Apr 2017 12:12:35 +0200 Subject: [PATCH] send_arp: update usage info --- heartbeat/IPaddr2 | 2 +- heartbeat/SendArp | 2 +- tools/send_arp.libnet.c | 70 ++++++++++++++++--------------------------------- tools/send_arp.linux.c | 60 ++++++++++++++++-------------------------- 4 files changed, 48 insertions(+), 86 deletions(-) diff --git a/heartbeat/IPaddr2 b/heartbeat/IPaddr2 index 27b7208..d07c622 100755 --- a/heartbeat/IPaddr2 +++ b/heartbeat/IPaddr2 @@ -708,7 +708,7 @@ run_send_arp() { LOGLEVEL=info fi if [ $ARP_COUNT -ne 0 ] ; then - ARGS="-i $OCF_RESKEY_arp_interval -r $ARP_COUNT -p $SENDARPPIDFILE $NIC $OCF_RESKEY_ip $MY_MAC not_used not_used" + ARGS="-i $OCF_RESKEY_arp_interval -c $ARP_COUNT -p $SENDARPPIDFILE -I $NIC -m $MY_MAC $OCF_RESKEY_ip" ocf_log $LOGLEVEL "$SENDARP $ARGS" if ocf_is_true $OCF_RESKEY_arp_bg; then ($SENDARP $ARGS || ocf_log err "Could not send gratuitous arps")& >&2 diff --git a/heartbeat/SendArp b/heartbeat/SendArp index dbcc7dc..033865f 100755 --- a/heartbeat/SendArp +++ b/heartbeat/SendArp @@ -156,7 +156,7 @@ sendarp_start() { fi - ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $INTERFACE $BASEIP auto $BASEIP $ARP_NETMASK" + ARGS="-i $ARP_INTERVAL_MS -c $ARP_REPEAT -p $SENDARPPIDFILE -I $INTERFACE -m auto $BASEIP" ocf_log debug "$SENDARP $ARGS" rc=$OCF_SUCCESS diff --git a/tools/send_arp.libnet.c b/tools/send_arp.libnet.c index 12fe7f1..bd96a49 100644 --- a/tools/send_arp.libnet.c +++ b/tools/send_arp.libnet.c @@ -62,35 +62,14 @@ #define PIDFILE_BASE PIDDIR "/send_arp-" static char print_usage[]={ -"send_arp: sends out custom ARP packet.\n" -" usage: send_arp [-i repeatinterval-ms] [-r repeatcount] [-p pidfile] \\\n" -" device src_ip_addr src_hw_addr broadcast_ip_addr netmask\n" -"\n" -" where:\n" -" repeatinterval-ms: timing, in milliseconds of sending arp packets\n" -" For each ARP announcement requested, a pair of ARP packets is sent,\n" -" an ARP request, and an ARP reply. This is becuse some systems\n" -" ignore one or the other, and this combination gives the greatest\n" -" chance of success.\n" -"\n" -" Each time an ARP is sent, if another ARP will be sent then\n" -" the code sleeps for half of repeatinterval-ms.\n" -"\n" -" repeatcount: how many pairs of ARP packets to send.\n" -" See above for why pairs are sent\n" -"\n" -" pidfile: pid file to use\n" -"\n" -" device: netowrk interace to use\n" -"\n" -" src_ip_addr: source ip address\n" -"\n" -" src_hw_addr: source hardware address.\n" -" If \"auto\" then the address of device\n" -"\n" -" broadcast_ip_addr: ignored\n" -"\n" -" netmask: ignored\n" +"Usage: send_arp [-i repeatinterval-ms] [-c count] [-p pidfile] [-I device] [-m mac] destination\n" +" -i repeatinterval-ms : repeat interval in milliseconds (ignored in Linux version)\n" +" -c count : how many packets to send\n" +" -p pidfile : pid file (ignored in Linux version)\n" +" -I device : which ethernet device to use\n" +" -m mac : source MAC address (ignored in Linux version).\n" +" If \"auto\" device address is used\n" +" destination : ask for what ip address\n" }; static const char * SENDARPNAME = "send_arp"; @@ -158,41 +137,38 @@ main(int argc, char *argv[]) cl_log_set_facility(LOG_USER); cl_inherit_logging_environment(0); - while ((flag = getopt(argc, argv, "i:r:p:")) != EOF) { + while ((flag = getopt(argc, argv, "h?c:I:i:p:m:")) != EOF) { switch(flag) { case 'i': msinterval= atol(optarg); break; - case 'r': repeatcount= atoi(optarg); + case 'c': repeatcount= atoi(optarg); break; case 'p': pidfilename= optarg; break; + case 'I': device= optarg; + break; + + case 'm': macaddr= optarg; + break; + + case 'h': + case '?': default: fprintf(stderr, "%s\n\n", print_usage); return 1; break; } } - if (argc-optind != 5) { - fprintf(stderr, "%s\n\n", print_usage); - return 1; - } - /* - * argv[optind+1] DEVICE dc0,eth0:0,hme0:0, - * argv[optind+2] IP 192.168.195.186 - * argv[optind+3] MAC ADDR 00a0cc34a878 - * argv[optind+4] BROADCAST 192.168.195.186 - * argv[optind+5] NETMASK ffffffffffff - */ + argc -= optind; + argv += optind; + if (argc != 1) + usage(); - device = argv[optind]; - ipaddr = argv[optind+1]; - macaddr = argv[optind+2]; - broadcast = argv[optind+3]; - netmask = argv[optind+4]; + ipaddr = *argv; if (!pidfilename) { if (snprintf(pidfilenamebuf, sizeof(pidfilenamebuf), "%s%s", diff --git a/tools/send_arp.linux.c b/tools/send_arp.linux.c index 477100a..348794c 100644 --- a/tools/send_arp.linux.c +++ b/tools/send_arp.linux.c @@ -137,22 +137,25 @@ static socklen_t sll_len(size_t halen) void usage(void) { fprintf(stderr, - "Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n" - " -f : quit on first reply\n" - " -q : be quiet\n" - " -b : keep broadcasting, don't go unicast\n" - " -D : duplicate address detection mode\n" - " -U : Unsolicited ARP mode, update your neighbours\n" - " -A : ARP answer mode, update your neighbours\n" - " -V : print version and exit\n" + "Usage: send_arp [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n" + " -f : quit on first reply (not available in libnet version)\n" + " -q : be quiet (not available in libnet version)\n" + " -b : keep broadcasting, don't go unicast (not available in libnet version)\n" + " -i : repeat interval in milliseconds (ignored)\n" + " -p : pid file (ignored)\n" + " -D : duplicate address detection mode (not available in libnet version)\n" + " -U : Unsolicited ARP mode, update your neighbours (not available in libnet version)\n" + " -A : ARP answer mode, update your neighbours (not available in libnet version)\n" + " -V : print version and exit (not available in libnet version)\n" " -c count : how many packets to send\n" - " -w timeout : how long to wait for a reply\n" + " -w timeout : how long to wait for a reply (not available in libnet version)\n" " -I device : which ethernet device to use" #ifdef DEFAULT_DEVICE_STR " (" DEFAULT_DEVICE_STR ")" #endif "\n" - " -s source : source ip address\n" + " -s source : source ip address (not available in libnet version)\n" + " -m mac : source MAC address (ignored).\n" " destination : ask for what ip address\n" ); exit(2); @@ -1044,7 +1047,7 @@ main(int argc, char **argv) disable_capability_raw(); - while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:Vr:i:p:")) != EOF) { + while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:Vi:m:p:")) != EOF) { switch(ch) { case 'b': broadcast_only=1; @@ -1063,9 +1066,6 @@ main(int argc, char **argv) case 'q': quiet++; break; - case 'r': /* send_arp.libnet compatibility option */ - hb_mode = 1; - /* fall-through */ case 'c': count = atoi(optarg); break; @@ -1086,9 +1086,10 @@ main(int argc, char **argv) exit(0); case 'p': case 'i': - hb_mode = 1; - /* send_arp.libnet compatibility options, ignore */ - break; + case 'm': + hb_mode = 1; + /* send_arp.libnet compatibility options, ignore */ + break; case 'h': case '?': default: @@ -1098,30 +1099,15 @@ main(int argc, char **argv) if(hb_mode) { /* send_arp.libnet compatibility mode */ - if (argc - optind != 5) { - usage(); - return 1; - } - /* - * argv[optind+1] DEVICE dc0,eth0:0,hme0:0, - * argv[optind+2] IP 192.168.195.186 - * argv[optind+3] MAC ADDR 00a0cc34a878 - * argv[optind+4] BROADCAST 192.168.195.186 - * argv[optind+5] NETMASK ffffffffffff - */ - unsolicited = 1; - device.name = argv[optind]; - target = argv[optind+1]; + } - } else { - argc -= optind; - argv += optind; - if (argc != 1) + argc -= optind; + argv += optind; + if (argc != 1) usage(); - target = *argv; - } + target = *argv; if (device.name && !*device.name) device.name = NULL;