module Net
Extended Modules
Defined in:
net/base.crnet/parser.cr
net/ip.cr
Constant Summary
-
BIG =
16777215
-
Bigger than we need, not too big to worry about overflow
-
CLASS_A_MASK =
Net.ipv4_mask(255, 0, 0, 0)
-
Default route masks for IPv4
-
CLASS_B_MASK =
Net.ipv4_mask(255, 255, 0, 0)
-
CLASS_C_MASK =
Net.ipv4_mask(255, 255, 255, 0)
-
IPV4_ALLROUTER =
ipv4(224, 0, 0, 2)
-
all systems
-
IPV4_ALLSYS =
ipv4(224, 0, 0, 1)
-
limited broadcast
-
IPV4_BCAST =
ipv4(255, 255, 255, 255)
-
Well-known IPv4 addresses
-
IPV4_ZERO =
ipv4(0, 0, 0, 0)
-
ALL ROUTERS
-
IPV4LEN =
4
-
IP address lenghts in bytes
-
IPV6_INTERFACE_LOCAL_ALL_NODES =
IP[255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
-
IPV6_LINK_LOCAL_ALL_NODES =
IP[255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
-
IPV6_LINK_LOCAL_ALL_ROUTERS =
IP[255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]
-
IPV6_LOOPBACK =
IP[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
-
IPV6_UNSPECIFIED =
IP[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-
IPV6_ZERO =
IP[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-
Well-known IPv6 addresses
-
IPV6LEN =
16
-
V4_IN_V6PREFIX =
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255] of Byte
Instance Method Summary
- #all_ff?(b : Bytes)
-
#cidr_mask(ones : Int, bits : Int) : IPMask?
cidr_mask returns an IPMask consisting of `ones' 1 bits followed by 0s up to a total length of `bits' bits.
-
#dtoi(s : String)
decimal to integer, returns number, characters consumed, success
-
#ipv4(a : Byte, b : Byte, c : Byte, d : Byte) : IP
ipv4 returns the IP address (in 16-byte form) of the ipv4 address a.b.c.d.
-
#ipv4_mask(a : Byte, b : Byte, c : Byte, d : Byte) : IPMask
IPv4Mask returns the IP mask (in 4-byte form) of the IPv4 mask a.b.c.d.
- #parse_cidr(s : String)
-
#simple_mask_length(mask : IPMask)
If mask is a sequence of 1 bits followed by 0 bits, returns the number of 1 bits.
-
#to_hex(i : UInt32)
convert i to a hexadecimal string.
-
#ubtoa(dst : Bytes, start : Int, v : UInt8)
ubtoa encodes the string form of the integer v to dst and returns the number of bytes written to dst.
-
#uitoa(val : UInt)
Convert unsigned integer to decimal string.
-
#xtoi(s : String)
Hexadecimal to integer.
- #zeros?(p : IP)
Instance Method Detail
cidr_mask returns an IPMask consisting of `ones' 1 bits followed by 0s up to a total length of `bits' bits. For a mask of this form, cidr_mask is the inverse of IPMask.Size.
ipv4 returns the IP address (in 16-byte form) of the ipv4 address a.b.c.d.
IPv4Mask returns the IP mask (in 4-byte form) of the IPv4 mask a.b.c.d.
If mask is a sequence of 1 bits followed by 0 bits, returns the number of 1 bits.
ubtoa encodes the string form of the integer v to dst and returns the number of bytes written to dst. The caller must ensure that dst has sufficient length