NetworkInterface

public class NetworkInterface : CallbackQueueProtocol

A (virtual) Network Interface

  • IPv4 address of the interface

    Declaration

    Swift

    public var address: IP4Address { get }
  • IPv4 netmask of the interface

    Declaration

    Swift

    public var netmask: IP4Address { get }
  • IPv4 gateway of the interface

    Declaration

    Swift

    public var gateway: IP4Address { get }
  • Create a new Network Interface

    Declaration

    Swift

    public init(address: IP4Address,
                netmask: IP4Address,
                gateway: IP4Address,
                mtu: UInt16 = 1500,
                output: @escaping (Data) -> Void,
                ready: ((_ interface: NetworkInterface) -> Void)? = nil)

    Parameters

    address

    IPv4 address of the interface

    netmask

    IPv4 netmask of the interface

    gateway

    IPv4 gateway of the interface

    mtu

    maximum transmission unit

    output

    function that writes packets to a packet stream

    ready

    will be called once the interface is ready

  • Start dispatching events of the network interface and set the queue to deliver the events on.

    Declaration

    Swift

    public func start(queue: DispatchQueue)

    Parameters

    queue

    The queue to dispatch the events on

  • Pass a packet to the network interface

    Declaration

    Swift

    public func input(packet: Data) throws
  • Remove the interface

    Declaration

    Swift

    public func remove()