IPV6 socket connection, with a link-local address

IPV6 socket connection, with a link-local address

am 11.01.2008 19:12:25 von gepapa

Here is my scenario:
If I use a global unicast IPV6 address, everything works as it should.
If I use a link local address, i.e. FE80::, I am not able to bind my
socket properly. I get an "unknown error" response. I have tried with
the scope (i.e. %6) and without.

Here are the issues I see:
1) If giving a peerAddr in the format [fe80::211:43ff:fe1e:ffed]:1300,
the _sock_info call works as it should, it strips off the port and
braces, and puts only fe80::211:43ff:fe1e:ffed in the $laddr. If
instead the peerAddr is in this format [fe80::211:43ff:fe1e:ffed%6]:
1300 (note the %6 scope id), _sock_info does not work as it should, it
does not strip off the braces I get [fe80::211:43ff:fe1e:ffed%6].

2) If I manually set $laddr to fe80::211:43ff:fe1e:ffed%6 (note I
removed the braces), the code continues successfully. I eventually get
to the inet_pton call, here is what I see:

DB<4> x 2 inet_pton(AF_INET6, 'fe80::211:43ff:fe1e:ffed%6')
undef

DB<5> x 2 inet_pton(AF_INET6, 'fe80::211:43ff:fe1e:ffed')
"■Ã=87\c@\c@\c@\c@\c@\c@\cB\cQC â–=A0\c^ φ"

So as you can see having the %6 in as part of the ip, causes the call
to return undef, not having it gives a somewhat valid return, but this
return does not allow for a bind to take place.

If I use a global unicast address, as I said everything works, I get
this:

DB<8> x 2 inet_pton(AF_INET6, '2002:80dd:254f::80dd:254f')
" \cBÇâ–=8C%O\c@\c@\c@\c@\c@\c@Çâ–=8C%O"

This return works and allows a successful bind.

I think the whole issue stems from the fact that the scope identifier
is not being treated correctly in inet_pton.
Any Ideas?