This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] [参考译文] 【常见问题解答】AM263P4:如何阻止使用特定单播地址的以太网数据包?

Guru**** 2789645 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1611875/faq-am263p4-how-to-block-ethernet-packets-with-a-particular-unicast-address

器件型号: AM263P4

可以根据以太网数据包的数据包地址阻止或转发以太网数据包。 单播地址是用于一对一通信的特定地址类型。

CPSW 子系统中的 ALE 可以配置为根据单播地址丢弃数据包。 ALE 是一个能够实现此功能的硬件模块。 在 AM263P 器件中、可以通过调用具有正确配置的 CPSW_ALE_IOCTL_ADD_UCAST 来启用该块特性。

请参阅以下 API、其中将 ALE 配置添加到阻止来自特定单播地址的数据包。

void blockUniCast(void)
{
    CpswAle_SetUcastEntryInArgs setUcastInArgs;
    uint32_t entryIdx;
    Enet_IoctlPrms prms;
    int32_t status = ENET_SOK;
    uint8_t uniCastMacAddr[6] = {0x00, 0xe0, 0x4c, 0x32, 0x79, 0x68};

    setUcastInArgs.addr.vlanId = 0;
    setUcastInArgs.info.portNum = CPSW_ALE_HOST_PORT_NUM;
    setUcastInArgs.info.blocked = true;
    setUcastInArgs.info.secure = false;
    setUcastInArgs.info.super = false;
    setUcastInArgs.info.ageable = false;
    setUcastInArgs.info.trunk = false;

    EnetUtils_copyMacAddr(&setUcastInArgs.addr.addr[0U], &uniCastMacAddr[0]);

    ENET_IOCTL_SET_INOUT_ARGS(&prms, &setUcastInArgs, &entryIdx);

    ENET_IOCTL(gEnetApp.perCtxt[0].hEnet, gEnetApp.coreId, CPSW_ALE_IOCTL_ADD_UCAST, &prms, status);
    if (status != ENET_SOK)
    {
        printf("Failed to add ucast entry: %d\r\n", status);
    }
}

此方法也适用于 AM263 和 AM261 器件。