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_CINFO
38 #include"drd64_marshald.h"
40 Drd64_Marshald_ConnectInfo *gp_marshald_cinfo;
41 int gi_marshald_cinfo_max;
42 int gi_marshald_cinfo_now;
46 Drd64_Marshald_ConnectInfo *
47 Drd64_Marshald_SearchINetConnection(
48 struct in_addr *p_addr )
51 Drd64_Marshald_ConnectInfo *p_cinfo;
55 for( i_cnt = 0; i_cnt < gi_marshald_cinfo_now; i_cnt++ ) {
56 p_cinfo = (gp_marshald_cinfo + i_cnt);
58 if( DRD64_MARSHALD_CINFOTYPE_CLIENT
59 == p_cinfo->b_cinfo_type ) {
60 if( 0x00 == Drd64_LibBrownie_INetAddr_CmpInAddr(
61 p_addr, &(p_cinfo->t_dest_addr_inet)) )
71 Drd64_Marshald_ConnectInfo *
72 Drd64_Marshald_CInfo_GetConnectInfo(
75 if(( 0 > i_cinfo_id ) || ( gi_marshald_cinfo_max < i_cinfo_id ))
77 return (gp_marshald_cinfo + i_cinfo_id);
83 Drd64_Marshald_ConnectInfo *
84 Drd64_Marshald_CInfo_AllocConnectInfo(
89 Drd64_Marshald_ConnectInfo *p_cinfo_temp;
90 Drd64_Marshald_ConnectInfo *p_cinfo_now;
95 if( gi_marshald_cinfo_now == gi_marshald_cinfo_max ) {
96 for( i_cnt = 0; i_cnt < gi_marshald_cinfo_max; i_cnt++ ) {
97 p_cinfo_temp = gp_marshald_cinfo + i_cnt;
99 if( -1 == p_cinfo_temp->i_cinfo_id ) {
100 i_cinfo_newid = i_cnt;
105 if( -1 == i_cinfo_newid ) {
107 = (Drd64_Marshald_ConnectInfo *)
108 realloc( gp_marshald_cinfo,
109 sizeof( Drd64_Marshald_ConnectInfo )
110 * ( gi_marshald_cinfo_max
111 + DRD64_MARSHALD_CINFO_UNITS) );
112 if( NULL == p_cinfo_temp ) { return NULL; }
114 gp_marshald_cinfo = p_cinfo_temp;
115 gi_marshald_cinfo_max += DRD64_MARSHALD_CINFO_UNITS;
116 i_cinfo_newid = gi_marshald_cinfo_now++;
120 i_cinfo_newid = gi_marshald_cinfo_now++;
123 if( -1 != i_cinfo_newid ) {
124 p_cinfo_now = gp_marshald_cinfo + i_cinfo_newid;
126 memset( p_cinfo_now, 0x00, sizeof( Drd64_Marshald_ConnectInfo ) );
127 p_cinfo_now->i_cinfo_id = i_cinfo_newid;
135 EXTERN_MARSHALD_CINFO
137 Drd64_Marshald_Cinfo_FreeConnectInfo(
138 Drd64_Marshald_ConnectInfo *p_cinfo )
140 if( NULL == p_cinfo ) { return 0x01; }
142 if( p_cinfo->i_cinfo_id + 1 == gi_marshald_cinfo_now )
143 { gi_marshald_cinfo_now--; }
145 p_cinfo->i_cinfo_id = -1;
151 EXTERN_MARSHALD_CINFO
153 Drd64_Marshald_CInfo_InitConnectInfo(
159 = (Drd64_Marshald_ConnectInfo *)malloc(
160 sizeof( Drd64_Marshald_ConnectInfo )
161 * DRD64_MARSHALD_CINFO_UNITS );
163 if( NULL == gp_marshald_cinfo ) {
167 memset( gp_marshald_cinfo, 0x00,
168 sizeof( Drd64_Marshald_ConnectInfo )
169 * DRD64_MARSHALD_CINFO_UNITS );
171 gi_marshald_cinfo_max = DRD64_MARSHALD_CINFO_UNITS;
172 gi_marshald_cinfo_now = 0;
178 EXTERN_MARSHALD_CINFO
180 Drd64_Marshald_CInfo_TermConnectInfo(
183 if( NULL != gp_marshald_cinfo ) {
184 free( gp_marshald_cinfo );
185 gp_marshald_cinfo = NULL;
188 gi_marshald_cinfo_max = DRD64_MARSHALD_CINFO_UNITS;
189 gi_marshald_cinfo_now = 0;
195 /* EOF of drd64_.c ----------------------------------- */