TSIPStack
public final class TSIPStack
This is the IP stack that receives and outputs IP packets.
outputBlock
and delegate
should be set before any input.
Then call receivedPacket(_:)
when a new IP packet is read from the TUN interface.
There is a timer running internally. When the device is going to sleep (which means the timer will not fire for some time), then the timer must be paused by calling suspendTimer()
and resumed by resumeTimer()
when the deivce wakes up.
Note
This class is NOT thread-safe.-
The singleton stack instance that developer should use. The
init()
method is a private method, which means there will never be more than one IP stack running at the same time.Declaration
Swift
public static var stack: TSIPStack
-
Undocumented
Declaration
Swift
public var processQueue: DispatchQueue
-
When the IP stack decides to output some IP packets, this block is called.
Warning
This should be set before any input.Declaration
Swift
public var outputBlock: (([Data], [NSNumber]) -> ())!
-
The delegate instance.
Warning
Setting this variable is not protected in the GCD queue, so this shoule be set before any input and shoule never change afterwards.Declaration
Swift
public weak var delegate: TSIPStackDelegate?
-
Suspend the timer. The timer should be suspended when the device is going to sleep.
Declaration
Swift
public func suspendTimer()
-
Resume the timer when the device is awoke.
Warning
Do not call this unless the stack is not resumed or you suspend the timer.Declaration
Swift
public func resumeTimer()
-
Input an IP packet.
Declaration
Swift
public func received(packet: Data)
Parameters
packet
the data containing the whole IP packet.