static bool SendNextIpStack(void) { // get the next stack to send if we have one if (wfmrf24.priv.pIpStackBeingTx == NULL) { wfmrf24.priv.pIpStackBeingTx = FFOutPacket(&wfmrf24.priv.ffptWrite); } // try and send it. if (wfmrf24.priv.pIpStackBeingTx != NULL) { IPSTACK * pIPStack = wfmrf24.priv.pIpStackBeingTx; int16_t cbTotal = pIPStack->cbFrame + pIPStack->cbIPHeader + pIPStack->cbTranportHeader + pIPStack->cbPayload; if (WF_TxPacketAllocate(cbTotal)) { // always have a frame, alwasy FRAME II (we don't support 802.3 outgoing frames; this is typical) WF_TxPacketCopy((uint8_t *) pIPStack->pFrameII, pIPStack->cbFrame); // IP Header if (pIPStack->cbIPHeader > 0) { WF_TxPacketCopy((uint8_t *) pIPStack->pIPHeader, pIPStack->cbIPHeader); } // Transport Header (TCP/UDP) if (pIPStack->cbTranportHeader > 0) { WF_TxPacketCopy((uint8_t *) pIPStack->pTransportHeader, pIPStack->cbTranportHeader); } // Payload / ARP / ICMP if (pIPStack->cbPayload > 0) { WF_TxPacketCopy((uint8_t *) pIPStack->pPayload, pIPStack->cbPayload); } // transmit WF_TxPacketTransmit(cbTotal); // we sent it, clean up pIPStack->fOwnedByAdp = false; IPSRelease(pIPStack); wfmrf24.priv.pIpStackBeingTx = NULL; return(true); } else { return(false); } } return(true); }
static IPSTACK * Read(IPSTATUS * pStatus) { IPSTACK * pIpStack = FFOutPacket(&wfmrf24.priv.ffptRead); if (pIpStack != NULL) { pIpStack->fOwnedByAdp = false; } AssignStatusSafely(pStatus, ipsSuccess); return(pIpStack); }
/*** void TCPServer::close(void) ** ** Synopsis: ** Stops Listening and closes all unaccepted sockets/connections ** and clears everything back to it's originally constructed state. ** ** Parameters: ** None ** ** Return Values: ** None ** ** Errors: ** None ** ** Notes: ** ** Returns the TCPServer instance to ** a state just as if the instance had just been ** constructed. It also, Close all connections ** and releases all resources (sockets). ** */ void TCPServer::close(void) { FFLL * pffll = NULL; // pull this off the listening list FFRemove(&_ffptPeriodTask, &_ffptInfo); // close and sockets added to the server while((pffll = (FFLL *) FFOutPacket(&_ffptSockets)) != NULL) { ((TCPSocket *) (pffll->_this))->close(); } clear(); }