[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(usagi-users 01098) Re: ioctl & ipv6
- To: usagi-users@xxxxxxxxxxxxxx
- Subject: (usagi-users 01098) Re: ioctl & ipv6
- From: Bhawana Bhatija <bbatija@xxxxxxxxxxx>
- Date: Sun, 23 Dec 2001 11:04:45 +0000 (GMT)
- In-reply-to: <20011221095400K.yoshfuji@linux-ipv6.org>
- Reply-to: usagi-users@xxxxxxxxxxxxxx
Hi YOSHIFUJI
I am attaching the code file
in which i creating a socket for AF_INET6
and try to get INET address for an interface (IPv6)
but every time it says invalid arguments.
Please suggest me
Thanks
Vineet Goel
--- YOSHIFUJI Hideaki / 吉藤英明
<yoshfuji@xxxxxxxxxxxxxx> wrote: > In article
>
<20011220185949.59876.qmail@xxxxxxxxxxxxxxxxxxxxxxxxx>
> (at Thu, 20 Dec 2001 18:59:49 +0000 (GMT)), Bhawana
> Bhatija <bbatija@xxxxxxxxxxx> says:
>
> > I am using ioctl to set system description
> (interface
> > description) using ioctl (SIOCSIFFLAGS,
> > SIOCSIFFLAGS)for IPv6.
>
> Isn't SIOC{G,S}IFFLAGS for setting system
> description, is it?
>
>
> > Porblem is when i execute my program systems goes
> > hang. I doubt that ioctl works for ipv6 atleast
> for
> > setting system values, though i am able to get
> values
> > usng ioctl.
>
> What did you do? minimum source code?
>
> --yoshfuji
>
________________________________________________________________________
For Stock Quotes, Finance News, Insurance, Tax Planners, Mutual Funds...
Visit http://in.finance.yahoo.com/#include <stdio.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
static u_char*
getAddr(const int sockfd, const char *pIfName)
{
int i, iCount;
int iRetval;
struct ifconf ifc;
struct sockaddr_in6 *addr;
char data[1024];
static char netip[16];
ifc.ifc_len = sizeof(data);
ifc.ifc_buf = data;
iRetval = ioctl( sockfd, SIOCGIFCONF, &ifc );
if ( iRetval < 0 )
{
printf("error: ioctl call fails\n");
return NULL;
}
iCount = ifc.ifc_len / sizeof(struct ifreq);
i = 0;
while ( iCount != 0 )
{
if ( strcasecmp(pIfName, ifc.ifc_req[i].ifr_name) != 0 )
{
++i;
--iCount;
continue;
}
iRetval = ioctl( sockfd, SIOCGIFADDR, &ifc.ifc_req[i]);
if ( iRetval < 0 )
{
perror("SIOCGIFADDR");
return NULL;
}
addr = (struct sockaddr_in6*)&ifc.ifc_req[i].ifr_addr;
inet_ntop(AF_INET6, &addr->sin6_addr, netip, sizeof(struct sockaddr_in6));
return netip;
++i;
--iCount;
}
return NULL;
}
main(){
u_char *addr;
int indx;
int sockfd;
sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
if(sockfd < 0)
{
printf("error:socket fails\n");
}
addr = getAddr(sockfd,"eth0" );
printf("address is =%s\n",addr);
}