From 1d2e773e6732fb30017b5e600db7ebfee10ab67b Mon Sep 17 00:00:00 2001 From: koinec <> Date: Sun, 28 Feb 2010 02:46:07 +0000 Subject: [PATCH] *** empty log message *** --- deamon/Makefile | 6 + deamon/drd64_marshald_cmd_detach.c | 225 ++++++++++++++++++++++++++++++++++ deamon/drd64_marshald_dispatch.c | 4 + drdrv1.c | 19 ++- include/drd64_packet.h | 9 ++ include/libdrd64.h | 5 + libdrd64/Makefile | 30 +++-- libdrd64/drd64_libdrd64_cinfo.c | 13 ++ libdrd64/drd64_libdrd64_cinfo.h | 6 + libdrd64/drd64_libdrd64_cmd_attach.c | 32 ++--- libdrd64/drd64_libdrd64_cmd_connect.c | 2 - libdrd64/drd64_libdrd64_cmd_detach.c | 73 ++++++----- libdrd64/drd64_libdrd64_packet.c | 1 - 13 files changed, 351 insertions(+), 74 deletions(-) create mode 100644 deamon/drd64_marshald_cmd_detach.c diff --git a/deamon/Makefile b/deamon/Makefile index 51e8c48..bb81020 100644 --- a/deamon/Makefile +++ b/deamon/Makefile @@ -92,6 +92,7 @@ MARSHALD_OBJS = drd64_marshald_main.o \ drd64_marshald_cmd_attach_request.o \ drd64_marshald_cmd_attach_link.o \ drd64_marshald_cmd_attach_report.o \ + drd64_marshald_cmd_detach.o \ drd64_marshald_msg_bootinfo.o \ drd64_marshald_send_connect.o \ drd64_marshald_connect_debugd.o \ @@ -182,6 +183,11 @@ drd64_marshald_cmd_attach_report.o: \ $(CC) -c -o drd64_marshald_cmd_attach_report.o $(FLAGS_DEBUG) \ drd64_marshald_cmd_attach_report.c +drd64_marshald_cmd_detach.o: \ + drd64_marshald_cmd_detach.c $(MARSHALD_HEADER) + $(CC) -c -o drd64_marshald_cmd_detach.o $(FLAGS_DEBUG) \ + drd64_marshald_cmd_detach.c + 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 diff --git a/deamon/drd64_marshald_cmd_detach.c b/deamon/drd64_marshald_cmd_detach.c new file mode 100644 index 0000000..72e27c8 --- /dev/null +++ b/deamon/drd64_marshald_cmd_detach.c @@ -0,0 +1,225 @@ +/*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_Cmd_AttachReport_Local_Answer( + int i_recv_id, + Drd64_PacketHeader *p_phead, + Drd64_PacketData_AttachReport *p_areport, + Drd64_Marshald_MasterInformation *p_marshald ) +{ + int i_result; + int i_err; + Drd64_Marshald_ConnectInfo *p_cinfo; + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (Local : Answer) Start"); + + i_result = DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE; + + p_phead->i_cid_dest = p_phead->i_cid_client; + + p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest ); + assert( NULL != p_cinfo ); + + p_phead->w_packettype ^= DRD64_PACKETTYPE_OPTION_INDICATE; + + i_err = send( p_cinfo->i_client_socket, (void *)p_phead, + DRD64_PacketSize(p_phead), 0x00 ); + DRD64_DEBUG_PRINT("send",i_err,"FD",p_cinfo->i_client_socket,"errno",errno); + if( i_err != DRD64_PacketSize(p_phead) ) { return 0x02; } + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (Local : Answer) Ended"); + + return i_result; +}*/ + + +/*---------------------------------------------------------------------- +----------------------------------------------------------------------*/ +/*int + Drd64_Marshald_Cmd_AttachReport_Local_Request( + int i_recv_id, + Drd64_PacketHeader *p_phead, + Drd64_PacketData_AttachReport *p_areport, + Drd64_Marshald_MasterInformation *p_marshald ) +{ + int i_result; + int i_err; + Drd64_Marshald_ConnectInfo *p_cinfo; + Drd64_Marshald_ConnectInfo *p_cinfo_debugd; + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (Local : Request) Start"); + + i_result = DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE; + + p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest ); + assert( NULL != p_cinfo ); + + p_cinfo_debugd = Drd64_Marshald_Connect_Debugd( + p_cinfo->str_dest_addr_local, + p_cinfo->i_prog_pid, + p_cinfo->i_debugd_pid ); + + p_cinfo->i_dest_socket = p_cinfo_debugd->i_dest_socket; + p_cinfo->i_debugd_socket = p_cinfo_debugd->i_dest_socket; + + + p_phead->w_packettype |= DRD64_PACKETTYPE_OPTION_INDICATE; + p_phead->i_cid_client = p_phead->i_cid_dest; + p_phead->i_cid_dest = DRD64_CONNECTID_NONE; + p_phead->i_cid_src = p_cinfo_debugd->i_cinfo_id; + + i_err = send( p_cinfo_debugd->i_dest_socket, (void *)p_phead, + DRD64_PacketSize(p_phead), 0x00 ); + DRD64_DEBUG_PRINT("send",i_err,"FD",p_cinfo_debugd->i_dest_socket,"errno",errno); + if( i_err != DRD64_PacketSize(p_phead) ) { return 0x02; } + + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (Local : Request) Ended"); + + return i_result; +}*/ + + +/*---------------------------------------------------------------------- +----------------------------------------------------------------------*/ +/*int + Drd64_Marshald_Cmd_AttachReport_Inet( + int i_recv_id, + Drd64_PacketHeader *p_phead, + Drd64_PacketData_AttachReport *p_areport, + Drd64_Marshald_MasterInformation *p_marshald ) +{ + int i_result; + int i_err; + Drd64_Marshald_ConnectInfo *p_cinfo; + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (INet) Start"); + + i_result = DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE; + + p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest ); + assert( NULL != p_cinfo ); + + p_phead->w_packettype |= DRD64_PACKETTYPE_FLAG_ANSWER; + + i_err = send( p_cinfo->i_client_socket, (void *)p_phead, + DRD64_PacketSize(p_phead), 0x00 ); + DRD64_DEBUG_PRINT("send",i_err,"FD",p_cinfo->i_client_socket,"errno",errno); + if( i_err != DRD64_PacketSize(p_phead) ) { return 0x02; } + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Attach Report (INet) Ended"); + + return i_result; +}*/ + +/*---------------------------------------------------------------------- +----------------------------------------------------------------------*/ +int + Drd64_Marshald_Cmd_Detach_Scn1_LocalRequest( + int i_recv_id, + Drd64_PacketHeader *p_phead, + Drd64_Marshald_ConnectInfo *p_cinfo, + Drd64_Marshald_MasterInformation *p_marshald ) +{ + int i_result; + int i_err; + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Detach (Local : Request) Start"); + + i_result = DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE; + + p_phead->w_packettype |= DRD64_PACKETTYPE_OPTION_INDICATE; + p_phead->i_cid_client = p_phead->i_cid_dest; + p_phead->i_cid_dest = DRD64_CONNECTID_NONE; + p_phead->i_cid_src = p_cinfo->i_cinfo_id; + + i_err = send( p_cinfo->i_dest_socket, (void *)p_phead, + DRD64_PacketSize(p_phead), 0x00 ); + DRD64_DEBUG_PRINT("send",i_err,"FD",p_cinfo->i_dest_socket,"errno",errno); + if( i_err != DRD64_PacketSize(p_phead) ) { return 0x02; } + + DRD64_LOG_DEBUG(" [DEBUG]CMD: Detach (Local : Request) Ended"); + + return i_result; +} + + +/*---------------------------------------------------------------------- +----------------------------------------------------------------------*/ +int + Drd64_Marshald_Cmd_Detach( + int i_recv_id, + Drd64_PacketHeader *p_phead, + Drd64_PacketData_AttachReport *p_areport, + Drd64_Marshald_MasterInformation *p_marshald ) +{ + int i_result; + Drd64_Marshald_ConnectInfo *p_cinfo; + + DRD64_LOG_VERBOSE("[STAT]CMD: Detach Start"); + + i_result = DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE; + + + if( DRD64_IsPacketType_Answer( p_phead ) ) { + } + else { + p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest ); + assert( NULL != p_cinfo ); + + /* Scnery 1: (Local)Detach Packet for Local Debugd */ + if( DRD64_CONNECTID_NONE == p_cinfo->i_dest_cinfo_id ) { + i_result = Drd64_Marshald_Cmd_Detach_Scn1_LocalRequest( + i_recv_id, p_phead, p_cinfo, p_marshald ); + } + /* Scnery 2: (INet)Detach Packet for INet Marshald */ + else { + } + } + + DRD64_LOG_VERBOSE("[STAT]CMD: Detach Ended"); + + return i_result; +} + + +/* EOF of drd64_.c ----------------------------------- */ diff --git a/deamon/drd64_marshald_dispatch.c b/deamon/drd64_marshald_dispatch.c index cacdaf0..fdf80ed 100644 --- a/deamon/drd64_marshald_dispatch.c +++ b/deamon/drd64_marshald_dispatch.c @@ -99,6 +99,8 @@ int } +/*---------------------------------------------------------------------- +----------------------------------------------------------------------*/ int Drd64_Marshald_Dispatch_ExecPacket( int i_recv_id, @@ -146,6 +148,8 @@ int i_recv_id, p_phead, pv_data, p_marshald ); } else if( DRD64_COMMAND_DETACH == p_phead->dw_command ) { + i_result = Drd64_Marshald_Cmd_Detach( + i_recv_id, p_phead, pv_data, p_marshald ); } else if( DRD64_COMMAND_EXIT == p_phead->dw_command ) { } diff --git a/drdrv1.c b/drdrv1.c index d06e304..2d5ac34 100644 --- a/drdrv1.c +++ b/drdrv1.c @@ -45,6 +45,7 @@ int { int i_target_pid; int i_err; + int i_cid; if( 2 > argc ) { puts(" drd64 [Target PID] "); @@ -55,16 +56,28 @@ int printf("TestProg. PID = %d\n", getpid()); Drd64_LibDrd64_InitSystem(); - Drd64_LibDrd64_Cmd_Connect(); + + /* 001. Connect Marshald */ + i_err = Drd64_LibDrd64_Cmd_Connect(); + if( 0x00 != i_err ) { + puts("[Error] Can't Connect Local-Marshald"); + return 0x00; + } if( 2 == argc ) { - Drd64_LibDrd64_Cmd_Attach( i_target_pid, "localhost" ); + i_cid = Drd64_LibDrd64_Cmd_Attach( i_target_pid, "localhost" ); } else if ( 2 < argc ) { - Drd64_LibDrd64_Cmd_Attach( i_target_pid, argv[2] ); + i_cid = Drd64_LibDrd64_Cmd_Attach( i_target_pid, argv[2] ); + } + if( 0 > i_cid ) { + puts("[Error] Can't Attach Target-Process"); + return 0x00; } + printf(" Attach CID = %d\n", i_cid ); sleep(2); + Drd64_LibDrd64_Cmd_Detach( i_cid ); Drd64_LibDrd64_Cmd_DisConecct(); Drd64_LibDrd64_TermSystem(); diff --git a/include/drd64_packet.h b/include/drd64_packet.h index 9d234bc..1957e16 100644 --- a/include/drd64_packet.h +++ b/include/drd64_packet.h @@ -164,6 +164,15 @@ typedef struct { } __attribute((packed)) Drd64_PacketData_AttachReport; +/* CMD: Detach =========================================*/ + +typedef struct { + /* Request Data */ + //INT i_cid; + + /* Answer Data */ + +} __attribute((packed)) Drd64_PacketData_Detach; #endif /* DRD64_HEADER_XXX */ diff --git a/include/libdrd64.h b/include/libdrd64.h index 13c58ca..5231b1b 100644 --- a/include/libdrd64.h +++ b/include/libdrd64.h @@ -64,6 +64,11 @@ LIBDRD64_FUNC int i_prog_pid, char *pstr_hostname ); +LIBDRD64_FUNC + int + Drd64_LibDrd64_Cmd_Detach( + int i_cid ); + #endif /* DRD64_HEADER_XXX */ diff --git a/libdrd64/Makefile b/libdrd64/Makefile index 2eff814..d5d4e20 100644 --- a/libdrd64/Makefile +++ b/libdrd64/Makefile @@ -58,7 +58,8 @@ LIBDRD64_OBJS = drd64_libdrd64_socket.o \ drd64_libdrd64_cinfo.o \ drd64_libdrd64_cmd_connect.o \ drd64_libdrd64_cmd_disconnect.o \ - drd64_libdrd64_cmd_attach.o + drd64_libdrd64_cmd_attach.o \ + drd64_libdrd64_cmd_detach.o LIBDRD64_HEADER = drd64_libdrd64.h all: $(LIBDRD64_TARGET) @@ -69,26 +70,37 @@ $(LIBDRD64_TARGET): $(LIBDRD64_OBJS) cp $(LIBDRD64_TARGET) .. drd64_libdrd64_system.o: drd64_libdrd64_system.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_system.o $(FLAGS_DEBUG) drd64_libdrd64_system.c + $(CC) -c -o drd64_libdrd64_system.o $(FLAGS_DEBUG) \ + drd64_libdrd64_system.c drd64_libdrd64_socket.o: drd64_libdrd64_socket.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_socket.o $(FLAGS_DEBUG) drd64_libdrd64_socket.c + $(CC) -c -o drd64_libdrd64_socket.o $(FLAGS_DEBUG) \ + drd64_libdrd64_socket.c drd64_libdrd64_packet.o: drd64_libdrd64_packet.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_packet.o $(FLAGS_DEBUG) drd64_libdrd64_packet.c + $(CC) -c -o drd64_libdrd64_packet.o $(FLAGS_DEBUG) \ + drd64_libdrd64_packet.c drd64_libdrd64_cinfo.o: drd64_libdrd64_cinfo.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_cinfo.o $(FLAGS_DEBUG) drd64_libdrd64_cinfo.c + $(CC) -c -o drd64_libdrd64_cinfo.o $(FLAGS_DEBUG) \ + drd64_libdrd64_cinfo.c drd64_libdrd64_cmd_connect.o: drd64_libdrd64_cmd_connect.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_cmd_connect.o $(FLAGS_DEBUG) drd64_libdrd64_cmd_connect.c + $(CC) -c -o drd64_libdrd64_cmd_connect.o $(FLAGS_DEBUG) \ + drd64_libdrd64_cmd_connect.c -drd64_libdrd64_cmd_disconnect.o: drd64_libdrd64_cmd_disconnect.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_cmd_disconnect.o $(FLAGS_DEBUG) drd64_libdrd64_cmd_disconnect.c +drd64_libdrd64_cmd_disconnect.o: drd64_libdrd64_cmd_disconnect.c \ + $(LIBDRD64_HEADER) + $(CC) -c -o drd64_libdrd64_cmd_disconnect.o $(FLAGS_DEBUG) \ + drd64_libdrd64_cmd_disconnect.c drd64_libdrd64_cmd_attach.o: drd64_libdrd64_cmd_attach.c $(LIBDRD64_HEADER) - $(CC) -c -o drd64_libdrd64_cmd_attach.o $(FLAGS_DEBUG) drd64_libdrd64_cmd_attach.c + $(CC) -c -o drd64_libdrd64_cmd_attach.o $(FLAGS_DEBUG) \ + drd64_libdrd64_cmd_attach.c +drd64_libdrd64_cmd_detach.o: drd64_libdrd64_cmd_detach.c $(LIBDRD64_HEADER) + $(CC) -c -o drd64_libdrd64_cmd_detach.o $(FLAGS_DEBUG) \ + drd64_libdrd64_cmd_detach.c clean: diff --git a/libdrd64/drd64_libdrd64_cinfo.c b/libdrd64/drd64_libdrd64_cinfo.c index 5700f37..4f1f33f 100644 --- a/libdrd64/drd64_libdrd64_cinfo.c +++ b/libdrd64/drd64_libdrd64_cinfo.c @@ -135,4 +135,17 @@ int return 0x00; } + +LIBDRD64_CINFO_EXTERN +Drd64_LibDrd64_ConnectInfo * + Drd64_LibDrd64_CInfo_GetConnectInfo( + int i_cid ) +{ + if(( gi_now_connect_info <= i_cid ) && ( 0 > i_cid )) + { return NULL; } + + return (gp_connect_info + i_cid); +} + + /* EOF of drd64_.c ----------------------------------- */ diff --git a/libdrd64/drd64_libdrd64_cinfo.h b/libdrd64/drd64_libdrd64_cinfo.h index 7efd605..01ff4de 100644 --- a/libdrd64/drd64_libdrd64_cinfo.h +++ b/libdrd64/drd64_libdrd64_cinfo.h @@ -99,6 +99,12 @@ LIBDRD64_CINFO_EXTERN Drd64_LibDrd64_TermConnectInfo( void ); +LIBDRD64_CINFO_EXTERN + Drd64_LibDrd64_ConnectInfo * + Drd64_LibDrd64_CInfo_GetConnectInfo( + int i_cid ); + + #endif /* DRD64_HEADER_XXX */ diff --git a/libdrd64/drd64_libdrd64_cmd_attach.c b/libdrd64/drd64_libdrd64_cmd_attach.c index f370190..ae2ea66 100644 --- a/libdrd64/drd64_libdrd64_cmd_attach.c +++ b/libdrd64/drd64_libdrd64_cmd_attach.c @@ -71,10 +71,7 @@ int sizeof( Drd64_PacketData_AttachReport ), sizeof( Drd64_PacketData_AttachReport ), 0x00 ); - printf("attach report: %d\n", i_err ); - if( 0 > i_err ) { - return -2; - } + if( 0 > i_err ) { return -2; } return 0x00; } @@ -86,7 +83,6 @@ int { int i_err; int i_socket; - //int i_socket_marshald; Drd64_PacketHeader *p_phead; Drd64_PacketData_AttachLink *p_alink; @@ -121,21 +117,13 @@ int DRD64_COMMAND_ATTACH_LINK, sizeof( Drd64_PacketData_AttachLink ) ); - /*p_alink - = (Drd64_PacketData_AttachLink *)DRD64_PacketData( gp_buffer ); - */ - /* Phase 3 : Send & Recv. Attach-Link Cmd */ i_err = Drd64_LibDrd64_Packet_SendPacket( i_socket, gp_buffer, sizeof( Drd64_PacketData_AttachLink ), sizeof( Drd64_PacketData_AttachLink ), 0x00 ); - printf("attach Link: %d\n", i_err ); - if( 0 > i_err ) { - return -2; - } - + if( 0 > i_err ) { return -2; } return 0x00; } @@ -190,7 +178,6 @@ int sizeof( Drd64_PacketData_AttachRequest ), sizeof( Drd64_PacketData_AttachRequest ), 0x01 ); - printf("attach: %d\n", i_err ); if( 0 > i_err ) { return 0x01; } @@ -212,8 +199,6 @@ int p_cinfo->i_marshald_cid = p_attach->i_cid_marshald; p_cinfo->i_marshald_socket = drd64_libdrd64_minfo.i_marshald_socket; - puts( p_cinfo->str_debugd_addr_local ); - return 0x00; } @@ -224,6 +209,7 @@ int int i_prog_pid, char *pstr_hostname ) { + int i_err; Drd64_LibDrd64_ConnectInfo *p_cinfo; /* Alloc Connect Info */ @@ -233,15 +219,19 @@ int } /* Phase 1: Attach Request */ - Drd64_LibDrd64_Cmd_Attach_Request( p_cinfo, i_prog_pid, pstr_hostname ); + i_err = Drd64_LibDrd64_Cmd_Attach_Request( + p_cinfo, i_prog_pid, pstr_hostname ); + if( 0x00 != i_err ) { return -2; } /* Phase 2: Attach Link */ - Drd64_LibDrd64_Cmd_Attach_Link( p_cinfo ); + i_err = Drd64_LibDrd64_Cmd_Attach_Link( p_cinfo ); + if( 0x00 != i_err ) { return -3; } /* Phase 3: Attach Report */ - Drd64_LibDrd64_Cmd_Attach_Report( p_cinfo ); + i_err = Drd64_LibDrd64_Cmd_Attach_Report( p_cinfo ); + if( 0x00 != i_err ) { return -4; } - return 0x00; + return p_cinfo->i_id; } diff --git a/libdrd64/drd64_libdrd64_cmd_connect.c b/libdrd64/drd64_libdrd64_cmd_connect.c index 838ede1..c857222 100644 --- a/libdrd64/drd64_libdrd64_cmd_connect.c +++ b/libdrd64/drd64_libdrd64_cmd_connect.c @@ -69,7 +69,6 @@ int i_socket_marshald = Drd64_LibBrownie_Socket_InitSocketClient_Local( DRD64_SOCKET_LOCAL_NAME_MARSHALD ); - printf("cnt = %d\n", i_socket_marshald ); /* Request Attach */ i_err = Drd64_LibDrd64_Packet_SendPacket( @@ -77,7 +76,6 @@ int sizeof( Drd64_PacketData_Connect ), sizeof( Drd64_PacketData_Connect ), 0x01 ); - printf("connect: %d\n", i_err ); if( 0 > i_err ) { return 0x01; } diff --git a/libdrd64/drd64_libdrd64_cmd_detach.c b/libdrd64/drd64_libdrd64_cmd_detach.c index f370190..5698f4d 100644 --- a/libdrd64/drd64_libdrd64_cmd_detach.c +++ b/libdrd64/drd64_libdrd64_cmd_detach.c @@ -37,7 +37,7 @@ Comment: #include"drd64_libdrd64.h" -int +/*int Drd64_LibDrd64_Cmd_Attach_Report( Drd64_LibDrd64_ConnectInfo *p_cinfo ) { @@ -49,14 +49,10 @@ int assert( NULL != p_cinfo ); - /* Phase 1 : Set Packet Data --- */ p_phead = (Drd64_PacketHeader *)gp_buffer; p_areport = (Drd64_PacketData_AttachReport *)DRD64_PacketData( gp_buffer ); - /*strncpy( p_alink->str_debugd_sockname, - p_cinfo->str_debugd_addr_local, - DRD64_MAX_PATH );*/ Drd64_LibDrd64_Packet_SetPacketHeader( p_phead, @@ -65,7 +61,6 @@ int DRD64_COMMAND_ATTACH_REPORT, sizeof( Drd64_PacketData_AttachReport ) ); - /* Phase 2 : Send & Recv. Attach-Link Cmd */ i_err = Drd64_LibDrd64_Packet_SendPacket( p_cinfo->i_marshald_socket, gp_buffer, sizeof( Drd64_PacketData_AttachReport ), @@ -77,23 +72,21 @@ int } return 0x00; -} +} */ -int +/*int Drd64_LibDrd64_Cmd_Attach_Link( Drd64_LibDrd64_ConnectInfo *p_cinfo ) { int i_err; int i_socket; - //int i_socket_marshald; Drd64_PacketHeader *p_phead; Drd64_PacketData_AttachLink *p_alink; assert( NULL != p_cinfo ); - /* Phase 1 : Create Socket for Debugd */ if( DRD64_LIBDRD64_CINFO_COMMTYPE_LOCAL == p_cinfo->b_commtype ) { i_socket = Drd64_LibBrownie_Socket_InitSocketClient_Local( p_cinfo->str_debugd_addr_local ); @@ -106,7 +99,6 @@ int if( 0 > i_socket ) { return -1; } - /* Phase 2 : Set Packet Data --- */ p_phead = (Drd64_PacketHeader *)gp_buffer; p_alink = (Drd64_PacketData_AttachLink *)DRD64_PacketData( gp_buffer ); @@ -121,11 +113,6 @@ int DRD64_COMMAND_ATTACH_LINK, sizeof( Drd64_PacketData_AttachLink ) ); - /*p_alink - = (Drd64_PacketData_AttachLink *)DRD64_PacketData( gp_buffer ); - */ - - /* Phase 3 : Send & Recv. Attach-Link Cmd */ i_err = Drd64_LibDrd64_Packet_SendPacket( i_socket, gp_buffer, sizeof( Drd64_PacketData_AttachLink ), @@ -136,13 +123,11 @@ int return -2; } - return 0x00; -} - +}*/ -int +/*int Drd64_LibDrd64_Cmd_Attach_Request( Drd64_LibDrd64_ConnectInfo *p_cinfo, int i_prog_pid, @@ -154,7 +139,6 @@ int Drd64_PacketHeader *p_phead; Drd64_PacketData_AttachRequest *p_attach; - /* Phase 1 : Set Packet Data --- */ p_phead = (Drd64_PacketHeader *)gp_buffer; Drd64_LibDrd64_Packet_SetPacketHeader( @@ -183,7 +167,6 @@ int p_attach->i_cid_debugd = DRD64_CONNECTID_NONE; p_attach->i_cid_marshald = DRD64_CONNECTID_NONE; - /* Phase 2 : Send Attach-Request Packet --- */ i_err = Drd64_LibDrd64_Packet_SendPacket( drd64_libdrd64_minfo.i_marshald_socket, gp_buffer, @@ -195,7 +178,6 @@ int return 0x01; } - /* Phase 3 : Set ConnectInfo from Result ---*/ p_cinfo->b_commtype = b_commtype; p_cinfo->i_prog_pid = i_prog_pid; @@ -215,31 +197,46 @@ int puts( p_cinfo->str_debugd_addr_local ); return 0x00; -} +}*/ LIBDRD64_FUNC int - Drd64_LibDrd64_Cmd_Attach( - int i_prog_pid, - char *pstr_hostname ) + Drd64_LibDrd64_Cmd_Detach( + int i_cid ) { + int i_err; + int i_socket; + int i_socket_marshald; + Drd64_PacketHeader *p_phead; + Drd64_PacketData_AttachReport *p_areport; Drd64_LibDrd64_ConnectInfo *p_cinfo; - /* Alloc Connect Info */ - p_cinfo = Drd64_LibDrd64_CInfo_AllocConnectInfo(); - if( NULL == p_cinfo ) { - return -1; - } + p_cinfo = Drd64_LibDrd64_CInfo_GetConnectInfo( i_cid ); + if( NULL == p_cinfo ) { return -1; } - /* Phase 1: Attach Request */ - Drd64_LibDrd64_Cmd_Attach_Request( p_cinfo, i_prog_pid, pstr_hostname ); + /* Phase 1 : Set Packet Data --- */ + p_phead = (Drd64_PacketHeader *)gp_buffer; + /*p_areport + = (Drd64_PacketData_AttachReport *)DRD64_PacketData( gp_buffer );*/ - /* Phase 2: Attach Link */ - Drd64_LibDrd64_Cmd_Attach_Link( p_cinfo ); + Drd64_LibDrd64_Packet_SetPacketHeader( + p_phead, + p_cinfo->i_marshald_cid, + DRD64_PACKETTYPE_CONTROL, + DRD64_COMMAND_DETACH, + 0 ); - /* Phase 3: Attach Report */ - Drd64_LibDrd64_Cmd_Attach_Report( p_cinfo ); + /* Phase 2 : Send & Recv. Attach-Link Cmd */ + i_err = Drd64_LibDrd64_Packet_SendPacket( + p_cinfo->i_marshald_socket, gp_buffer, + 0, + 0, + 0x00 ); + printf("detach: %d\n", i_err ); + if( 0 > i_err ) { + return -2; + } return 0x00; } diff --git a/libdrd64/drd64_libdrd64_packet.c b/libdrd64/drd64_libdrd64_packet.c index 5dadf4a..759242f 100644 --- a/libdrd64/drd64_libdrd64_packet.c +++ b/libdrd64/drd64_libdrd64_packet.c @@ -92,7 +92,6 @@ int p_phead = (Drd64_PacketHeader *)p_packet; p_data = p_packet + sizeof( Drd64_PacketHeader ); - printf("size: %d\n", p_phead->i_datalen ); if( i_rsize < p_phead->i_datalen ) { return -2; } -- 2.11.0