/** * ARP FSM is executed. * @preCondition ARP packet is ready in MAC buffer. * @return */ BOOL ARPProcess(void) { NODE_INFO remoteNode; BYTE opCode; //If a valid ARP packet addressed to us was received, true is returned and //opcode (ARP_REPLY or ARP_REQUEST) is writen to given opCode buffer. switch(smARP) { case SM_ARP_IDLE: if ( !ARPGet(&remoteNode, &opCode) ) break; if ( opCode == ARP_REPLY ) //We have received an ARP reply resolving a requested IP address's MAC address { #ifdef STACK_CLIENT_MODE Cache.MACAddr = remoteNode.MACAddr; Cache.IPAddr.Val = remoteNode.IPAddr.Val; #endif break; } else smARP = SM_ARP_REPLY; default: if(ARPPut(&remoteNode, ARP_REPLY)) { smARP = SM_ARP_IDLE; } else return FALSE; break; } return TRUE; }
/********************************************************************* * Function: BOOL ARPProcess(void) * * PreCondition: ARP packet is ready in MAC buffer. * * Input: None * * Output: ARP FSM is executed. * * Side Effects: None * * Overview: None * * Note: None ********************************************************************/ BOOL ARPProcess(void) { NODE_INFO remoteNode; BYTE opCode; switch(smARP) { case SM_ARP_IDLE: if ( !ARPGet(&remoteNode, &opCode) ) break; if ( opCode == ARP_REPLY ) { #ifdef STACK_CLIENT_MODE Cache.MACAddr = remoteNode.MACAddr; Cache.IPAddr.Val = remoteNode.IPAddr.Val; #endif break; } else smARP = SM_ARP_REPLY; default: if(ARPPut(&remoteNode, ARP_REPLY)) { smARP = SM_ARP_IDLE; } else return FALSE; break; } return TRUE; }