<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Project><name>IPy</name>
<shortdesc>Class and tools for handling of IPv4 and IPv6 addresses and networks</shortdesc>
<description>IPy - class and tools for handling of IPv4 and IPv6 addresses and networks.

Presentation of the API
=======================

The IP class allows a comfortable parsing and handling for most
notations in use for IPv4 and IPv6 addresses and networks. It was
greatly inspired by RIPE's Perl module NET::IP's interface but
doesn't share the implementation. It doesn't share non-CIDR netmasks,
so funky stuff like a netmask of 0xffffff0f can't be done here.

    &gt;&gt;&gt; from IPy import IP
    &gt;&gt;&gt; ip = IP('127.0.0.0/30')
    &gt;&gt;&gt; for x in ip:
    ...  print x
    ...
    127.0.0.0
    127.0.0.1
    127.0.0.2
    127.0.0.3
    &gt;&gt;&gt; ip2 = IP('0x7f000000/30')
    &gt;&gt;&gt; ip == ip2
    1
    &gt;&gt;&gt; ip.reverseNames()
    ['0.0.0.127.in-addr.arpa.', '1.0.0.127.in-addr.arpa.', '2.0.0.127.in-addr.arpa.', '3.0.0.127.in-addr.arpa.']
    &gt;&gt;&gt; ip.reverseName()
    '0-3.0.0.127.in-addr.arpa.'
    &gt;&gt;&gt; ip.iptype()
    'PRIVATE'


Supports most IP address formats
================================

It can detect about a dozen different ways of expressing IP addresses
and networks, parse them and distinguish between IPv4 and IPv6 addresses:

    &gt;&gt;&gt; IP('10.0.0.0/8').version()
    4
    &gt;&gt;&gt; IP('::1').version()
    6

IPv4 addresses
--------------

    &gt;&gt;&gt; print IP(0x7f000001)
    127.0.0.1
    &gt;&gt;&gt; print IP('0x7f000001')
    127.0.0.1
    &gt;&gt;&gt; print IP('127.0.0.1')
    127.0.0.1
    &gt;&gt;&gt; print IP('10')
    10.0.0.0

IPv6 addresses
--------------

    &gt;&gt;&gt; print IP('1080:0:0:0:8:800:200C:417A')
    1080::8:800:200c:417a
    &gt;&gt;&gt; print IP('1080::8:800:200C:417A')
    1080::8:800:200c:417a
    &gt;&gt;&gt; print IP('::1')
    ::1
    &gt;&gt;&gt; print IP('::13.1.68.3')
    ::d01:4403

Network mask and prefixes
-------------------------

    &gt;&gt;&gt; print IP('127.0.0.0/8')
    127.0.0.0/8
    &gt;&gt;&gt; print IP('127.0.0.0/255.0.0.0')
    127.0.0.0/8
    &gt;&gt;&gt; print IP('127.0.0.0-127.255.255.255')
    127.0.0.0/8


Derive network address
===========================

IPy can transform an IP address into a network address by applying the given
netmask:
&gt;&gt;&gt; print IP('127.0.0.1/255.0.0.0', make_net=True)
127.0.0.0/8

This can also be done for existing IP instances:
&gt;&gt;&gt; print IP('127.0.0.1').make_net('255.0.0.0')
127.0.0.0/8


Convert address to string
=========================

Nearly all class methods which return a string have an optional
parameter 'wantprefixlen' which controls if the prefixlen or netmask
is printed. Per default the prefilen is always shown if the network
contains more than one address::

    wantprefixlen == 0 / None     don't return anything   1.2.3.0
    wantprefixlen == 1            /prefix                 1.2.3.0/24
    wantprefixlen == 2            /netmask                1.2.3.0/255.255.255.0
    wantprefixlen == 3            -lastip                 1.2.3.0-1.2.3.255

You can also change the defaults on an per-object basis by fiddling with
the class members:

 * NoPrefixForSingleIp
 * WantPrefixLen

Examples of string conversions:

    &gt;&gt;&gt; IP('10.0.0.0/32').strNormal()
    '10.0.0.0'
    &gt;&gt;&gt; IP('10.0.0.0/24').strNormal()
    '10.0.0.0/24'
    &gt;&gt;&gt; IP('10.0.0.0/24').strNormal(0)
    '10.0.0.0'
    &gt;&gt;&gt; IP('10.0.0.0/24').strNormal(1)
    '10.0.0.0/24'
    &gt;&gt;&gt; IP('10.0.0.0/24').strNormal(2)
    '10.0.0.0/255.255.255.0'
    &gt;&gt;&gt; IP('10.0.0.0/24').strNormal(3)
    '10.0.0.0-10.0.0.255'
    &gt;&gt;&gt; ip = IP('10.0.0.0')
    &gt;&gt;&gt; print ip
    10.0.0.0
    &gt;&gt;&gt; ip.NoPrefixForSingleIp = None
    &gt;&gt;&gt; print ip
    10.0.0.0/32
    &gt;&gt;&gt; ip.WantPrefixLen = 3
    &gt;&gt;&gt; print ip
    10.0.0.0-10.0.0.0


Compatibility and links
=======================

IPy 0.60 works on Python version 2.4 and 2.5.

This Python module is under BSD license: see COPYING file.

Further Information might be available at:
http://software.inl.fr/trac/trac.cgi/wiki/IPy


TODO
====

 * better comparison (__cmp__ and friends)
 * tests for __cmp__
 * always write hex values lowercase
 * interpret 2001:1234:5678:1234/64 as 2001:1234:5678:1234::/64
 * move size in bits into class variables to get rid of
   some "if self._ipversion ..."
 * support for base85 encoding
 * support for output of IPv6 encoded IPv4 Addresses
 * update address type tables
 * first-last notation should be allowed for IPv6
 * add IPv6 docstring examples
 * check better for negative parameters
 * add addition / aggregation
 * move reverse name stuff out of the classes and refactor it
 * support for aggregation of more than two nets at once
 * support for aggregation with "holes"
 * support for finding common prefix
 * '&gt;&gt;' and '&lt;&lt;' for prefix manipulation
 * add our own exceptions instead ValueError all the time
 * rename checkPrefix to checkPrefixOk
 * add more documentation and doctests
 * refactor

What's new
==========

Version 0.70 (2009-10-29)
	* New "major" version because it may break compatibility
	* Fix __cmp__(): IP('0.0.0.0/0') and IP('0.0.0.0') are not equal
	* Fix IP.net() of the network "::/0": "::" instead of "0.0.0.0".
	  IPy 0.63 should fix this bug, but it wasn't.

Version 0.64 (2009-08-19)
	* Create MANIFEST.in to fix setup.py bdist_rpm, fix by Robert Nickel

Version 0.63 (2009-06-23)
	* Fix formatting of "IPv4 in IPv6" network, eg. IP('::ffff:192.168.10.0/120'),
	  the netmask ("/120" in the example) was missing!

Version 0.62 (2008-07-15)
	* Fix reverse DNS of IPv6 address: use ".ip6.arpa." suffix instead of
	  deprecated ".ip6.int." suffix

Version 0.61 (2008-06-12)
	* Patch from Aras Vaichas allowing the [-1] operator
	  to work with an IP object of size 1.

Version 0.60 (2008-05-16)
	* strCompressed() formats '::ffff:a.b.c.d' correctly
	* Use strCompressed() instead of strFullsize() to format IP addresses,
	  ouput is smarter with IPv6 address
	* Remove check_addr_prefixlen because it generates invalid IP address</description>
<download-page>http://software.inl.fr/trac/trac.cgi/wiki/IPy</download-page>
<homepage rdf:resource="http://software.inl.fr/trac/trac.cgi/wiki/IPy" />
<maintainer><foaf:Person><foaf:name>Victor Stinner</foaf:name>
<foaf:mbox_sha1sum>5206fef2057a62e0bf699163097aa93366221876</foaf:mbox_sha1sum></foaf:Person></maintainer>
<release><Version><revision>0.70</revision></Version></release>
</Project></rdf:RDF>