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 #include"drd64_marshald.h"
40 /*----------------------------------------------------------------------
42 Drd64_Intel64_DisAsm_GetSize_SizeID(
43 : Get Operand Size form Intel 64 DB SizeID
45 int i_operandsize, : [src] Default Operand Size
46 Word w_methodtype, : [src] Method Type ID
47 Word w_sizeid ) : [src] Size ID
48 ----------------------------------------------------------------------*/
50 Drd64_Marshald_Cmd_ConnectCount_Client(
52 Drd64_PacketHeader *p_phead,
53 Drd64_PacketData_ConnectCount *p_ccount )
55 Drd64_Marshald_ConnectInfo *p_cinfo;
57 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Client) Start");
59 p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo(
61 assert( NULL != p_cinfo );
63 p_cinfo->i_cinfo_refcount += p_ccount->i_refcount_diff;
65 if( p_cinfo->i_cinfo_refcount != p_ccount->i_refcount_server ) {
66 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Client) Error");
69 if( 0 == p_cinfo->i_cinfo_refcount ) {
70 Drd64_Marshald_Dispatch_CloseSocket( p_cinfo->i_dest_socket );
71 //Drd64_Marshald_Cinfo_FreeConnectInfo( p_cinfo );
73 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Client) DisConnect");
76 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Client) Ended");
78 return DRD64_MARSHALD_DISPATCH_RESULT_RESTART;
82 /*----------------------------------------------------------------------
83 ----------------------------------------------------------------------*/
85 Drd64_Marshald_Cmd_ConnectCount_Server(
87 Drd64_PacketHeader *p_phead,
88 Drd64_PacketData_ConnectCount *p_ccount )
92 Drd64_Marshald_ConnectInfo *p_cinfo;
93 Drd64_Server_RecvStatus *p_recv;
95 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Server) Start");
97 p_recv = Drd64_Server_RecvStatus_GetRecvStatus( i_recv_id );
98 assert( NULL != p_recv );
99 i_fds = p_recv->i_fds_id;
101 /* Alloc ConnectInfo. */
102 p_cinfo = Drd64_Marshald_CInfo_GetConnectInfo( p_phead->i_cid_dest );
103 assert( NULL != p_cinfo );
105 p_cinfo->i_cinfo_refcount += p_ccount->i_refcount_diff;
106 /* XXX : Connection Lock
107 if( 0 == p_cinfo->i_cinfo_refcount ) {
112 /* Set Answer Data ---------*/
113 p_phead->w_packettype |= DRD64_PACKETTYPE_FLAG_ANSWER;
114 p_ccount->i_refcount_server = p_cinfo->i_cinfo_refcount;
116 i_wlen = send( i_fds, (void *)p_phead, DRD64_PacketSize(p_phead), 0x00 );
117 DRD64_DEBUG_PRINT("send",i_wlen,"FD",i_fds,"errno",errno);
118 if( i_wlen != DRD64_PacketSize(p_phead) )
119 { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; } // XXX > error
121 DRD64_LOG_DEBUG(" [DEBUG] CMD: ConnectCount(Server) Complete ");
123 return DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE;
127 /*----------------------------------------------------------------------
128 ----------------------------------------------------------------------*/
130 Drd64_Marshald_Cmd_ConnectCount(
132 Drd64_PacketHeader *p_phead,
133 Drd64_PacketData_ConnectCount *p_ccount )
137 DRD64_LOG_VERBOSE("[STAT]CMD: Connect Count Start");
139 if( DRD64_IsPacketType_Answer( p_phead ) ) {
140 i_result = Drd64_Marshald_Cmd_ConnectCount_Client(
141 i_recv_id, p_phead, p_ccount );
145 i_result = Drd64_Marshald_Cmd_ConnectCount_Server(
146 i_recv_id, p_phead, p_ccount );
149 DRD64_LOG_VERBOSE("[STAT]CMD: Connect Count Ended");
155 /* EOF of drd64_.c ----------------------------------- */