In the function prvAllowIPPacketIPv4(), why is it that we are checking for broadcast Source IPv4 address when endpoint is up

I just downloaded the FreeRTOS-Plus-TCP source code from github: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP for comparing with the one I am using.
I saw that in prvAllowIPPacketIPv4() function in FreeRTOS_IPv4.c, you are checking for source IP address to be Broadcast address only when endpoint is up.

else if( FreeRTOS_IsEndPointUp( pxEndPoint ) != pdFALSE )
        {
            if(
                /* Not destined for the assigned endpoint IPv4 address? */
                ( ulDestinationIPAddress != pxEndPoint->ipv4_settings.ulIPAddress ) &&
                /* Also not an IPv4 broadcast address ? */
                ( ulDestinationIPAddress != pxEndPoint->ipv4_settings.ulBroadcastAddress ) &&
                ( ulDestinationIPAddress != FREERTOS_INADDR_BROADCAST ) &&
                /* And not an IPv4 multicast address ? */
                ( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) )
            {
                /* Packet is not for this node, release it */
                eReturn = eReleaseBuffer;
            }
            /* Is the source address correct? */
            else if( ( ulSourceIPAddress == pxEndPoint->ipv4_settings.ulBroadcastAddress ) ||
                     ( ulSourceIPAddress == FREERTOS_INADDR_BROADCAST ) )
            

So, I just came here to ask out of curiosity as to why write there, it could also be written before that else if statement.

It could be because you only know the broadcast address once you have a network defined and configured, because it is computed from the network and mask.

@Raghav

As @richard-damon mentioned, the ipv4_settings of the endpoint are correctly configured only after the endpoint is up. The network packets could arrive even before the endpoint is up, for example, the hardware unicast DHCP datagrams. This change was done as part of this PR: 1232.

The PR makes the TCP/IP complaint with RFC 2131 by accepting and forwarding to the IP layer any IP packets delivered to the client’s hardware address before the IP address is configured.