Example #1
0
def ip4addr_test_goodint_goodstr24():
    addr = ip4addr.IP4Addr(16885952, "255.255.255.0")

    assert_equals(addr.isValid(), True)
    assert_equals(addr.getAddr(), ("192.168.1.1", 3232235777))
    assert_equals(addr.getMask(), ("255.255.255.0", 4294967040))
    assert_equals(addr.getHostmask(), ("0.0.0.255", 255))
    assert_equals(addr.getBroadcast(), ("192.168.1.255", 3232236031))
    assert_equals(addr.getNetwork(), ("192.168.1.0", 3232235776))
    assert_equals(addr.getPlen(), 24)
Example #2
0
def ip4addr_test_goodstr_goodplen30():
    addr = ip4addr.IP4Addr("10.0.4.2", 30)

    assert_equals(addr.isValid(), True)
    assert_equals(addr.getAddr(), ("10.0.4.2", 167773186))
    assert_equals(addr.getMask(), ("255.255.255.252", 4294967292))
    assert_equals(addr.getHostmask(), ("0.0.0.3", 3))
    assert_equals(addr.getBroadcast(), ("10.0.4.3", 167773187))
    assert_equals(addr.getNetwork(), ("10.0.4.0", 167773184))
    assert_equals(addr.getPlen(), 30)
Example #3
0
def ip4addr_test_goodstr_goodplen_hostroute():
    addr = ip4addr.IP4Addr("192.168.1.1", 32)

    assert_equals(addr.isValid(), True)
    assert_equals(addr.getAddr(), ("192.168.1.1", 3232235777))
    assert_equals(addr.getMask(), ("255.255.255.255", 4294967295))
    assert_equals(addr.getHostmask(), ("0.0.0.0", 0))
    assert_equals(addr.getBroadcast(), ("192.168.1.1", 3232235777))
    assert_equals(addr.getNetwork(), ("192.168.1.1", 3232235777))
    assert_equals(addr.getPlen(), 32)
Example #4
0
def ip4addr_test_goodstr_goodplen_default():
    addr = ip4addr.IP4Addr("0.0.0.0", 0)

    assert_equals(addr.isValid(), True)
    assert_equals(addr.getAddr(), ("0.0.0.0", 0))
    assert_equals(addr.getMask(), ("0.0.0.0", 0))
    assert_equals(addr.getHostmask(), ("255.255.255.255", 4294967295))
    assert_equals(addr.getBroadcast(), ("255.255.255.255", 4294967295))
    assert_equals(addr.getNetwork(), ("0.0.0.0", 0))
    assert_equals(addr.getPlen(), 0)
Example #5
0
def ip4addr_test_goodstr_badmask_nbo8():
    addr = ip4addr.IP4Addr("10.0.4.2", 4278190080)
    invalid_addr(addr)
Example #6
0
def ip4addr_test_goodstr_badsnmask_toohigh():
    addr = ip4addr.IP4Addr("192.168.1.1", 4294967293)
    invalid_addr(addr)
Example #7
0
def ip4addr_test_goodstr_badplen_toohigh():
    addr = ip4addr.IP4Addr("192.168.1.1", 33)
    invalid_addr(addr)
Example #8
0
def ip4addr_test_goodstr_badplen_negative():
    addr = ip4addr.IP4Addr("192.168.1.1", -1)
    invalid_addr(addr)
Example #9
0
def ip4addr_test_goodstr_badmask():
    addr = ip4addr.IP4Addr("1.1.1.1", 64)
    invalid_addr(addr)
Example #10
0
def ip4addr_test_badstr_goodplen24():
    addr = ip4addr.IP4Addr("1", 24)
    invalid_addr(addr)