Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
kaa_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 
22 #ifndef KAA_COMMON_H_
23 #define KAA_COMMON_H_
24 
25 #include <stdint.h>
26 #include "kaa_error.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef enum {
36  // Don't change numbers. They are critical to platform protocol.
46 
47 /*
48  * Standard error handling macros
49  */
50 #define KAA_RETURN_IF_ERR(E) \
51  do { if (E) return E; } while (0)
52 
53 #define KAA_RETURN_IF_NIL(p, E) \
54  do { if (!(p)) return E; } while (0)
55 
56 #define KAA_RETURN_IF_NIL2(p1, p2, E) \
57  do { if (!(p1) || !(p2)) return E; } while (0)
58 
59 #define KAA_RETURN_IF_NIL3(p1, p2, p3, E) \
60  do { if (!(p1) || !(p2) || !(p3)) return E; } while (0)
61 
62 #define KAA_RETURN_IF_NIL4(p1, p2, p3, p4, E) \
63  do { if (!(p1) || !(p2) || !(p3) || !(p4)) return E; } while (0)
64 
65 #define KAA_RETURN_IF_NIL5(p1, p2, p3, p4, p5,E) \
66  do { if (!(p1) || !(p2) || !(p3) || !(p4) || !(p5)) return E; } while (0)
67 
71 typedef struct {
72  uint32_t id;
73  uint16_t version;
75 
77 {
78  return first && second && first->id == second->id && first->version == second->version;
79 }
80 
85 typedef struct {
86  uint32_t id;
90 
91 /*
92  * Endpoint ID
93  */
94 #define KAA_ENDPOINT_ID_LENGTH 20
96 typedef const uint8_t *kaa_endpoint_id_p;
97 
98 
99 
100 #ifdef __cplusplus
101 } /* extern "C" */
102 #endif
103 #endif /* KAA_COMMON_H_ */
uint8_t kaa_endpoint_id[KAA_ENDPOINT_ID_LENGTH]
Definition: kaa_common.h:95
static int kaa_transport_protocol_id_equals(const kaa_transport_protocol_id_t *first, const kaa_transport_protocol_id_t *second)
Definition: kaa_common.h:76
Definition: kaa_common.h:38
Definition: kaa_common.h:42
uint16_t version
Definition: kaa_common.h:73
#define KAA_ENDPOINT_ID_LENGTH
Definition: kaa_common.h:94
Identifier used to uniquely represent transport protocol.
Definition: kaa_common.h:71
Definition: kaa_common.h:44
uint32_t id
Definition: kaa_common.h:86
Kaa error codes.
kaa_extension_id
Kaa extensions.
Definition: kaa_common.h:35
Definition: kaa_common.h:39
Definition: kaa_common.h:41
Definition: kaa_common.h:43
Definition: kaa_common.h:37
uint16_t connection_data_len
Definition: kaa_common.h:87
const uint8_t * kaa_endpoint_id_p
Definition: kaa_common.h:96
char * connection_data
Definition: kaa_common.h:88
Definition: kaa_common.h:40
Connection parameters used by transport channels to establish connection both to Bootstrap and Operat...
Definition: kaa_common.h:85
uint32_t id
Definition: kaa_common.h:72