IPV6 socket connection, with a link-local address

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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')

DB<5> x 2 inet_pton(AF_INET6, 'fe80::211:43ff:fe1e:ffed')

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

DB<8> x 2 inet_pton(AF_INET6, '2002:80dd:254f::80dd:254f')
" \cB=C3=87=E2=96=8C%O\c@\c@\c@\c@\c@\c@=C3=87=E2=96=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?

Site Timeline