OSDN Git Service

*** empty log message ***
authorkoinec <>
Sun, 28 Mar 2010 02:56:58 +0000 (02:56 +0000)
committerkoinec <>
Sun, 28 Mar 2010 02:56:58 +0000 (02:56 +0000)
deamon/Makefile
deamon/drd64_marshald_cmd_attach_request.c
deamon/drd64_marshald_connect_marshald.c [new file with mode: 0644]
deamon/drd64_marshald_send_connect.c
include/drd64_error.h

index 6c73b27..214ffbe 100644 (file)
@@ -99,6 +99,7 @@ MARSHALD_OBJS = drd64_marshald_main.o \
                                drd64_marshald_send_connect.o \
                                drd64_marshald_send_connect_count.o \
                                drd64_marshald_boot_debugd.o \
+                               drd64_marshald_connect_marshald.o \
                                drd64_marshald_connect_debugd.o \
                                drd64_common_function.o \
                                $(SERVER_OBJS)
@@ -224,6 +225,12 @@ drd64_marshald_boot_debugd.o: \
        $(CC) -c -o drd64_marshald_boot_debugd.o $(FLAGS_DEBUG) \
                drd64_marshald_boot_debugd.c
 
+drd64_marshald_connect_marshald.o: \
+                       drd64_marshald_connect_marshald.c \
+                       $(MARSHALD_HEADER)
+       $(CC) -c -o drd64_marshald_connect_marshald.o $(FLAGS_DEBUG) \
+               drd64_marshald_connect_marshald.c
+
 drd64_marshald_connect_debugd.o: \
                        drd64_marshald_connect_debugd.c \
                        $(MARSHALD_HEADER)
index e42d3bd..f6432bb 100644 (file)
@@ -178,6 +178,7 @@ int
                Drd64_PacketData_AttachRequest  *p_attachreq,
                Drd64_Marshald_MasterInformation        *p_marshald )
 {
+       int             i_err;
        int             i_result;
        DWord   dw_errcode;
        DWord   dw_location;
@@ -193,20 +194,28 @@ int
                                                DRD64_SRCID_MARSHALD_CMD_ATTACH_REQUEST,
                                                DRD64_FUNCID_Marshald_Cmd_AttachRequest_Scn4 );
 
-       p_cinfo_inet = Drd64_Marshald_SendCmd_Connect(
-                                                       &(p_attachreq->t_prog_addr), i_recv_id );
-       if( NULL != p_cinfo_inet )      {
+       i_err   = Drd64_Marshald_Connect_Marshald(
+                               &p_cinfo_inet, &(p_attachreq->t_prog_addr), i_recv_id );
+
+       /*p_cinfo_inet = Drd64_Marshald_SendCmd_Connect(
+                                                       &(p_attachreq->t_prog_addr), i_recv_id ); */
+
+       //if( NULL != p_cinfo_inet )    {
+       if( 0 < i_err ) {
                i_result
                        = Drd64_Marshald_Cmd_AttachRequest_Scn3_TransAttachRequest(
                                                i_recv_id, p_phead, p_attachreq, p_marshald );
        }
-       else    {
+       else if( 0 == i_err )   {
                Drd64_Server_RecvStatus_SetCmdStatus( i_recv_id,
                                                DRD64_CMDSTATUS_ATTACHREQ_WAITCONNECT );
 
                /* Polling form debugd-Initialized */
                i_result        = DRD64_MARSHALD_DISPATCH_RESULT_POLL; 
        }
+       else    {
+
+       }
 
        DRD64_LOG_DEBUG("  [DEBUG]CMD: Attach Req. (Scn2:ConnectINetMarshald) Ended");
 
diff --git a/deamon/drd64_marshald_connect_marshald.c b/deamon/drd64_marshald_connect_marshald.c
new file mode 100644 (file)
index 0000000..ef7ac24
--- /dev/null
@@ -0,0 +1,108 @@
+/*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: 
+----------------------------------------------------------------------*/
+
+#define        DRD64_SRCID_MARSHALD_CONNECT_MARSHALD   0x0000
+#include"drd64_marshald.h"
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+#define        DRD64_FUNCID_Marshald_Connect_Marshald  0x01
+int
+       Drd64_Marshald_Connect_Marshald(
+               Drd64_Marshald_ConnectInfo      **pp_cinfo,
+               struct  in_addr *p_addr_dest,
+               int             i_resume_rid )
+{
+       int                                                     i_err;
+       int                                                     i_result;
+       DWord                                           dw_errcode;
+       DWord                                           dw_location;
+       Drd64_Marshald_ConnectInfo      *p_cinfo;
+
+       DRD64_LOG_DEBUG("  [DEBUG] Connect Marshald(INet) Start");
+
+       dw_errcode  = DRD64_ERROR_CODE_CLEAR;
+       dw_location = DRD64_ERROR_SET_LOCATION(
+                                               DRD64_ERROR_MODULE_MARSHALD,
+                                               DRD64_ERROR_ARCH_NODEPEND,
+                                               DRD64_SRCID_MARSHALD_CONNECT_MARSHALD,
+                                               DRD64_FUNCID_Marshald_Connect_Marshald );
+       *pp_cinfo       = NULL;
+       i_result        = 0;
+
+       /* 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_resume_rid );
+               if( 0x00 != i_err )             {
+                       dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                               DRD64_ERROR_PTN_FUNCTION, 0x00, 0x06 );
+                       Drd64_LibBrownie_Error_SetErrorInfo(
+                                                               dw_errcode, dw_location, errno );
+                       i_result        = -0x02;
+               }
+               else    {
+                       *pp_cinfo       = p_cinfo;
+                       i_result        = 1;    
+               }
+       }
+       else    {
+               i_err   = Drd64_Marshald_SendCmd_Connect(
+                                                       &p_cinfo, p_addr_dest, i_resume_rid );
+               if( 0x00 != i_err )             {
+                       dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                               DRD64_ERROR_PTN_FUNCTION, 0x00, 0x06 );
+                       Drd64_LibBrownie_Error_SetErrorInfo(
+                                                               dw_errcode, dw_location, errno );
+                       i_result        = -0x01;
+               }
+               else    {
+                       *pp_cinfo       = p_cinfo;
+               }
+       }
+
+
+       DRD64_LOG_DEBUG("  [DEBUG] Connect Marshald(INet) Ended");
+
+       return i_result;
+}
+
+
+
+
+/* EOF of drd64_.c ----------------------------------- */
index 1e0b6b8..e9d3be1 100644 (file)
@@ -41,8 +41,9 @@ Comment:
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
 #define        DRD64_FUNCID_Marshald_SendCmd_Connect   0x01
-Drd64_Marshald_ConnectInfo *
+int    
        Drd64_Marshald_SendCmd_Connect(
+               Drd64_Marshald_ConnectInfo **pp_cinfo,
                struct  in_addr *p_addr_dest,
                int             i_recv_id )
 {
@@ -64,33 +65,22 @@ Drd64_Marshald_ConnectInfo *
                                                DRD64_ERROR_ARCH_NODEPEND,
                                                DRD64_SRCID_MARSHALD_SEND_CONNECT,
                                                DRD64_FUNCID_Marshald_SendCmd_Connect );
+       *pp_cinfo       = NULL;
 
-       /* 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 );
-               //XXX
-               
-               DRD64_LOG_DEBUG("  [DEBUG]SEND: Connect Cmd (for INet-Marshald) Exit");
-
-               return  NULL;
-       }
-
-       /* Phase 2 : Init & Set Packet Data ----------*/
+       /* Alloc CInfo ----*/
        p_cinfo = Drd64_Marshald_CInfo_AllocConnectInfo();
        if( NULL == p_cinfo )   {
-               dw_errcode  = DRD64_ERROR_SET_CODE(
-                                                       DRD64_ERROR_TYPE_ERROR,
-                                                       DRD64_ERROR_PTN_NOMEMORY,
-                                                       0x00, 0x01 );
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_NOMEMORY, 0x00, 0x01 );
                Drd64_LibBrownie_Error_SetErrorInfo(
                                dw_errcode, dw_location, errno );
 
-               return NULL;
+               return -0x01;
        }
 
+
+       /* Set Packet Header ---*/
        p_phead = (Drd64_PacketHeader *)gp_sendbuffer;
        memset( gp_sendbuffer, 0x00, ( sizeof( Drd64_PacketHeader )
                                                                + sizeof( Drd64_PacketData_Connect ) ));
@@ -114,24 +104,53 @@ Drd64_Marshald_ConnectInfo *
        p_connect->i_connect_id                 = -1;
        i_err   = Drd64_LibBrownie_INetAddr_SetInAddr_LocalHost(
                                                                &(p_connect->t_client_addr_inet) );
-       /* XXX : i_err Handling  */
-       
+       if( 0x00 != i_err )             {
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_INETADDR, 0x00, 0x02 );
+               Drd64_LibBrownie_Error_SetErrorInfo(
+                               dw_errcode, dw_location, errno );
+
+               Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
+               return -0x02;
+       }
 
-       /* Phase 3 : Create INet-Marshald Socket ------*/
+
+       /* Create INet-Marshald Socket ------*/
        i_socket_inet   =
                Drd64_LibBrownie_Socket_InitSocketClient_INet(
                                                p_addr_dest, DRD64_SOCKET_NETWORK_PORT ); 
+       if( 0 > i_socket_inet )         {
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_SOCKET, 0x00, 0x03 );
+               Drd64_LibBrownie_Error_SetErrorInfo(
+                               dw_errcode, dw_location, errno );
+
+               Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
 
+               return -0x03;
+       }
+
+
+       /* Init. RecvStatus for INet-Socket ---- */
        p_recv = Drd64_Server_RecvStatus_AllocRecvStatus(
                                        i_socket_inet, DRD64_MARSHALD_RECVSTATUS_UNITS );
-       if( NULL == p_recv )    { return NULL; }
+       if( NULL == p_recv )    {
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_NOMEMORY, 0x00, 0x04 );
+               Drd64_LibBrownie_Error_SetErrorInfo(
+                               dw_errcode, dw_location, errno );
 
-       Drd64_Marshald_Dispatch_SetFD( i_socket_inet );
+               Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
+               return -0x04;
+       }
+
+       //Drd64_Marshald_Dispatch_SetFD( i_socket_inet );
        Drd64_Server_RecvStatus_InitRecvStatus( p_recv, i_socket_inet );
        Drd64_Server_RecvStatus_AddSocketsChain( p_recv );
-
+       /* Error Proc. is NONE. => Error Pattern is p_recv = NULL only */
        Drd64_Server_RecvStatus_SetConnectionInfoPointer(
                                                                p_recv, (void *)p_cinfo );
+       Drd64_Marshald_Dispatch_SetFD( i_socket_inet );
 
 
        /* Phase 4 : Send Packet to INet Marshald -----*/
@@ -139,7 +158,15 @@ Drd64_Marshald_ConnectInfo *
                                                                DRD64_PacketSize(p_phead), 0x00 );
        DRD64_DEBUG_PRINT("send",i_wlen,"FD",i_socket_inet,"errno",errno);
        if( i_wlen != DRD64_PacketSize(p_phead) )       {
-               return NULL; 
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_SOCKET, 0x00, 0x05 );
+               Drd64_LibBrownie_Error_SetErrorInfo(
+                               dw_errcode, dw_location, errno );
+
+               Drd64_Marshald_Dispatch_CloseSocket( p_recv );
+               Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
+
+               return -0x05;
        } 
 
        /* Phase 5 : Set Cinfo Data ------------------*/
@@ -166,13 +193,26 @@ Drd64_Marshald_ConnectInfo *
 
        i_err   = Drd64_LibBrownie_INetAddr_SetInAddr_LocalHost(
                                                                &(p_cinfo->t_client_addr_inet) );
+       if( 0x00 != i_err )             {
+               dw_errcode  = DRD64_ERROR_SET_CODE( DRD64_ERROR_TYPE_ERROR,
+                                                       DRD64_ERROR_PTN_INETADDR, 0x00, 0x06 );
+               Drd64_LibBrownie_Error_SetErrorInfo(
+                               dw_errcode, dw_location, errno );
+
+               Drd64_Marshald_Dispatch_CloseSocket( p_recv );
+               Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
+
+               return -0x06;
+       }
+
        p_cinfo->i_client_socket                = i_socket_inet;
        p_cinfo->i_client_pid                   = getpid();
 
+       *pp_cinfo       = p_cinfo;
 
        DRD64_LOG_DEBUG("  [DEBUG]SEND: Connect Cmd (for INet-Marshald) Ended");
 
-       return NULL;
+       return 0x00;
 }
 
 
index 729164f..51a5c84 100644 (file)
@@ -86,6 +86,8 @@ DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD*/
 #define        DRD64_ERROR_PTN_NOEXIST                 0x00060000
 #define        DRD64_ERROR_PTN_NOMEMORY                0x00070000
 #define        DRD64_ERROR_PTN_SOCKET                  0x00080000
+#define        DRD64_ERROR_PTN_INETADDR                0x00090000
+#define        DRD64_ERROR_PTN_FUNCTION                0x00ff0000
 
 
 /* [Location] Module Level-1 Code ===== __*+______ */