2 Unix SMB/CIFS implementation.
3 process incoming packets - main loop
4 Copyright (C) Jean François Micouleau 1998-2002.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "wins_repl.h"
24 /* we can exchange info with 64 partners at any given time */
25 WINS_PARTNER current_partners
[64];
26 int total_current_partners
;
28 /*******************************************************************
29 verify if we know this partner
30 ********************************************************************/
31 BOOL
check_partner(int assoc
)
35 DEBUG(5,("check_partner: total_current_partners: %d\n", total_current_partners
));
37 for (i
=0; i
<total_current_partners
; i
++)
38 if (current_partners
[i
].client_assoc
==assoc
)
44 /*******************************************************************
45 add a new entry to the list
46 ********************************************************************/
47 BOOL
add_partner(int client_assoc
, int server_assoc
, BOOL pull
, BOOL push
)
49 DEBUG(5,("add_partner: total_current_partners: %d\n", total_current_partners
));
51 if (total_current_partners
==64)
54 current_partners
[total_current_partners
].client_assoc
=client_assoc
;
55 current_partners
[total_current_partners
].server_assoc
=server_assoc
;
56 current_partners
[total_current_partners
].pull_partner
=pull
;
57 current_partners
[total_current_partners
].push_partner
=push
;
59 total_current_partners
++;
64 /*******************************************************************
65 remove an entry to the list
66 ********************************************************************/
67 BOOL
remove_partner(int client_assoc
)
71 DEBUG(5,("remove_partner: total_current_partners: %d\n", total_current_partners
));
73 for (i
=0; current_partners
[i
].client_assoc
!=client_assoc
&& i
<total_current_partners
; i
++)
76 if (i
==total_current_partners
)
79 for (j
=i
+1; j
<total_current_partners
; j
++) {
80 current_partners
[j
-1].client_assoc
=current_partners
[j
].client_assoc
;
81 current_partners
[j
-1].server_assoc
=current_partners
[j
].server_assoc
;
82 current_partners
[j
-1].pull_partner
=current_partners
[j
].pull_partner
;
83 current_partners
[j
-1].push_partner
=current_partners
[j
].push_partner
;
84 current_partners
[j
-1].partner_server
.s_addr
=current_partners
[j
].partner_server
.s_addr
;
85 current_partners
[j
-1].other_server
.s_addr
=current_partners
[j
].other_server
.s_addr
;
88 total_current_partners
--;
93 /*******************************************************************
94 link the client and server context
95 ********************************************************************/
96 BOOL
update_server_partner(int client_assoc
, int server_assoc
)
100 DEBUG(5,("update_server_partner: total_current_partners: %d\n", total_current_partners
));
102 for (i
=0; i
<total_current_partners
; i
++)
103 if (current_partners
[i
].client_assoc
==client_assoc
) {
104 current_partners
[i
].server_assoc
=server_assoc
;
111 /*******************************************************************
112 verify if it's a pull partner
113 ********************************************************************/
114 BOOL
check_pull_partner(int assoc
)
118 DEBUG(5,("check_pull_partner: total_current_partners: %d\n", total_current_partners
));
120 for (i
=0; i
<total_current_partners
; i
++)
121 if (current_partners
[i
].client_assoc
==assoc
&&
122 current_partners
[i
].pull_partner
==True
)
128 /*******************************************************************
129 verify if it's a push partner
130 ********************************************************************/
131 BOOL
check_push_partner(int assoc
)
135 DEBUG(5,("check_push_partner: total_current_partners: %d\n", total_current_partners
));
137 for (i
=0; i
<total_current_partners
; i
++)
138 if (current_partners
[i
].client_assoc
==assoc
&&
139 current_partners
[i
].push_partner
==True
)
145 /*******************************************************************
146 return the server ctx linked to the client ctx
147 ********************************************************************/
148 int get_server_assoc(int assoc
)
152 DEBUG(5,("get_server_assoc: total_current_partners: %d\n", total_current_partners
));
154 for (i
=0; i
<total_current_partners
; i
++)
155 if (current_partners
[i
].client_assoc
==assoc
)
156 return current_partners
[i
].server_assoc
;
162 /*******************************************************************
163 link the client and server context
164 ********************************************************************/
165 BOOL
write_server_assoc_table(int client_assoc
, struct in_addr partner
, struct in_addr server
)
169 DEBUG(5,("write_server_assoc_table: total_current_partners: %d\n", total_current_partners
));
171 for (i
=0; i
<total_current_partners
; i
++)
172 if (current_partners
[i
].client_assoc
==client_assoc
) {
173 current_partners
[i
].partner_server
=partner
;
174 current_partners
[i
].other_server
=server
;
181 /*******************************************************************
182 link the client and server context
183 ********************************************************************/
184 BOOL
get_server_assoc_table(int client_assoc
, struct in_addr
*partner
, struct in_addr
*server
)
188 DEBUG(5,("get_server_assoc_table: total_current_partners: %d\n", total_current_partners
));
190 for (i
=0; i
<total_current_partners
; i
++)
191 if (current_partners
[i
].client_assoc
==client_assoc
) {
192 partner
->s_addr
=current_partners
[i
].partner_server
.s_addr
;
193 server
->s_addr
=current_partners
[i
].other_server
.s_addr
;