- sed -e "s/char[[:space:]]*\*[[:space:]]*argv\[\]/char **argv/g"
[oweals/busybox.git] / networking / ether-wake.c
index cc2fb62a3c1471f6aaaa9e335e7b42ae08a7ddc8..e971ba39c5b91e4dace1eef1c9b43432cb0e5944 100644 (file)
@@ -105,9 +105,11 @@ static inline void get_dest_addr(const char *arg, struct ether_addr *eaddr);
 static inline int get_fill(unsigned char *pkt, struct ether_addr *eaddr, int broadcast);
 static inline int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd);
 
-int ether_wake_main(int argc, char *argv[])
+int ether_wake_main(int argc, char **argv);
+int ether_wake_main(int argc, char **argv)
 {
-       char *ifname = "eth0", *pass = NULL;
+       const char *ifname = "eth0";
+       char *pass = NULL;
        unsigned long flags;
        unsigned char wol_passwd[6];
        int wol_passwd_sz = 0;
@@ -145,7 +147,7 @@ int ether_wake_main(int argc, char *argv[])
        {
                struct ifreq if_hwaddr;
 
-               strcpy(if_hwaddr.ifr_name, ifname);
+               strncpy(if_hwaddr.ifr_name, ifname, sizeof(if_hwaddr.ifr_name));
                if (ioctl(s, SIOCGIFHWADDR, &if_hwaddr) < 0)
                        bb_perror_msg_and_die("SIOCGIFHWADDR on %s failed", ifname);
 
@@ -175,8 +177,7 @@ int ether_wake_main(int argc, char *argv[])
 
        /* This is necessary for broadcasts to work */
        if (flags /*& 1 [OPT_BROADCAST]*/) {
-               int one = 1;
-               if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (void *)&one, sizeof(one)) < 0)
+               if (setsockopt_broadcast(s) < 0)
                        bb_perror_msg("SO_BROADCAST");
        }
 
@@ -224,8 +225,6 @@ static inline void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
 #if !defined(__UCLIBC__)
        } else if (ether_hostton(hostid, eaddr) == 0) {
                bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr));
-#else
-# warning Need to implement ether_hostton() for uClibc
 #endif
        } else
                bb_show_usage();