| 143 | } |
| 144 | |
| 145 | static void |
| 146 | setip6eui64(const char *cmd, int dummy __unused, int s, |
| 147 | const struct afswtch *afp) |
| 148 | { |
| 149 | struct ifaddrs *ifap, *ifa; |
| 150 | const struct sockaddr_in6 *sin6 = NULL; |
| 151 | const struct in6_addr *lladdr = NULL; |
| 152 | struct in6_addr *in6; |
| 153 | |
| 154 | if (afp->af_af != AF_INET6) |
| 155 | errx(EXIT_FAILURE, "%s not allowed for the AF", cmd); |
| 156 | in6 = (struct in6_addr *)&in6_addreq.ifra_addr.sin6_addr; |
| 157 | if (memcmp(&in6addr_any.s6_addr[8], &in6->s6_addr[8], 8) != 0) |
| 158 | errx(EXIT_FAILURE, "interface index is already filled"); |
| 159 | if (getifaddrs(&ifap) != 0) |
| 160 | err(EXIT_FAILURE, "getifaddrs"); |
| 161 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { |
| 162 | if (ifa->ifa_addr->sa_family == AF_INET6 && |
| 163 | strcmp(ifa->ifa_name, name) == 0) { |
| 164 | sin6 = (const struct sockaddr_in6 *)ifa->ifa_addr; |
| 165 | if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { |
| 166 | lladdr = &sin6->sin6_addr; |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | if (!lladdr) |
| 172 | errx(EXIT_FAILURE, "could not determine link local address"); |
| 173 | |
| 174 | memcpy(&in6->s6_addr[8], &lladdr->s6_addr[8], 8); |
| 175 | |
| 176 | freeifaddrs(ifap); |
| 177 | } |
| 178 | |
| 179 | static void |
| 180 | in6_status(int s __unused, const struct ifaddrs *ifa) |
nothing calls this directly
no test coverage detected