More code to store ACEs and SIDs. I have almost enough to start testing
[Samba/gebeck_regimport.git] / source3 / wrepld / partners.c
blob2387f5b45f665e67c29d72b7a2fc6147d69f09ac
1 /*
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.
21 #include "includes.h"
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)
33 int i;
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)
39 return True;
41 return False;
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)
52 return False;
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++;
61 return True;
64 /*******************************************************************
65 remove an entry to the list
66 ********************************************************************/
67 BOOL remove_partner(int client_assoc)
69 int i,j;
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)
77 return False;
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--;
90 return True;
93 /*******************************************************************
94 link the client and server context
95 ********************************************************************/
96 BOOL update_server_partner(int client_assoc, int server_assoc)
98 int i;
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;
105 return True;
108 return False;
111 /*******************************************************************
112 verify if it's a pull partner
113 ********************************************************************/
114 BOOL check_pull_partner(int assoc)
116 int i;
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)
123 return True;
125 return False;
128 /*******************************************************************
129 verify if it's a push partner
130 ********************************************************************/
131 BOOL check_push_partner(int assoc)
133 int i;
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)
140 return True;
142 return False;
145 /*******************************************************************
146 return the server ctx linked to the client ctx
147 ********************************************************************/
148 int get_server_assoc(int assoc)
150 int i;
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;
158 return 0;
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)
167 int i;
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;
175 return True;
178 return False;
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)
186 int i;
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;
194 return True;
197 return False;