OSDN Git Service

838ede1a7975eab4344e3b4c08829a691ea09688
[drdeamon64/drdeamon64.git] / libdrd64 / drd64_libdrd64_cmd_connect.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
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.
16
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.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #include"drd64_libdrd64.h"
38
39
40 LIBDRD64_FUNC
41 int
42         Drd64_LibDrd64_Cmd_Connect(
43                 void )
44 {
45         int             i_err;
46         int             i_socket_marshald;
47         Drd64_PacketHeader                      *p_phead;
48         Drd64_PacketData_Connect        *p_connect;
49
50         p_phead = (Drd64_PacketHeader *)gp_buffer;
51
52         Drd64_LibDrd64_Packet_SetPacketHeader(
53                                                         p_phead,
54                                                 DRD64_CONNECTID_NONE,
55                                                         DRD64_PACKETTYPE_CONTROL, 
56                                                         DRD64_COMMAND_CONNECT,
57                                                 sizeof( Drd64_PacketData_Connect ) );
58
59
60         p_connect       = (Drd64_PacketData_Connect *)DRD64_PacketData( gp_buffer );
61         p_connect->i_client_pid = getpid();
62         i_err   = Drd64_LibBrownie_INetAddr_SetInAddr_LocalHost(
63                                                         &(p_connect->t_client_addr_inet) );
64
65         p_connect->i_client_cinfo_id    = -1;
66         p_connect->i_connect_id         = -1;
67                 
68         /* Create Local marshald Socket */
69         i_socket_marshald
70                         = Drd64_LibBrownie_Socket_InitSocketClient_Local(
71                                                 DRD64_SOCKET_LOCAL_NAME_MARSHALD );
72         printf("cnt = %d\n", i_socket_marshald );
73
74         /* Request Attach */
75         i_err   = Drd64_LibDrd64_Packet_SendPacket(
76                                         i_socket_marshald, gp_buffer,
77                                         sizeof( Drd64_PacketData_Connect ),
78                                         sizeof( Drd64_PacketData_Connect ),
79                                         0x01 );
80         printf("connect: %d\n", i_err );
81         if( 0 > i_err )         {
82                 return 0x01;
83         }
84
85         /* Result */
86         drd64_libdrd64_minfo.i_marshald_socket          = i_socket_marshald;
87         drd64_libdrd64_minfo.i_marshald_connectid       = p_connect->i_connect_id;
88         drd64_libdrd64_minfo.i_marshald_pid                     = p_connect->i_marshald_pid;
89
90         return 0x00;
91 }
92
93
94 /* EOF of drd64_.c ----------------------------------- */