1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_MARSHALD_CONNECT_DEBUGD
38 #include"drd64_marshald.h"
41 /*----------------------------------------------------------------------
42 ----------------------------------------------------------------------*/
43 EXTERN_MARSHALD_CONNECT_DEBUGD
44 Drd64_Marshald_ConnectInfo *
45 Drd64_Marshald_Connect_Debugd(
46 char *pstr_socketname_debugd,
51 Drd64_Marshald_ConnectInfo *p_cinfo;
52 Drd64_Server_RecvStatus *p_recv;
54 DRD64_LOG_DEBUG(" [DEBUG]SEND: Connect Cmd (for Debugd) Start");
56 /* Phase 1 : Check Exist Same-Connection */
57 p_cinfo = Drd64_Marshald_Search_DebugdConnection( i_prog_pid );
58 if( NULL != p_cinfo ) {
59 p_cinfo->i_cinfo_refcount++;
61 DRD64_LOG_DEBUG(" [DEBUG]SEND: Connect Cmd (for Debugd) Exit");
64 /* Phase 3 : Create INet-Marshald Socket ------*/
65 i_socket = Drd64_LibBrownie_Socket_InitSocketClient_Local(
66 pstr_socketname_debugd );
67 if( 0 > i_socket ) { return NULL; }
69 p_recv = Drd64_Server_RecvStatus_AllocRecvStatus(
70 i_socket, DRD64_MARSHALD_RECVSTATUS_UNITS );
71 if( NULL == p_recv ) { return NULL; }
73 Drd64_Marshald_Dispatch_SetFD( i_socket );
74 Drd64_Server_RecvStatus_InitRecvStatus( p_recv, i_socket );
75 Drd64_Server_RecvStatus_AddSocketsChain( p_recv );
77 /* Phase 2 : Init & Set Packet Data ----------*/
78 p_cinfo = Drd64_Marshald_CInfo_AllocConnectInfo();
79 if( NULL == p_cinfo ) { return NULL; }
81 /* Phase 5 : Set Cinfo Data ------------------*/
82 p_cinfo->b_cinfo_type = DRD64_MARSHALD_CINFOTYPE_DEBUGD;
83 p_cinfo->i_cinfo_refcount = 1;
85 Drd64_LibBrownie_INetAddr_SetInAddr_LocalHost(
86 &(p_cinfo->t_dest_addr_inet) );
87 p_cinfo->i_dest_cinfo_id = -1;
88 p_cinfo->i_dest_socket = i_socket;
89 strncpy( p_cinfo->str_dest_addr_local,
90 pstr_socketname_debugd, DRD64_MAX_PATH );
92 /* p_cinfo->t_src_addr_inet = NONE */
93 p_cinfo->i_src_cinfo_id = -1;
94 p_cinfo->i_src_socket = -1;
96 /* t_prog_addr_inet = NONE */
97 p_cinfo->i_prog_pid = i_prog_pid;
99 p_cinfo->i_debugd_pid = i_debugd_pid;
100 p_cinfo->i_debugd_socket = i_socket;
102 /* p_cinfo->t_client_addr_inet = NONE */
103 p_cinfo->i_client_socket = -1;
104 p_cinfo->i_client_pid = -1;
106 Drd64_Server_RecvStatus_SetConnectionInfoPointer(
107 p_recv, (void *)p_cinfo );
109 DRD64_LOG_DEBUG(" [DEBUG]SEND: Connect Cmd (for Debugd) Ended");
116 /* EOF of drd64_.c ----------------------------------- */