aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-10-14 19:04:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-10-14 19:04:20 +0200
commiteba5faec67da1c95cf9616b5deacbea24fbd3998 (patch)
treee569be132ff3e5bfe6fd7a2609c05314fc3bb3b7
parentd074b416f8d3ca6b6ae7b44d17e204ea8d81e7a0 (diff)
downloadbusybox-eba5faec67da1c95cf9616b5deacbea24fbd3998.tar.gz
ether-wake: shorten help text, reduce packet buffer size
function old new delta ether_wake_main 726 727 +1 packed_usage 29468 29434 -34 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/ether-wake.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
index 2d389ea30..c38547dda 100644
--- a/networking/ether-wake.c
+++ b/networking/ether-wake.c
@@ -62,17 +62,17 @@
* An alternative to needing 'root' is using a UDP broadcast socket, however
* doing so only works with adapters configured for unicast+broadcast Rx
* filter. That configuration consumes more power.
-*/
+ */
//usage:#define ether_wake_trivial_usage
-//usage: "[-b] [-i iface] [-p aa:bb:cc:dd[:ee:ff]] MAC"
+//usage: "[-b] [-i IFACE] [-p aa:bb:cc:dd[:ee:ff]/a.b.c.d] MAC"
//usage:#define ether_wake_full_usage "\n\n"
//usage: "Send a magic packet to wake up sleeping machines.\n"
//usage: "MAC must be a station address (00:11:22:33:44:55) or\n"
//usage: "a hostname with a known 'ethers' entry.\n"
-//usage: "\n -b Send wake-up packet to the broadcast address"
-//usage: "\n -i iface Interface to use (default eth0)"
-//usage: "\n -p pass Append four or six byte password PW to the packet"
+//usage: "\n -b Broadcast the packet"
+//usage: "\n -i IFACE Interface to use (default eth0)"
+//usage: "\n -p PASSWORD Append four or six byte PASSWORD to the packet"
#include "libbb.h"
#include <netpacket/packet.h>
@@ -130,7 +130,8 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
}
}
-static int get_fill(unsigned char *pkt, struct ether_addr *eaddr, int broadcast)
+#define PKT_HEADER_SIZE (20 + 16*6)
+static int fill_pkt_header(unsigned char *pkt, struct ether_addr *eaddr, int broadcast)
{
int i;
unsigned char *station_addr = eaddr->ether_addr_octet;
@@ -153,7 +154,7 @@ static int get_fill(unsigned char *pkt, struct ether_addr *eaddr, int broadcast)
memcpy(pkt, station_addr, 6); /* 20,26,32,... */
}
- return 20 + 16*6; /* length of packet */
+ return PKT_HEADER_SIZE; /* length of packet */
}
static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd)
@@ -195,7 +196,7 @@ int ether_wake_main(int argc UNUSED_PARAM, char **argv)
int wol_passwd_sz = 0;
int s; /* Raw socket */
int pktsize;
- unsigned char outpack[1000];
+ unsigned char outpack[PKT_HEADER_SIZE + 6 /* max passwd size */ + 16 /* paranoia */];
struct ether_addr eaddr;
struct whereto_t whereto; /* who to wake up */
@@ -217,7 +218,7 @@ int ether_wake_main(int argc UNUSED_PARAM, char **argv)
get_dest_addr(argv[optind], &eaddr);
/* fill out the header of the packet */
- pktsize = get_fill(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */);
+ pktsize = fill_pkt_header(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */);
bb_debug_dump_packet(outpack, pktsize);