当前位置: 首页>>代码示例>>Python>>正文


Python models.IPAddress类代码示例

本文整理汇总了Python中veripy.models.IPAddress的典型用法代码示例。如果您正苦于以下问题:Python IPAddress类的具体用法?Python IPAddress怎么用?Python IPAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IPAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_it_should_get_the_global_ip_of_tr3if1

    def test_it_should_get_the_global_ip_of_tr3if1(self):
        options, args = sampleOptions("--configuration tests/mocks/veripy.cfg host")

        c = Configuration(args, options)

        self.assertEqual(2, len(c.test_network().tr1.if0_ips))
        self.assertTrue(IPAddress.identify("2012:6970:7636::fe:104") in c.test_network().tr3.if1_ips)
        self.assertTrue(IPAddress.identify("fe80::7a2b:cbff:fefe:104") in c.test_network().tr3.if1_ips)
开发者ID:bobdoah,项目名称:veripy,代码行数:8,代码来源:configuration.py

示例2: test_it_should_not_get_received_packets_for_another_ip

    def test_it_should_not_get_received_packets_for_another_ip(self):
        l = Link('A')
        n = TestNode('TNN',     link0=l, ips0=[IPAddress.identify("2001:db8::1"), IPAddress.identify("fe80::1")])

        l.accept(IPv6(src="2001:db8::2", dst="2001:db8::3")/ICMPv6EchoRequest())
        l.accept(IPv6(src="2001:db8::3", dst="2001:db8::2")/ICMPv6EchoReply())

        self.assertEqual(0, len(n.received()))
开发者ID:bobdoah,项目名称:veripy,代码行数:8,代码来源:test_network.py

示例3: test_it_should_get_the_link_local_ip_of_tn1

    def test_it_should_get_the_link_local_ip_of_tn1(self):
        options, args = sampleOptions("--configuration tests/mocks/veripy.cfg host")

        c = Configuration(args, options)

        self.assertEqual(3, len(c.test_network().tn1.if0_ips))
        self.assertTrue(IPAddress.identify("fe80::7a2b:cbff:feef:0102") in c.test_network().tn1.if0_ips)
        self.assertTrue(IPAddress.identify("fe80::7a2b:cbff:feca:ad05") in c.test_network().tn1.if0_ips)
开发者ID:bobdoah,项目名称:veripy,代码行数:8,代码来源:configuration.py

示例4: test_it_should_get_received_packets_for_its_own_v4_address

    def test_it_should_get_received_packets_for_its_own_v4_address(self):
        l = Link('A')
        n = TestNode('TNN',     link0=l, ips0=[IPAddress.identify("2001:db8::1"), IPAddress.identify("fe80::1"), IPAddress.identify("10.0.0.1")])

        l.accept(IP(src="10.0.0.2", dst="10.0.0.1")/ICMP())
        l.accept(IP(src="10.0.0.1", dst="10.0.0.2")/ICMP())

        self.assertEqual(1, len(n.received()))
        self.assertTrue(n.received()[0].haslayer(ICMP))
开发者ID:bobdoah,项目名称:veripy,代码行数:9,代码来源:test_network.py

示例5: test_it_should_not_forward_router_solicitations

    def test_it_should_not_forward_router_solicitations(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ll_addr0="00:b0:d0:86:bb:f7", ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ll_addr1="00:b0:d0:86:bb:f8", ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        l.accept(IPv6(src="fe80:500:88:200::20", dst="ff02::2")/ICMPv6ND_RS())
        
        self.assertFalse(any(map(lambda p: p.haslayer(ICMPv6ND_RS), m.forwarded())))
开发者ID:bobdoah,项目名称:veripy,代码行数:9,代码来源:test_network.py

示例6: setUp

 def setUp(self):
     self.c = IPAddressCollection(
         [
             IPAddress.identify("2001:500:88:200::10"),
             IPAddress.identify("2001:500:88:200::11"),
             IPAddress.identify("fe80:500:88:200::10"),
             IPAddress.identify("192.0.43.10"),
         ]
     )
开发者ID:bobdoah,项目名称:veripy,代码行数:9,代码来源:ip_address_collection.py

示例7: test_it_should_get_received_packets_for_its_own_link_local

    def test_it_should_get_received_packets_for_its_own_link_local(self):
        l = Link('A')
        n = TestNode('TNN',     link0=l, ips0=[IPAddress.identify("2001:db8::1"), IPAddress.identify("fe80::1")])

        l.accept(IPv6(src="fe80::2", dst="fe80::1")/ICMPv6EchoRequest())
        l.accept(IPv6(src="fe80::1", dst="fe80::2")/ICMPv6EchoReply())

        self.assertEqual(1, len(n.received()))
        self.assertTrue(n.received()[0].haslayer(ICMPv6EchoRequest))
开发者ID:bobdoah,项目名称:veripy,代码行数:9,代码来源:test_network.py

示例8: test_it_should_not_forward_neighbour_advertisements

    def test_it_should_not_forward_neighbour_advertisements(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ll_addr0="00:b0:d0:86:bb:f7", ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ll_addr1="00:b0:d0:86:bb:f8", ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        l.accept(IPv6(src="fe80:500:88:200::20", dst="ff02::2")/ICMPv6ND_NA())

        self.assertEqual(0, len(m.forwarded()))
开发者ID:bobdoah,项目名称:veripy,代码行数:9,代码来源:test_network.py

示例9: test_it_should_have_ip_addresses_on_if1

    def test_it_should_have_ip_addresses_on_if1(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        self.assertEqual("2001:600:88:200::10", r.ip(1).short_form())
        self.assertEqual("2001:600:88:200::10", r.global_ip(1).short_form())
        self.assertEqual("2001:600:88:200::11", r.global_ip(1, offset=1).short_form())
        self.assertEqual("192.1.43.10", r.ip(1, type='v4').short_form())
开发者ID:bobdoah,项目名称:veripy,代码行数:10,代码来源:test_network.py

示例10: test_it_should_not_forward_global_traffic_addressed_to_the_interface

    def test_it_should_not_forward_global_traffic_addressed_to_the_interface(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        l.accept(IPv6(dst="2001:500:88:200::10"))

        self.assertEqual(1, len(l.forwarded()))
        self.assertEqual(0, len(m.forwarded()))
开发者ID:bobdoah,项目名称:veripy,代码行数:10,代码来源:test_network.py

示例11: test_it_should_receive_traffic_from_if1

    def test_it_should_receive_traffic_from_if1(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        m.accept(IPv6(src="2001:600:88:200::90", dst="2001:600:88:200::10"))

        self.assertEqual(0, len(r.received()))
        self.assertEqual(1, len(r.received(1)))
        self.assertTrue(r.received(1)[0].haslayer(IPv6))
开发者ID:bobdoah,项目名称:veripy,代码行数:11,代码来源:test_network.py

示例12: test_it_should_send_traffic_on_if1

    def test_it_should_send_traffic_on_if1(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")])

        r.send("This is a packet.", iface=1)

        self.assertEqual(0, len(l.forwarded()))
        self.assertEqual(1, len(m.forwarded()))
        self.assertEqual("This is a packet.", m.forwarded()[0])
开发者ID:bobdoah,项目名称:veripy,代码行数:11,代码来源:test_network.py

示例13: test_it_should_not_forward_link_local_traffic

    def test_it_should_not_forward_link_local_traffic(self):
        l = Link('A')
        m = Link('B')
        r = TestRouter('TNN',   link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")],
                                link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")],
                                forwards_to_0=[Network("2001:0500:0088:0200:0000:0000:0000:0000/64")],
                                forwards_to_1=[Network("2001:0600:0088:0200:0000:0000:0000:0000/64")])

        l.accept(IPv6(dst="fe80:600:88:200::10"))

        self.assertEqual(1, len(l.forwarded()))
        self.assertEqual(0, len(m.forwarded()))
开发者ID:bobdoah,项目名称:veripy,代码行数:12,代码来源:test_network.py

示例14: test_it_should_get_the_global_ip_of_tn4

    def test_it_should_get_the_global_ip_of_tn4(self):
        options, args = sampleOptions("--configuration tests/mocks/veripy.cfg host")

        c = Configuration(args, options)

        self.assertEqual(2, len(c.test_network().tn4.if0_ips))
        self.assertTrue(IPAddress.identify("2012:6d77:7269::ef:0105") in c.test_network().tn4.if0_ips)
开发者ID:bobdoah,项目名称:veripy,代码行数:7,代码来源:configuration.py

示例15: test_it_should_not_respond_to_an_arp_reply_address

    def test_it_should_not_respond_to_an_arp_reply_address(self):
        l = Link('A')
        n = TestNode('TNN',     link0=l, ll_addr0="00:b0:d0:86:bb:f7", ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")])

        l.accept(ARP(hwsrc="00:01:02:03:04:05", psrc="192.0.43.100", pdst="192.0.43.200", op=0x002))

        self.assertEqual(1, len(l.forwarded()))
开发者ID:bobdoah,项目名称:veripy,代码行数:7,代码来源:test_network.py


注:本文中的veripy.models.IPAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。