mirror of
https://git.photon.obnh.io/AXSY/whois.git
synced 2026-03-13 02:01:32 +00:00
Initial commit: mwhois with SCION AS support and decimal AS conversion
Based on mwhois by Antonios A. Chariton Modifications for SCION AS support by Olaf Baumert, Axpo Systems AG
This commit is contained in:
108
netaddr/tests/2.x/ip/subnet.txt
Normal file
108
netaddr/tests/2.x/ip/subnet.txt
Normal file
@@ -0,0 +1,108 @@
|
||||
=IP Subnet Tests=
|
||||
|
||||
Copyright (c) 2008-2015, David P. D. Moss. All rights reserved.
|
||||
|
||||
{{{
|
||||
|
||||
>>> from netaddr import *
|
||||
|
||||
}}}
|
||||
|
||||
Incrementing IP objects.
|
||||
|
||||
{{{
|
||||
|
||||
>>> ip = IPNetwork('192.0.2.0/28')
|
||||
>>> for i in range(16):
|
||||
... str(ip)
|
||||
... ip += 1
|
||||
'192.0.2.0/28'
|
||||
'192.0.2.16/28'
|
||||
'192.0.2.32/28'
|
||||
'192.0.2.48/28'
|
||||
'192.0.2.64/28'
|
||||
'192.0.2.80/28'
|
||||
'192.0.2.96/28'
|
||||
'192.0.2.112/28'
|
||||
'192.0.2.128/28'
|
||||
'192.0.2.144/28'
|
||||
'192.0.2.160/28'
|
||||
'192.0.2.176/28'
|
||||
'192.0.2.192/28'
|
||||
'192.0.2.208/28'
|
||||
'192.0.2.224/28'
|
||||
'192.0.2.240/28'
|
||||
|
||||
>>> ip = IPNetwork('2001:470:1f04::/48')
|
||||
>>> for i in ip.subnet(128):
|
||||
... print i
|
||||
... break
|
||||
2001:470:1f04::/128
|
||||
|
||||
}}}
|
||||
|
||||
IP address and subnet sortability.
|
||||
|
||||
{{{
|
||||
|
||||
>>> ip_list = []
|
||||
|
||||
>>> for subnet in IPNetwork('192.0.2.0/24').subnet(28, 3):
|
||||
... ip_list.append(subnet)
|
||||
... ip_list.extend([ip for ip in subnet])
|
||||
|
||||
>>> for addr in sorted(ip_list):
|
||||
... print '%r' % addr
|
||||
IPNetwork('192.0.2.0/28')
|
||||
IPAddress('192.0.2.0')
|
||||
IPAddress('192.0.2.1')
|
||||
IPAddress('192.0.2.2')
|
||||
IPAddress('192.0.2.3')
|
||||
IPAddress('192.0.2.4')
|
||||
IPAddress('192.0.2.5')
|
||||
IPAddress('192.0.2.6')
|
||||
IPAddress('192.0.2.7')
|
||||
IPAddress('192.0.2.8')
|
||||
IPAddress('192.0.2.9')
|
||||
IPAddress('192.0.2.10')
|
||||
IPAddress('192.0.2.11')
|
||||
IPAddress('192.0.2.12')
|
||||
IPAddress('192.0.2.13')
|
||||
IPAddress('192.0.2.14')
|
||||
IPAddress('192.0.2.15')
|
||||
IPNetwork('192.0.2.16/28')
|
||||
IPAddress('192.0.2.16')
|
||||
IPAddress('192.0.2.17')
|
||||
IPAddress('192.0.2.18')
|
||||
IPAddress('192.0.2.19')
|
||||
IPAddress('192.0.2.20')
|
||||
IPAddress('192.0.2.21')
|
||||
IPAddress('192.0.2.22')
|
||||
IPAddress('192.0.2.23')
|
||||
IPAddress('192.0.2.24')
|
||||
IPAddress('192.0.2.25')
|
||||
IPAddress('192.0.2.26')
|
||||
IPAddress('192.0.2.27')
|
||||
IPAddress('192.0.2.28')
|
||||
IPAddress('192.0.2.29')
|
||||
IPAddress('192.0.2.30')
|
||||
IPAddress('192.0.2.31')
|
||||
IPNetwork('192.0.2.32/28')
|
||||
IPAddress('192.0.2.32')
|
||||
IPAddress('192.0.2.33')
|
||||
IPAddress('192.0.2.34')
|
||||
IPAddress('192.0.2.35')
|
||||
IPAddress('192.0.2.36')
|
||||
IPAddress('192.0.2.37')
|
||||
IPAddress('192.0.2.38')
|
||||
IPAddress('192.0.2.39')
|
||||
IPAddress('192.0.2.40')
|
||||
IPAddress('192.0.2.41')
|
||||
IPAddress('192.0.2.42')
|
||||
IPAddress('192.0.2.43')
|
||||
IPAddress('192.0.2.44')
|
||||
IPAddress('192.0.2.45')
|
||||
IPAddress('192.0.2.46')
|
||||
IPAddress('192.0.2.47')
|
||||
|
||||
}}}
|
||||
Reference in New Issue
Block a user