Remove packet type and dst mac when sending raw packet

This is now derived from the passed packet data by
NetworkStack.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Ida06c00e6f499b782cb903c9fa0a4154c2d8cf84
This commit is contained in:
Junyu Lai 2024-07-02 18:26:21 +08:00
commit 161dc10f60

View file

@ -137,16 +137,12 @@ def send_broadcast_empty_ethercat_packet(
packet += "00" * 46
# Send the packet using a raw socket.
send_raw_packet_downstream(
ad, ETH_P_ETHERCAT, iface_name, ETHER_BROADCAST, packet
)
send_raw_packet_downstream(ad, iface_name, packet)
def send_raw_packet_downstream(
ad: android_device.AndroidDevice,
packetType: str,
iface_name: str,
dst_mac: str,
packet_in_hex: str,
) -> None:
"""Sends a raw packet over the specified downstream interface.
@ -158,11 +154,8 @@ def send_raw_packet_downstream(
Args:
ad: The AndroidDevice object representing the connected device.
packetType: The type of packet to send (e.g., "88A4" for EtherCAT).
iface_name: The name of the network interface to use (e.g., "wlan0",
"eth0").
dst_mac: The destination MAC address of the packet (e.g., "FFFFFFFFFFFF"
for broadcast).
packet_in_hex: The raw packet data starting from L2 header encoded in
hexadecimal string format.
@ -181,7 +174,7 @@ def send_raw_packet_downstream(
cmd = (
"cmd network_stack send-raw-packet-downstream"
f" {packetType} {iface_name} {dst_mac} {packet_in_hex}"
f" {iface_name} {packet_in_hex}"
)
# Expect no output or Unknown command if NetworkStack is too old. Throw otherwise.