UDPProcess 由 StackTesk.C 的 StackTask(void) 呼叫 , 如下:
void StackTask(void)
{
...
...
case SM_STACK_UDP:
if ( UDPProcess(&remoteNode, &tempLocalIP, dataCount) )
smStack = SM_STACK_IDLE;
break;
...
...
}
数据放在什么地方啊 ??
=> 就放在 &remoteNode 指向的地方UDPProcess 實作在UDP.C 中 , 如下:
BOOL UDPProcess(NODE_INFO *remoteNode, IP_ADDR *localIP, WORD len)
{
UDP_HEADER h;
UDP_SOCKET s;
PSEUDO_HEADER pseudoHeader;
WORD_VAL checksum;
// Retrieve UDP header.
MACGetArray((BYTE*)&h, sizeof(h));[color=990000]原始資料在此取得, 放在 h 所指處[/color]
h.SourcePort = swaps(h.SourcePort);
h.DestinationPort = swaps(h.DestinationPort);
h.Length = swaps(h.Length) - sizeof(UDP_HEADER);
...
...
s = FindMatchingSocket(&h, remoteNode, localIP);[color=660000]從remoteNode 找到相關資訊[/color][color=00FF00]S[/color]
if ( s == INVALID_UDP_SOCKET )
{
// If there is no matching socket, There is no one to handle
// this data. Discard it.
MACDiscardRx();
}
else
{
UDPSocketInfo[s].RxCount = h.Length;[color=660000]將S告訴UDPSocketInfo供上層使用[/color]
UDPSocketInfo[s].Flags.bFirstRead = TRUE;
}
return TRUE;
}