Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
kaatcp_common.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef KAATCP_COMMON_H_
18 #define KAATCP_COMMON_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <platform/defaults.h>
25 
26 #define KAATCP_PROTOCOL_NAME_MAX_SIZE 10
27 
28 #define FIRST_BIT 0x80
29 #define MAX_MESSAGE_TYPE_LENGTH 0x0F
30 #define MAX_MESSAGE_LENGTH 0x0FFFFFFF
31 #define PROTOCOL_VERSION 0x01
32 
33 #define KAA_SYNC_HEADER_LENGTH 12
34 #define KAA_SYNC_ZIPPED_BIT 0x02
35 #define KAA_SYNC_ENCRYPTED_BIT 0x04
36 #define KAA_SYNC_REQUEST_BIT 0x01
37 #define KAA_SYNC_SYNC_BIT 0x10
38 #define KAA_SYNC_BOOTSTRAP_BIT 0x20
39 
40 #define KAA_BOOTSTRAP_RSA_PKSC8 0x01
41 #define KAA_BOOTSTRAP_CHANNEL_HTTP 0x01
42 #define KAA_BOOTSTRAP_CHANNEL_HTTPLP 0x02
43 #define KAA_BOOTSTRAP_CHANNEL_KAATCP 0x03
44 
45 #define KAA_CONNECT_FLAGS 0x02
46 #define KAA_CONNECT_HEADER_LENGTH 18
47 
48 #define KAA_CONNECT_KEY_AES_RSA 0x11
49 #define KAA_CONNECT_SIGNATURE_SHA1 0x01
50 
51 #define KAA_TCP_NAME "Kaatcp"
52 #define KAA_TCP_NAME_LENGTH 6
53 
54 #define KAA_PING_MESSAGE_SIZE 2
55 #define KAA_DISCONNECT_MESSAGE_SIZE 4
56 
57 typedef enum {
65 
66 typedef enum {
75 
76 typedef struct {
78  char protocol_name[KAATCP_PROTOCOL_NAME_MAX_SIZE];
79 
81 
82  uint8_t connect_flags;
83 
84  uint32_t next_ptorocol_id;
85 
87  uint8_t signature_flags;
88 
89  uint16_t keep_alive;
90 
92  char *session_key;
93 
95  char *signature;
96 
98  char *sync_request;
99 
101 
102 typedef enum {
112 
113 typedef struct {
114  uint16_t return_code;
116 
117 typedef enum {
123 
124 typedef struct {
125  uint16_t reason;
127 
128 typedef struct {
130  char protocol_name[KAATCP_PROTOCOL_NAME_MAX_SIZE];
131 
133  uint16_t message_id;
134  uint8_t flags;
136 
137 typedef struct {
139 
143 
144 #ifdef __cplusplus
145 } /* extern "C" */
146 #endif
147 #endif /* KAATCP_COMMON_H_ */
uint8_t connect_flags
Definition: kaatcp_common.h:82
uint16_t return_code
Definition: kaatcp_common.h:114
Definition: kaatcp_common.h:62
Definition: kaatcp_common.h:120
uint8_t protocol_version
Definition: kaatcp_common.h:132
Definition: kaatcp_common.h:106
Definition: kaatcp_common.h:73
Definition: kaatcp_common.h:105
uint8_t signature_flags
Definition: kaatcp_common.h:87
kaatcp_connack_code_t
Definition: kaatcp_common.h:102
uint16_t reason
Definition: kaatcp_common.h:125
uint8_t session_key_flags
Definition: kaatcp_common.h:86
Definition: kaatcp_common.h:128
Definition: kaatcp_common.h:118
size_t sync_request_size
Definition: kaatcp_common.h:140
Definition: kaatcp_common.h:71
Definition: kaatcp_common.h:113
Definition: kaatcp_common.h:124
uint16_t message_id
Definition: kaatcp_common.h:133
kaatcp_error_t
Definition: kaatcp_common.h:57
Definition: kaatcp_common.h:76
uint16_t protocol_name_length
Definition: kaatcp_common.h:77
Definition: kaatcp_common.h:72
size_t signature_size
Definition: kaatcp_common.h:94
Definition: kaatcp_common.h:70
kaatcp_kaasync_header_t sync_header
Definition: kaatcp_common.h:138
Definition: kaatcp_common.h:59
Definition: kaatcp_common.h:104
Definition: kaatcp_common.h:137
char * sync_request
Definition: kaatcp_common.h:141
Definition: kaatcp_common.h:67
Definition: kaatcp_common.h:103
Definition: kaatcp_common.h:107
kaatcp_message_type_t
Definition: kaatcp_common.h:66
kaatcp_disconnect_reason_t
Definition: kaatcp_common.h:117
Definition: kaatcp_common.h:60
size_t sync_request_size
Definition: kaatcp_common.h:97
uint16_t protocol_name_length
Definition: kaatcp_common.h:129
Definition: kaatcp_common.h:61
char * sync_request
Definition: kaatcp_common.h:98
Definition: kaatcp_common.h:63
#define KAATCP_PROTOCOL_NAME_MAX_SIZE
Definition: kaatcp_common.h:26
Definition: kaatcp_common.h:58
uint16_t keep_alive
Definition: kaatcp_common.h:89
size_t session_key_size
Definition: kaatcp_common.h:91
uint8_t flags
Definition: kaatcp_common.h:134
Definition: kaatcp_common.h:68
Definition: kaatcp_common.h:69
char * session_key
Definition: kaatcp_common.h:92
uint8_t protocol_version
Definition: kaatcp_common.h:80
Definition: kaatcp_common.h:110
Definition: kaatcp_common.h:109
Definition: kaatcp_common.h:121
char * signature
Definition: kaatcp_common.h:95
Definition: kaatcp_common.h:108
uint32_t next_ptorocol_id
Definition: kaatcp_common.h:84
Definition: kaatcp_common.h:119