IPSTACK * IPSRefresh(IPSTACK * pIpStack, const LLADP * pLLAdp, IPSTATUS * pStatus) { AssignStatusSafely(pStatus, ipsSuccess); if(pIpStack == NULL) { pIpStack = IPSGetIpStackFromAdaptor(pLLAdp, ippnTCP, pStatus); } else { pIpStack = IPSSwapSrcAndDest(pIpStack); } if(pIpStack != NULL) { // the payload may have a pointer in it that we are going to clear // that pointer may or may not be from the heap; but if it is not from // the heap, the pointer will be outside of the heap ranage and be ignored // by the heap manager with no damage. if(pIpStack->fFreePayloadToAdp) { RRHPFree(pIpStack->pLLAdp->pNwAdp->hAdpHeap, pIpStack->pPayload); } pIpStack->cbPayload = 0; pIpStack->pPayload = NULL; switch(pIpStack->protocol) { case ippnUDP: pIpStack->pUDPHdr->cbHdrData = sizeof(UDPHDR); pIpStack->pUDPHdr->checksum = 0; break; case ippnTCP: pIpStack->pTCPHdr->u16Flags = 0; pIpStack->pTCPHdr->dataOffset = sizeof(TCPHDR)/sizeof(uint32_t); pIpStack->pTCPHdr->urgentPtr = 0; pIpStack->pTCPHdr->checksum = 0; break; default: break; } } return(pIpStack); }
void ICMPv4Process(IPSTACK * pIpStack) { IPv4 IpSrc; switch(pIpStack->pICMPHdr->icmpType) { case icmpTypeEcho: // We are going to resuse this inboud packet as the outbound one // RFC 792 says swap source and destination change type code // set type to reply pIpStack->pICMPHdr->icmpType = icmpTypeEchoReply; // swap source and dest IPSSwapSrcAndDest(pIpStack); // now send it // Don't care about errors ILSend(pIpStack, NULL); break; case icmpTypeEchoReply: case icmpTypeDestinationUnreachable: case icmpTypeSourceQuench: case icmpTypeRedirect: case icmpTypeTimeExceeded: case icmpTypeParameterProblem: case icmpTypeTimestamp: case icmpTypeTimestampReply: case icmpTypeInformationRequest: case icmpTypeInformationReply: default: return; } }