diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-16 23:23:33 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-16 23:23:33 +0000 |
commit | 517d1aac7f42958a2b1c3c1f7ffbf83731c6e263 (patch) | |
tree | 3d27ce10258694ae07eab87f0566e50e9707c7f5 /networking | |
parent | 198714c0dd2f6456b31a089fb58ba27ad88785c4 (diff) | |
download | busybox-w32-517d1aac7f42958a2b1c3c1f7ffbf83731c6e263.tar.gz busybox-w32-517d1aac7f42958a2b1c3c1f7ffbf83731c6e263.tar.bz2 busybox-w32-517d1aac7f42958a2b1c3c1f7ffbf83731c6e263.zip |
ether-wake: save a few more bytes of code
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ether-wake.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/networking/ether-wake.c b/networking/ether-wake.c index 71c3abfc3..ed41590aa 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c | |||
@@ -182,11 +182,10 @@ int ether_wake_main(int argc, char **argv); | |||
182 | int ether_wake_main(int argc, char **argv) | 182 | int ether_wake_main(int argc, char **argv) |
183 | { | 183 | { |
184 | const char *ifname = "eth0"; | 184 | const char *ifname = "eth0"; |
185 | char *pass = NULL; | 185 | char *pass; |
186 | unsigned flags; | 186 | unsigned flags; |
187 | unsigned char wol_passwd[6]; | 187 | unsigned char wol_passwd[6]; |
188 | int wol_passwd_sz = 0; | 188 | int wol_passwd_sz = 0; |
189 | |||
190 | int s; /* Raw socket */ | 189 | int s; /* Raw socket */ |
191 | int pktsize; | 190 | int pktsize; |
192 | unsigned char outpack[1000]; | 191 | unsigned char outpack[1000]; |
@@ -195,23 +194,23 @@ int ether_wake_main(int argc, char **argv) | |||
195 | struct whereto_t whereto; /* who to wake up */ | 194 | struct whereto_t whereto; /* who to wake up */ |
196 | 195 | ||
197 | /* handle misc user options */ | 196 | /* handle misc user options */ |
197 | opt_complementary = "=1"; | ||
198 | flags = getopt32(argc, argv, "bi:p:", &ifname, &pass); | 198 | flags = getopt32(argc, argv, "bi:p:", &ifname, &pass); |
199 | if (optind == argc) | 199 | if (flags & 4) /* -p */ |
200 | bb_show_usage(); | ||
201 | if (pass) | ||
202 | wol_passwd_sz = get_wol_pw(pass, wol_passwd); | 200 | wol_passwd_sz = get_wol_pw(pass, wol_passwd); |
201 | flags &= 1; /* we further interested only in -b [bcast] flag */ | ||
203 | 202 | ||
204 | /* create the raw socket */ | 203 | /* create the raw socket */ |
205 | s = make_socket(); | 204 | s = make_socket(); |
206 | 205 | ||
207 | /* now that we have a raw socket we can drop root */ | 206 | /* now that we have a raw socket we can drop root */ |
208 | xsetuid(getuid()); | 207 | /* xsetuid(getuid()); - but save on code size... */ |
209 | 208 | ||
210 | /* look up the dest mac address */ | 209 | /* look up the dest mac address */ |
211 | get_dest_addr(argv[optind], &eaddr); | 210 | get_dest_addr(argv[optind], &eaddr); |
212 | 211 | ||
213 | /* fill out the header of the packet */ | 212 | /* fill out the header of the packet */ |
214 | pktsize = get_fill(outpack, &eaddr, flags & 1 /* OPT_BROADCAST */); | 213 | pktsize = get_fill(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */); |
215 | 214 | ||
216 | bb_debug_dump_packet(outpack, pktsize); | 215 | bb_debug_dump_packet(outpack, pktsize); |
217 | 216 | ||
@@ -249,7 +248,7 @@ int ether_wake_main(int argc, char **argv) | |||
249 | bb_debug_dump_packet(outpack, pktsize); | 248 | bb_debug_dump_packet(outpack, pktsize); |
250 | 249 | ||
251 | /* This is necessary for broadcasts to work */ | 250 | /* This is necessary for broadcasts to work */ |
252 | if (flags & 1 /* OPT_BROADCAST */) { | 251 | if (flags /* & 1 OPT_BROADCAST */) { |
253 | if (setsockopt_broadcast(s) != 0) | 252 | if (setsockopt_broadcast(s) != 0) |
254 | bb_perror_msg("SO_BROADCAST"); | 253 | bb_perror_msg("SO_BROADCAST"); |
255 | } | 254 | } |