X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fether-wake.c;h=deeb68c096aeaebb1456afe6af9b1fde7fdf37fb;hb=765b0eed3ef29a80115708c3249d3a541509cd24;hp=b67e1b5d8973a749dd7323e601ac23896a384164;hpb=fb79a2e2cfe33002398f1898c26d8e4f341db006;p=oweals%2Fbusybox.git diff --git a/networking/ether-wake.c b/networking/ether-wake.c index b67e1b5d8..deeb68c09 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c @@ -92,7 +92,7 @@ void bb_debug_dump_packet(unsigned char *outpack, int pktsize) printf("packet dump:\n"); for (i = 0; i < pktsize; ++i) { printf("%2.2x ", outpack[i]); - if (i % 20 == 19) puts(""); + if (i % 20 == 19) bb_putchar('\n'); } printf("\n\n"); } @@ -111,16 +111,19 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) { struct ether_addr *eap; - eap = ether_aton(hostid); + eap = ether_aton_r(hostid, eaddr); if (eap) { - *eaddr = *eap; - bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eaddr)); -#if !defined(__UCLIBC__) + bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap)); +#if !defined(__UCLIBC_MAJOR__) \ + || __UCLIBC_MAJOR__ > 0 \ + || __UCLIBC_MINOR__ > 9 \ + || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ >= 30) } else if (ether_hostton(hostid, eaddr) == 0) { bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr)); #endif - } else + } else { bb_show_usage(); + } } static int get_fill(unsigned char *pkt, struct ether_addr *eaddr, int broadcast) @@ -164,7 +167,7 @@ static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd) byte_cnt = sscanf(ethoptarg, "%u.%u.%u.%u", &passwd[0], &passwd[1], &passwd[2], &passwd[3]); if (byte_cnt < 4) { - bb_error_msg("cannot read Wake-On-LAN pass"); + bb_error_msg("can't read Wake-On-LAN pass"); return 0; } // TODO: check invalid numbers >255?? @@ -178,8 +181,8 @@ static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd) return byte_cnt; } -int ether_wake_main(int argc, char **argv); -int ether_wake_main(int argc, char **argv) +int ether_wake_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int ether_wake_main(int argc UNUSED_PARAM, char **argv) { const char *ifname = "eth0"; char *pass; @@ -195,7 +198,7 @@ int ether_wake_main(int argc, char **argv) /* handle misc user options */ opt_complementary = "=1"; - flags = getopt32(argc, argv, "bi:p:", &ifname, &pass); + flags = getopt32(argv, "bi:p:", &ifname, &pass); if (flags & 4) /* -p */ wol_passwd_sz = get_wol_pw(pass, wol_passwd); flags &= 1; /* we further interested only in -b [bcast] flag */ @@ -219,7 +222,7 @@ int ether_wake_main(int argc, char **argv) { struct ifreq if_hwaddr; - strncpy(if_hwaddr.ifr_name, ifname, sizeof(if_hwaddr.ifr_name)); + strncpy_IFNAMSIZ(if_hwaddr.ifr_name, ifname); ioctl_or_perror_and_die(s, SIOCGIFHWADDR, &if_hwaddr, "SIOCGIFHWADDR on %s failed", ifname); memcpy(outpack+6, if_hwaddr.ifr_hwaddr.sa_data, 6); @@ -255,7 +258,7 @@ int ether_wake_main(int argc, char **argv) #if defined(PF_PACKET) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + strncpy_IFNAMSIZ(ifr.ifr_name, ifname); xioctl(s, SIOCGIFINDEX, &ifr); memset(&whereto, 0, sizeof(whereto)); whereto.sll_family = AF_PACKET;