TUNInterface

open class TUNInterface

TUN interface provide a scheme to register a set of IP Stacks (implementing IPStackProtocol) to process IP packets from a virtual TUN interface.

  • Initialize TUN interface with a packet flow.

    Declaration

    Swift

    public init(packetFlow: NEPacketTunnelFlow)

    Parameters

    packetFlow

    The packet flow to work with.

  • Start processing packets, this should be called after registering all IP stacks.

    A stopped interface should never start again. Create a new interface instead.

    Declaration

    Swift

    open func start()
  • Stop processing packets, this should be called before releasing the interface.

    Declaration

    Swift

    open func stop()
  • Register a new IP stack.

    When a packet is read from TUN interface (the packet flow), it is passed into each IP stack according to the registration order until one of them takes it in.

    Declaration

    Swift

    open func register(stack: IPStackProtocol)

    Parameters

    stack

    The IP stack to append to the stack list.