(Original) iOS development compatible with IPv6-only network

    Apple announced some time ago that starting from June 1, 2016, the App Store will implement a new strategy. At that time, all iOS application applications submitted to the Apple App Store must be compatible with the latest Internet protocol for hardware identification and network routing – IPv6-only standard. Because it may affect the subsequent listing, I spent some time in the past two days to look at the relevant things. It is roughly organized as follows:

How to be compatible with IPV6

1. Use High-Level Networking Frameworks to avoid using socket API

APIs in blue support IPv6 by default

If your project uses APIs like WebKit or third-party libraries such as AFNetWorking and Alamofire, congratulations, there shouldn't be many related changes? Why not have no changes, please continue to read.

2. Don't use IP addresses

Where there is a network request, make sure to use a domain name, not an IP address like 192.168.0.1.

3. Check the code to pay attention to the support of IPv4 and IPv6

These are IPV4-specific codes, if there are these codes, they need to be modified

 

  • inet_addr()

  • inet_aton()

  • inet_lnaof()

  • inet_makeaddr()

  • inet_netof()

  • inet_network()

  • inet_ntoa()

  • inet_ntoa_r()

  • bindresvport()

  • getipv4sourcefilter()

  • setipv4sourcefilter()

The following is a comparison of some defined types of IPv4 and IPv6, which should also be found in the code.

IPv4

IPv6

AF_INET

AF_INET6

PF_INET

PF_INET6

struct in_addr

struct in_addr6

struct sockaddr_in

struct sockaddr_in6

kDNSServiceProtocol_IPv4

kDNSServiceProtocol_IPv6

    In our project, AFNetWorking is used, and the encapsulation of the network interface is also based on this. However, when checking the third item, it is found that there is only  sockaddr_in but no sockaddr_in6 in the code. Why? Because our project used the 2.5.X version of AFNetWorking earlier, and the latest version on the official website is 3.1.0. Resolutely update it, as expected, the latest version supports IPV6. Therefore, I remind students who see here to check items 2 and 3 to see if they are sure to support IPV6, so as to prevent the old version of the third-party library from not supporting IPV6.

References:

 

Supporting IPv6-only Networks

https://developer.apple.com/news/?id=05042016a

Supporting IPv6 DNS64/NAT64 Networks

 

https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1

 

IPv6-only compatibility solution

http://www.jianshu.com/p/8837739251ad?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io

 

Application Aspects of IPv6 Transition

https://tools.ietf.org/html/rfc4038

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326819425&siteId=291194637