CWBool CWACSendFragments(int WTPIndex) { int i; if (gWTPs[WTPIndex].messages == NULL) return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL); for (i = 0; i < gWTPs[WTPIndex].messagesCount; i++) { #ifdef CW_NO_DTLS if (!CWNetworkSendUnsafeUnconnected(gWTPs[WTPIndex].socket, &gWTPs[WTPIndex].address, gWTPs[WTPIndex].messages[i].msg, gWTPs[WTPIndex].messages[i].offset)) { #else if (! (CWSecuritySend (gWTPs[WTPIndex].session, gWTPs[WTPIndex].messages[i].msg, gWTPs[WTPIndex].messages[i].offset))) { #endif return CW_FALSE; } } /* * BUG - ML12 * * 20/10/2009 - Donato Capitella */ CW_FREE_WTP_MSG_ARRAY(WTPIndex); CWLog("Message Sent\n"); return CW_TRUE; } CWBool CWACResendAcknowledgedPacket(int WTPIndex) { if (!CWACSendFragments(WTPIndex)) return CW_FALSE; CWThreadSetSignals(SIG_BLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL); if (! (CWTimerRequest (gCWRetransmitTimer, &(gWTPs[WTPIndex].thread), &(gWTPs[WTPIndex].currentPacketTimer), CW_SOFT_TIMER_EXPIRED_SIGNAL))) { return CW_FALSE; } CWThreadSetSignals(SIG_UNBLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL); return CW_TRUE; } __inline__ CWBool CWACSendAcknowledgedPacket(int WTPIndex, int msgType, int seqNum) { gWTPs[WTPIndex].retransmissionCount = 0; gWTPs[WTPIndex].isRetransmitting = CW_TRUE; gWTPs[WTPIndex].responseType = msgType; gWTPs[WTPIndex].responseSeqNum = seqNum; // CWDebugLog("~~~~~~seq num in Send: %d~~~~~~", gWTPs[WTPIndex].responseSeqNum); return CWACResendAcknowledgedPacket(WTPIndex); }
CWBool ACEnterConfigure(int WTPIndex, CWProtocolMessage *msgPtr) { int seqNum; CWProtocolConfigureRequestValues configureRequest; CWLog("\n"); CWLog("######### Configure State #########"); if(!(CWParseConfigureRequestMessage(msgPtr->msg, msgPtr->offset, &seqNum, &configureRequest))) { /* note: we can kill our thread in case of out-of-memory * error to free some space. * we can see this just calling CWErrorGetLastErrorCode() */ return CW_FALSE; } CWLog("Configure Request Received"); if(!(CWSaveConfigureRequestMessage(&configureRequest, &(gWTPs[WTPIndex].WTPProtocolManager)))){ return CW_FALSE; } if(!(CWAssembleConfigureResponse(&(gWTPs[WTPIndex].messages), &(gWTPs[WTPIndex].messagesCount), gWTPs[WTPIndex].pathMTU, seqNum))) { return CW_FALSE; } if(!CWACSendFragments(WTPIndex)) { return CW_FALSE; } CWLog("Configure Response Sent"); /* Destroy ConfigStatePending timer */ if(!CWErr(CWTimerCancel(&(gWTPs[WTPIndex].currentTimer)))) { CWLog("%s %d [%d] CWTimerCancel Fail, close thread!",__FILE__,__LINE__,WTPIndex); //CWCloseThread(); gWTPs[WTPIndex].isRequestClose = CW_TRUE; return CW_FALSE; } /* start Change State Pending timer */ if(!CWErr(CWTimerRequest(gCWChangeStatePendingTimer, &(gWTPs[WTPIndex].thread), &(gWTPs[WTPIndex].currentTimer), CW_CRITICAL_TIMER_EXPIRED_SIGNAL))) { CWLog("%s %d [%d] CWTimerRequest Fail, close thread!",__FILE__,__LINE__,WTPIndex); //CWCloseThread(); gWTPs[WTPIndex].isRequestClose = CW_TRUE; return CW_FALSE; } //CWLog("CWTimerRequest Success !!!"); gWTPs[WTPIndex].currentState = CW_ENTER_DATA_CHECK; return CW_TRUE; }