summaryrefslogtreecommitdiff
path: root/apps/netutils
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-03 08:54:42 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-03 08:54:42 -0600
commit26c2bd077a39cb19d9b86daafb1cf24167afd450 (patch)
tree42ab477e20efaad52dfea24f8b99cb1c0dfd14fb /apps/netutils
parent5694858d44cc20fae42518c739ba59afd8d77b87 (diff)
downloadpx4-nuttx-26c2bd077a39cb19d9b86daafb1cf24167afd450.tar.gz
px4-nuttx-26c2bd077a39cb19d9b86daafb1cf24167afd450.tar.bz2
px4-nuttx-26c2bd077a39cb19d9b86daafb1cf24167afd450.zip
Add an ioctal() that can be used to perform ICMPv6 auto-configuration
Diffstat (limited to 'apps/netutils')
-rw-r--r--apps/netutils/netlib/netlib_autoconfig.c31
1 files changed, 14 insertions, 17 deletions
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;
}