(usagi-users 03751) Re: want same behavior as ipv4(scope_id)

Rémi Denis-Courmont <[email protected]> Sun, 1 Oct 2006 22:24:55 +0300
Newsgroups gmane.linux.ipv6.usagi.users
Organization SimPhalempin.Com
Message-ID <[email protected]>
Le dimanche 1 octobre 2006 22:16, Amrit Soni a écrit :
> Thanks for the prompt reply.
>
> sorry it was 1 for loopback interface.
>
> But when i keep scope_id as 0, it returns error while binding.
> What should i assign to scope id so that it can work for both
> loopback as well as for ethernet interface. I'm not using
> getaddrinfo() api.

int fd;
struct sockaddr_in6 addr;

/*...*/

fd = socket (PF_INET6, SOCK_xxx, IPPROTO_xxx);

/* ... */

memset (&addr, 0, sizeof (addr));
addr.sin6_family = AF_INET6;
/* addr.sin6_len = sizeof (addrlen); -- required on *BSDs */

bind (fd, (struct sockaddr *)&addr, sizeof (addr));


Works fine with me.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBFIBYKw+xtvt1tEr0RAp3RAKDEI3aFJbmoSnKCXWtfHSM4YgpU5QCgqyk2
B6y3ZShmh6YMw4sIpataGaw=
=ZStn
-----END PGP SIGNATURE-----