blob: 4633d3721869ac19bc67b98389f9382d24827240 [file] [log] [blame]
Junyu Lai32a2d152024-07-03 16:05:41 +08001# Copyright (C) 2024 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Junyu Lai6f6b1a42024-07-04 15:34:30 +080015from net_tests_utils.host.python import apf_test_base
Junyu Lai32a2d152024-07-03 16:05:41 +080016
Junyu Lai6f6b1a42024-07-04 15:34:30 +080017# Constants.
Junyu Lai32a2d152024-07-03 16:05:41 +080018COUNTER_DROPPED_ETHERTYPE_NOT_ALLOWED = "DROPPED_ETHERTYPE_NOT_ALLOWED"
Junyu Lai6f6b1a42024-07-04 15:34:30 +080019ETHER_BROADCAST_ADDR = "FFFFFFFFFFFF"
20ETH_P_ETHERCAT = "88A4"
Junyu Lai32a2d152024-07-03 16:05:41 +080021
22
Junyu Laicf655862024-07-04 11:09:52 +080023class ApfV4Test(apf_test_base.ApfTestBase):
Junyu Lai32a2d152024-07-03 16:05:41 +080024
25 def test_apf_drop_ethercat(self):
Junyu Lai6f6b1a42024-07-04 15:34:30 +080026 # Ethernet header (14 bytes).
27 packet = ETHER_BROADCAST_ADDR # Destination MAC (broadcast)
28 packet += self.server_mac_address.replace(":", "") # Source MAC
29 packet += ETH_P_ETHERCAT # EtherType (EtherCAT)
Junyu Lai32a2d152024-07-03 16:05:41 +080030
Junyu Lai6f6b1a42024-07-04 15:34:30 +080031 # EtherCAT header (2 bytes) + 44 bytes of zero padding.
32 packet += "00" * 46
33 self.send_packet_and_expect_counter_increased(
34 packet, COUNTER_DROPPED_ETHERTYPE_NOT_ALLOWED
Junyu Laicf655862024-07-04 11:09:52 +080035 )