Ejemplo n.º 1
0
def test_task08(riot_ctrl, log_nodes):
    node = riot_ctrl(0, APP, Shell, port=TAP)
    host_netif = bridge(TAP)
    host_lladdr = get_link_local(host_netif)

    node_netifs = NETIF_PARSER.parse(node.ifconfig_list())
    node_netif = next(iter(node_netifs))
    node_hwaddr = node_netifs[node_netif]["hwaddr"]
    node_lladdr = [
        addr["addr"] for addr in node_netifs[node_netif]["ipv6_addrs"]
        if addr["scope"] == "link"
    ][0]
    ip_addr_add(host_netif, "beef::1/64")
    ip_route_add(host_netif, "affe::/64", node_lladdr)
    node.nib_route_add(node_netif, "beef::/64", host_lladdr)
    node.nib_route_add(node_netif, "affe::/64", "fe80::ab25:f123")

    pkt = srp1(Ether(dst=node_hwaddr) /
               IPv6(src="beef::1", dst="affe::1", hlim=1) / UDP(dport=48879),
               iface=host_netif,
               timeout=5,
               verbose=log_nodes)
    assert ICMPv6TimeExceeded in pkt
    assert pkt[ICMPv6TimeExceeded].code == 0
    assert pkt[IPv6].src == node_lladdr
Ejemplo n.º 2
0
def test_task09(riot_ctrl, log_nodes):
    node = riot_ctrl(0, APP, Shell, port=TAP)
    host_netif = bridge(TAP)
    host_lladdr = get_link_local(host_netif)

    node_netifs = NETIF_PARSER.parse(node.ifconfig_list())
    node_netif = next(iter(node_netifs))
    node_hwaddr = node_netifs[node_netif]["hwaddr"]
    node_lladdr = [
        addr["addr"] for addr in node_netifs[node_netif]["ipv6_addrs"]
        if addr["scope"] == "link"
    ][0]
    ip_addr_add(host_netif, "beef::1/64")
    ip_route_add(host_netif, "affe::/64", node_lladdr)
    node.nib_route_add(node_netif, "beef::/64", host_lladdr)
    node.nib_route_add(node_netif, "affe::/64", "fe80::ab25:f123")

    pkt = srp1(Ether(dst=node_hwaddr) /
               IPv6(src="beef::1", dst="affe::1", plen=20) / UDP(dport=48879),
               iface=host_netif,
               timeout=5,
               verbose=log_nodes)
    assert ICMPv6ParamProblem in pkt
    assert pkt[ICMPv6ParamProblem].code == 0
    err_bytes = raw(pkt[IPerror6])
    ptr = pkt[ICMPv6ParamProblem].ptr
    # plen is a 2 byte field in network byte order (big endian)
    ptr_val = (err_bytes[ptr] << 8) | err_bytes[ptr + 1]
    assert ptr_val == 20
    assert pkt[IPv6].src == node_lladdr
Ejemplo n.º 3
0
def test_task07(riot_ctrl, log_nodes):
    node = riot_ctrl(0,
                     APP,
                     Shell,
                     cflags="-DCONFIG_GNRC_IPV6_NIB_SLAAC=1 "
                     "-DCONFIG_GNRC_IPV6_NIB_QUEUE_PKT=1",
                     termflags="-z [::]:17755",
                     modules="socket_zep netdev_tap",
                     port=TAP)
    host_netif = bridge(TAP)
    host_lladdr = get_link_local(host_netif)

    time.sleep(5)
    node_netifs = NETIF_PARSER.parse(node.ifconfig_list())
    node_netif = [n for n in node_netifs if node_netifs[n]["mtu"] == 1500][0]
    fwd_netif = [n for n in node_netifs if node_netifs[n]["mtu"] < 1500][0]
    node_hwaddr = node_netifs[node_netif]["hwaddr"]
    node_lladdr = [
        addr["addr"] for addr in node_netifs[node_netif]["ipv6_addrs"]
        if addr["scope"] == "link"
    ][0]
    ip_addr_add(host_netif, "beef::1/64")
    ip_route_add(host_netif, "affe::/64", node_lladdr)
    node.nib_route_add(node_netif, "beef::/64", host_lladdr)
    node.nib_route_add(fwd_netif, "affe::/64", "fe80::ab25:f123")

    pkt = srp1(Ether(dst=node_hwaddr) / IPv6(src="beef::1", dst="affe::1") /
               UDP(dport=48879) / ("x" * 1452),
               iface=host_netif,
               timeout=5,
               verbose=log_nodes)
    assert ICMPv6PacketTooBig in pkt
    assert pkt[ICMPv6PacketTooBig].code == 0
    assert node_netifs[fwd_netif]["mtu"] == pkt[ICMPv6PacketTooBig].mtu == 1280
    assert pkt[IPv6].src == node_lladdr