49 lines
957 B
Plaintext
49 lines
957 B
Plaintext
=IP Function Tests=
|
|
|
|
Copyright (c) 2008-2012, David P. D. Moss. All rights reserved.
|
|
|
|
{{{
|
|
|
|
>>> from netaddr import *
|
|
|
|
}}}
|
|
|
|
During a cidr merge operation, the address 0.0.0.0/0, representing the whole of the IPv4 address space, should swallow anything it is merged with.
|
|
|
|
{{{
|
|
|
|
>>> cidr_merge(['0.0.0.0/0', '0.0.0.0'])
|
|
[IPNetwork('0.0.0.0/0')]
|
|
|
|
>>> cidr_merge(['0.0.0.0/0', '255.255.255.255'])
|
|
[IPNetwork('0.0.0.0/0')]
|
|
|
|
>>> cidr_merge(['0.0.0.0/0', '192.0.2.0/24', '10.0.0.0/8'])
|
|
[IPNetwork('0.0.0.0/0')]
|
|
|
|
}}}
|
|
|
|
Same goes for the IPv6 CIDR ::/0, representing the whole of the IPv6 address space.
|
|
|
|
{{{
|
|
|
|
>>> cidr_merge(['::/0', 'fe80::1'])
|
|
[IPNetwork('::/0')]
|
|
|
|
>>> cidr_merge(['::/0', '::'])
|
|
[IPNetwork('::/0')]
|
|
|
|
>>> cidr_merge(['::/0', '::192.0.2.0/124', 'ff00::101'])
|
|
[IPNetwork('::/0')]
|
|
|
|
}}}
|
|
|
|
This also applies to mixed IPv4 and IPv6 address lists.
|
|
|
|
{{{
|
|
|
|
>>> cidr_merge(['0.0.0.0/0', '0.0.0.0', '::/0', '::'])
|
|
[IPNetwork('0.0.0.0/0'), IPNetwork('::/0')]
|
|
|
|
}}}
|