nw_ip_options_set_version not working - SDK bug?

I'm debugging an issue on IPv4 networks and am trying to force a nw_connection to use IPv4 as opposed to IPv6, which it's defaulting to on my network.

The documentation for IP Options is extremely sparse, so I had to dive into the nwcat example to see how one is supposed to use nw_ip_options_set_version.

Here's what I've got:

Code Block c
nw_parameters_t parameters = nw_parameters_create_secure_tcp(configure_tls, configure_tcp);
nw_protocol_stack_t protocol_stack = nw_parameters_copy_default_protocol_stack(parameters);
nw_protocol_options_t ip_options = nw_protocol_stack_copy_internet_protocol(protocol_stack);
nw_ip_options_set_version(ip_options, nw_ip_version_4);


This matches what is done in the nwcat example at main.c:359

The problem is, despite explicitly setting the IP version ip IPv4, it's still using IPv6 (the website in question supports both). I can see this by looking at the effective remote endpoint.

This issue happens both in my iOS app as well as the nwcat example itself, which I verified with Wireshark

Is this a SDK bug? Or is just bad luck that the documentation is lacking and the example is incorrect?


Yeah, using nw_ip_options_set_version(ip_options, nw_ip_version_4); in this case is what I would have recommended. I'm not sure what is happening here, but to dig in further I would recommend opening a DTS incident so I can take a closer look.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Thanks Matt, I submitted a TSI with ID #757876124
Thank you. I seen it come through and added it to my queue.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
nw_ip_options_set_version not working - SDK bug?
 
 
Q