forked from gladish/rtMessage_original
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtMessageHeader.h
60 lines (51 loc) · 1.64 KB
/
rtMessageHeader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Copyright [2017] [Comcast, Corp.]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RT_MESSAGE_HEADER_H__
#define __RT_MESSAGE_HEADER_H__
#include "rtError.h"
#include <stdint.h>
#define RTMSG_HEADER_MAX_TOPIC_LENGTH 128
// size of all fields in
// #define RTMSG_HEADER_SIZE (24 + (2 * RTMSG_HEADER_MAX_TOPIC_LENGTH))
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
rtMessageFlags_Request = 0x01,
rtMessageFlags_Response = 0x02
} rtMessageFlags;
typedef struct
{
uint16_t version;
uint16_t header_length;
uint32_t sequence_number;
uint32_t flags;
uint32_t control_data;
uint32_t payload_length;
uint32_t topic_length;
char topic[RTMSG_HEADER_MAX_TOPIC_LENGTH];
uint32_t reply_topic_length;
char reply_topic[RTMSG_HEADER_MAX_TOPIC_LENGTH];
} rtMessageHeader;
rtError rtMessageHeader_Init(rtMessageHeader* hdr);
rtError rtMessageHeader_Encode(rtMessageHeader* hdr, uint8_t* buff);
rtError rtMessageHeader_Decode(rtMessageHeader* hdr, uint8_t const* buff);
rtError rtMessageHeader_SetIsRequest(rtMessageHeader* hdr);
int rtMessageHeader_IsRequest(rtMessageHeader const* hdr);
#ifdef __cplusplus
}
#endif
#endif