Mercury
mercury_proc_header.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Argonne National Laboratory, Department of Energy,
3  *                    UChicago Argonne, LLC and The HDF Group.
4  * All rights reserved.
5  *
6  * The full copyright notice, including terms governing use, modification,
7  * and redistribution, is contained in the COPYING file that can be
8  * found at the root of the source code distribution tree.
9  */
10 
11 #ifndef MERCURY_PROC_HEADER_H
12 #define MERCURY_PROC_HEADER_H
13 
14 #include "mercury_types.h"
15 
17  hg_uint8_t hg; /* Mercury identifier */
18  hg_uint32_t protocol; /* Version number */
19  hg_id_t id; /* RPC request identifier */
20  hg_uint8_t flags; /* Flags (extra buffer) */
21  hg_uint32_t cookie; /* Random cookie */
22  hg_uint16_t crc16; /* CRC16 checksum */
23  /* Should be 128 bits here */
24  hg_bulk_t extra_buf_handle; /* Extra handle (large data) */
25 };
26 
28  hg_uint8_t flags; /* Flags */
29  hg_error_t error; /* Error */
30  hg_uint32_t cookie; /* Cookie */
31  hg_uint16_t crc16; /* CRC16 checksum */
32  hg_uint8_t padding;
33  /* Should be 96 bits here */
34 };
35 
36 /*
37  * 0 HG_PROC_HEADER_SIZE size
38  * |______________|__________________________|
39  * | Header | Encoded Data |
40  * |______________|__________________________|
41  *
42  *
43  * Request:
44  * mercury byte / protocol version number / rpc id / flags (e.g. for extra buf) /
45  * random cookie / crc16 / (bulk handle, there is space since payload is copied)
46  *
47  * Response:
48  * flags / error / cookie / crc16 / payload
49  */
50 
51 /* Mercury identifier for packets sent */
52 #define HG_IDENTIFIER (('H' << 1) | ('G')) /* 0xD7 */
53 
54 /* Mercury protocol version number */
55 #define HG_PROTOCOL_VERSION 0x00000002
56 
57 /* Encode/decode version number into uint32 */
58 #define HG_GET_MAJOR(value) ((value >> 24) & 0xFF)
59 #define HG_GET_MINOR(value) ((value >> 16) & 0xFF)
60 #define HG_GET_PATCH(value) (value & 0xFFFF)
61 #define HG_VERSION ((HG_VERSION_MAJOR << 24) | (HG_VERSION_MINOR << 16) \
62  | HG_VERSION_PATCH)
63 
64 #ifndef HG_PROC_HEADER_INLINE
65  #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
66  #define HG_PROC_HEADER_INLINE extern HG_INLINE
67  #else
68  #define HG_PROC_HEADER_INLINE HG_INLINE
69  #endif
70 #endif
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
78 
86 {
87  /* hg_bulk_t is optional and is not really part of the header */
88  return (sizeof(struct hg_header_request) - sizeof(hg_bulk_t));
89 }
90 
98 {
99  return sizeof(struct hg_header_response);
100 }
101 
110 HG_EXPORT void
111 hg_proc_header_request_init(hg_id_t id, hg_bulk_t extra_buf_handle,
112  struct hg_header_request *header);
113 
120 HG_EXPORT void
122 
123 
134 HG_EXPORT hg_return_t
135 hg_proc_header_request(void *buf, size_t buf_size,
136  struct hg_header_request *header, hg_proc_op_t op);
137 
148 HG_EXPORT hg_return_t
149 hg_proc_header_response(void *buf, size_t buf_size,
150  struct hg_header_response *header, hg_proc_op_t op);
151 
159 HG_EXPORT hg_return_t
161 
169 HG_EXPORT hg_return_t
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* MERCURY_PROC_HEADER_H */
void * hg_bulk_t
Definition: mercury_types.h:23
hg_int32_t hg_error_t
Definition: mercury_types.h:19
HG_EXPORT HG_PROC_HEADER_INLINE size_t hg_proc_header_response_get_size(void)
Get size reserved for response header (separate user data stored in payload).
HG_EXPORT void hg_proc_header_request_init(hg_id_t id, hg_bulk_t extra_buf_handle, struct hg_header_request *header)
Initialize RPC request header.
HG_EXPORT hg_return_t hg_proc_header_request(void *buf, size_t buf_size, struct hg_header_request *header, hg_proc_op_t op)
Process private information for sending/receiving RPC request.
HG_EXPORT HG_PROC_HEADER_INLINE size_t hg_proc_header_request_get_size(void)
Get size reserved for request header (separate user data stored in payload).
hg_uint32_t hg_id_t
Definition: mercury_types.h:17
HG_EXPORT hg_return_t hg_proc_header_response_verify(struct hg_header_response header)
Verify private information from response header.
#define HG_PROC_HEADER_INLINE
HG_EXPORT hg_return_t hg_proc_header_request_verify(struct hg_header_request header)
Verify private information from request header.
hg_proc_op_t
Proc operations.
Definition: mercury_types.h:50
enum hg_return hg_return_t
HG_EXPORT hg_return_t hg_proc_header_response(void *buf, size_t buf_size, struct hg_header_response *header, hg_proc_op_t op)
Process private information for sending/receiving response.
HG_EXPORT void hg_proc_header_response_init(struct hg_header_response *header)
Initialize RPC response header.