diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-10-14 19:04:20 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-10-14 19:04:20 +0200 |
| commit | eba5faec67da1c95cf9616b5deacbea24fbd3998 (patch) | |
| tree | e569be132ff3e5bfe6fd7a2609c05314fc3bb3b7 | |
| parent | d074b416f8d3ca6b6ae7b44d17e204ea8d81e7a0 (diff) | |
| download | busybox-w32-eba5faec67da1c95cf9616b5deacbea24fbd3998.tar.gz busybox-w32-eba5faec67da1c95cf9616b5deacbea24fbd3998.tar.bz2 busybox-w32-eba5faec67da1c95cf9616b5deacbea24fbd3998.zip | |
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.c | 19 |
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 @@ | |||
| 62 | * An alternative to needing 'root' is using a UDP broadcast socket, however | 62 | * An alternative to needing 'root' is using a UDP broadcast socket, however |
| 63 | * doing so only works with adapters configured for unicast+broadcast Rx | 63 | * doing so only works with adapters configured for unicast+broadcast Rx |
| 64 | * filter. That configuration consumes more power. | 64 | * filter. That configuration consumes more power. |
| 65 | */ | 65 | */ |
| 66 | 66 | ||
| 67 | //usage:#define ether_wake_trivial_usage | 67 | //usage:#define ether_wake_trivial_usage |
| 68 | //usage: "[-b] [-i iface] [-p aa:bb:cc:dd[:ee:ff]] MAC" | 68 | //usage: "[-b] [-i IFACE] [-p aa:bb:cc:dd[:ee:ff]/a.b.c.d] MAC" |
| 69 | //usage:#define ether_wake_full_usage "\n\n" | 69 | //usage:#define ether_wake_full_usage "\n\n" |
| 70 | //usage: "Send a magic packet to wake up sleeping machines.\n" | 70 | //usage: "Send a magic packet to wake up sleeping machines.\n" |
| 71 | //usage: "MAC must be a station address (00:11:22:33:44:55) or\n" | 71 | //usage: "MAC must be a station address (00:11:22:33:44:55) or\n" |
| 72 | //usage: "a hostname with a known 'ethers' entry.\n" | 72 | //usage: "a hostname with a known 'ethers' entry.\n" |
| 73 | //usage: "\n -b Send wake-up packet to the broadcast address" | 73 | //usage: "\n -b Broadcast the packet" |
| 74 | //usage: "\n -i iface Interface to use (default eth0)" | 74 | //usage: "\n -i IFACE Interface to use (default eth0)" |
| 75 | //usage: "\n -p pass Append four or six byte password PW to the packet" | 75 | //usage: "\n -p PASSWORD Append four or six byte PASSWORD to the packet" |
| 76 | 76 | ||
| 77 | #include "libbb.h" | 77 | #include "libbb.h" |
| 78 | #include <netpacket/packet.h> | 78 | #include <netpacket/packet.h> |
| @@ -130,7 +130,8 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) | |||
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static int get_fill(unsigned char *pkt, struct ether_addr *eaddr, int broadcast) | 133 | #define PKT_HEADER_SIZE (20 + 16*6) |
| 134 | static int fill_pkt_header(unsigned char *pkt, struct ether_addr *eaddr, int broadcast) | ||
| 134 | { | 135 | { |
| 135 | int i; | 136 | int i; |
| 136 | unsigned char *station_addr = eaddr->ether_addr_octet; | 137 | 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) | |||
| 153 | memcpy(pkt, station_addr, 6); /* 20,26,32,... */ | 154 | memcpy(pkt, station_addr, 6); /* 20,26,32,... */ |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | return 20 + 16*6; /* length of packet */ | 157 | return PKT_HEADER_SIZE; /* length of packet */ |
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd) | 160 | 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) | |||
| 195 | int wol_passwd_sz = 0; | 196 | int wol_passwd_sz = 0; |
| 196 | int s; /* Raw socket */ | 197 | int s; /* Raw socket */ |
| 197 | int pktsize; | 198 | int pktsize; |
| 198 | unsigned char outpack[1000]; | 199 | unsigned char outpack[PKT_HEADER_SIZE + 6 /* max passwd size */ + 16 /* paranoia */]; |
| 199 | 200 | ||
| 200 | struct ether_addr eaddr; | 201 | struct ether_addr eaddr; |
| 201 | struct whereto_t whereto; /* who to wake up */ | 202 | struct whereto_t whereto; /* who to wake up */ |
| @@ -217,7 +218,7 @@ int ether_wake_main(int argc UNUSED_PARAM, char **argv) | |||
| 217 | get_dest_addr(argv[optind], &eaddr); | 218 | get_dest_addr(argv[optind], &eaddr); |
| 218 | 219 | ||
| 219 | /* fill out the header of the packet */ | 220 | /* fill out the header of the packet */ |
| 220 | pktsize = get_fill(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */); | 221 | pktsize = fill_pkt_header(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */); |
| 221 | 222 | ||
| 222 | bb_debug_dump_packet(outpack, pktsize); | 223 | bb_debug_dump_packet(outpack, pktsize); |
| 223 | 224 | ||
