Skip to content

Commit 7b287f2

Browse files
committed
code cleanup
1 parent 7335495 commit 7b287f2

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

pytcp/tests/integration/test__packet_handler__arp__rx.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,39 @@
115115
),
116116
"_expected__packet_stats_tx": PacketStatsTx(),
117117
},
118+
{
119+
"_description": "Ethernet/ARP - unsupported ARP operation, drop",
120+
"_frames_rx": [
121+
# Ethernet II
122+
# Destination MAC : ff:ff:ff:ff:ff:ff (broadcast)
123+
# Source MAC : 02:00:00:00:00:91
124+
# Ethertype : 0x0806 (ARP)
125+
# Frame length : 42 bytes
126+
#
127+
# ARP (Ethernet/IPv4)
128+
# Hardware type : 1 (Ethernet)
129+
# Protocol type : 0x0800 (IPv4)
130+
# HLEN / PLEN : 6 / 4
131+
# Operation : 3 (unsupported)
132+
# Sender MAC : 02:00:00:00:00:91
133+
# Sender IP : 10.0.1.91
134+
# Target MAC : 02:00:00:00:00:07
135+
# Target IP : 10.0.1.7
136+
#
137+
# Summary: Broadcast ARP frame with an unsupported operation code; parser rejects it.
138+
b"\xff\xff\xff\xff\xff\xff\x02\x00\x00\x00\x00\x91\x08\x06\x00\x01"
139+
b"\x08\x00\x06\x04\x00\x03\x02\x00\x00\x00\x00\x91\x0a\x00\x01\x5b"
140+
b"\x02\x00\x00\x00\x00\x07\x0a\x00\x01\x07",
141+
],
142+
"_expected__frames_tx": [],
143+
"_expected__packet_stats_rx": PacketStatsRx(
144+
ethernet__pre_parse=1,
145+
ethernet__dst_broadcast=1,
146+
arp__pre_parse=1,
147+
arp__failed_parse__drop=1,
148+
),
149+
"_expected__packet_stats_tx": PacketStatsTx(),
150+
},
118151
{
119152
"_description": "Ethernet/ARP - request for stack MAC, broadcasted",
120153
"_frames_rx": [
@@ -241,6 +274,37 @@
241274
ethernet__dst_spec__send=1,
242275
),
243276
},
277+
{
278+
"_description": "Ethernet/ARP - request for stack IP, unicast to foreign MAC (ignore)",
279+
"_frames_rx": [
280+
# Ethernet II
281+
# Destination MAC : 02:00:00:00:00:99 (foreign unicast)
282+
# Source MAC : 02:00:00:00:00:91
283+
# Ethertype : 0x0806 (ARP)
284+
# Frame length : 42 bytes
285+
#
286+
# ARP (Ethernet/IPv4)
287+
# Hardware type : 1 (Ethernet)
288+
# Protocol type : 0x0800 (IPv4)
289+
# HLEN / PLEN : 6 / 4
290+
# Operation : 1 (Request)
291+
# Sender MAC : 02:00:00:00:00:91
292+
# Sender IP : 10.0.1.91
293+
# Target MAC : 00:00:00:00:00:00
294+
# Target IP : 10.0.1.7 (our IP)
295+
#
296+
# Summary: Unicast ARP request toward another host, dropped at Ethernet because dst ≠ our MAC.
297+
b"\x02\x00\x00\x00\x00\x99\x02\x00\x00\x00\x00\x91\x08\x06\x00\x01"
298+
b"\x08\x00\x06\x04\x00\x01\x02\x00\x00\x00\x00\x91\x0a\x00\x01\x5b"
299+
b"\x00\x00\x00\x00\x00\x00\x0a\x00\x01\x07",
300+
],
301+
"_expected__frames_tx": [],
302+
"_expected__packet_stats_rx": PacketStatsRx(
303+
ethernet__pre_parse=1,
304+
ethernet__dst_unknown__drop=1,
305+
),
306+
"_expected__packet_stats_tx": PacketStatsTx(),
307+
},
244308
{
245309
"_description": "Ethernet/ARP - request (SHA=00:00:00:00:00:00), drop",
246310
"_frames_rx": [

0 commit comments

Comments
 (0)