#include <netinet/if_ether.h>
#endif
#include "inet_common.h"
-#include "busybox.h"
+#include "libbb.h"
#if ENABLE_FEATURE_IFCONFIG_SLIP
# include <net/if_slip.h>
* Our main function.
*/
-int ifconfig_main(int argc, char **argv);
+int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ifconfig_main(int argc, char **argv)
{
struct ifreq ifr;
}
/* We fell through, so treat as possible hostname. */
- a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1;
+ a1op = Arg1Opt + ARRAY_SIZE(Arg1Opt) - 1;
mask = op->arg_flags;
goto HOSTNAME;
}
#endif
else {
- len_and_sockaddr *lsa = xhost2sockaddr(host, 0);
+ len_and_sockaddr *lsa;
+ if (strcmp(host, "inet") == 0)
+ continue; /* compat stuff */
+ lsa = xhost2sockaddr(host, 0);
#if ENABLE_FEATURE_IPV6
if (lsa->sa.sa_family == AF_INET6) {
int sockfd6;
/* Create a channel to the NET kernel. */
sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0);
- if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0)
- bb_perror_msg_and_die("SIOGIFINDEX");
+ xioctl(sockfd6, SIOGIFINDEX, &ifr);
ifr6.ifr6_ifindex = ifr.ifr_ifindex;
ifr6.ifr6_prefixlen = prefix_len;
- if (ioctl(sockfd6, a1op->selector, &ifr6) < 0)
- bb_perror_msg_and_die(a1op->name);
+ ioctl_or_perror_and_die(sockfd6, a1op->selector, &ifr6, "%s", a1op->name);
if (ENABLE_FEATURE_CLEAN_UP)
free(lsa);
continue;
p = ((char *)&ifr) + a1op->ifr_offset;
#if ENABLE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
if (mask & A_MAP_TYPE) {
- if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0)
- bb_perror_msg_and_die("SIOCGIFMAP");
+ xioctl(sockfd, SIOCGIFMAP, &ifr);
if ((mask & A_MAP_UCHAR) == A_MAP_UCHAR)
*((unsigned char *) p) = i;
else if (mask & A_MAP_USHORT)
*((int *) p) = i;
}
- if (ioctl(sockfd, a1op->selector, &ifr) < 0)
- bb_perror_msg_and_die(a1op->name);
+ ioctl_or_perror_and_die(sockfd, a1op->selector, &ifr, "%s", a1op->name);
#ifdef QUESTIONABLE_ALIAS_CASE
if (mask & A_COLON_CHK) {
/*
mask = N_SET;
}
- if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0)
- bb_perror_msg_and_die("SIOCGIFFLAGS");
+ xioctl(sockfd, SIOCGIFFLAGS, &ifr);
selector = op->selector;
if (mask & SET_MASK)
ifr.ifr_flags |= selector;
else
ifr.ifr_flags &= ~selector;
- if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0)
- bb_perror_msg_and_die("SIOCSIFFLAGS");
+ xioctl(sockfd, SIOCSIFFLAGS, &ifr);
} /* while () */
if (ENABLE_FEATURE_CLEAN_UP)