2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2017
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/>.
21 #include "system/network.h"
27 #include "protocol_api.h"
28 #include "protocol_private.h"
30 size_t ctdb_req_keepalive_len(struct ctdb_req_header
*h
,
31 struct ctdb_req_keepalive
*c
)
33 return ctdb_req_header_len(h
) +
34 ctdb_uint32_len(&c
->version
) +
35 ctdb_uint32_len(&c
->uptime
);
38 int ctdb_req_keepalive_push(struct ctdb_req_header
*h
,
39 struct ctdb_req_keepalive
*c
,
40 uint8_t *buf
, size_t *buflen
)
42 size_t length
, offset
= 0, np
;
44 length
= ctdb_req_keepalive_len(h
, c
);
45 if (*buflen
< length
) {
51 ctdb_req_header_push(h
, buf
+offset
, &np
);
54 ctdb_uint32_push(&c
->version
, buf
+offset
, &np
);
57 ctdb_uint32_push(&c
->uptime
, buf
+offset
, &np
);
63 int ctdb_req_keepalive_pull(uint8_t *buf
, size_t buflen
,
64 struct ctdb_req_header
*h
,
66 struct ctdb_req_keepalive
*c
)
68 struct ctdb_req_header header
;
69 size_t offset
= 0, np
;
72 ret
= ctdb_req_header_pull(buf
, buflen
, &header
, &np
);
82 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->version
, &np
);
88 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->uptime
, &np
);