This module implements cross-platform network interfaces list. Currently supported OSes are Windows, Linux, MacOS, BSD(not tested).
Types
InterfaceAddress = object host*: TransportAddress net*: IpNet
- Source Edit
InterfaceState = enum StatusError = 0, StatusUp, StatusDown, StatusTesting, StatusUnknown, StatusDormant, StatusNotPresent, StatusLowerLayerDown
- Source Edit
InterfaceType = enum IfError = 0, IfOther = 1, IfRegular1822 = 2, IfHdh1822 = 3, IfDdnX25 = 4, IfRfc877X25 = 5, IfEthernetCsmacd = 6, IfIso88023Csmacd = 7, IfIso88024TokenBus = 8, IfIso88025TokenRing = 9, IfIso88026MAN = 10, IfStarlan = 11, IfProteon10Mbit = 12, IfProteon80Mbit = 13, IfHyperChannel = 14, IfFddi = 15, IfLapB = 16, IfSdlc = 17, IfDs1 = 18, IfE1 = 19, IfBasicIsdn = 20, IfPrimaryIsdn = 21, IfPropPoint2PointSerial = 22, IfPpp = 23, IfSoftwareLoopback = 24, IfEon = 25, IfEthernet3Mbit = 26, IfNsip = 27, IfSlip = 28, IfUltra = 29, IfDs3 = 30, IfSip = 31, IfFrameRelay = 32, IfRs232 = 33, IfPara = 34, IfArcNet = 35, IfArcNetPlus = 36, IfAtm = 37, IfMioX25 = 38, IfSonet = 39, IfX25Ple = 40, IfIso88022Llc = 41, IfLocalTalk = 42, IfSmdsDxi = 43, IfFrameRelayService = 44, IfV35 = 45, IfHssi = 46, IfHippi = 47, IfModem = 48, IfAal5 = 49, IfSonetPath = 50, IfSonetVt = 51, IfSmdsIcip = 52, IfPropVirtual = 53, IfPropMultiplexor = 54, IfIeee80212 = 55, IfFibreChannel = 56, IfHippiInterface = 57, IfFrameRelayInterconnect = 58, IfAflane8023 = 59, IfAflane8025 = 60, IfCctemul = 61, IfFastEther = 62, IfIsdn = 63, IfV11 = 64, IfV36 = 65, IfG70364K = 66, IfG7032MB = 67, IfQllc = 68, IfFastEtherFx = 69, IfChannel = 70, IfIeee80211 = 71, IfIbm370Parchan = 72, IfEscon = 73, IfDlsw = 74, IfIsdnS = 75, IfIsdnU = 76, IfLapD = 77, IfIpSwitch = 78, IfRsrb = 79, IfAtmLogical = 80, IfDs0 = 81, IfDs0Bundle = 82, IfBsc = 83, IfAsync = 84, IfCnr = 85, IfIso88025rDtr = 86, IfEplrs = 87, IfArap = 88, IfPropCnls = 89, IfHostPad = 90, IfTermPad = 91, IfFrameRelayMpi = 92, IfX213 = 93, IfAdsl = 94, IfRadsl = 95, IfSdsl = 96, IfVdsl = 97, IfIso88025Crfprint = 98, IfMyrInet = 99, IfVoiceEm = 100, IfVoiceFxo = 101, IfVoiceFxs = 102, IfVoiceEncap = 103, IfVoiceOverip = 104, IfAtmDxi = 105, IfAtmFuni = 106, IfAtmIma = 107, IfPppMultilinkBundle = 108, IfIpoverCdlc = 109, IfIpoverClaw = 110, IfStackToStack = 111, IfVirtualIpAddress = 112, IfMpc = 113, IfIpoverAtm = 114, IfIso88025Fiber = 115, IfTdlc = 116, IfGigabitEthernet = 117, IfHdlc = 118, IfLapF = 119, IfV37 = 120, IfX25Mlp = 121, IfX25HuntGroup = 122, IfTransPhdlc = 123, IfInterleave = 124, IfFast = 125, IfIp = 126, IfDocScableMaclayer = 127, IfDocScableDownstream = 128, IfDocScableUpstream = 129, IfA12MppSwitch = 130, IfTunnel = 131, IfCoffee = 132, IfCes = 133, IfAtmSubInterface = 134, IfL2Vlan = 135, IfL3IpVlan = 136, IfL3IpxVlan = 137, IfDigitalPowerline = 138, IfMediaMailOverIp = 139, IfDtm = 140, IfDcn = 141, IfIpForward = 142, IfMsdsl = 143, IfIeee1394 = 144, IfIfGsn = 145, IfDvbrccMaclayer = 146, IfDvbrccDownstream = 147, IfDvbrccUpstream = 148, IfAtmVirtual = 149, IfMplsTunnel = 150, IfSrp = 151, IfVoiceOverAtm = 152, IfVoiceOverFrameRelay = 153, IfIdsl = 154, IfCompositeLink = 155, IfSs7SigLink = 156, IfPropWirelessP2p = 157, IfFrForward = 158, IfRfc1483 = 159, IfUsb = 160, IfIeee8023AdLag = 161, IfBgpPolicyAccounting = 162, IfFrf16MfrBundle = 163, IfH323Gatekeeper = 164, IfH323Proxy = 165, IfMpls = 166, IfMfSigLink = 167, IfHdsl2 = 168, IfShdsl = 169, IfDs1Fdl = 170, IfPos = 171, IfDvbAsiIn = 172, IfDvbAsiOut = 173, IfPlc = 174, IfNfas = 175, IfTr008 = 176, IfGr303Rdt = 177, IfGr303Idt = 178, IfIsup = 179, IfPropDocsWirelessMaclayer = 180, IfPropDocsWirelessDownstream = 181, IfPropDocsWirelessUpstream = 182, IfHiperLan2 = 183, IfPropBwaP2mp = 184, IfSonetOverheadChannel = 185, IfDigitalWrapperOverheadChannel = 186, IfAal2 = 187, IfRadioMac = 188, IfAtmRadio = 189, IfImt = 190, IfMvl = 191, IfReachDsl = 192, IfFrDlciEndpt = 193, IfAtmVciEndpt = 194, IfOpticalChannel = 195, IfOpticalTransport = 196, IfIeee80216Wman = 237, IfWwanPp = 243, IfWwanPp2 = 244, IfIeee802154 = 259, IfXboxWireless = 281
- Source Edit
NetworkInterface = object ifIndex*: int ifType*: InterfaceType name*: string desc*: string mtu*: int64 flags*: uint64 state*: InterfaceState mac*: array[MaxAdapterAddressLength, byte] maclen*: int addresses*: seq[InterfaceAddress]
- Source Edit
Route = object ifIndex*: int dest*: TransportAddress source*: TransportAddress gateway*: TransportAddress metric*: int
- Source Edit
Procs
proc `$`(ifa: InterfaceAddress): string {....raises: [], tags: [].}
- Return string representation of ifa. Source Edit
proc `$`(iface: NetworkInterface): string {....raises: [], tags: [].}
- Return string representation of network interface iface. Source Edit
proc broadcast(ifa: InterfaceAddress): TransportAddress {....raises: [], tags: [].}
- Return broadcast address for ifa. Source Edit
proc cmp(a, b: NetworkInterface): int {....raises: [], tags: [].}
- Source Edit
proc getBestRoute(address: TransportAddress): Route {....raises: [], raises: [], tags: [].}
- Return best applicable OS route, which will be used for connecting to address address. Source Edit
proc getInterfaces(): seq[NetworkInterface] {....raises: [], raises: [], tags: [].}
- Return list of available interfaces. Source Edit
proc init(ift: typedesc[InterfaceAddress]; address: TransportAddress; prefix: int): InterfaceAddress {....raises: [].}
- Initialize InterfaceAddress using address and prefix length prefix. Source Edit
proc netmask(ifa: InterfaceAddress): TransportAddress {....raises: [], tags: [].}
- Return network mask for ifa. Source Edit
proc network(ifa: InterfaceAddress): TransportAddress {....raises: [], tags: [].}
- Return network address for ifa. Source Edit
Templates
template RTA_PAYLOAD(length: uint): uint
- Source Edit
Exports
-
DualStackType, ==, AddressFamily, toHex, ==, toIPv6, TransportTooManyError, init, address, getError, isLoopback, isLinkLocalMulticast, ip, resolveTAddress, -, getTransportTooManyError, checkClosed, getTransportError, TransportAddress, isLinkLocalUnicast, contains, getAutoAddresses, initTAddress, getAutoAddress, checkWriteEof, ServerStatus, host, isMulticast, init, isV4Mapped, isUniqueLocal, TransportAddressError, isInterfaceLocalMulticast, ==, AnyAddress, getTransportOsError, $, $, setDualstack, init, TransportLimitError, $, ==, TransportNoSupport, TransportUseClosedError, broadcast, TransportUseEofError, isUnspecified, resolveTAddress, isZero, isSiteLocal, initTAddress, isShared, +, isAnyLocal, $, setDualstack, inc, ==, isDocumentation, isPrivate, getConnectionAbortedError, checkClosed, toSAddr, isUnicastLinkLocal, isLinkLocal, subnetMask, TransportError, ==, getDomain, TransportAbortedError, isNone, getConnectionAbortedError, getServerUseClosedError, mask, isReserved, ServerFlags, toIpAddress, isGlobal, TransportIncompleteError, and, resolveTAddress, getTransportOsError, ServerCommand, resolveTAddress, toIPv4, initTAddress, $, isUnicast, fromSAddr, raiseTransportOsError, getTransportUseClosedError, resolveTAddress, ==, init, prefix, isBroadcast, resolveTAddress, not, init, ==, resolveTAddress, isAvailable, $, init, SocketServer, dec, DefaultDatagramBufferSize, init, windowsAnyAddressFix, IpMask, network, DefaultStreamBufferSize, initIp, raiseTransportError, getDomain, AnyAddress6, IpNet, resolveTAddress, TransportOsError, TransportState, isBenchmarking, isGlobalMulticast, or, subnetMask, initTAddress