From owner-freebsd-net@FreeBSD.ORG Fri Jul 9 04:13:55 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6A8E1065672 for ; Fri, 9 Jul 2010 04:13:55 +0000 (UTC) (envelope-from rmaglasang@infoweapons.com) Received: from infoweapons.com (mailroute.hughesnet.org [204.2.248.50]) by mx1.freebsd.org (Postfix) with ESMTP id 5EE268FC15 for ; Fri, 9 Jul 2010 04:13:55 +0000 (UTC) Received: from ([120.89.47.15]) by mail0.infoweapons.com with ESMTP with TLS id 4321444.7688447; Thu, 08 Jul 2010 23:58:33 -0400 Received: from sho2.cebu.infoweapons.com (2001:418:5403:2410:215:f2ff:fe2e:b2d6) by webmail.infoweapons.com (2001:418:5403:2410::10:11) with Microsoft SMTP Server (TLS) id 8.2.254.0; Fri, 9 Jul 2010 11:58:33 +0800 Message-ID: <4C36A237.7020508@infoweapons.com> Date: Fri, 9 Jul 2010 12:14:47 +0800 From: Sho User-Agent: Thunderbird 2.0.0.21 (X11/20090706) MIME-Version: 1.0 To: "Krishna.Mohan@my.panasonic.com" References: <4C353D91.4060405@my.panasonic.com> In-Reply-To: <4C353D91.4060405@my.panasonic.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1"; format="flowed" Cc: "freebsd-net@freebsd.org" Subject: Re: IPv6 Duplicate Address Detection X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jul 2010 04:13:55 -0000 Krishna wrote: > Hi, > > I am implementing a user space program to create and assign IPv6 address > to a linux host. > I am able to create and assign the IP successfully. But, if i am > assigning the duplicate address, > still the address gets assigned. I understand the kernel is handling the > DAD and reporting to kernel log. > Is there any way, i can use IOCTL to get the TENTATIVE flag value and > delete the IP if it is duplicate. > By the way, i use IOCTL system call to assign the IP too. > > I went through some posts in freebsd-net where they have mentioned about > "SIOCGIFAFLAG_IN6 ioctl" > which gives the flags value where the TENTATIVE flag value can be plooed. > I tried to use the same API in my user program but failed. > > Can somebody post me the working sample code of SIOCGIFAFLAG ioctl ? > > Thanks, > -Krishna > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > Here's a sample code fragment to retrieve the status. -- ipv6_addr = "1234:2:3:4:5::1001"; ifname = "vr0"; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; ret = getaddrinfo(ipv6_addr, NULL, &hints, &res); if (ret != 0) { fprintf(stderr, "Invalid IPv6 address: [%s]\n", ipv6_addr); return(1); } bcopy(res->ai_addr, &ifr6.ifr_addr, res->ai_addrlen); strncpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)); if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { fprintf(stderr, "socket(AF_INET6, SOCK_DGRAM) failed!\n"); return(1); } if (ioctl(s6, SIOCGIFAFLAG_IN6, &ifr6) < 0) { fprintf(stderr, "ioctl(SIOCGIFAFLAG_IN6) failed!\n"); close(s6); return(1); } flags6 = ifr6.ifr_ifru.ifru_flags6; close(s6); fprintf(stdout, " Status: "); if ((flags6 & IN6_IFF_DUPLICATED) != 0) fprintf(stdout, "duplicated "); if ((flags6 & IN6_IFF_TENTATIVE) != 0) fprintf(stdout, "tentative "); -- You might want to check the code of ifconfig at in6_status()/usr/src/sbin/ifconfig/af_inet6.c.