Пример #1
0
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        q = self.build_dhcpv6_information_request(self.node(2))
        q = self.build_dhcpv6_relay_forward(q, self.node(2), self.router(1))
        self.router(1).send(
            IPv6(src=str(self.router(1).iface(1).link_local_ip()),
                 dst=AllDHCPv6RelayAgentsAndServers) /
            UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort) / q,
            iface=1)

        self.logger.info("Checking for a DHCPv6 Relay Reply message.")
        r2 = self.node(1).received(
            src=str(self.target(1).link_local_ip()),
            dst=str(self.router(1).iface(1).link_local_ip()),
            type=DHCP6_RelayReply)
        assertEqual(1, len(r2), "expected to receive a DHCPv6 Relay Reply")
        p = r2[0]

        self.logger.info(
            "Checking that DHCPv6 Relay Reply is properly formatted.")
        assertEqual(q.hopcount, p.hopcount,
                    "DHCPv6 Relay Reply has an incorrect hop count.")
        assertEqual(IPv6Address(q.peeraddr), p.peeraddr,
                    "DHCPv6 Relay Reply has an incorrect peer address.")
        assertEqual(IPv6Address(q.linkaddr), p.linkaddr,
                    "DHCPv6 Relay Reply has an incorrect link address.")
        assertHasLayer(DHCP6OptRelayMsg, p)
    def run(self):
        self.ui.tell("Ensure the RUT transmits a Router Advertisement with the site-local prefix FEC0::/10, and configure a site-local address on ifx.")
        
        self.logger.info("Requesting user to enter the address")
        site_local_ip = IPv6Address(self.ui.read("What is the NUT's Site Local address? (starting fec0:)"))

        assertNotNone(site_local_ip, "expected a valid site-local IPv6 address to be assigned")

        self.logger.info("Sending Echo request to NUT site local address")
        self.node(1).send( \
            IPv6(src=str(self.node(1).link_local_ip()), dst=str(site_local_ip))/
                ICMPv6EchoRequest(seq=self.next_seq()))

        self.logger.info("Checking for reply")
        r1 = self.node(1).received(src=site_local_ip, seq=self.seq(), type=ICMPv6EchoReply)

        assertEqual(1, len(r1), "expected a reply to the ICMPv6 Echo Request")

        self.logger.info("Check packets dst is TN1s link local address")
        assertEqual(self.node(1).link_local_ip(), r1[0].getlayer(IPv6).dst, "expected dst to be TN1's link-local address")

        self.logger.info("Check packet has valid checksum")
        p1 = IPv6(r1[0].build())
        p1.getlayer(ICMPv6EchoReply).cksum = None
        p1 = IPv6(p1.build())

        assertEqual(p1.getlayer(ICMPv6EchoReply).cksum, r1[0].getlayer(ICMPv6EchoReply).cksum, "expected the Echo Reply to have a valid checksum")
    def run(self):
        self.logger.info("Sending RA for Site-Local prefix")
        self.logger.info("Send Router advertisement with site local prefix FEC0::/10")
        self.router(1).send( \
            IPv6(src=str(self.router(1).link_local_ip(iface=1)), dst="ff02::1")/
                ICMPv6ND_RA(routerlifetime=90, reachabletime=10, retranstimer=1)/
                    ICMPv6NDOptSrcLLAddr(lladdr=self.router(1).iface(1).ll_addr)/
                    ICMPv6NDOptMTU(mtu=self.router(1).iface(1).ll_protocol.mtu)/
                    ICMPv6NDOptPrefixInfo(validlifetime=90, preferredlifetime=90, prefix="fec0::", prefixlen=64), iface=1)
        # TODO: review the use of the prefix length 64, technically it should
        #       be 10, but this results in an error stating the prefix is
        #       invalid
        
        self.logger.info("Requesting user to enter the address")
        site_local_ip = IPv6Address(self.ui.read("What is the NUT's Site Local address? (starting fec0:)"))

        assertNotNone(site_local_ip, "expected a valid site-local IPv6 address to be assigned")
        
        self.logger.info("Sending Echo request to NUT site local address")
        self.node(1).send( \
            IPv6(src=str(self.node(1).link_local_ip()), dst=str(site_local_ip))/
                ICMPv6EchoRequest(seq=self.next_seq()))
        
        self.logger.info("Checking for reply")
        r1 = self.node(1).received(src=site_local_ip, seq=self.seq(), type=ICMPv6EchoReply)

        assertEqual(1, len(r1), "expected a reply to the ICMPv6 Echo Request")
        
        self.logger.info("Check packets dst is TN1s link local address")
        assertEqual(self.node(1).link_local_ip(), r1[0].getlayer(IPv6).dst, "expected dst to be TN1's link-local address")

        self.logger.info("Check packet has valid checksum")
        p1 = IPv6(r1[0].build())
        p1.getlayer(ICMPv6EchoReply).cksum = None
        p1 = IPv6(p1.build())

        assertEqual(p1.getlayer(ICMPv6EchoReply).cksum, r1[0].getlayer(ICMPv6EchoReply).cksum, "expected the Echo Reply to have a valid checksum")
Пример #4
0
    def test_it_should_implement__ne__for_a_pair_of_v6_addresses(self):
        ip1 = IPv6Address("2001:500:88:200::10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertTrue(ip1 != ip2)
        self.assertFalse(ip1 != ip1)
Пример #5
0
    def test_it_should_compare_ipv6_addresses_case_insensitively(self):
        ip1 = IPv6Address("2001:db8::1")

        self.assertTrue(ip1 == "2001:DB8::1")
        
Пример #6
0
    def test_it_should_identify_a_v6_address_as_a_tunnel(self):
        ip = IPv6Address("2002:500:88:200::10")

        self.assertTrue(ip.is_tunnel())
Пример #7
0
    def test_it_should_identify_the_loopback_v6_address_as_interface_local_scope(self):
        ip = IPv6Address("::1")

        self.assertEqual('interface-local', ip.scope())
Пример #8
0
    def test_it_should_get_the_canonical_form_of_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", ip.canonical_form())
Пример #9
0
    def test_it_should_identify_a_v6_address_as_multicast(self):
        ip = IPv6Address("ff01::2")

        self.assertTrue(ip.is_multicast())
Пример #10
0
    def test_it_should_have_a_subnet_prefix_size(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual(64, ip.prefix_size)
Пример #11
0
    def test_it_should_canonicalise_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", str(ip))
Пример #12
0
    def test_it_should_identify_a_v6_multicast_address_as_organisation_local_scope(self):
        ip = IPv6Address("ff80::200:10")

        self.assertEqual('organisation-local', ip.scope())
Пример #13
0
    def test_it_should_identify_a_v6_multicast_address_as_global_scope(self):
        ip = IPv6Address("ffe0::200:10")

        self.assertEqual('global', ip.scope())
Пример #14
0
    def test_it_should_identify_a_v6_multicast_address_as_site_local_scope(self):
        ip = IPv6Address("ff50::200:10")

        self.assertEqual('site-local', ip.scope())
Пример #15
0
    def test_it_should_identify_a_v6_address_as_global_scope(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual('global', ip.scope())
Пример #16
0
    def test_it_should_identify_a_v6_address_as_site_local_scope(self):
        ip = IPv6Address("fec0:500:88:200::10")

        self.assertEqual('site-local', ip.scope())
Пример #17
0
 def test_it_should_return_a_v6_address_as_a_string(self):
     ip = IPv6Address("2001:0500:0088:0200:0000:0000:0000:0010")
     
     self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", str(ip))
Пример #18
0
    def test_it_should_have_a_netmask(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("ffff:ffff:ffff:ffff:0000:0000:0000:0000", ip.netmask())
Пример #19
0
    def test_it_should_return_the_version_of_a_v6_address(self):
        ip = IPv6Address("2001:0500:0088:0200:0000:0000:0000:0010")

        self.assertEqual(6, ip.version())
Пример #20
0
    def test_it_should_change_the_netmask_to_reflect_the_subnet_prefix_size(self):
        ip = IPv6Address("2001:500:88:200::10")
        ip.prefix_size = 96

        self.assertEqual("ffff:ffff:ffff:ffff:ffff:ffff:0000:0000", ip.netmask())
Пример #21
0
    def test_it_should_canonicalise_a_v4_mapped_address(self):
        ip = IPv6Address("::ffff:10.0.0.1")

        self.assertEqual("0000:0000:0000:0000:0000:ffff:0a00:0001", str(ip))
Пример #22
0
    def test_it_should_calculate_the_network_prefix_of_a_slash_96(self):
        ip = IPv6Address("2001:500:88:200::10")
        ip.prefix_size = 96

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0000", ip.network())
Пример #23
0
    def test_it_should_get_the_short_form_of_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:500:88:200::10", ip.short_form())
Пример #24
0
    def test_it_should_identify_the_loopback_v6_address(self):
        ip = IPv6Address("::1")

        self.assertTrue(ip.is_loopback())
Пример #25
0
    def test_it_should_not_identify_a_v6_address_as_multicast(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertFalse(ip.is_multicast())
Пример #26
0
    def test_it_should_identify_the_undefined_v6_address(self):
        ip = IPv6Address("::")

        self.assertTrue(ip.is_undefined())
Пример #27
0
    def test_it_should_implement__eq__for_a_v6_and_a_v6str_addresses(self):
        ip1 = IPv6Address("2001:500:88:200::10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertTrue(ip1 == str(ip1))
        self.assertFalse(ip1 == str(ip2))
Пример #28
0
    def test_it_should_identify_a_v6_address_is_v4_mapped(self):
        ip = IPv6Address("::ffff:a00:1")

        self.assertTrue(ip.is_v4_mapped())
Пример #29
0
 def global_ip_y(self):
     return  IPv6Address(self.prefix_y() + in6_mactoifaceid(self.target(1).ll_addr()))
Пример #30
0
    def test_it_should_implement__eq__for_a_v4str_and_a_v6_addresses(self):
        ip1 = IPv4Address("192.0.43.10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertFalse(str(ip2) == ip1)