Commit 617102f4 authored by Stefan van den Oord's avatar Stefan van den Oord

Updated NetUtils to latest

parent 38d87235
......@@ -3,7 +3,7 @@ PODS:
- CocoaAsyncSocket (7.4.2)
- IGDigest (1.1.2)
- lz4 (128)
- NetUtils (1.1.1)
- NetUtils (1.2.0)
- Nimble (2.0.0-rc.2)
- OpenSSL-Framework (1.0.201)
- Quick (0.5.1)
......@@ -25,7 +25,7 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: f5783bdedd232d91b89769bc4b5a1580aed518ad
IGDigest: 066753c10f3f1b593b00037b9ee93dc96b9e7762
lz4: 5e066195ca751d552becaa026f8fe213ff738adf
NetUtils: 0384e14f009d8ebc8ba5d68ab6d0e6b62e5b2803
NetUtils: bf5ac285196d544dd5e0de1d3e18d945d66eedf8
Nimble: e3cf5e73a491daf21c2bc88783dbfc55ce8b8e02
OpenSSL-Framework: f10c6aa8a92f69fca94303c3774b4773860a9690
Quick: 7426537a99e75076d6930c5b6da58006e4a9f38a
......
......@@ -3,7 +3,7 @@ PODS:
- CocoaAsyncSocket (7.4.2)
- IGDigest (1.1.2)
- lz4 (128)
- NetUtils (1.1.1)
- NetUtils (1.2.0)
- Nimble (2.0.0-rc.2)
- OpenSSL-Framework (1.0.201)
- Quick (0.5.1)
......@@ -25,7 +25,7 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: f5783bdedd232d91b89769bc4b5a1580aed518ad
IGDigest: 066753c10f3f1b593b00037b9ee93dc96b9e7762
lz4: 5e066195ca751d552becaa026f8fe213ff738adf
NetUtils: 0384e14f009d8ebc8ba5d68ab6d0e6b62e5b2803
NetUtils: bf5ac285196d544dd5e0de1d3e18d945d66eedf8
Nimble: e3cf5e73a491daf21c2bc88783dbfc55ce8b8e02
OpenSSL-Framework: f10c6aa8a92f69fca94303c3774b4773860a9690
Quick: 7426537a99e75076d6930c5b6da58006e4a9f38a
......
......@@ -33,25 +33,40 @@ public class Interface : CustomStringConvertible, CustomDebugStringConvertible {
return interfaces
}
public init(data:ifaddrs) {
self.name = String.fromCString(data.ifa_name)!
family = Interface.extractFamily(data)
address = Interface.extractAddress(data.ifa_addr.memory)
netmask = Interface.extractAddress(data.ifa_netmask.memory)
/**
* Returns a new Interface instance that does not represent a real network interface, but can be used for (unit) testing.
*/
public static func createTestDummy(name:String, family:Family, address:String, multicastSupported:Bool, broadcastAddress:String?) -> Interface
{
return Interface(name: name, family: family, address: address, netmask: nil, running: true, up: true, loopback: false, multicastSupported: multicastSupported, broadcastAddress: broadcastAddress)
}
public init(name:String, family:Family, address:String?, netmask:String?, running:Bool, up:Bool, loopback:Bool, multicastSupported:Bool, broadcastAddress:String?) {
self.name = name
self.family = family
self.address = address
self.netmask = netmask
self.running = running
self.up = up
self.loopback = loopback
self.multicastSupported = multicastSupported
self.broadcastAddress = broadcastAddress
}
convenience init(data:ifaddrs) {
let flags = Int32(data.ifa_flags)
running = ((flags & IFF_RUNNING) == IFF_RUNNING)
up = ((flags & IFF_UP) == IFF_UP)
loopback = ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
multicastSupported = ((flags & IFF_MULTICAST) == IFF_MULTICAST)
let broadcastValid : Bool = ((flags & IFF_BROADCAST) == IFF_BROADCAST)
if broadcastValid && data.ifa_dstaddr != nil {
broadcastAddress = Interface.extractAddress(data.ifa_dstaddr.memory)
}
else {
broadcastAddress = nil
}
self.init(name: String.fromCString(data.ifa_name)!,
family: Interface.extractFamily(data),
address: Interface.extractAddress(data.ifa_addr.memory),
netmask: Interface.extractAddress(data.ifa_netmask.memory),
running: ((flags & IFF_RUNNING) == IFF_RUNNING),
up: ((flags & IFF_UP) == IFF_UP),
loopback: ((flags & IFF_LOOPBACK) == IFF_LOOPBACK),
multicastSupported: ((flags & IFF_MULTICAST) == IFF_MULTICAST),
broadcastAddress: ((broadcastValid && data.ifa_dstaddr != nil) ? Interface.extractAddress(data.ifa_dstaddr.memory) : nil))
}
private static func extractFamily(data:ifaddrs) -> Family {
var family : Family = .other
let addr = data.ifa_addr.memory
......
module ifaddrs [system] [extern_c] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/ifaddrs.h"
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/ifaddrs.h"
export *
}
module ifaddrs [system] [extern_c] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/ifaddrs.h"
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/ifaddrs.h"
export *
}
module ifaddrs [system] [extern_c] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ifaddrs.h"
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ifaddrs.h"
export *
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<string>1.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment