s3:lib: implement serverid_equal() as macro of server_id_equal()
[gd/samba-autobuild/.git] / source3 / include / serverid.h
1 /*
2    Unix SMB/CIFS implementation.
3    Implementation of a reliable server_exists()
4    Copyright (C) Volker Lendecke 2010
5
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 3 of the License, or
9    (at your option) any later version.
10
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.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __SERVERID_H__
21 #define __SERVERID_H__
22
23 #include "includes.h"
24
25 /*
26  * Register a server with its unique id
27  */
28 bool serverid_register(const struct server_id id, uint32_t msg_flags);
29
30 /*
31  * De-register a server with its unique id
32  */
33 bool serverid_deregister(const struct server_id id);
34
35 /*
36  * (De)register additional message flags
37  */
38 bool serverid_register_msg_flags(const struct server_id id, bool do_reg,
39                                  uint32_t msg_flags);
40
41 /*
42  * Check existence of a server id
43  */
44 bool serverid_exists(const struct server_id *id);
45
46 /*
47  * Check existence of a list of server ids
48  */
49 bool serverids_exist(const struct server_id *ids, int num_ids, bool *results);
50
51 /*
52  * Walk the list of server_ids registered
53  */
54 bool serverid_traverse(int (*fn)(struct db_record *rec,
55                                  const struct server_id *id,
56                                  uint32_t msg_flags,
57                                  void *private_data),
58                        void *private_data);
59
60 /*
61  * Walk the list of server_ids registered read-only
62  */
63 bool serverid_traverse_read(int (*fn)(const struct server_id *id,
64                                       uint32_t msg_flags,
65                                       void *private_data),
66                             void *private_data);
67 /*
68  * Ensure CLEAR_IF_FIRST works fine, to be called from the parent smbd
69  */
70 bool serverid_parent_init(TALLOC_CTX *mem_ctx);
71
72 /*
73  * Get a random unique_id and make sure that it is not
74  * SERVERID_UNIQUE_ID_NOT_TO_VERIFY
75  */
76 uint64_t serverid_get_random_unique_id(void);
77
78 #endif