Skip to content

Commit df32bee

Browse files
committed
Add special use constants for IPv6.
1 parent 5708900 commit df32bee

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

iptools/ipv6.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,27 @@
3030
'long2ip',
3131
'validate_cidr',
3232
'validate_ip',
33+
'DOCUMENTATION_NETWORK',
34+
'IPV4_MAPPED',
35+
'IPV6_TO_IPV4_NETWORK',
36+
'LINK_LOCAL',
37+
'LOCALHOST',
38+
'LOOPBACK',
3339
'MAX_IP',
3440
'MIN_IP',
41+
'MULTICAST',
42+
'MULTICAST_GLOBAL',
43+
'MULTICAST_LOCAL',
44+
'MULTICAST_LOCAL_DHCP',
45+
'MULTICAST_LOCAL_NODES',
46+
'MULTICAST_LOCAL_ROUTERS',
47+
'MULTICAST_LOOPBACK',
48+
'MULTICAST_SITE',
49+
'MULTICAST_SITE',
50+
'MULTICAST_SITE_DHCP',
51+
'PRIVATE_NETWORK',
52+
'TEREDO_NETWORK',
53+
'UNSPECIFIED_ADDRESS',
3554
)
3655

3756

@@ -53,6 +72,73 @@
5372
#: Minimum IPv6 integer
5473
MIN_IP = 0x0
5574

75+
#: Absence of an address (only valid as source address)
76+
#: (`RFC 4291 <https://tools.ietf.org/html/rfc4291>`_)
77+
UNSPECIFIED_ADDRESS = "::/128"
78+
79+
#: Loopback addresses on the local host
80+
#: (`RFC 4291 <https://tools.ietf.org/html/rfc4291>`_)
81+
LOOPBACK = "::1/128"
82+
83+
#: Common `localhost` address
84+
#: (`RFC 4291 <https://tools.ietf.org/html/rfc4291>`_)
85+
LOCALHOST = LOOPBACK
86+
87+
#: IPv4 mapped to IPv6 (not globally routable)
88+
#: (`RFC 4291 <https://tools.ietf.org/html/rfc4291>`_)
89+
IPV4_MAPPED = "::ffff:0:0/96"
90+
91+
#: Documentation and example network
92+
#: (`RFC 3849 <https://tools.ietf.org/html/rfc3849>`_)
93+
DOCUMENTATION_NETWORK = "2001::db8::/32"
94+
95+
#: 6to4 Address block
96+
#: (`RFC 3056 <https://tools.ietf.org/html/rfc3056>`_)
97+
IPV6_TO_IPV4_NETWORK = "2002::/16"
98+
99+
#: Teredo addresses
100+
#: (`RFC 4380 <https://tools.ietf.org/html/rfc4380>`_)
101+
TEREDO_NETWORK = "2001::/32"
102+
103+
#: Private network
104+
#: (`RFC 4193 <https://tools.ietf.org/html/rfc4193>`_)
105+
PRIVATE_NETWORK = "fd00::/8"
106+
107+
#: Link-Local unicast networks (not globally routable)
108+
#: (`RFC 4291 <https://tools.ietf.org/html/rfc4291>`_)
109+
LINK_LOCAL = "fe80::/10"
110+
111+
#: Multicast reserved block
112+
#: (`RFC 5771 <https://tools.ietf.org/html/rfc5771>`_)
113+
MULTICAST = "ff00::/8"
114+
115+
#: Interface-Local multicast
116+
MULTICAST_LOOPBACK = "ff01::/16"
117+
118+
#: Link-Local multicast
119+
MULTICAST_LOCAL = "ff02::/16"
120+
121+
#: Site-Local multicast
122+
MULTICAST_SITE = "ff05::/16"
123+
124+
#: Organization-Local multicast
125+
MULTICAST_SITE = "ff08::/16"
126+
127+
#: Organization-Local multicast
128+
MULTICAST_GLOBAL = "ff0e::/16"
129+
130+
#: All nodes on the local segment
131+
MULTICAST_LOCAL_NODES = "ff02::1"
132+
133+
#: All routers on the local segment
134+
MULTICAST_LOCAL_ROUTERS = "ff02::2"
135+
136+
#: All DHCP servers and relay agents on the local segment
137+
MULTICAST_LOCAL_DHCP = "ff02::1:2"
138+
139+
#: All DHCP servers and relay agents on the local site
140+
MULTICAST_SITE_DHCP = "ff05::1:3"
141+
56142

57143
def validate_ip(s):
58144
"""Validate a hexidecimal IPv6 ip address.

0 commit comments

Comments
 (0)