MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setip6eui64

Function setip6eui64

tools/ifconfig/af_inet6.c:145–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145static void
146setip6eui64(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
179static void
180in6_status(int s __unused, const struct ifaddrs *ifa)

Callers

nothing calls this directly

Calls 4

getifaddrsFunction · 0.85
strcmpFunction · 0.85
freeifaddrsFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected