aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-16 23:23:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-16 23:23:33 +0000
commit517d1aac7f42958a2b1c3c1f7ffbf83731c6e263 (patch)
tree3d27ce10258694ae07eab87f0566e50e9707c7f5 /networking
parent198714c0dd2f6456b31a089fb58ba27ad88785c4 (diff)
downloadbusybox-517d1aac7f42958a2b1c3c1f7ffbf83731c6e263.tar.gz
ether-wake: save a few more bytes of code
Diffstat (limited to 'networking')
-rw-r--r--networking/ether-wake.c15
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);
int ether_wake_main(int argc, char **argv)
{
const char *ifname = "eth0";
- char *pass = NULL;
+ char *pass;
unsigned flags;
unsigned char wol_passwd[6];
int wol_passwd_sz = 0;
-
int s; /* Raw socket */
int pktsize;
unsigned char outpack[1000];
@@ -195,23 +194,23 @@ int ether_wake_main(int argc, char **argv)
struct whereto_t whereto; /* who to wake up */
/* handle misc user options */
+ opt_complementary = "=1";
flags = getopt32(argc, argv, "bi:p:", &ifname, &pass);
- if (optind == argc)
- bb_show_usage();
- if (pass)
+ if (flags & 4) /* -p */
wol_passwd_sz = get_wol_pw(pass, wol_passwd);
+ flags &= 1; /* we further interested only in -b [bcast] flag */
/* create the raw socket */
s = make_socket();
/* now that we have a raw socket we can drop root */
- xsetuid(getuid());
+ /* xsetuid(getuid()); - but save on code size... */
/* look up the dest mac address */
get_dest_addr(argv[optind], &eaddr);
/* fill out the header of the packet */
- pktsize = get_fill(outpack, &eaddr, flags & 1 /* OPT_BROADCAST */);
+ pktsize = get_fill(outpack, &eaddr, flags /* & 1 OPT_BROADCAST */);
bb_debug_dump_packet(outpack, pktsize);
@@ -249,7 +248,7 @@ int ether_wake_main(int argc, char **argv)
bb_debug_dump_packet(outpack, pktsize);
/* This is necessary for broadcasts to work */
- if (flags & 1 /* OPT_BROADCAST */) {
+ if (flags /* & 1 OPT_BROADCAST */) {
if (setsockopt_broadcast(s) != 0)
bb_perror_msg("SO_BROADCAST");
}