-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write packets according to a certain "dump" rule into IPC Shared Memory
- Loading branch information
Showing
66 changed files
with
1,434 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.75 KB
autotests/units/001_one_port/067_dump_after_term/001-expect-dump-ring1.pcap
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
autotests/units/001_one_port/067_dump_after_term/autotest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
steps: | ||
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1" | ||
- ipv6Update: "::/0 -> fe80::1" | ||
- sendPackets: | ||
- port: kni0 | ||
send: 001-send.pcap | ||
expect: 001-expect.pcap | ||
- dumpPackets: | ||
- ringTag: ring1 | ||
expect: 001-expect-dump-ring1.pcap |
42 changes: 42 additions & 0 deletions
42
autotests/units/001_one_port/067_dump_after_term/controlplane.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"modules": { | ||
"lp0.100": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "100", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "acl0" | ||
}, | ||
"lp0.200": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "200", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "acl0" | ||
}, | ||
"acl0": { | ||
"type": "acl", | ||
"firewall": "firewall.txt", | ||
"nextModules": [ | ||
"vrf0" | ||
] | ||
}, | ||
"vrf0": { | ||
"type": "route", | ||
"interfaces": { | ||
"kni0.100": { | ||
"ipv6Prefix": "fe80::2/64", | ||
"neighborIPv6Address": "fe80::1", | ||
"neighborMacAddress": "00:00:00:11:11:11", | ||
"nextModule": "lp0.100" | ||
}, | ||
"kni0.200": { | ||
"ipv4Prefix": "200.0.0.2/24", | ||
"neighborIPv4Address": "200.0.0.1", | ||
"neighborMacAddress": "00:00:00:22:22:22", | ||
"nextModule": "lp0.200" | ||
} | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
autotests/units/001_one_port/067_dump_after_term/firewall.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:BEGIN | ||
add skipto :IN ip from any to any in | ||
|
||
:IN | ||
add allow tcp from 10.0.0.0/24 to 1.2.3.4 53 | ||
add dump ring1 ip from any to any | ||
add deny ip from any to any | ||
|
||
add allow udp from 10.0.0.0/24 to 1.2.3.4 53 | ||
add allow ip from any to any frag | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from typing import List | ||
|
||
from scapy.layers.inet import UDP, TCP, IP, fragment | ||
from scapy.layers.inet6 import IPv6 | ||
from scapy.layers.l2 import Ether, Dot1Q | ||
from scapy.packet import Packet | ||
from scapy.utils import PcapWriter | ||
|
||
|
||
def write_pcap(path: str, packets: List[Packet]) -> None: | ||
with PcapWriter(path) as fh: | ||
for p in packets: | ||
fh.write(p) | ||
|
||
|
||
def ipv4_send(src: str, dst: str) -> Packet: | ||
return Ether(dst="00:11:22:33:44:55", src="00:00:00:11:11:11") / Dot1Q(vlan=100) / IP(src=src, dst=dst, ttl=64) | ||
|
||
|
||
def ipv4_recv(src: str, dst: str) -> Packet: | ||
return Ether(dst="00:00:00:22:22:22", src="00:11:22:33:44:55") / Dot1Q(vlan=200) / IP(src=src, dst=dst, ttl=63) | ||
|
||
|
||
write_pcap("001-send.pcap", [ | ||
fragment(ipv4_send("10.0.0.1", "1.2.3.4") / UDP(sport=1024, dport=53)/("ABCDEFGH1234AAAAAAAA"*128), fragsize=1208), | ||
ipv4_send("10.0.0.1", "1.2.3.4") / UDP(sport=1024, dport=53), | ||
ipv4_send("10.0.0.1", "1.2.3.4") / TCP(sport=1024, dport=53), | ||
]) | ||
|
||
write_pcap("001-expect.pcap", [ | ||
ipv4_recv("10.0.0.1", "1.2.3.4") / TCP(sport=1024, dport=53), | ||
]) | ||
|
||
write_pcap("001-expect-dump-ring1.pcap", [ | ||
fragment(ipv4_send("10.0.0.1", "1.2.3.4") / UDP(sport=1024, dport=53)/("ABCDEFGH1234AAAAAAAA"*128), fragsize=1208), | ||
ipv4_send("10.0.0.1", "1.2.3.4") / UDP(sport=1024, dport=53), | ||
]) |
Binary file added
BIN
+98 Bytes
autotests/units/001_one_port/067_dump_default/001-expect-dump-ring1.pcap
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
autotests/units/001_one_port/067_dump_default/autotest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
steps: | ||
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1" | ||
- ipv6Update: "::/0 -> fe80::1" | ||
- sendPackets: | ||
- port: kni0 | ||
send: 001-send.pcap | ||
expect: 001-expect.pcap | ||
- dumpPackets: | ||
- ringTag: ring1 | ||
expect: 001-expect-dump-ring1.pcap |
Oops, something went wrong.