Addresses and related utilities
Types
FlowId = distinct uint32
-
A 20-bit flow identifier. As RFC3493 does not specify an interpretation, the library treats this type as opaque and does not perform any byte-ordering conversions.
From testing, it appears that most operating systems use network byte ordering for values of this type.
Source Edit IP4Endpoint = IP4EndpointImpl
- An IPv4 endpoint, which is a combination of an IPv4 address and a port. Source Edit
IP6Endpoint = IP6EndpointImpl
- An IPv6 endpoint, which is a combination of an IPv4 address, a port, a flow identifier and a scope identifier. Source Edit
IPEndpoint = object case kind*: IPEndpointKind of V4: v4*: IP4Endpoint of V6: v6*: IP6Endpoint
- An object containing either IPv4 or IPv6 endpoint. Source Edit
IPEndpointKind {.pure.} = enum V4, V6
- The address family of an endpoint. Source Edit
ScopeId = distinct uint32
-
A 32-bit address scope identifier. As RFC3493 does not specify an interpretation, the library treats this type as opaque and does not perform any byte-ordering conversions.
From testing, it appears that most operating systems use host byte ordering for values of this type.
Source Edit
Consts
IP4Broadcast = (s_addr: 4294967295'u)
- The IPv4 address used to signify any host. Source Edit
IP4Loopback = (s_addr: 16777343'u)
- The IPv4 loopback address. Source Edit
IP6Any = (s6_addr: [0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u])
- The IPv6 address used to specify binding to any address. Source Edit
IP6Loopback = (s6_addr: [0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 0'u, 1'u])
- The IPv6 loopback address. Source Edit
Procs
proc `$`(e: IP4Endpoint): string {....raises: [], tags: [], forbids: [].}
- Source Edit
func `$`(ip: IP4): string {.inline, ...raises: [], tags: [], forbids: [].}
- Returns the string representation of ip. Source Edit
func `==`(a, b: IP4): bool {.inline, ...raises: [], tags: [], forbids: [].}
- Returns whether a and b points to the same address. Source Edit
proc flowId(e: IP6Endpoint): FlowId {....raises: [], tags: [], forbids: [].}
- Returns the flow identifier of the endpoint. Source Edit
proc initEndpoint(ip: IP4; port: Port): IP4Endpoint {....raises: [], tags: [], forbids: [].}
- Creates an endpoint from an IP address and a port. Source Edit
proc initEndpoint(ip: IP6; port: Port; flowId = 0.FlowId; scopeId = 0.ScopeId): IP6Endpoint {. ...raises: [], tags: [], forbids: [].}
- Creates an IPv6 endpoint. Source Edit
proc ip(e: IP4Endpoint): IP4 {....raises: [], tags: [], forbids: [].}
- Returns the IPv4 address of the endpoint. Source Edit
proc ip(e: IP6Endpoint): IP6 {....raises: [], tags: [], forbids: [].}
- Returns the IPv6 address of the endpoint. Source Edit
func isV4Mapped(ip: IP6): bool {....raises: [], tags: [], forbids: [].}
- Returns whether ip is an IPv4-mapped address as described in RFC4291. Source Edit
proc port(e: IP4Endpoint): Port {....raises: [], tags: [], forbids: [].}
- Returns the port of the endpoint. Source Edit
proc port(e: IP6Endpoint): Port {....raises: [], tags: [], forbids: [].}
- Returns the port of the endpoint. Source Edit
proc scopeId(e: IP6Endpoint): ScopeId {....raises: [], tags: [], forbids: [].}
- Returns the scope identifier of the endpoint. Source Edit