#include "page0.h"
#include "v_task.h"

void TaskInitialize()                   
{
	UpgradeInitialize();
	TelnetInitialize();
}

void TaskSignalMsg(UCHAR iType)
{
	switch (iType)
	{
	case SIGNAL_IP_CONFLICT:
		DisplayString(g_cDuplicatedIP, 0);
		SysSleep(5000000);
		break;
	}
}

void OnLogoff()
{
}

void TaskHandleTimer()
{
	UpgradeHandleTimer();
	TelnetHandleTimer();
}

void TaskDnsCompleted()				
{
}
			
void TaskDnsFailed()				
{
}
			
void TaskWaitPacket()
{
	SysSleep(256 + p_rand_char());
//	SysSleep(p_rand()&1023);
}

void TaskSendPacket(USHORT iLen, PXCHAR pPacket)
{
	Ne2000Send(iLen, pPacket);
}

BOOLEAN TaskRunTcp()
{
	if (UpgradeRun())		return TRUE;
	if (TelnetRun())		return TRUE;
	return FALSE;
}

BOOLEAN TaskRunUdp()
{
    if (Adapter_iReceiveUdpPort == UDP_TEST_SRC_PORT)
    {
		UdpTestRun();
	}
	else if (Adapter_iReceiveUdpPort == UDP_DEBUG_SRC_PORT)
    {
		ReportRun();
	}
	else
	{	// Unknown udp data, ignore
		return FALSE;
	}
	return TRUE;
}

