int
- Drd64_Marshald_Cmd_Connect(
+ Drd64_Marshald_Cmd_Connect_Client(
+ int i_fds,
+ Drd64_PacketHeader *p_phead,
+ Drd64_PacketData_Connect *p_connect )
+{
+ Drd64_Marshald_ConnectInfo *p_cinfo;
+
+ p_cinfo = Drd64_Marshald_GetConnectInfo( p_connect->i_client_cinfo_id );
+ assert( NULL != p_cinfo );
+
+ //p_cinfo->b_cinfo_type = DRD64_MARSHALD_CINFOTYPE_CLIENT;
+ //p_cinfo->i_cinfo_refcount = 1;
+ //p_cinfo->i_dest_socket = i_socket_inet;
+ //p_cinfo->str_dest_addr_local[0] = '\0';
+ //Drd64_Server_INetAddr_CopyInAddr(
+ // &(p_cinfo->t_dest_addr_inet), p_addr_dest );
+ //p_cinfo->i_src_socket = -1;
+ //p_cinfo->i_src_cinfo_id = -1;
+ //p_cinfo->i_prog_pid = -1;
+ //p_cinfo->i_debugd_pid = -1;
+ //i_err = Drd64_Server_INetAddr_SetInAddr_LocalHost(
+ // &(p_cinfo->t_client_addr_inet) );
+ //p_cinfo->i_client_pid = getpid();
+ p_cinfo->i_dest_cinfo_id = p_connect->i_connect_id;
+
+ return DRD64_MARSHALD_DISPATCH_RESULT_RESTART;
+}
+
+
+
+int
+ Drd64_Marshald_Cmd_Connect_Server(
int i_fds,
Drd64_PacketHeader *p_phead,
Drd64_PacketData_Connect *p_connect )
/* Alloc ConnectInfo. */
p_cinfo = Drd64_Marshald_CInfo_AllocConnectInfo();
if( NULL == p_cinfo )
- { return 0x00; }
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
p_cinfo->b_cinfo_type = DRD64_MARSHALD_CINFOTYPE_CONNECT;
p_cinfo->i_cinfo_refcount = 1;
p_connect->i_marshald_pid = getpid();
i_wlen = send( i_fds, (void *)p_phead, DRD64_PacketSize(p_phead), 0x00 );
+ if( i_wlen != DRD64_PacketSize(p_phead) )
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
- if( i_wlen != DRD64_PacketSize(p_phead) ) {
- return 0x00;
+ return DRD64_MARSHALD_DISPATCH_RESULT_COMPLETE;
+}
+
+
+int
+ Drd64_Marshald_Cmd_Connect(
+ int i_fds,
+ Drd64_PacketHeader *p_phead,
+ Drd64_PacketData_Connect *p_connect )
+{
+ int i_result;
+
+ if( DRD64_PACKETTYPE_ANSWER == p_phead->w_packettype ) {
+ i_result = Drd64_Marshald_Cmd_Connect_Client(
+ i_fds, p_phead, p_connect );
+
+ }
+ else {
+ i_result = Drd64_Marshald_Cmd_Connect_Server(
+ i_fds, p_phead, p_connect );
}
- return 0x02;
+ return i_result;
}
return;
}
+int
+ Drd64_Marshald_Dispatch_CallCommandFunction(
+ int i_fds,
+ Drd64_PacketHeader *p_phead,
+ void *pv_data,
+ Drd64_Marshald_MasterInformation *p_marshald )
+{
+ int i_result;
+ i_result = 0x00;
+
+ if( DRD64_COMMAND_CONNECT == p_phead->dw_command ) {
+ i_result = Drd64_Marshald_Cmd_Connect( i_fds, p_phead, pv_data );
+ }
+ else if( DRD64_COMMAND_DISCONNECT == p_phead->dw_command ) {
+ i_result = Drd64_Marshald_Cmd_DisConnect( i_fds, p_phead, pv_data );
+ }
+ else if( DRD64_COMMAND_ATTACH_REQUEST == p_phead->dw_command ) {
+ i_result = Drd64_Marshald_Cmd_AttachRequest(
+ i_fds, p_phead, pv_data, p_marshald );
+ }
+ else if( DRD64_COMMAND_DEBUG_REQUEST == p_phead->dw_command ) {
+ }
+ else if( DRD64_COMMAND_DETACH == p_phead->dw_command ) {
+ }
+ else if( DRD64_COMMAND_EXIT == p_phead->dw_command ) {
+ }
+ else
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
+
+ return i_result;
+}
+
int
Drd64_Marshald_Dispatch_JudgePacket(
int i_result;
Drd64_Server_RecvStatus *p_recv;
Drd64_PacketHeader *p_phead;
- Drd64_PacketData_AttachRequest *p_attach;
void *pv_data;
i_result = 0x00;
/* Judge 1: Receiving : Remain Bytes Receiving = 0x01 */
if( 0 < i_remainbytes )
- { return 0x01; }
+ { return DRD64_MARSHALD_DISPATCH_RESULT_RECEVING; }
/* Judge 2: Error: Connection Down or Close = 0x00 */
else if( 0 > i_remainbytes )
- { return 0x00; }
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
p_phead = (Drd64_PacketHeader *)p_recv->pv_buf;
-
assert( NULL != p_phead );
/* Check 1 : Header Check */
if( DRD64_PACKET_HEADER != p_phead->w_header )
- { return 0x01; }
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
/* Judge 3: Remain Packet Data? = 0x01 */
if(( DRD64_SERVER_RECVSTATUS_PHASE_HEADER == p_recv->i_read_phase ) &&
p_recv->i_read_phase = DRD64_SERVER_RECVSTATUS_PHASE_DATA;
/* Check BOF Attack */
if( DRD64_MAX_PACKET_DATA < p_phead->i_datalen )
- { return 0x00; }
+ { return DRD64_MARSHALD_DISPATCH_RESULT_CLOSE; }
p_recv->i_remain_bytes = p_phead->i_datalen;
puts("remain");
- return 0x01;
+ return DRD64_MARSHALD_DISPATCH_RESULT_RECEVING;
}
/*if(( DRD64_SERVER_RECVSTATUS_PHASE_END == p_recv->i_read_phase ) &&
{ pv_data = NULL; }
-
-
- if( DRD64_COMMAND_CONNECT == p_phead->dw_command ) {
- i_result = Drd64_Marshald_Cmd_Connect( i_fds, p_phead, pv_data );
- }
- else if( DRD64_COMMAND_DISCONNECT == p_phead->dw_command ) {
- i_result = Drd64_Marshald_Cmd_DisConnect( i_fds, p_phead, pv_data );
- }
- else if( DRD64_COMMAND_ATTACH_REQUEST == p_phead->dw_command ) {
- p_attach= pv_data;
- printf("%08x\n", p_attach->t_prog_addr );
- i_result = Drd64_Marshald_Cmd_AttachRequest(
+ i_result = Drd64_Marshald_Dispatch_CallCommandFunction(
i_fds, p_phead, pv_data, p_marshald );
- }
- else if( DRD64_COMMAND_DEBUG_REQUEST == p_phead->dw_command ) {
- }
- else if( DRD64_COMMAND_DETACH == p_phead->dw_command ) {
- }
- else if( DRD64_COMMAND_EXIT == p_phead->dw_command ) {
- }
- else
- { return 0x00; }
+
p_recv->i_read_phase = DRD64_SERVER_RECVSTATUS_PHASE_HEADER;
p_recv->i_remain_bytes = sizeof( Drd64_PacketHeader );
i_cnt, i_err, &drd64_marshald_info );
/* 0x00 = Judge 1 : Disconnect ( Others Packet ) */
- if( 0x00 == i_result ) {
+ if( DRD64_MARSHALD_DISPATCH_RESULT_CLOSE == i_result ) {
close( i_cnt );
FD_CLR( i_cnt, &fds_orig );
Drd64_Server_RecvStatus_FreeRecvStatus( i_cnt );