Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_proto.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2017 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
#include <stddef.h>
20
#include <stdint.h>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/******************************************************************************
27
* TYPES
28
*****************************************************************************/
29
30
#if defined(__APPLE__) || defined(CF_WINDOWS)
31
32
#pragma pack(push, 1) // packing is now 1
33
typedef
struct
as_proto_s
{
34
uint64_t
version
:8;
35
uint64_t
type
:8;
36
uint64_t
sz
:48;
37
} as_proto;
38
#pragma pack(pop) // packing is back to what it was
39
40
#pragma pack(push, 1) // packing is now 1
41
typedef
struct
as_compressed_proto_s
{
42
as_proto
proto
;
43
uint64_t
uncompressed_sz
;
44
} as_compressed_proto;
45
#pragma pack(pop) // packing is back to what it was
46
47
#pragma pack(push, 1) // packing is now 1
48
typedef
struct
as_msg_s
{
49
/*00*/
uint8_t
header_sz
;
// number of uint8_ts in this header
50
/*01*/
uint8_t
info1
;
// bitfield about this request
51
/*02*/
uint8_t
info2
;
52
/*03*/
uint8_t
info3
;
53
/*04*/
uint8_t
unused
;
54
/*05*/
uint8_t
result_code
;
55
/*06*/
uint32_t
generation
;
56
/*10*/
uint32_t
record_ttl
;
57
/*14*/
uint32_t
transaction_ttl
;
58
/*18*/
uint16_t
n_fields
;
// size in uint8_ts
59
/*20*/
uint16_t
n_ops
;
// number of operations
60
/*22*/
uint8_t
data
[0];
// data contains first the fields, then the ops
61
} as_msg;
62
#pragma pack(pop) // packing is back to what it was
63
64
#pragma pack(push, 1) // packing is now 1
65
typedef
struct
as_proto_msg_s
{
66
as_proto
proto
;
67
as_msg
m
;
68
} as_proto_msg;
69
#pragma pack(pop) // packing is back to what it was
70
71
#else
72
73
typedef
struct
as_proto_s
{
74
uint8_t
version
;
75
uint8_t
type
;
76
uint64_t
sz
:48;
77
uint8_t
data
[];
78
}
__attribute__
((__packed__)) as_proto;
79
80
typedef struct
as_compressed_proto_s
{
81
as_proto
proto
;
82
uint64_t
uncompressed_sz
;
83
uint8_t
data
[];
// compressed bytes
84
}
__attribute__
((__packed__)) as_compressed_proto;
85
86
typedef struct
as_msg_s
{
87
/*00*/
uint8_t
header_sz
;
// number of uint8_ts in this header
88
/*01*/
uint8_t
info1
;
// bitfield about this request
89
/*02*/
uint8_t
info2
;
90
/*03*/
uint8_t
info3
;
91
/*04*/
uint8_t
unused
;
92
/*05*/
uint8_t
result_code
;
93
/*06*/
uint32_t
generation
;
94
/*10*/
uint32_t
record_ttl
;
95
/*14*/
uint32_t
transaction_ttl
;
96
/*18*/
uint16_t
n_fields
;
// size in uint8_ts
97
/*20*/
uint16_t
n_ops
;
// number of operations
98
/*22*/
uint8_t
data
[];
// data contains first the fields, then the ops
99
}
__attribute__
((__packed__)) as_msg;
100
101
typedef struct
as_proto_msg_s
{
102
as_proto
proto
;
103
as_msg
m
;
104
}
__attribute__
((__packed__)) as_proto_msg;
105
106
#endif
107
108
/******************************************************************************
109
* FUNCTIONS
110
******************************************************************************/
111
112
void
as_proto_swap_to_be
(as_proto *
m
);
113
void
as_proto_swap_from_be
(as_proto *
m
);
114
void
as_msg_swap_header_from_be
(as_msg *
m
);
115
116
#ifdef __cplusplus
117
}
// end extern "C"
118
#endif