From ba03c67892229394d48b90ec881a9408d922ac14 Mon Sep 17 00:00:00 2001 From: ryuz Date: Mon, 17 Sep 2007 02:53:46 +0000 Subject: [PATCH] (none) --- aplfw/driver/tcpip/tcpip/tcpip.h | 17 ++++++++- aplfw/driver/tcpip/tcpip/tcpip_local.h | 1 + aplfw/driver/tcpip/tcpip/tcpip_recv.c | 68 +++++++++++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/aplfw/driver/tcpip/tcpip/tcpip.h b/aplfw/driver/tcpip/tcpip/tcpip.h index eb11eba..05d8df6 100755 --- a/aplfw/driver/tcpip/tcpip/tcpip.h +++ b/aplfw/driver/tcpip/tcpip/tcpip.h @@ -18,6 +18,16 @@ +typedef struct t_tcpip_address +{ + unsigned char ubAddress[4]; + unsigned short uhPort; +} T_TCPIP_ADDRESS; + + + +struct c_tcpipfile; + typedef struct c_tcpip { C_CHRDRV ChrDrv; /* キャラクタ型デバイスドライバを継承 */ @@ -27,7 +37,10 @@ typedef struct c_tcpip int iOpenCount; /* オープンカウンタ */ SYSPRC_HANDLE hPrcRecv; /* 受信プロセス */ - + + struct c_tcpipfile *pUdpHead; + struct c_tcpipfile *pTcpHead; + unsigned short uhPacketId; // unsigned char ubSendBuf[IPETHER_MAXPACKET_SIZE]; @@ -36,6 +49,8 @@ typedef struct c_tcpip } C_TCPIP; + + #ifdef __cplusplus extern "C" { #endif diff --git a/aplfw/driver/tcpip/tcpip/tcpip_local.h b/aplfw/driver/tcpip/tcpip/tcpip_local.h index 97b9fe6..afedd42 100755 --- a/aplfw/driver/tcpip/tcpip/tcpip_local.h +++ b/aplfw/driver/tcpip/tcpip/tcpip_local.h @@ -39,6 +39,7 @@ typedef struct c_tcpipfile char iType; unsigned char ubIpAddr[4]; unsigned short uhPortNum; + SYSEVT_HANDLE hEvtRecv; struct c_tcpipfile *pNext; struct c_tcpipfile *pPrev; diff --git a/aplfw/driver/tcpip/tcpip/tcpip_recv.c b/aplfw/driver/tcpip/tcpip/tcpip_recv.c index 32f3d71..a50c126 100755 --- a/aplfw/driver/tcpip/tcpip/tcpip_recv.c +++ b/aplfw/driver/tcpip/tcpip/tcpip_recv.c @@ -10,15 +10,77 @@ #include +#include "hosaplfw.h" #include "tcpip_local.h" #include "library/algorithm/ipchecksum/ipchecksum.h" +static void Tcpip_IcmpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize); -void Tcpip_IcmpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize); +void Tcpip_UdpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize) +{ + const unsigned char ubDumy[2] = {0, 17}; + C_TCPIPFILE *pFile; + T_TCPIP_ADDRESS Addr; + C_IPCHECKSUM ics; + unsigned short uhDstPort; + unsigned short uhSrcPort; + unsigned short uhUdpSize; + unsigned short uhCheckSum; + unsigned short uhSum; + + uhDstPort = IP_GET_HALFWORD(&pubBuf[20]); + uhSrcPort = IP_GET_HALFWORD(&pubBuf[22]); + uhUdpSize = IP_GET_HALFWORD(&pubBuf[24]); + uhCheckSum = IP_GET_HALFWORD(&pubBuf[26]); + + + /* ---------------------- */ + /* チェックサム計算 */ + /* ---------------------- */ + + IpCheckSum_Create(&ics); + + /* UDP擬似ヘッダ(pseudo header)*/ + IpCheckSum_Update(&ics, &pubBuf[12], 8); /* 送信元アドレス& 送信先アドレス */ + IpCheckSum_Update(&ics, ubDumy, 2); + IpCheckSum_Update(&ics, &pubBuf[24], 2); /* パケット長 */ + + /* パケット */ + IpCheckSum_Update(&ics, &pubBuf[20], 6); + IpCheckSum_Update(&ics, &pubBuf[28], uhUdpSize - 8); + + uhSum = IpCheckSum_GetDigest(&ics); + + IpCheckSum_Delete(&ics); + + if ( uhCheckSum != 0x0000 && uhCheckSum != uhSum ) + { + return; + } + + + /* 受信ポート探索 */ + pFile = self->pUdpHead; + if ( pFile != NULL ) + { + do + { + if ( pFile->uhPortNum == uhDstPort ) + { + + } + + pFile = pFile->pNext; + } while ( pFile == self->pUdpHead ); + } + +} + + void Tcpip_TcpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize) { const unsigned char *pubRecvTcp; @@ -94,10 +156,6 @@ void Tcpip_TcpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize) } -void Tcpip_UdpRecv(C_TCPIP *self, const unsigned char *pubBuf, int iSize) -{ - -} /* 受信プロセス */ -- 2.11.0