OSDN Git Service

*** empty log message ***
authorkoinec <>
Sat, 20 Jun 2009 13:04:00 +0000 (13:04 +0000)
committerkoinec <>
Sat, 20 Jun 2009 13:04:00 +0000 (13:04 +0000)
deamon/Makefile
deamon/drd64_marshald.h
deamon/drd64_marshald_cmd_connect.c
deamon/drd64_marshald_dispatch.c

index 94b776e..08953ce 100644 (file)
@@ -38,6 +38,8 @@ MARSHALD_OBJS = drd64_marshald_main.o \
                                $(SERVER_OBJS)
 MARSHALD_HEADER =      drd64_marshald.h \
                                        drd64_marshald_info.h \
+                                       drd64_marshald_cinfo.h \
+                                       drd64_marshald_dispatch.h \
                                        $(SERVER_HEADER)
 
 all:   $(DEBUGD_TARGET) \
index 0c0f87e..d8ec394 100644 (file)
@@ -60,6 +60,7 @@ Comment:
 #include"drd64_server_recvstatus.h"
 #include"drd64_marshald_info.h"
 #include"drd64_marshald_cinfo.h"
+#include"drd64_marshald_dispatch.h"
 
 #define DRD64_MARSHALD_RECVSTATUS_UNITS                20
 #define        DRD64_MARSHALD_CINFO_UNITS                      40
index 3d9c406..c3d8fa5 100644 (file)
@@ -38,7 +38,38 @@ Comment:
 
 
 int
-       Drd64_Marshald_Cmd_Connect(
+       Drd64_Marshald_Cmd_Connect_Client(
+               int             i_fds,
+               Drd64_PacketHeader      *p_phead,
+               Drd64_PacketData_Connect        *p_connect )
+{
+       Drd64_Marshald_ConnectInfo      *p_cinfo;
+       
+       p_cinfo = Drd64_Marshald_GetConnectInfo( p_connect->i_client_cinfo_id );
+       assert( NULL != p_cinfo );
+
+       //p_cinfo->b_cinfo_type         = DRD64_MARSHALD_CINFOTYPE_CLIENT;
+       //p_cinfo->i_cinfo_refcount     = 1;
+       //p_cinfo->i_dest_socket                = i_socket_inet;
+       //p_cinfo->str_dest_addr_local[0]       = '\0';
+       //Drd64_Server_INetAddr_CopyInAddr(
+       //                              &(p_cinfo->t_dest_addr_inet), p_addr_dest );
+       //p_cinfo->i_src_socket         = -1;
+       //p_cinfo->i_src_cinfo_id               = -1;
+       //p_cinfo->i_prog_pid                   = -1;
+       //p_cinfo->i_debugd_pid         = -1;
+       //i_err   = Drd64_Server_INetAddr_SetInAddr_LocalHost(
+       //                              &(p_cinfo->t_client_addr_inet) );
+       //p_cinfo->i_client_pid         = getpid();
+       p_cinfo->i_dest_cinfo_id        = p_connect->i_connect_id;
+
+       return DRD64_MARSHALD_DISPATCH_RESULT_RESTART;
+}
+
+
+
+int
+       Drd64_Marshald_Cmd_Connect_Server(
                int             i_fds,
                Drd64_PacketHeader      *p_phead,
                Drd64_PacketData_Connect        *p_connect )
@@ -49,7 +80,7 @@ int
        /* Alloc ConnectInfo. */
        p_cinfo = Drd64_Marshald_CInfo_AllocConnectInfo();
        if( NULL == p_cinfo )
-               { return 0x00; }
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
 
        p_cinfo->b_cinfo_type   = DRD64_MARSHALD_CINFOTYPE_CONNECT;
        p_cinfo->i_cinfo_refcount       = 1;
@@ -75,12 +106,32 @@ int
     p_connect->i_marshald_pid  = getpid();
 
        i_wlen  = send( i_fds, (void *)p_phead, DRD64_PacketSize(p_phead), 0x00 );
+       if( i_wlen != DRD64_PacketSize(p_phead) )
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
        
-       if( i_wlen != DRD64_PacketSize(p_phead) )       {
-               return 0x00;
+       return DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE;
+}
+
+
+int
+       Drd64_Marshald_Cmd_Connect(
+               int             i_fds,
+               Drd64_PacketHeader      *p_phead,
+               Drd64_PacketData_Connect        *p_connect )
+{
+       int             i_result;
+
+       if( DRD64_PACKETTYPE_ANSWER == p_phead->w_packettype )  {
+               i_result        = Drd64_Marshald_Cmd_Connect_Client(
+                                                               i_fds, p_phead, p_connect );
+
+       }
+       else    {
+               i_result        = Drd64_Marshald_Cmd_Connect_Server(
+                                                               i_fds, p_phead, p_connect );
        }
        
-       return 0x02;
+       return i_result;
 }
 
 
index 39c1109..358cdc7 100644 (file)
@@ -47,6 +47,38 @@ void
        return;
 }
 
+int
+       Drd64_Marshald_Dispatch_CallCommandFunction(
+               int                                     i_fds,
+               Drd64_PacketHeader      *p_phead,
+               void                            *pv_data,
+        Drd64_Marshald_MasterInformation *p_marshald )
+{
+       int             i_result;
+       i_result        = 0x00;
+
+       if( DRD64_COMMAND_CONNECT == p_phead->dw_command )      {
+               i_result = Drd64_Marshald_Cmd_Connect( i_fds, p_phead, pv_data );
+       }
+       else if( DRD64_COMMAND_DISCONNECT == p_phead->dw_command )      {
+               i_result = Drd64_Marshald_Cmd_DisConnect( i_fds, p_phead, pv_data );
+       }
+       else if( DRD64_COMMAND_ATTACH_REQUEST == p_phead->dw_command )  {
+               i_result = Drd64_Marshald_Cmd_AttachRequest(
+                                                       i_fds, p_phead, pv_data, p_marshald );
+       }
+       else if( DRD64_COMMAND_DEBUG_REQUEST == p_phead->dw_command )   {
+       }
+       else if( DRD64_COMMAND_DETACH == p_phead->dw_command )  {
+       }
+       else if( DRD64_COMMAND_EXIT == p_phead->dw_command )    {
+       }
+       else
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
+
+       return i_result;
+}
+
 
 int
        Drd64_Marshald_Dispatch_JudgePacket(
@@ -57,7 +89,6 @@ int
        int             i_result;
        Drd64_Server_RecvStatus         *p_recv;
        Drd64_PacketHeader                      *p_phead;
-       Drd64_PacketData_AttachRequest  *p_attach;
        void                                            *pv_data;
 
        i_result        = 0x00;
@@ -67,18 +98,17 @@ int
 
        /* Judge 1: Receiving : Remain Bytes Receiving = 0x01 */
        if( 0 < i_remainbytes )
-               { return 0x01; }
+               { return DRD64_MARSHALD_DISPATCH_RESULT_RECEVING; }
        /* Judge 2: Error: Connection Down or Close = 0x00 */
        else if( 0 > i_remainbytes )
-               { return 0x00; }
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
 
        p_phead = (Drd64_PacketHeader *)p_recv->pv_buf;
-
        assert( NULL != p_phead );
 
        /* Check 1 : Header Check */
        if( DRD64_PACKET_HEADER != p_phead->w_header )
-               { return 0x01; }
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
 
        /* Judge 3: Remain Packet Data? = 0x01 */
        if(( DRD64_SERVER_RECVSTATUS_PHASE_HEADER == p_recv->i_read_phase ) &&
@@ -86,11 +116,11 @@ int
                p_recv->i_read_phase    = DRD64_SERVER_RECVSTATUS_PHASE_DATA;
                /* Check BOF Attack */
                if( DRD64_MAX_PACKET_DATA < p_phead->i_datalen )
-                       { return 0x00; }
+                       { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
                p_recv->i_remain_bytes  = p_phead->i_datalen;
                puts("remain");
                
-               return 0x01;
+               return DRD64_MARSHALD_DISPATCH_RESULT_RECEVING;
        }
 
        /*if(( DRD64_SERVER_RECVSTATUS_PHASE_END == p_recv->i_read_phase ) &&
@@ -110,28 +140,9 @@ int
                { pv_data       = NULL; }
 
 
-       
-
-       if( DRD64_COMMAND_CONNECT == p_phead->dw_command )      {
-               i_result = Drd64_Marshald_Cmd_Connect( i_fds, p_phead, pv_data );
-       }
-       else if( DRD64_COMMAND_DISCONNECT == p_phead->dw_command )      {
-               i_result = Drd64_Marshald_Cmd_DisConnect( i_fds, p_phead, pv_data );
-       }
-       else if( DRD64_COMMAND_ATTACH_REQUEST == p_phead->dw_command )  {
-               p_attach= pv_data;
-               printf("%08x\n", p_attach->t_prog_addr );
-               i_result = Drd64_Marshald_Cmd_AttachRequest(
+       i_result = Drd64_Marshald_Dispatch_CallCommandFunction(
                                                        i_fds, p_phead, pv_data, p_marshald );
-       }
-       else if( DRD64_COMMAND_DEBUG_REQUEST == p_phead->dw_command )   {
-       }
-       else if( DRD64_COMMAND_DETACH == p_phead->dw_command )  {
-       }
-       else if( DRD64_COMMAND_EXIT == p_phead->dw_command )    {
-       }
-       else
-               { return 0x00; }
+
 
        p_recv->i_read_phase    = DRD64_SERVER_RECVSTATUS_PHASE_HEADER;
        p_recv->i_remain_bytes  = sizeof( Drd64_PacketHeader );
@@ -230,7 +241,7 @@ int
                                                                i_cnt, i_err, &drd64_marshald_info );
 
                                        /* 0x00 = Judge 1 : Disconnect ( Others Packet ) */
-                                       if( 0x00 == i_result )  {
+                                       if( DRD64_MARSHALD_DISPATCH_RESULT_CLOSE == i_result )  {
                                                close( i_cnt );
                                                FD_CLR( i_cnt, &fds_orig );
                                                Drd64_Server_RecvStatus_FreeRecvStatus( i_cnt );