/* Convert the host ID string to a MAC address. * The string may be a: * Host name * IP address string * MAC address string */ static inline void get_dest_addr(const char *hostid, struct ether_addr *eaddr) { struct ether_addr *eap; eap = ether_aton(hostid); if (eap) { *eaddr = *eap; bb_debug_msg("The target station address is %s\n\n", ether_ntoa(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)); #endif } else bb_show_usage(); }
/* Convert the host ID string to a MAC address. * The string may be a: * Host name * IP address string * MAC address string */ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) { struct ether_addr *eap; eap = ether_aton_r(hostid, eaddr); if (eap) { bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap)); #if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 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 { bb_show_usage(); } }
static inline int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd) { int passwd[6]; int byte_cnt, i; /* handle MAC format */ byte_cnt = sscanf(ethoptarg, "%2x:%2x:%2x:%2x:%2x:%2x", &passwd[0], &passwd[1], &passwd[2], &passwd[3], &passwd[4], &passwd[5]); /* handle IP format */ if (byte_cnt < 4) byte_cnt = sscanf(ethoptarg, "%d.%d.%d.%d", &passwd[0], &passwd[1], &passwd[2], &passwd[3]); if (byte_cnt < 4) { bb_error_msg("cannot read Wake-On-LAN pass"); return 0; } for (i = 0; i < byte_cnt; ++i) wol_passwd[i] = passwd[i]; bb_debug_msg("password: %2.2x %2.2x %2.2x %2.2x (%d)\n\n", wol_passwd[0], wol_passwd[1], wol_passwd[2], wol_passwd[3], byte_cnt); return byte_cnt; }
static int get_wol_pw(const char *ethoptarg, unsigned char *wol_passwd) { unsigned passwd[6]; int byte_cnt, i; /* handle MAC format */ byte_cnt = sscanf(ethoptarg, "%2x:%2x:%2x:%2x:%2x:%2x", &passwd[0], &passwd[1], &passwd[2], &passwd[3], &passwd[4], &passwd[5]); /* handle IP format */ // FIXME: why < 4?? should it be < 6? if (byte_cnt < 4) byte_cnt = sscanf(ethoptarg, "%u.%u.%u.%u", &passwd[0], &passwd[1], &passwd[2], &passwd[3]); if (byte_cnt < 4) { bb_error_msg("can't read Wake-On-LAN pass"); return 0; } // TODO: check invalid numbers >255?? for (i = 0; i < byte_cnt; ++i) wol_passwd[i] = passwd[i]; bb_debug_msg("password: %2.2x %2.2x %2.2x %2.2x (%d)\n\n", wol_passwd[0], wol_passwd[1], wol_passwd[2], wol_passwd[3], byte_cnt); return byte_cnt; }
/* Convert the host ID string to a MAC address. * The string may be a: * Host name * IP address string * MAC address string */ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) { struct ether_addr *eap; eap = ether_aton_r(hostid, eaddr); if (eap) { 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 { bb_show_usage(); } }