OSDN Git Service

(none)
authorryuz <ryuz>
Mon, 17 Sep 2007 02:53:46 +0000 (02:53 +0000)
committerryuz <ryuz>
Mon, 17 Sep 2007 02:53:46 +0000 (02:53 +0000)
aplfw/driver/tcpip/tcpip/tcpip.h
aplfw/driver/tcpip/tcpip/tcpip_local.h
aplfw/driver/tcpip/tcpip/tcpip_recv.c

index eb11eba..05d8df6 100755 (executable)
 
 
 
+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
index 97b9fe6..afedd42 100755 (executable)
@@ -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;
index 32f3d71..a50c126 100755 (executable)
 
 
 #include <string.h>
+#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)
-{
-       
-}
 
 
 /* 受信プロセス */