ctdb-server: Use find_public_ip_vnn() in a couple of extra places
[samba4-gss.git] / lib / util / server_id.h
blobc9630b7f7749f2dc0a4f6403accba1635a7f12ee
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Bartlett 2011
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.
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, see <http://www.gnu.org/licenses/>.
20 #ifndef __LIB_UTIL_SERVER_ID_H__
21 #define __LIB_UTIL_SERVER_ID_H__
23 #include "replace.h"
25 struct server_id;
27 struct server_id_buf {
29 * 4294967295 uses 10 chars
30 * 18446744073709551615 uses 20 chars
32 * We have these combinations:
33 * - "disconnected"
34 * - PID64
35 * - PID64.TASK32
36 * - VNN32:PID64.TASK32
38 * The largest has 10 + 1 + 20 + 1 + 10 + 1 = 43 chars
40 * Optionally we allow :UNIQUE64 added,
41 * which adds 21 chars, so we are at 64 chars
42 * and that's 8 byte aligned.
44 char buf[64];
47 bool server_id_same_process(const struct server_id *p1,
48 const struct server_id *p2);
49 int server_id_cmp(const struct server_id *p1, const struct server_id *p2);
50 bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
51 char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
52 char *server_id_str_buf_unique_ex(struct server_id id,
53 char unique_delimiter,
54 struct server_id_buf *dst);
55 char *server_id_str_buf_unique(struct server_id id,
56 struct server_id_buf *dst);
58 struct server_id server_id_from_string(uint32_t local_vnn,
59 const char *pid_string);
60 struct server_id server_id_from_string_ex(uint32_t local_vnn,
61 char unique_delimiter,
62 const char *pid_string);
64 /**
65 * Set the serverid to the special value that represents a disconnected
66 * client for (e.g.) durable handles.
68 void server_id_set_disconnected(struct server_id *id);
70 /**
71 * check whether a serverid is the special placeholder for
72 * a disconnected client
74 bool server_id_is_disconnected(const struct server_id *id);
76 #define SERVER_ID_BUF_LENGTH 24
77 void server_id_put(uint8_t buf[SERVER_ID_BUF_LENGTH],
78 const struct server_id id);
79 void server_id_get(struct server_id *id,
80 const uint8_t buf[SERVER_ID_BUF_LENGTH]);
82 #endif