Fawkes API  Fawkes Development Version
frame_header.h
1 
2 /***************************************************************************
3  * frame_header.h - Basic framing header or each message
4  *
5  * Created: Mon Jan 21 12:05:03 2013
6  * Copyright 2013 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * - Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * - Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  * - Neither the name of the authors nor the names of its contributors
20  * may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34  * OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #ifndef _PROTOBUF_COMM_FRAME_HEADER_H_
38 #define _PROTOBUF_COMM_FRAME_HEADER_H_
39 
40 #include <cstdint>
41 
42 namespace protobuf_comm {
43 
44 #pragma pack(push, 4)
45 
46 #define PB_ENCRYPTION_NONE 0x00
47 #define PB_ENCRYPTION_AES_128_ECB 0x01
48 #define PB_ENCRYPTION_AES_128_CBC 0x02
49 #define PB_ENCRYPTION_AES_256_ECB 0x03
50 #define PB_ENCRYPTION_AES_256_CBC 0x04
51 
52 /** Network frame header version to use.
53  * V1 is the old version which for example is required to communicate with the
54  * LLSF Referee Box before RC2014
55  * V2 supports data encryption.
56  */
57 typedef enum {
58  PB_FRAME_V1 = 1, ///< Version 1
59  PB_FRAME_V2 = 2 ///< Version 2
60 } frame_header_version_t;
61 
62 /** Network framing header.
63  * Header that is prepended to all messages. The payload size does
64  * not include the size of the header. All numbers are given in
65  * network byte order (big endian). The encryption type can be set if
66  * encryption is used. If the mode requires an initialization vector
67  * (IV) it is appended directly after the frame header (and not
68  * counted in the payload size).
69  * @author Tim Niemueller
70  */
71 typedef struct
72 {
73  /// Frame header version
74  uint8_t header_version;
75  /// One of PB_ENCRYPTION_*
76  uint8_t cipher;
77  /// reserved for future use
78  uint8_t reserved_2;
79  /// reserved for future use
80  uint8_t reserved_3;
81  /// payload size in bytes
82  /// includes message and
83  /// header, _not_ IV
84  uint32_t payload_size;
86 
87 /** Network message header.
88  * Header that is prepended to all messages.
89  * The component ID can be used to route a message to a particular
90  * software component. The component then can use the message type to
91  * determine how the message must be parse the payload. It is appended
92  * immediately following the header. The payload size does not include
93  * the size of the header.
94  * All numbers are given in network byte order (big endian).
95  * @author Tim Niemueller
96  */
97 typedef struct
98 {
99  /// component id
100  uint16_t component_id;
101  /// message type
102  uint16_t msg_type;
104 
105 /** Old network message framing header.
106  * Header that is prepended to all messages.
107  * The component ID can be used to route a message to a particular
108  * software component. The component then can use the message type to
109  * determine how the message must be parse the payload. It is appended
110  * immediately following the header. The payload size does not include
111  * the size of the header.
112  * All numbers are given in network byte order (big endian).
113  * @author Tim Niemueller
114  */
115 typedef struct
116 {
117  /** component id */
118  uint16_t component_id;
119  /** message type */
120  uint16_t msg_type;
121  /** payload size in bytes */
122  uint32_t payload_size;
124 
125 #pragma pack(pop)
126 
127 } // end namespace protobuf_comm
128 
129 #endif
uint8_t reserved_2
reserved for future use
Definition: frame_header.h:78
uint16_t msg_type
message type
Definition: frame_header.h:102
Old network message framing header.
Definition: frame_header.h:115
uint32_t payload_size
payload size in bytes
Definition: frame_header.h:122
uint8_t cipher
One of PB_ENCRYPTION_*.
Definition: frame_header.h:76
uint8_t reserved_3
reserved for future use
Definition: frame_header.h:80
Network framing header.
Definition: frame_header.h:71
uint32_t payload_size
payload size in bytes includes message and header, not IV
Definition: frame_header.h:84
uint16_t component_id
component id
Definition: frame_header.h:118
uint8_t header_version
Frame header version.
Definition: frame_header.h:74
uint16_t msg_type
message type
Definition: frame_header.h:120
Network message header.
Definition: frame_header.h:97
uint16_t component_id
component id
Definition: frame_header.h:100