Main Page
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-2015 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_msg_s
{
42
/*00*/
uint8_t
header_sz
;
// number of uint8_ts in this header
43
/*01*/
uint8_t
info1
;
// bitfield about this request
44
/*02*/
uint8_t
info2
;
45
/*03*/
uint8_t
info3
;
46
/*04*/
uint8_t
unused
;
47
/*05*/
uint8_t
result_code
;
48
/*06*/
uint32_t
generation
;
49
/*10*/
uint32_t
record_ttl
;
50
/*14*/
uint32_t
transaction_ttl
;
51
/*18*/
uint16_t
n_fields
;
// size in uint8_ts
52
/*20*/
uint16_t
n_ops
;
// number of operations
53
/*22*/
uint8_t
data
[0];
// data contains first the fields, then the ops
54
} as_msg;
55
#pragma pack(pop) // packing is back to what it was
56
57
#pragma pack(push, 1) // packing is now 1
58
typedef
struct
as_proto_msg_s
{
59
as_proto
proto
;
60
as_msg
m
;
61
} as_proto_msg;
62
#pragma pack(pop) // packing is back to what it was
63
64
#else
65
66
typedef
struct
as_proto_s
{
67
uint8_t
version
;
68
uint8_t
type
;
69
uint64_t
sz
:48;
70
uint8_t
data
[];
71
}
__attribute__
((__packed__)) as_proto;
72
73
typedef struct
as_msg_s
{
74
/*00*/
uint8_t
header_sz
;
// number of uint8_ts in this header
75
/*01*/
uint8_t
info1
;
// bitfield about this request
76
/*02*/
uint8_t
info2
;
77
/*03*/
uint8_t
info3
;
78
/*04*/
uint8_t
unused
;
79
/*05*/
uint8_t
result_code
;
80
/*06*/
uint32_t
generation
;
81
/*10*/
uint32_t
record_ttl
;
82
/*14*/
uint32_t
transaction_ttl
;
83
/*18*/
uint16_t
n_fields
;
// size in uint8_ts
84
/*20*/
uint16_t
n_ops
;
// number of operations
85
/*22*/
uint8_t
data
[];
// data contains first the fields, then the ops
86
}
__attribute__
((__packed__)) as_msg;
87
88
typedef struct
as_proto_msg_s
{
89
as_proto
proto
;
90
as_msg
m
;
91
}
__attribute__
((__packed__)) as_proto_msg;
92
93
#endif
94
95
/******************************************************************************
96
* FUNCTIONS
97
******************************************************************************/
98
99
void
as_proto_swap_to_be
(as_proto *
m
);
100
void
as_proto_swap_from_be
(as_proto *
m
);
101
void
as_msg_swap_header_from_be
(as_msg *
m
);
102
103
#ifdef __cplusplus
104
}
// end extern "C"
105
#endif