-#ifdef CONFIG_FEATURE_IPV6
- } else if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) {
- int sockfd6;
- struct in6_ifreq ifr6;
-
- memcpy((char *) &ifr6.ifr6_addr,
- (char *) &sai6.sin6_addr,
- sizeof(struct in6_addr));
-
- /* Create a channel to the NET kernel. */
- if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- bb_perror_msg_and_die("socket6");
- }
- if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) {
- perror("SIOGIFINDEX");
- ++goterr;
+ else {
+ 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;
+ struct in6_ifreq ifr6;
+
+ memcpy((char *) &ifr6.ifr6_addr,
+ (char *) &(lsa->sin6.sin6_addr),
+ sizeof(struct in6_addr));
+
+ /* 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");
+ 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);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ free(lsa);