[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(usagi-users 02745) Re: multicast to ff05::/16



Steven,

Thank you for the response.
It is a real code I tested. it has slight inaccuracy, but it 
isn't essential.
I wonder why it fails only when ff05::/16.
It works with other addresses(ff04::1, ff06::1, etc) and on other OS.
I tried using scope id as your mail, but in vain.

The result of test program is as follow.
(getaddrinfo() returns 0, of course)

./a.out ff05::1 1234
sendto: Cannot assign requested address

Frankly speaking, I think it is a bug.

Regards,
Takashi Hibi


> Takashi,
>       I didn't see a response to this. I'm guessing this
> isn't the real code you're using, because I didn't see "paddr"
> declared or initialized in what you quoted. Also, though I haven't
> checked, the man page says "non zero", not "negative" as an
> error value for getaddrinfo()-- if all error codes are negative, it
> won't affect your code, but a positive value would indicate
> an error but not be caught by the code you quoted.
> 
>       Also, to select the interface you want to send the packet
> on, you'll want to set the scope_id field in the sockaddr_in6
> structure to be the interface index. Something like:
> 
>       paddr.sin6_scope_id = if_nametoindex("eth0");
> 
> (or whatever other method you're using to get the index). Assuming
> "paddr" is a sockaddr_in6 and points to the sockaddr you got from
> the getaddrinfo() call.
> 
> Multicast addresses, like (remote) link-local addresses, don't
> identify which interface you intend, since the same prefix can appear
> on any interface, which is why you'll want to set the scope_id to
> send it out a particular one of your choosing.
> 
>                   +-DLS
> 
> 
> Takashi Hibi <hibi665@xxxxxxx> on 01/05/2004 08:09:35 PM
> 
> Please respond to usagi-users@xxxxxxxxxxxxxx
> 
> To:    <usagi-users@xxxxxxxxxxxxxx>
> cc:
> Subject:    (usagi-users 02736) multicast to ff05::/16
> 
> 
> 
> Hi all,
> 
> I have a simple question.
> 
> Is it possible to send multicast packet to ff05::/16 network?
> The following is a simple test code.
> If ff05::x (x=1,2,..) is specified as argv[1], sendto() fails.
> The error message is "Cannot assign requested address".
> But it works on FreeBSD and Windows
> What is wrong?
> 
> Regards,
> Takashi Hibi
> 
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <netdb.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> 
> int main(int argc, char *argv[])
> {
>         addrinfo hint;
>         addrinfo *AI;
>         int s;
>         int ret;
>         char buf[64];
> 
>         memset(&hint, 0, sizeof(hint));
>         hint.ai_family = AF_INET6;
>         hint.ai_socktype = SOCK_DGRAM;
>         ret = getaddrinfo(argv[1], argv[2], &hint, &AI);
>         if (ret < 0) {
>                 printf("%s\n", gai_strerror(ret));
>                 return -1;
>         }
> 
>         s = socket(AF_INET6, SOCK_DGRAM, 0);
>         ret = sendto(s, buf, sizeof(buf), 0, (sockaddr *)paddr,
>         sizeof(*paddr));
>         if (ret < 0) {
>                 perror("sendto");
>         }
> 
>         freeaddrinfo(AI);
> 
>         return 0;
> }
> ~
> 
>