Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 #----------------------------------------------------------------------------- 3 # Copyright (c) 2008-2009, David P. D. Moss. All rights reserved. 4 # 5 # Released under the BSD license. See the LICENSE file for details. 6 #----------------------------------------------------------------------------- 7 """ 8 network address manipulation, done Pythonically 9 """ 10 import sys as _sys 11 if _sys.version_info[0:2] < (2, 4): 12 raise RuntimeError('Python 2.4.x or higher is required!') 13 14 __version__ = '0.6.3' 15 16 import struct as _struct 17 18 #----------------------------------------------------------------------------- 19 # Constants. 20 #----------------------------------------------------------------------------- 21 22 #: True if platform is natively big endian, False otherwise. 23 BIG_ENDIAN_PLATFORM = _struct.pack('=h', 1) == _struct.pack('>h', 1) 24 25 AT_UNSPEC = 0x0 #: unspecified address type constant. 26 AT_INET = 0x4 #: IPv4 address type constant. 27 AT_INET6 = 0x6 #: IPv6 address type constant. 28 AT_LINK = 0x30 #: MAC/EUI-48 address type constant. 29 AT_EUI64 = 0x40 #: EUI-64 address type constant. 30 31 #: Address type to address description lookup dictionary. 32 AT_NAMES = { 33 # Address Type : Descriptive Name. 34 AT_UNSPEC : 'unspecified', 35 AT_INET : 'IPv4', 36 AT_INET6 : 'IPv6', 37 AT_LINK : 'MAC', 38 AT_EUI64 : 'EUI-64', 39 } 40 41 #----------------------------------------------------------------------------- 42 # Custom exceptions. 43 #----------------------------------------------------------------------------- 44 50 57 58 #----------------------------------------------------------------------------- 59 # Submodule imports. 60 #----------------------------------------------------------------------------- 61 62 from netaddr.address import nrange, IP, IPRange, IPRangeSet, CIDR, \ 63 Wildcard, EUI 64 65 from netaddr.eui import OUI, IAB, NotRegisteredError 66 67 import netaddr.ip 68 69 from netaddr.strategy import ST_IPV4, ST_IPV6, ST_EUI48, ST_EUI64 70 71 #----------------------------------------------------------------------------- 72 # Public interface. 73 #----------------------------------------------------------------------------- 74 __all__ = [ 75 # type constants 76 'AT_UNSPEC', 'AT_INET', 'AT_INET6', 'AT_LINK', 'AT_EUI64', 77 78 # module specific exceptions 79 'AddrFormatError', 'AddrConversionError', 'NotRegisteredError', 80 81 # shared strategy objects 82 'ST_IPV4', 'ST_IPV6', 'ST_EUI48', 'ST_EUI64', 83 84 # main interface classes 85 'CIDR', 'IP', 'IPRange', 'IPRangeSet', 'Wildcard', 86 'EUI', 'OUI', 'IAB', 87 88 # functions 89 'nrange', 90 ] 91
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Jun 23 22:47:44 2009 | http://epydoc.sourceforge.net |