Mercury
Main Page
Classes
Files
File List
File Members
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
16
struct
hg_header_request
{
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
27
struct
hg_header_response
{
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
76
HG_EXPORT
HG_PROC_HEADER_INLINE
size_t
hg_proc_header_request_get_size
(
void
);
77
HG_EXPORT
HG_PROC_HEADER_INLINE
size_t
hg_proc_header_response_get_size
(
void
);
78
84
HG_PROC_HEADER_INLINE
size_t
85
hg_proc_header_request_get_size
(
void
)
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
96
HG_PROC_HEADER_INLINE
size_t
97
hg_proc_header_response_get_size
(
void
)
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
121
hg_proc_header_response_init
(
struct
hg_header_response
*header);
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
160
hg_proc_header_request_verify
(
struct
hg_header_request
header);
161
169
HG_EXPORT
hg_return_t
170
hg_proc_header_response_verify
(
struct
hg_header_response
header);
171
172
#ifdef __cplusplus
173
}
174
#endif
175
176
#endif
/* MERCURY_PROC_HEADER_H */
hg_header_request::cookie
hg_uint32_t cookie
Definition:
mercury_proc_header.h:21
hg_header_response::cookie
hg_uint32_t cookie
Definition:
mercury_proc_header.h:30
hg_header_response::error
hg_error_t error
Definition:
mercury_proc_header.h:29
hg_header_request::crc16
hg_uint16_t crc16
Definition:
mercury_proc_header.h:22
hg_bulk_t
void * hg_bulk_t
Definition:
mercury_types.h:23
hg_header_request::hg
hg_uint8_t hg
Definition:
mercury_proc_header.h:17
hg_error_t
hg_int32_t hg_error_t
Definition:
mercury_types.h:19
hg_proc_header_response_get_size
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).
Definition:
mercury_proc_header.h:97
hg_header_request
Definition:
mercury_proc_header.h:16
hg_proc_header_request_init
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_proc_header_request
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_proc_header_request_get_size
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).
Definition:
mercury_proc_header.h:85
hg_id_t
hg_uint32_t hg_id_t
Definition:
mercury_types.h:17
hg_header_request::flags
hg_uint8_t flags
Definition:
mercury_proc_header.h:20
hg_proc_header_response_verify
HG_EXPORT hg_return_t hg_proc_header_response_verify(struct hg_header_response header)
Verify private information from response header.
HG_PROC_HEADER_INLINE
#define HG_PROC_HEADER_INLINE
Definition:
mercury_proc_header.h:68
hg_proc_header_request_verify
HG_EXPORT hg_return_t hg_proc_header_request_verify(struct hg_header_request header)
Verify private information from request header.
hg_header_response
Definition:
mercury_proc_header.h:27
hg_header_response::crc16
hg_uint16_t crc16
Definition:
mercury_proc_header.h:31
hg_header_response::padding
hg_uint8_t padding
Definition:
mercury_proc_header.h:32
hg_proc_op_t
hg_proc_op_t
Proc operations.
Definition:
mercury_types.h:50
hg_return_t
enum hg_return hg_return_t
hg_proc_header_response
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_header_request::extra_buf_handle
hg_bulk_t extra_buf_handle
Definition:
mercury_proc_header.h:24
mercury_types.h
hg_header_request::id
hg_id_t id
Definition:
mercury_proc_header.h:19
hg_header_request::protocol
hg_uint32_t protocol
Definition:
mercury_proc_header.h:18
hg_proc_header_response_init
HG_EXPORT void hg_proc_header_response_init(struct hg_header_response *header)
Initialize RPC response header.
hg_header_response::flags
hg_uint8_t flags
Definition:
mercury_proc_header.h:28
Generated by
1.8.6