univention.ipcalc package
univention.ipcalc package¶
Univention IP Calculator for DNS records (IPv6 edition).
- univention.ipcalc.calculate_ipv6_reverse(network)[source]¶
Return reversed network part of IPv4 network. >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/0’)) ‘0’ >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/1’)) ‘0’ >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/4’)) ‘0’ >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/16’)) ‘0123’ >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/124’)) ‘0123:4567:89ab:cdef:0123:4567:89ab:cde’ >>> calculate_ipv6_reverse(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/128’)) ‘0123:4567:89ab:cdef:0123:4567:89ab:cde’
- univention.ipcalc.calculate_ipv4_reverse(network)[source]¶
Return reversed network part of IPv4 network. >>> calculate_ipv4_reverse(IPv4Interface(u’1.2.3.4/0’)) ‘1’ >>> calculate_ipv4_reverse(IPv4Interface(u’1.2.3.4/8’)) ‘1’ >>> calculate_ipv4_reverse(IPv4Interface(u’1.2.3.4/16’)) ‘1.2’ >>> calculate_ipv4_reverse(IPv4Interface(u’1.2.3.4/24’)) ‘1.2.3’ >>> calculate_ipv4_reverse(IPv4Interface(u’1.2.3.4/32’)) ‘1.2.3’
- univention.ipcalc.calculate_ipv6_network(network)[source]¶
Return network part of IPv6 network. >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/0’)) ‘’ >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/1’)) ‘’ >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/4’)) ‘0’ >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/16’)) ‘0123’ >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/112’)) ‘0123:4567:89ab:cdef:0123:4567:89ab’ >>> calculate_ipv6_network(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/128’)) ‘0123:4567:89ab:cdef:0123:4567:89ab:cdef’
- univention.ipcalc.calculate_ipv4_network(network)[source]¶
Return network part of IPv4 network. >>> calculate_ipv4_network(IPv4Interface(u’1.2.3.4/0’)) ‘’ >>> calculate_ipv4_network(IPv4Interface(u’1.2.3.4/1’)) ‘’ >>> calculate_ipv4_network(IPv4Interface(u’1.2.3.4/8’)) ‘1’ >>> calculate_ipv4_network(IPv4Interface(u’1.2.3.4/24’)) ‘1.2.3’ >>> calculate_ipv4_network(IPv4Interface(u’1.2.3.4/32’)) ‘1.2.3.4’
- univention.ipcalc.calculate_ipv6_pointer(network)[source]¶
Return host part of IPv6 network. >>> calculate_ipv6_pointer(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/0’)) ‘f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1’ >>> calculate_ipv6_pointer(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/1’)) ‘f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1’ >>> calculate_ipv6_pointer(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/4’)) ‘f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1’ >>> calculate_ipv6_pointer(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/124’)) ‘f’ >>> calculate_ipv6_pointer(IPv6Interface(u’0123:4567:89ab:cdef:0123:4567:89ab:cdef/128’)) ‘f’
- univention.ipcalc.calculate_ipv4_pointer(network)[source]¶
Return host part of IPv4 network. >>> calculate_ipv4_pointer(IPv4Interface(u’1.2.3.4/0’)) ‘4.3.2’ >>> calculate_ipv4_pointer(IPv4Interface(u’1.2.3.4/1’)) ‘4.3.2’ >>> calculate_ipv4_pointer(IPv4Interface(u’1.2.3.4/8’)) ‘4.3.2’ >>> calculate_ipv4_pointer(IPv4Interface(u’1.2.3.4/24’)) ‘4’ >>> calculate_ipv4_pointer(IPv4Interface(u’1.2.3.4/32’)) ‘4’