NetDev_AddrMulticastRemove()
The next API function is the AddrMulticastRemove()
function used to remove an (IP-to-Ethernet) multicast hardware address from a device.
Files
Every device driver’s net_dev.c
Prototype
...
Code Block |
---|
static void NetDev_AddrMulticastRemove (NET_IF *p_if,
CPU_INT08U *p_addr_hw,
CPU_INT08U addr_hw_len,
NET_ERR *p_err); |
Note that since every device driver’s AddrMulticastRemove()
function is accessed only by function pointer via the device driver’s API structure, it doesn’t need to be globally available and should therefore be declared as ‘static
’.
Arguments
p_if
Pointer to the interface to remove a multicast address.
...
Pointer to variable that will receive the return error code from this function.
Returned Value
None.
Required Configuration
Necessary only if if NET_MCAST_CFG_IPv4_RX_EN or NET_IPMCAST_CFG_MULTICAST_SELIPv4_TX_EN is configured for transmit and receive multicasting (see section D-9-2).
Notes / Warnings
Use same exact code as in NetDev_AddrMulticastAdd()
to calculate the device’s CRC hash (see section B-1-6 NetDev_MgmtDemux()), but remove a multicast address by decrementing the device’s hash bit reference counters and clearing the appropriate bits in the device’s multicast registers.
...
Code Block |
---|
/* ---------- CALCULATE HASH CODE ---------- */
/* Use NetDev_AddrMulticastAdd()'s algorithm to calculate CRC hash. */
/* - REMOVE MULTICAST ADDRESS FROM DEVICE -- */
paddr_hash_ctrs = &pdev_data->MulticastAddrHashBitCtr[hash];
if (*paddr_hash_ctrs > 1u) { /* If multiple multicast addresses hashed, ..*/
(*paddr_hash_ctrs)--; /* .. decrement hash bit reference counter ..*/
*perr = NET_DEV_ERR_NONE; /* .. but do NOT unconfigure hash register. */
return;
}
*paddr_hash_ctrs = 0u; /* Clear hash bit reference counter. */
if (hash <= 31u) { /* Clear multicast hash register bit. */
pdev->MCAST_REG_LO &= ~(1u << reg_bit); /* (Substitute 'MCAST_REG_LO/HI' with .. */
} else { /* .. device's actual multicast registers.) */
pdev->MCAST_REG_HI &= ~(1u << reg_bit);
} |