IPV6 source IP of packets received truncated on NAT 64 network

Hi,


We have a VoIP application which has a feature that with RTP media the app can send it back to the source IP of received packets. This is useful sometimes as in the SIP negotiation the SDP remote address can be incorrect. When the app receives media packets it reads the source IP address, however

on the MAC simulated NAT64 network we just read the following 64:ff9b:: rather than the full 64::ff9b::3417:a4cd that packets are coming from.


Any ideas why this is?

Thanks

Replies

Just to clarify we are using the following API to read source IP of received packets


char ip[INET6_ADDRSTRLEN];

inet_ntop(AF_INET6,&(address._sockaddr_in6.sin6_addr), ip,INET6_ADDRSTRLEN);

To start, you need to determine if this is a problem with the

sockaddr_in6
you get back from the networking stack or a problem with how you’re rendering that (via
inet_ntop
). If you hex dump the
sockaddr_in6
, what do you see?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Quinn


The problem was the structure allocated to read the socket int the recvfrom call was 'sockaddr' but should

be 'sockaddr_storage' to handle the IPV6 information so data was truncated.


Regards

Hello I am facing this same issue in my VOIP application. Can you please tell at which place to make changes exactly?


Thanks.

It’s unlikely that anyone will be able to tell you exactly where to make this change. It depends on the structure of your code, and no one knows you code better than you.

However, I recommend you focus on calls that return address information, including

accept
,
recvfrom
and
recvmsg
. When you make calls like this you can’t just pass in a
sockaddr_in
, because it’s not big enough to hold an IPv6 address (
sockaddr_in6
). Rather, you should pass in a
sockaddr_storage
, which is big enough to hold any address.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"