iPv6 support for Application (objective-c) - ios

Apple has mentioned in their document to eliminate some API for iPV6 support.
We are using below API in our application.
inet_ntoa()
inet_aton()
Is there any other API instead of above API for support both IPv4 & IPv6?

inet_ntoa(3N) interprets an IPv4 internet address and converts it to a character string.
instead of inetntoa function i used inet_ntop(3N) function.
This function perform the same operation for both IPv4 and IPv6 addresses
below link helped me lot to support iPv6 for my app.
http://uw714doc.sco.com/en/SDK_netapi/sockC.PortIPv4appIPv6.html

Related

routing the network over ipv4 instead of ipv6 in iOS

I am using the 3rd party library which only support ipv4.
Whenever there is ipv6 network in my iOs device 3rd party fail.Is there any way I can force or convert or create ipv4 network and do routineg of the application in ipv4 instead of ipv6.
I found the below link but don't know how to implement it or does apple will approve that. https://developer.apple.com/documentation/networkextension/neipv4route
Any help on this please
I think you’ve answered your own question. The library your using only supports ipv4. So either you need to find a library that supports ipv6 or write your own since you can’t control what the network is broadcasting.
Apple has a write up on this here : supporting ipv6

All apps submitted to the App Store must support IPv6-only networking

what does mean by All apps submitted to the App Store must support IPv6-only networking
is it something to do with HTTP addresses and HTTPS addresses
also should I have to change API URLs
And please don't tell me to read the difference between IPV4 AND IPV6 Because I already did that
There is no thing to do with http/https/apis , you have to enable IPV6 in your server

How to get a remote MAC address via IPv6 in iOS programmatically

I need to find a solution how to get the MAC address from the other device in the WiFi network. There is a good method how to do this for IPv4 (How does iOS app Fing get MAC Address?), but how to do this for IPv6? Since ARP was replaced by the NDP (Neighbour Discovery Protocol), the latter method doesn't work. I would greatly appreciate if anyone could help me.
Layer and Encapsulation
The network architecture is layered, the upper layer encapsulate the different implementations of lower layer and provide higher abstraction relative to lower layer.
The network layer which use IP encapsulate different link layers protocols, like Ethernet, WiFi, PPP (which may run on serial cable which not use MAC address) etc.
So, the first problem is what do you mean by remote?
If you mean other hosts in WAN, it is impossible unless both device implement a specific protocol: you send a request to those device, they reply with his mac address.
If you mean other host in the same LAN, you can use ARP protocol in IPv4 and NDP (which ) in IPv6.
Arp & NDP
ARP send broadcast in LAN when it knows the IP address of a host but not MAC address, then the hosts which find someone is calling for him reply its MAC address.
NDP provides two main part of functionality, the first is the same with ARP: mapping between network- and link-layer addresses. (The difference is NDP using a multicast address: prefix f02::1:f/104, combined with the low-order 24 bits of the solicited IPv6 address)
So what you need is to send ICMPv6 Neighbor Solicitation message.
Address Assignment in IPv6
Link-local IPv6 addresses (and some global IPv6 addresses) use interface identifiers (IIDs) as a basis for unicast IPv6 address assignment. ... IIDs are ordinarily 64 bits long and are formed either directly from the underlyinglink-layer MAC address of a network interface using a modified EUI-64 format. or by another
process that randomizes the value in hopes of providing some degree of privacy against address tracking.
So in the most common cases, you can get the MAC address of a device directly from their IPv6 link local address.
Conclusion:
implement your protocol in both devices
send NDP message to solicited node if it is in same LAN
extract MAC address from link local IPv6 address
Ref
Wikipedia
TCP/IP Illustrated, volume 1
I'm using MMLanScan for that purpose. It's very simple to get working to find IP/MAC addresses of devices on your LAN.
I use it some time ago but I think it's works with IPv6 also.

IPv6 Apple updates

With the recent announcements by Apple regarding Supporting IPv6-only Networks. I have few queries:
1) I have code which uses NSURLConnection all over the place and I think it comes under CFNetwork APIs.
Do I need to update my code to NSURLSession mandatorily as mentioned on their website: https://developer.apple.com/news/?id=05042016a
2) IPv4-specific APIs or hard-coded IP addresses:
What does IPv4 specific APIs are there ? I dont see good documentation on Apple website about this. If anyone has any insights on this and can help me out it would be really helpful.
NSURLConnection is fine (see https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW21)
Apple lets you use BSD sockets directly, and it would be possible to implement code based on that which doesn't cope with IPv6. Hardcoded IPv4 addresses "123.123.123.123" won't resolve over IPv6, you should always be looking up IP addresses "www.stackoverflow.com"
In fact, it's probably a good idea to read the whole of the doc I linked to above. Amongst other things, it includes details of how to test IPv6 compatibility by sharing your regular internet connection using a El Capitan Mac as an simulated IPv6 access point.

Programmatically find if the iPad is on IPv4 or an IPv6 network

I have a functionality in iOS which I need to disable if the user's device network in IPv6. Is there a way we can get the device (iPhone/iPad) IP address as a string programmatically, and then check if it's IPv4 or IPv6 network (or simply tell whether it is on IPv4 or IPv6 network without fetching the actual address)?
The closest I could get to was iPhone/iPad/OSX: How to get my IP address programmatically? (by David H.), which again wants us to specify the network beforehand only, hence doesn't solve my purpose...
By his solution either I always get an IPv4 or always an IPv6.
For testing on IPv6 I'm using the Apple's recommended NAT64 tool (https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html).
As a workaround I'm using the DNS to check (https://hirooka.pro/?p=6169) currently, which I feel is not a proper way as it should be IP address based.
Also, quite weirdly, the iPad always shows an IPv4 address (even when connected to IPv6 network) but only varies in the DNS style... Anybody knows why that happens ?
Thanks in advance.

Resources