From 26c2bd077a39cb19d9b86daafb1cf24167afd450 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 3 Feb 2015 08:54:42 -0600 Subject: Add an ioctal() that can be used to perform ICMPv6 auto-configuration --- apps/netutils/netlib/netlib_autoconfig.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'apps/netutils') diff --git a/apps/netutils/netlib/netlib_autoconfig.c b/apps/netutils/netlib/netlib_autoconfig.c index f3040e2bb..da4c13282 100644 --- a/apps/netutils/netlib/netlib_autoconfig.c +++ b/apps/netutils/netlib/netlib_autoconfig.c @@ -74,36 +74,33 @@ int netlib_icmpv6_autoconfiguration(FAR const char *ifname) { int ret = ERROR; -#if 1 /* Not yet implemented */ + /* Verify that an interface name was provided */ -# warning Missing logic - errno = ENOSYS; - -#else if (ifname) { + /* Get an IPv6 socket */ + int sockfd = socket(PF_INET6, NETLIB_SOCK_IOCTL, 0); if (sockfd >= 0) { - FAR struct sockaddr_in6 *inaddr; - struct lifreq req; - - /* Add the device name to the request */ + /* Create a request consisting only of the interface name */ + struct lifreq req; strncpy(req.lifr_name, ifname, IFNAMSIZ); - /* Add the INET address to the request */ + /* Perform the ICMPv6 auto-configuration and close the socket */ - inaddr = (FAR struct sockaddr_in6 *)&req.lifr_addr; - inaddr->sin6_family = AF_INET6; - inaddr->sin6_port = 0; - memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr)); - - ret = ioctl(sockfd, SIOCSLIFNETMASK, (unsigned long)((uintptr_t)&req)); + ret = ioctl(sockfd, SIOCIFAUTOCONF, + (unsigned long)((uintptr_t)&req)); close(sockfd); } } -#endif + else + { + /* No interface name */ + + set_errno(EINVAL); + } return ret; } -- cgit v1.2.3