OSDN Git Service

*** empty log message ***
authorkoinec <>
Sat, 6 Mar 2010 07:35:31 +0000 (07:35 +0000)
committerkoinec <>
Sat, 6 Mar 2010 07:35:31 +0000 (07:35 +0000)
deamon/Makefile
deamon/drd64_marshald_cmd_connect_count.c [new file with mode: 0644]
deamon/drd64_marshald_dispatch.c
deamon/drd64_marshald_send_connect.c
deamon/drd64_marshald_send_connect_count.c [new file with mode: 0644]
include/drd64_packet.h

index a54de4d..72124c8 100644 (file)
@@ -89,6 +89,7 @@ MARSHALD_OBJS = drd64_marshald_main.o \
                                drd64_marshald_dispatch.o \
                                drd64_marshald_cinfo.o \
                                drd64_marshald_cmd_connect.o \
+                               drd64_marshald_cmd_connect_count.o \
                                drd64_marshald_cmd_disconnect.o \
                                drd64_marshald_cmd_attach_request.o \
                                drd64_marshald_cmd_attach_link.o \
@@ -96,6 +97,7 @@ MARSHALD_OBJS = drd64_marshald_main.o \
                                drd64_marshald_cmd_detach.o \
                                drd64_marshald_msg_bootinfo.o \
                                drd64_marshald_send_connect.o \
+                               drd64_marshald_send_connect_count.o \
                                drd64_marshald_connect_debugd.o \
                                drd64_common_function.o \
                                $(SERVER_OBJS)
@@ -168,8 +170,15 @@ drd64_marshald_dispatch.o: drd64_marshald_dispatch.c $(MARSHALD_HEADER)
 drd64_marshald_cinfo.o: drd64_marshald_cinfo.c $(MARSHALD_HEADER)
        $(CC) -c -o drd64_marshald_cinfo.o $(FLAGS_DEBUG) drd64_marshald_cinfo.c
 
-drd64_marshald_cmd_connect.o: drd64_marshald_cmd_connect.c $(MARSHALD_HEADER)
-       $(CC) -c -o drd64_marshald_cmd_connect.o $(FLAGS_DEBUG) drd64_marshald_cmd_connect.c
+drd64_marshald_cmd_connect.o: \
+                       drd64_marshald_cmd_connect.c $(MARSHALD_HEADER)
+       $(CC) -c -o drd64_marshald_cmd_connect.o $(FLAGS_DEBUG) \
+                       drd64_marshald_cmd_connect.c
+
+drd64_marshald_cmd_connect_count.o: \
+                       drd64_marshald_cmd_connect_count.c $(MARSHALD_HEADER)
+       $(CC) -c -o drd64_marshald_cmd_connect_count.o $(FLAGS_DEBUG) \
+                       drd64_marshald_cmd_connect_count.c
 
 drd64_marshald_cmd_disconnect.o: drd64_marshald_cmd_disconnect.c $(MARSHALD_HEADER)
        $(CC) -c -o drd64_marshald_cmd_disconnect.o $(FLAGS_DEBUG) drd64_marshald_cmd_disconnect.c
@@ -198,8 +207,15 @@ drd64_marshald_msg_bootinfo.o: drd64_marshald_msg_bootinfo.c $(MARSHALD_HEADER)
        $(CC) -c -o drd64_marshald_msg_bootinfo.o $(FLAGS_DEBUG) \
                drd64_marshald_msg_bootinfo.c
 
-drd64_marshald_send_connect.o: drd64_marshald_send_connect.c $(MARSHALD_HEADER)
-       $(CC) -c -o drd64_marshald_send_connect.o $(FLAGS_DEBUG) drd64_marshald_send_connect.c
+drd64_marshald_send_connect.o: \
+                       drd64_marshald_send_connect.c $(MARSHALD_HEADER)
+       $(CC) -c -o drd64_marshald_send_connect.o $(FLAGS_DEBUG) \
+               drd64_marshald_send_connect.c
+
+drd64_marshald_send_connect_count.o: \
+                       drd64_marshald_send_connect_count.c $(MARSHALD_HEADER)
+       $(CC) -c -o drd64_marshald_send_connect_count.o $(FLAGS_DEBUG) \
+               drd64_marshald_send_connect_count.c
 
 drd64_marshald_connect_debugd.o: \
                        drd64_marshald_connect_debugd.c \
diff --git a/deamon/drd64_marshald_cmd_connect_count.c b/deamon/drd64_marshald_cmd_connect_count.c
new file mode 100644 (file)
index 0000000..9624c2a
--- /dev/null
@@ -0,0 +1,139 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#include"drd64_marshald.h"
+
+
+/*----------------------------------------------------------------------
+static int
+        Drd64_Intel64_DisAsm_GetSize_SizeID(
+                : Get Operand Size form Intel 64 DB SizeID
+
+                int i_operandsize,      : [src] Default Operand Size
+                Word w_methodtype,      : [src] Method Type ID
+                Word w_sizeid )         : [src] Size ID
+----------------------------------------------------------------------*/
+int
+       Drd64_Marshald_Cmd_ConnectCount_Client(
+               int             i_fds,
+               Drd64_PacketHeader      *p_phead,
+               Drd64_PacketData_ConnectCount   *p_ccount )
+{
+       Drd64_Marshald_ConnectInfo      *p_cinfo;
+
+       DRD64_LOG_DEBUG("  [DEBUG] CMD: ConnectCount(Client) Start");
+       
+       p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo(
+                                                                       p_phead->i_cid_src );
+       assert( NULL != p_cinfo );
+
+       if( p_cinfo->i_cinfo_refcount != p_ccount->i_refcount_server )  {
+               DRD64_LOG_DEBUG("  [DEBUG] CMD: ConnectCount(Client) Error");
+       }
+
+       DRD64_LOG_DEBUG("  [DEBUG] CMD: ConnectCount(Client) Ended");
+
+       return DRD64_MARSHALD_DISPATCH_RESULT_RESTART;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+int
+       Drd64_Marshald_Cmd_ConnectCount_Server(
+               int             i_recv_id,
+               Drd64_PacketHeader      *p_phead,
+               Drd64_PacketData_ConnectCount   *p_ccount )
+{
+       int                     i_wlen;
+       int                     i_fds;
+       Drd64_Marshald_ConnectInfo              *p_cinfo;
+       Drd64_Server_RecvStatus                 *p_recv;
+
+       DRD64_LOG_DEBUG("  [DEBUG] CMD: ConnectCount(Server) Start");
+
+       p_recv  = Drd64_Server_RecvStatus_GetRecvStatus( i_recv_id );
+       assert( NULL != p_recv );
+       i_fds   = p_recv->i_fds_id;
+       
+       /* Alloc ConnectInfo. */
+       p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest );
+       assert( NULL != p_cinfo );
+
+       p_cinfo->i_cinfo_refcount       += p_ccount->i_refcount_diff; 
+
+       /* Set Answer Data ---------*/
+       p_phead->w_packettype           |= DRD64_PACKETTYPE_FLAG_ANSWER;
+       p_ccount->i_refcount_server     = p_cinfo->i_cinfo_refcount;
+
+       i_wlen  = send( i_fds, (void *)p_phead, DRD64_PacketSize(p_phead), 0x00 );
+       DRD64_DEBUG_PRINT("send",i_wlen,"FD",i_fds,"errno",errno);
+       if( i_wlen != DRD64_PacketSize(p_phead) )
+               { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }        // XXX > error
+       
+       DRD64_LOG_DEBUG("  [DEBUG] CMD: ConnectCount(Server) Complete ");
+
+       return DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE;
+}
+
+
+int
+       Drd64_Marshald_Cmd_ConnectCount(
+               int             i_recv_id,
+               Drd64_PacketHeader      *p_phead,
+               Drd64_PacketData_ConnectCount   *p_ccount )
+{
+       int             i_result;
+
+       DRD64_LOG_VERBOSE("[STAT]CMD: Connect Count Start");
+       
+       if( DRD64_IsPacketType_Answer( p_phead ) )      {
+               i_result        = Drd64_Marshald_Cmd_ConnectCount_Client(
+                                                               i_recv_id, p_phead, p_ccount );
+
+       }
+       else    {
+               i_result        = Drd64_Marshald_Cmd_ConnectCount_Server(
+                                                               i_recv_id, p_phead, p_ccount );
+       }
+       
+       DRD64_LOG_VERBOSE("[STAT]CMD: Connect Count Ended");
+
+       return i_result;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
index fdf80ed..2c37f99 100644 (file)
@@ -126,7 +126,13 @@ int
        /* Phase 2 : Exec. Command ========================*/
        /* CMD: Connect -----------------------------------*/
        if( DRD64_COMMAND_CONNECT == p_phead->dw_command )      {
-               i_result = Drd64_Marshald_Cmd_Connect( i_recv_id, p_phead, pv_data );
+               i_result = Drd64_Marshald_Cmd_Connect(
+                                                       i_recv_id, p_phead, pv_data );
+       }
+       /* CMD: Connect Count -----------------------------*/
+       else if( DRD64_COMMAND_CONNECT_COUNT == p_phead->dw_command )   {
+               i_result = Drd64_Marshald_Cmd_ConnectCount(
+                                                       i_recv_id, p_phead, pv_data );
        }
        /* CMD: DisConnect --------------------------------*/
        else if( DRD64_COMMAND_DISCONNECT == p_phead->dw_command )      {
index ed74a31..2dfbe85 100644 (file)
@@ -57,11 +57,15 @@ Drd64_Marshald_ConnectInfo *
        /* Phase 1 : Check Exist Same-Connection */
        p_cinfo = Drd64_Marshald_SearchINetConnection( p_addr_dest );
        if( NULL != p_cinfo )   {
+
+               i_err   = Drd64_Marshald_SendCmd_ConnectCount(
+                                                                       p_cinfo, 1, i_recv_id );
                p_cinfo->i_cinfo_refcount++;
                
                DRD64_LOG_DEBUG("  [DEBUG]SEND: Connect Cmd (for INet-Marshald) Exit");
 
-               return  p_cinfo;
+               //return        p_cinfo;
+               return  NULL;
        }
 
        /* Phase 2 : Init & Set Packet Data ----------*/
diff --git a/deamon/drd64_marshald_send_connect_count.c b/deamon/drd64_marshald_send_connect_count.c
new file mode 100644 (file)
index 0000000..c5fa734
--- /dev/null
@@ -0,0 +1,94 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#include"drd64_marshald.h"
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+int
+       Drd64_Marshald_SendCmd_ConnectCount(
+               Drd64_Marshald_ConnectInfo      *p_cinfo,
+               int             i_refcount_diff, 
+               int             i_rid_resume )
+{
+       int                                                     i_wlen;
+       Drd64_PacketHeader                      *p_phead;
+       Drd64_PacketData_ConnectCount   *p_ccount;
+
+       DRD64_LOG_DEBUG(
+               "  [DEBUG]SEND: ConnectCount Cmd (for INet-Marshald) Start");
+
+       /* Phase 1 : Check Exist Same-Connection */
+       p_phead = (Drd64_PacketHeader *)gp_sendbuffer;
+       memset( gp_sendbuffer, 0x00, ( sizeof( Drd64_PacketHeader )
+                                                       + sizeof( Drd64_PacketData_ConnectCount ) ));
+
+       p_phead->w_header               = DRD64_PACKET_HEADER;
+       p_phead->i_cid_dest             = p_cinfo->i_dest_cinfo_id;
+       p_phead->i_cid_src              = p_cinfo->i_cinfo_id;
+       p_phead->i_cid_client   = DRD64_CONNECTID_NONE;
+       p_phead->dw_command             = DRD64_COMMAND_CONNECT_COUNT;
+       p_phead->w_packettype   = DRD64_PACKETTYPE_LINK;
+       p_phead->i_datalen              = sizeof( Drd64_PacketData_ConnectCount );
+       p_phead->i_rid_resume   = i_rid_resume;
+       p_phead->i_result               = 0x00;
+       p_phead->i_error                = 0x00;
+
+       p_ccount
+               = (Drd64_PacketData_ConnectCount *)DRD64_PacketData( gp_sendbuffer );
+
+       p_ccount->i_refcount_diff       = p_cinfo->i_cinfo_refcount;
+       p_ccount->i_refcount_client     = i_refcount_diff;
+       
+
+       /* Phase 3 : Send Packet to INet Marshald -----*/
+       i_wlen  = send( p_cinfo->i_dest_socket, (void *)p_phead,
+                                                               DRD64_PacketSize(p_phead), 0x00 );
+       DRD64_DEBUG_PRINT("send",i_wlen,"FD",p_cinfo->i_dest_socket,"errno",errno);
+       if( i_wlen != DRD64_PacketSize(p_phead) )       {
+               return -1; 
+       } 
+
+       DRD64_LOG_DEBUG(
+               "  [DEBUG]SEND: ConnectCount Cmd (for INet-Marshald) Ended");
+
+       return 0x00;
+}
+
+
+
+/* EOF of drd64_.c ----------------------------------- */
index 1957e16..c1acbee 100644 (file)
@@ -44,6 +44,7 @@ Comment:
 #define        DRD64_PACKET_HEADER             0x8664
 
 #define        DRD64_COMMAND_CONNECT                   0x0010
+#define        DRD64_COMMAND_CONNECT_COUNT             0x0012
 #define        DRD64_COMMAND_DISCONNECT                0x0020
 #define        DRD64_COMMAND_ATTACH_REQUEST    0x0031
 #define        DRD64_COMMAND_ATTACH_LINK               0x0032
@@ -125,6 +126,19 @@ typedef struct     {
 } __attribute((packed)) Drd64_PacketData_Connect;
 
 
+/* CMD: ConnectCount Data ==============================*/
+
+typedef struct {
+       /* Request Data */
+       INT                                     i_refcount_diff;
+       INT                                     i_refcount_client;
+
+       /* Answer Data */
+       INT                                     i_refcount_server;
+
+} __attribute((packed)) Drd64_PacketData_ConnectCount;
+
+
 /* CMD: Attach Request ===================================*/
 
 typedef struct {