示例#1
0
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;
}
示例#2
0
CWBool ACEnterJoin(int WTPIndex, CWProtocolMessage *msgPtr)
{	
	int seqNum;
	CWProtocolJoinRequestValues joinRequest;
	CWList msgElemList = NULL;
	
	CWLog("\n");
	CWLog("######### Join State #########");	

	if(msgPtr == NULL) return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);
	
	if(!(CWParseJoinRequestMessage(msgPtr->msg, msgPtr->offset, &seqNum, &joinRequest))) {
		/* 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;
	}

	// cancel waitJoin timer
	if(!CWTimerCancel(&(gWTPs[WTPIndex].currentTimer)))
	{
		return CW_FALSE;
	}

	CWBool ACIpv4List = CW_FALSE;
	CWBool ACIpv6List = CW_FALSE;
	CWBool resultCode = CW_TRUE;
	int resultCodeValue = CW_PROTOCOL_SUCCESS;
	/* CWBool sessionID = CW_FALSE; */

	if(!(CWSaveJoinRequestMessage(&joinRequest, &(gWTPs[WTPIndex].WTPProtocolManager)))) {

		resultCodeValue = CW_PROTOCOL_FAILURE_RES_DEPLETION;
	}
	
	CWMsgElemData *auxData;
	if(ACIpv4List) {
		CW_CREATE_OBJECT_ERR(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL););
                auxData->type = CW_MSG_ELEMENT_AC_IPV4_LIST_CW_TYPE;
		auxData->value = 0;
		CWAddElementToList(&msgElemList,auxData);
	}
CWBool ACEnterDataCheck(int WTPIndex, CWProtocolMessage * msgPtr)
{

	/*CWProtocolMessage *messages = NULL; */
	int seqNum;
	CWProtocolChangeStateEventRequestValues *changeStateEvent;

	CWLog("\n");
	CWDebugLog("######### Status Event #########");

	/* Destroy ChangeStatePending timer */
	if (!CWErr(CWTimerCancel(&(gWTPs[WTPIndex].currentTimer)))) {

		CWCloseThread();
	}

	CW_CREATE_OBJECT_ERR(changeStateEvent,
			     CWProtocolChangeStateEventRequestValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );
void CWACStopRetransmission(int WTPIndex)
{
	if (gWTPs[WTPIndex].isRetransmitting) {
		int i;
		CWDebugLog("Stop Retransmission");
		gWTPs[WTPIndex].isRetransmitting = CW_FALSE;
		CWThreadSetSignals(SIG_BLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL);
		if (!CWTimerCancel(&(gWTPs[WTPIndex].currentPacketTimer))) {
			CWDebugLog("Error Cancelling a Timer... possible error!");
		}
		CWThreadSetSignals(SIG_UNBLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL);
		gWTPs[WTPIndex].responseType = UNUSED_MSG_TYPE;
		gWTPs[WTPIndex].responseSeqNum = 0;

		for (i = 0; i < gWTPs[WTPIndex].messagesCount; i++) {
			CW_FREE_PROTOCOL_MESSAGE(gWTPs[WTPIndex].messages[i]);
		}

		CW_FREE_OBJECT(gWTPs[WTPIndex].messages);
//      CWDebugLog("~~~~~~ End of Stop Retransmission");
	}
}
示例#5
0
CWBool ACEnterJoin(int WTPIndex, CWProtocolMessage *msgPtr)
{	
	int seqNum;
	CWProtocolJoinRequestValues joinRequest;
	memset(&joinRequest,0,sizeof(CWProtocolJoinRequestValues));
	CWList msgElemList = NULL;
	int ret = 0;
	wid_syslog_debug_debug(WID_WTPINFO,"######### WTP %d Enter Join State #########",WTPIndex);	
	if(msgPtr == NULL) {
		wid_syslog_err("wtp %d join msgPtr is NULL\n", WTPIndex);
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);
	}
	
	if(!(CWParseJoinRequestMessage(msgPtr->msg, msgPtr->offset, &seqNum, &joinRequest, WTPIndex))) {
		wid_syslog_err("parse wtp %d jion request failed\n", WTPIndex);
		return CW_FALSE;
	}

	if(!CWTimerCancel(&(gWTPs[WTPIndex].currentTimer),1))
	{
		return CW_FALSE;
	}
	
	if((find_in_wtp_list(WTPIndex) == CW_TRUE))
	{
		wid_syslog_debug_debug(WID_DEFAULT, "find wtp %d update info in updatelist\n", WTPIndex);
		if(!CWTimerCancel(&(gWTPs[WTPIndex].updateTimer),1))
		{
			wid_syslog_info("CWTimerCancel error\n");
			return CW_FALSE;
		}
	}

	CWBool ACIpv4List = CW_FALSE;
	CWBool ACIpv6List = CW_FALSE;
	CWBool resultCode = CW_TRUE;
	int resultCodeValue = CW_PROTOCOL_SUCCESS;
	//CWBool sessionID = CW_FALSE;
/*	unsigned char *mac;	
	mac = (unsigned char*)malloc(6);
	memset(mac,0,6);
	if(!(CWCheckWTPBoardData(WTPIndex, &(joinRequest.WTPBoardData), mac))){
		gWTPs[WTPIndex].currentState = CW_QUIT;
		AC_WTP[WTPIndex]->WTPStat = 0;
		memset(AC_WTP[WTPIndex]->WTPIP, 0, 128);
		free(mac);
		mac = NULL;
		return CW_TRUE;
	}	
	memcpy(AC_WTP[WTPIndex]->WTPMAC, mac, 6);
	free(mac);
	mac = NULL;*/
	if(!(CWSaveJoinRequestMessage(&joinRequest,&(gWTPs[WTPIndex].WTPProtocolManager),WTPIndex))) 
	{
		resultCodeValue = CW_PROTOCOL_FAILURE_RES_DEPLETION;
	}
	
	CWMsgElemData *auxData;
	if(ACIpv4List) {
		CW_CREATE_OBJECT_ERR_WID(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL););
		auxData->type = CW_MSG_ELEMENT_AC_IPV4_LIST_CW_TYPE;
		auxData->value = 0;
		CWAddElementToList(&msgElemList,auxData);
	}