GCS  0.2.3
gcs_act_proto.h
1 /*
2  * Copyright (C) 2008 Codership Oy <info@codership.com>
3  *
4  * $Id: gcs_act_proto.h 3473 2014-02-28 02:03:19Z alex $
5  */
6 /*
7  * Interface to action protocol
8  * (to be extended to support protocol versions, currently supports only v0)
9  */
10 
11 #ifndef _gcs_act_proto_h_
12 #define _gcs_act_proto_h_
13 
14 #include "gcs.h" // for gcs_seqno_t
15 
16 #include <galerautils.h>
17 #include <stdint.h>
18 typedef uint8_t gcs_proto_t;
19 
21 #define GCS_ACT_PROTO_MAX 0
22 
24 typedef struct gcs_act_frag
25 {
26  gcs_seqno_t act_id;
27  size_t act_size;
28  const void* frag; // shall override it only once
29  size_t frag_len;
30  unsigned long frag_no;
31  gcs_act_type_t act_type;
32  int proto_ver;
33 }
35 
38 extern long
39 gcs_act_proto_write (gcs_act_frag_t* frag, void* buf, size_t buf_len);
40 
43 extern long
44 gcs_act_proto_read (gcs_act_frag_t* frag, const void* buf, size_t buf_len);
45 
50 static inline long
51 gcs_act_proto_inc (void* buf)
52 {
53  uint32_t frag_no = gtohl(((uint32_t*)buf)[3]) + 1;
54 #ifdef GCS_DEBUG_PROTO
55  if (!frag_no) return -EOVERFLOW;
56 #endif
57  ((uint32_t*)buf)[3] = htogl(frag_no);
58  return frag_no;
59 }
60 
62 extern long
63 gcs_act_proto_hdr_size (long version);
64 
66 static inline int
67 gcs_act_proto_ver (void* buf)
68 {
69  return *((uint8_t*)buf);
70 }
71 
72 #endif /* _gcs_act_proto_h_ */
Definition: gcs_act_proto.h:24