Objective-C IP parsing library
ip provides methods for parsing, decoding, and converting IPv4 and IPv6 addresses.
Using Carthage, add the following
line to your Cartfile
:
github "victorgama/ip"
IPv4 *v4 = [[IPv4 alloc] initWithAddress:@"127.0.0.1/16"];
v4.subnet // => @"/16"
[v4 isInSubnet:[[IPv4 alloc] initWithAddress:@"127.0.0.1/16"]] // => YES
[v4 reversedForm] // => @"1.0.0.127.in-addr.arpa."
IPv6 *v6 = [[IPv6 alloc] initWithAddress:@"2001:db8:0:0:1:0:0:1/128"];
[v6 correctForm] // => @"2001:db8::1:0:0:1"
[v6 canonicalForm] // => @"2001:0db8:0000:0000:0001:0000:0000:0001"
[v6 v4inv6] // => @"2001:db8::1:0:0.0.0.1"
[v6 decimal] // => @"08193:03512:00000:00000:00001:00000:00000:00001"
IPv6 *v6 = [[IPv6 alloc] initWithAddress:@"2001:4860:4001:803::1011"];
[v6 reversedForm] // => @""1.1.0.1.0.0.0.0.0.0.0.0.0.0.0.0.3.0.8.0.1.0.0.4.0.6.8.4.1.0.0.2.ip6.arpa."
Note: Other methods and operations are available and documented.
The MIT License (MIT)
Copyright (c) 2018 Victor Gama
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.