#include "p_apps.h"
#include "v_task.h"
#include "autoprov.h"

//211.95.122.249

#ifndef OEM_NET2PHONE 

#ifdef OEM_POLYLINK
static CCHAR _cCodeUsername[] = "123";
static CCHAR _cCodePassword[] = "123";
#elif defined OEM_MOBITAI
static CCHAR _cCodeUsername[] = "voip";
static CCHAR _cCodePassword[] = "voip9876";
#elif defined OEM_IPN
static CCHAR _cCodeUsername[] = "ftp.19909.net";
static CCHAR _cCodePassword[] = "19909.net";
//static CCHAR _cCodeUsername[] = "webmaster@zheren.com";
//static CCHAR _cCodePassword[] = "zhangn";
//static CCHAR _cCodeUsername[] = "anonymous";
//static CCHAR _cCodePassword[] = "anonymous";
//*****VIDA CHANGED*****//
#elif defined VER_IPH_E00
static XCHAR _cCodeUsername[] = "00-09-45-10-00-00";
static XCHAR _cCodePassword[] = "aabbccddeeff";
#else
static CCHAR _cCodeUsername[] = "anonymous";
static CCHAR _cCodePassword[] = "anonymous";
#endif

static CCHAR _cCodeUSER[] = "USER";
static CCHAR _cCodePASS[] = "PASS";
static CCHAR _cCodePORT[] = "PORT";
static CCHAR _cCodeRETR[] = "RETR";
static CCHAR _cCodeTYPE[] = "TYPE";
static CCHAR _cCodeQUIT[] = "QUIT";
static CCHAR _cCodePASV[] = "PASV";

#define FTP_CONN_OK		0
#define FTP_USER_CMD	1
#define FTP_PASS_CMD	2
#define FTP_TYPE_CMD	3
#define FTP_PORT_CMD	4
#define FTP_RETR_CMD	5
#define FTP_QUIT_CMD	6
#define FTP_PASV_CMD	7

#define FTP_TIME_OUT	15

#define FTP_TASK_NONE		0
#define FTP_TASK_PASV		1	// send PASV command
#define FTP_TASK_QUIT		2	// send QUIT command
#define FTP_TASK_DATA		3	// OPEN data TCP connection

static XCHAR _iSendLength;
static XCHAR _iLastReqType;
static XSHORT _iReplyCode;
static XSHORT _iLocalDataPort;
static XSHORT _iServerPort;

static BOOLEAN _bCtrlFinished;
static BOOLEAN _bDataFinished;
static BOOLEAN _bMultiLine;
static BOOLEAN _bLogin;
static BOOLEAN _bNeedUpgrade;

static XCHAR _iExtraTask;

// xxx,xxx,xxx,xxx,xx,xx
PXCHAR _GetFtpIPPort()
{
	DCHAR i;
	PXCHAR_D pCur;

	pCur = (PXCHAR)Sdram_pDataCache;
	pCur[0] = 0;
	for (i = 0; i < IP_ALEN; i ++)
	{
		p_itoa(Local_pIPAddress[i], (PXCHAR)(pCur + p_strlen_x(pCur)), 10);
		p_strcat_char2x(pCur, ',');
	}

	p_itoa(((_iLocalDataPort>>8) & 0xff), (PXCHAR)(pCur + p_strlen_x(pCur)), 10);
	p_strcat_char2x(pCur, ',');
	p_itoa((_iLocalDataPort & 0xff), (PXCHAR)(pCur + p_strlen_x(pCur)), 10);

	return pCur;
}


UCHAR _GetLineLen(PXCHAR pData)
{
	DCHAR iLen;

	iLen = 0;
	while (pData[iLen] != 0x0a && pData[iLen] != 0x0d)
	{
		iLen ++;
	}
	if ((pData[iLen] == 0x0d && pData[iLen+1] == 0x0a) 
		|| (pData[iLen] == 0x0a && pData[iLen+1] == 0x0d))
	{
		iLen += 2;
	}
	else
	{
		iLen ++;
	}
	return iLen;
}

void _FindMultiLineEnd(PXCHAR pData, UCHAR iTotalLen)
{
	PXCHAR_D pCur;
	DCHAR iLineLen, iLen;

	if (!iTotalLen)	return;
	pCur = pData;
	iLen = 0;
	while (iLen < iTotalLen)
	{
		if (pCur[3] == ' ' && p_atoi(pCur, 10) == _iReplyCode)
		{
			_bMultiLine = FALSE;
			return;
		}
		iLineLen = _GetLineLen(pCur);
		pCur += iLineLen;
		iLen += iLineLen;
	}
}

void _SendFtpReq(PCCHAR pCmd, PXCHAR pString, UCHAR iType)
{
	PXCHAR_D pData;

	pData = (PXCHAR)Adapter_pSendTcpData;
	_iLastReqType = iType;

	p_strcpy_c2x(pData, pCmd);
	if (pString)
	{
		p_strcat_char2x(pData, ' ');
		p_strcat_x2x(pData, pString);
	}
	p_strcat_c2x(pData, (PCCHAR)"\r\n");
	_iSendLength = p_strlen_x(pData);
}

void _SendFtpReq_c(PCCHAR pCmd, PCCHAR pString, UCHAR iType)
{
	p_strcpy_c2x((PXCHAR)Sdram_pDataCache, pString);
	_SendFtpReq(pCmd, (PXCHAR)Sdram_pDataCache, iType);
}

void _SendFtpReqRetr()
{
	SdramReadData(OPTIONS_SDRAM_POS+UPGRADE_FILENAME_LO);
	_SendFtpReq(_cCodeRETR, (PXCHAR)Sdram_pDataCache, FTP_RETR_CMD);
}

void _SendFtpReqQuit()
{
	_SendFtpReq(_cCodeQUIT, (PXCHAR)0, FTP_QUIT_CMD);
	_bLogin = FALSE;
}

#ifdef	VER_IPH_E00
void _FTPChkSum(PXCHAR pChkSum)
{
	DSHORT i;
	DCHAR j,k;
	DCHAR iTmp[4] = {0,0,0,0};

	DCHAR iLen;
	DCHAR iMaxLen;

	BOOLEAN bSkip;
	BOOLEAN bStr;

	DCHAR iPos;
//	XCHAR pChkSum[8];

	SdramReadOptions();
	for (i = 0, j = 0; i < 512; i++)
	{
		//skip the values without calculate
		bSkip = ((i<OPTIONS_DDA_ADDR) ||		//0x00-0x09
			     (i==OPTIONS_RING_TYPE) ||		//0x0f
			     ((i>=OPTIONS_SUBNET_MASK)&&(i<OPTIONS_DSP_OPTION)) ||	//0x20-0x2a
			     ((i>=OPTIONS_DNS_ADDR)&&(i<OPTIONS_JITTER_SIZE)) ||		//0x2c-0x2f
			     ((i>=OPTIONS_HANDFREE_OUTPUT)&&(i<OPTIONS_AUDIO_FRAMES)) ||		//0x33-0x34
			     ((i>=OPTIONS_DNS_ADDR2)&&(i<OPTIONS_NAT_TRAVERSAL)) ||	//0x3b-0x3e
			     ((i>=OPTIONS_REALTIME)&&(i<OPTIONS_CALL_TYPE)) ||		//0x42-0x45
			     ((i>=OPTIONS_PASSWORD)&&(i<OPTIONS_COUNTRY_CODE)) ||	//0x48-0x57
			     ((i>=OPTIONS_PIN)&&(i<OPTIONS_RAS_PORT))||				//0x6e-0xef
			  // ((i>OPTION_VIDA_ACTIVATION_HI)&&(i<OPTIONS_OUTPUT_DEBUG))||				//0xfc-0xfd
			     ((i>OPTIONS_USE_DIGITMAP)&&(i<OPTIONS_CODEC_TYPE))||	//0x100-0x11f
			     ((i>=0x125)&&(i<OPTIONS_SUPER_PASSWORD))||  //0x125-0x12f
			     ((i>=OPTIONS_FWD_NUMBER)&&(i<OPTIONS_FWD_TYPE))||		//0x140-0x157
			     ((i>=OPTIONS_PROGRAM_BUTTONS)&&(i<OPTIONS_RTP_TOS))||		//0x159-0x15d
			  // (i==0x160) ||		//0x160
			     ((i>=OPTIONS_TIME_ZONE)&&(i<OPTIONS_SYS_TEST)));				//0x162-0x166

		//calculate correct len with string values
		switch(i)
		{
		case OPTIONS_PHONE_NUMBER:		//0x10
			iMaxLen = PHONE_NUMBER_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_COUNTRY_CODE:	//0x58
			iMaxLen = MAX_COUNTRY_CODE_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_INTL_PREFIX:	//0x5c
			iMaxLen = MAX_INTL_PREFIX_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_AREA_CODE:		//0x60
			iMaxLen = MAX_AREA_CODE_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_LONG_PREFIX:	//0x64
			iMaxLen = MAX_LONG_PREFIX_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_DUALMODE_PREFIX:	//0x69
			iMaxLen = MAX_DUALMODE_PREFIX_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_INNERLINE_PREFIX:	//0x6b
			iMaxLen = MAX_INNERLINE_PREFIX_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_SUPER_PASSWORD://0x130
			iMaxLen = MAX_SUPERPASSWORD_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_DIAL_NUMBER:	//0x170
			iMaxLen = DIAL_NUMBER_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_SERVICE_ID:	//0x180
			iMaxLen = MAX_SERVICE_ID_LEN;
			bStr = TRUE;
			break;
		case OPTIONS_SERVICE_DNS:	//0x1a0
		case OPTIONS_UPGRADE_DNS:	//0x1c0				
		case OPTIONS_NAT_DNS:		//0x1e0
			iMaxLen = MAX_DNS_ADDR_LEN;
			bStr = TRUE;
			break;
		default:
			bStr = FALSE;
			break;
		}

			
		 if(!bSkip)							
		 {
		 	if(bStr)
		 	{
				iLen=p_strlen_x((PXCHAR)(Sdram_pDataCache+i));
				
				for(k = 0;k < iMaxLen; k++)
				{
					if(k<iLen)
					{
						iTmp[j%4]+=X_VAL(Sdram_pDataCache, i);
					}
					i++;
					j++;
				}
				i--;
			}
			else
			{
				iTmp[j%4]+=X_VAL(Sdram_pDataCache, i);
				j++;
			}
		 }
	}
	
	for (i = 0, iPos = 0; i < 4; i ++)
	{
		if (iTmp[i] < 0x10)
		{
			pChkSum[iPos] = '0';
			iPos ++;
			p_itoa(iTmp[i], (PXCHAR)(pChkSum+iPos), 16);
			iPos ++;
		}
		else
		{
			p_itoa(iTmp[i], (PXCHAR)(pChkSum+iPos), 16);
			iPos += 2;
		}
	}		 

	p_memcpy_x2x_0(Sys_pPin, (PXCHAR)(Sdram_pDataCache+OPTIONS_PIN), MAX_PIN_LEN);
	p_strcat_x2x(pChkSum,Sys_pPin);

}
#endif

void _FtpFailed()
{
	if (_bLogin)
	{
		_SendFtpReqQuit();
	}

	DisplayString(g_cFailed, 1);
	OutputString(IDS_FTP_CLOSE);
	TcpClose(FTP_CTRL_SDRAM_LO);
}

void _RunFtpControl()
{
	DCHAR i, iLen;
	PXCHAR_D pCur;
	XCHAR pServerIP[IP_ALEN];
	ULONG lFileSize;

	// data in Adapter_pReceiveTcpData, data length in Adapter_iReceiveLen;
	pCur = (PXCHAR)Adapter_pReceiveTcpData;
	if (_bMultiLine)
	{
		_FindMultiLineEnd(pCur, (UCHAR)Adapter_iReceiveLen);
	}
	else
	{
		if (pCur[3] == '-')
		{
			_bMultiLine = TRUE;
			_iReplyCode = p_atoi(pCur, 10);
			iLen = _GetLineLen(pCur);
			pCur += iLen;
			_FindMultiLineEnd(pCur, (UCHAR)(Adapter_iReceiveLen - iLen));
		}
		else if (pCur[3] == ' ')
		{
			_iReplyCode = p_atoi(pCur, 10);
		}
		else
		{
			return;
		}
	}

	if (_bMultiLine)	return;

	switch(_iLastReqType)
	{
	case FTP_CONN_OK:
		switch (_iReplyCode)
		{
		case 220:
#ifdef VER_IPH_E00
			p_Mac2String(Local_pMacAddress, (PXCHAR)_cCodeUsername);
			_SendFtpReq(_cCodeUSER, _cCodeUsername, FTP_USER_CMD);
#else
			_SendFtpReq_c(_cCodeUSER, _cCodeUsername, FTP_USER_CMD);
#endif
		break;

		case 421:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_USER_CMD:
		switch (_iReplyCode)
		{
		case 230:
			_bLogin = TRUE;
			_SendFtpReq_c(_cCodeTYPE, (PCCHAR)"I", FTP_TYPE_CMD);
			break;

		case 331:
		case 332:
#ifdef VER_IPH_E00
			_FTPChkSum((PXCHAR)_cCodePassword);
			_SendFtpReq(_cCodePASS, _cCodePassword, FTP_PASS_CMD);
#else
			_SendFtpReq_c(_cCodePASS, _cCodePassword, FTP_PASS_CMD);
#endif
			break;

		case 530:
		case 500:
		case 501:
		case 421:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_PASS_CMD:
		switch (_iReplyCode)
		{
		case 202:
		case 230:
			_bLogin = TRUE;
			_SendFtpReq_c(_cCodeTYPE, (PCCHAR)"I", FTP_TYPE_CMD);
			break;

		case 530:
		case 500:
		case 501:
		case 503:
		case 421:
		case 332:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_TYPE_CMD:
		switch (_iReplyCode)
		{
		case 200:
			_SendFtpReq(_cCodePASV, (PXCHAR)0, FTP_PASV_CMD);
			break;

		case 500:
		case 501:
		case 504:
		case 421:
		case 530:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_PORT_CMD:
		switch (_iReplyCode)
		{
		case 200:
			_SendFtpReqRetr();
			break;

		case 500:
		case 501:
		case 421:
		case 530:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_RETR_CMD:
		switch (_iReplyCode)
		{
		case 150:
			OutputString(IDS_FTP_START_DATA);		
			if (Upgrade_iType != UPGRADE_GET_SET)
			{
//				pCur = p_strchr_x((PXCHAR)Adapter_pReceiveTcpData, (UCHAR)'(');
//				pCur ++;
//				SoloFileSetLimit(p_atol((PXCHAR)pCur, 10));
				pCur = p_strchr_x((PXCHAR)Adapter_pReceiveTcpData, (UCHAR)'(');
				if (pCur)
				{
					pCur ++;
					lFileSize = p_atol((PXCHAR)pCur, 10);
					if (lFileSize)
					{
						SoloFileSetLimit(lFileSize);
					}
					else
					{
						SoloFileSetLimit(FILE_WRITE_MAX_SIZE);
					}
				}
				else
				{
					SoloFileSetLimit(FILE_WRITE_MAX_SIZE);
				}
			}
		break;

		case 226:
		case 250:
			OutputString(IDS_FTP_FINISH_DATA);
			_bCtrlFinished = TRUE;
			break;

		case 425:
		case 426:
		case 451:
		case 450:
		case 550:
		case 500:
		case 501:
		case 421:
		case 530:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_QUIT_CMD:
		switch (_iReplyCode)
		{
		case 221:
			OutputString(IDS_FTP_CLOSE);
			TcpClose(FTP_CTRL_SDRAM_LO);
			break;

		case 500:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}
		break;

	case FTP_PASV_CMD:
		switch (_iReplyCode)
		{
		case 227:
			pCur = (PXCHAR)Adapter_pReceiveTcpData;
			pCur = p_strchr_x(pCur, '(');
			pCur ++;
			for (i = 0; i < IP_ALEN; i ++)
			{
				pServerIP[i] = (UCHAR)p_atoi(pCur, 10);
				pCur = p_strchr_x(pCur, ',');
				pCur ++;
			}

			if (p_memcmp_x2x(pServerIP, Upgrade_pServerIP, IP_ALEN))
			{
				OutputString(IDS_FTP_SERVER_UNMATCH);
			}
			_iServerPort = (UCHAR)p_atoi(pCur, 10) * 256;
			pCur = p_strchr_x(pCur, ',');
			pCur ++;
			_iServerPort += (UCHAR)p_atoi(pCur, 10);

			_SendFtpReqRetr();
			_iExtraTask = FTP_TASK_DATA;
			break;

		case 500:
		case 501:
		case 502:
		case 530:
			_SendFtpReq(_cCodePORT, _GetFtpIPPort(), FTP_PORT_CMD);
			break;

		case 421:
			OutputVal(_iReplyCode, IDS_FTP_ERROR_RESPONSE);
			_FtpFailed();
			break;
		}		
		break;
	}
}

void _RunFtpData()
{
	PXCHAR_D pCur;

	// data in Adapter_pReceiveTcpData, data length in Adapter_iReceiveLen;
	OutputString(IDS_FTP_GET_FILE);
	pCur = (PXCHAR)Adapter_pReceiveTcpData;
	
	while (Adapter_iReceiveLen >= 256)
	{
		SoloFileWrite(pCur, (UCHAR)256);
		pCur += 256;
		Adapter_iReceiveLen -= 256;
	}
	if (Adapter_iReceiveLen)
	{
		SoloFileWrite(pCur, (UCHAR)Adapter_iReceiveLen);
	}

	DisplayFileStatus();
}

void _FtpSendPasv()
{
	if (TcbClosed(FTP_CTRL_SDRAM_LO))	return;
	if (!TcbAcked())	return;

	_SendFtpReq(_cCodePASV, (PXCHAR)0, FTP_PASV_CMD);
	TcpSend(_iSendLength);
	_iSendLength = 0;
	_iExtraTask = FTP_TASK_NONE;
}

void _FtpSendQuit()
{
	if (TcbClosed(FTP_CTRL_SDRAM_LO))	return;
	if (!TcbAcked())	return;

	_SendFtpReqQuit();
	TcpSend(_iSendLength);
	_iSendLength = 0;
	_iExtraTask = FTP_TASK_NONE;
}

void _FtpClosed()
{
	if (_bNeedUpgrade)
	{
		ProvStartUpgrade();
	}
	else
	{
		CloseFileAndCheckLimit();
	}
}

void _DataTcbInit()
{
	_iLocalDataPort = (USHORT)(FTP_SRC_PORT + p_rand_char());
	TcbInit(_iLocalDataPort, FTP_TIME_OUT, FTP_DATA_SDRAM_LO);		// Ftp Data
}

void FtpInitialize()
{
	// TCP Init
	TcbInit((USHORT)FTP_SRC_PORT, 0, FTP_CTRL_SDRAM_LO);			// Ftp Control
	_DataTcbInit();

	_bDataFinished = FALSE;
	_bCtrlFinished = FALSE;
	_bLogin = FALSE;
	_bNeedUpgrade = FALSE;
	_bMultiLine = FALSE;

	_iSendLength = 0;
	_iExtraTask = FTP_TASK_NONE;
}

BOOLEAN FtpControlRun()
{
	if (!TcbRun(FTP_CTRL_SDRAM_LO))	return FALSE;

/*	accept event will not come as you are connecting server in your side
	if (Tcp_bAcceptEvent)
	{
		Tcp_bAcceptEvent = FALSE;
	}
*/
	if (Tcp_bConnectEvent)
	{
		// handle connect event here
		_iLastReqType = FTP_CONN_OK;
		Tcp_bConnectEvent = FALSE;
		OutputString(IDS_FTP_CONNECT);
	}

    if (Tcp_bDataEvent)
    {
		// Handle user messages here
		_RunFtpControl();
		Tcp_bDataEvent = FALSE;
    }

    if (Tcp_bCloseEvent)
    {
		OutputString(IDS_FTP_CLOSE);
		TcpClose(FTP_CTRL_SDRAM_LO);
	}

	TcpSend(_iSendLength);	// change 0 to output data length if you need to send data out in _RunFtp
	_iSendLength = 0;

	if (_iExtraTask == FTP_TASK_DATA)
	{
		TcpOpen(Upgrade_pServerIP, _iServerPort, FTP_DATA_SDRAM_LO);
		_iExtraTask = FTP_TASK_NONE;
	}

	if (TcbAcked() && _iExtraTask && _bCtrlFinished)
	{
		// Handle the extra data.
		switch (_iExtraTask)
		{
		case FTP_TASK_PASV:
			_FtpSendPasv();
			break;

		case FTP_TASK_QUIT:
			_FtpSendQuit();
			break;
		}
		_bCtrlFinished = FALSE;
	}

    if (Tcp_bCloseEvent)
    {
		Tcp_bCloseEvent = FALSE;
		_FtpClosed();
	}

	if (Tcp_bResetEvent)
	{
		_FtpClosed();
		Tcp_bResetEvent = FALSE;
	}

	return TRUE;
}

BOOLEAN FtpDataRun()
{
	BOOLEAN bQuit;


	if (!TcbRun(FTP_DATA_SDRAM_LO))	return FALSE;

	if (Tcp_bAcceptEvent)
	{
		Tcp_bAcceptEvent = FALSE;
	}

	if (Tcp_bConnectEvent)
	{
		// handle connect event here
		OutputString(IDS_FTP_DATA_CONNECT);
		Tcp_bConnectEvent = FALSE;

		CreateUpgradeFile();
	}

    if (Tcp_bDataEvent)
    {
		// Handle user messages here
		_RunFtpData();
		Tcp_bDataEvent = FALSE;
    }

    if (Tcp_bCloseEvent)
    {
		OutputString(IDS_FTP_DATA_CLOSE);
		TcpClose(FTP_DATA_SDRAM_LO);
		_bDataFinished = TRUE;
	}

	TcpSend(0);	// change 0 to output data length if you need to send data out in _RunFtp

	if (_bDataFinished)
	{
		SoloFileClose();
		bQuit = TRUE;
		if (Upgrade_iType == UPGRADE_GET_SET)
		{
			ProvHandleSetFile();
			if (Upgrade_iType != UPGRADE_GET_SET)
				bQuit = FALSE;
		}
		else
		{
			_bNeedUpgrade = TRUE;
		}
		if (_bCtrlFinished)
		{
			if (bQuit)
			{
				_FtpSendQuit();
			}
			else
			{
				_FtpSendPasv();
			}
			_bCtrlFinished = FALSE;
		}
		else
		{
			if (bQuit)
			{
				_iExtraTask = FTP_TASK_QUIT;
			}
			else
			{
				_iExtraTask = FTP_TASK_PASV;
			}
		}
		_bDataFinished = FALSE;
	}

	if (Tcp_bCloseEvent)
	{
		_DataTcbInit();
		Tcp_bCloseEvent = FALSE;
	}
	if (Tcp_bResetEvent)
	{
		CloseFileAndCheckLimit();
		Tcp_bResetEvent = FALSE;
	}

	return TRUE;
}

void FtpControlHandleTimer()
{
	if (TcbHandleTimer(FTP_CTRL_SDRAM_LO))
	{
		return;
	}

	OutputString(IDS_FTP_TIME_FAILED);
	_FtpClosed();
}

void FtpDataHandleTimer()
{
	if (TcbHandleTimer(FTP_DATA_SDRAM_LO))
	{
		return;
	}

	OutputString(IDS_FTP_DATA_TIME_FAILED);
	_FtpClosed();
}

void FtpUpgrade(UCHAR iType)
{
	Upgrade_iType = iType;
	ProvGetFileName();
	TcpOpen(Upgrade_pServerIP, FTP_SERVER_PORT, FTP_CTRL_SDRAM_LO);
}

#endif


