1
2 #pragma once
3
4 #include <cstdint>
5 #include <functional>
6 #include <iomanip>
7 #include <optional>
8 #include <sstream>
9 #include <string>
10 #include <type_traits>
11
12 #include "packet/base_packet_builder.h"
13 #include "packet/bit_inserter.h"
14 #include "packet/custom_field_fixed_size_interface.h"
15 #include "packet/iterator.h"
16 #include "packet/packet_builder.h"
17 #include "packet/packet_struct.h"
18 #include "packet/packet_view.h"
19 #include "packet/checksum_type_checker.h"
20 #include "packet/custom_type_checker.h"
21
22 #if __has_include(<bluetooth/log.h>)
23
24 #include <bluetooth/log.h>
25
26 #ifndef ASSERT
27 #define ASSERT(cond) bluetooth::log::assert_that(cond, #cond)
28 #endif // !defined(ASSERT)
29
30 #else
31
32 #ifndef ASSERT
33 #define ASSERT(cond) assert(cond)
34 #endif // !defined(ASSERT)
35
36 #endif // __has_include(<bluetooth/log.h>)
37
38
39 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
40 #include "packet/raw_builder.h"
41 #endif
42 #include "l2cap/fcs.h"
43
44
45 namespace bluetooth {
46 namespace l2cap {
47
48
49 using ::bluetooth::l2cap::Fcs;
50
51 using ::bluetooth::packet::BasePacketBuilder;
52 using ::bluetooth::packet::BitInserter;
53 using ::bluetooth::packet::CustomFieldFixedSizeInterface;
54 using ::bluetooth::packet::CustomTypeChecker;
55 using ::bluetooth::packet::Iterator;
56 using ::bluetooth::packet::kLittleEndian;
57 using ::bluetooth::packet::PacketBuilder;
58 using ::bluetooth::packet::PacketStruct;
59 using ::bluetooth::packet::PacketView;
60 using ::bluetooth::packet::parser::ChecksumTypeChecker;
61
62 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
63 using ::bluetooth::packet::RawBuilder;
64 #endif
65 enum class Continuation : uint8_t {END = 0x0,CONTINUE = 0x1,};
66
67
68 enum class FrameType : uint8_t {I_FRAME = 0x0,S_FRAME = 0x1,};
69
70
71 enum class SupervisoryFunction : uint8_t {RECEIVER_READY = 0x0,REJECT = 0x1,RECEIVER_NOT_READY = 0x2,SELECT_REJECT = 0x3,};
72
73
74 enum class RetransmissionDisable : uint8_t {NORMAL = 0x0,DISABLE = 0x1,};
75
76
77 enum class SegmentationAndReassembly : uint8_t {UNSEGMENTED = 0x0,START = 0x1,END = 0x2,CONTINUATION = 0x3,};
78
79
80 enum class Poll : uint8_t {NOT_SET = 0x0,POLL = 0x1,};
81
82
83 enum class Final : uint8_t {NOT_SET = 0x0,POLL_RESPONSE = 0x1,};
84
85
86 enum class CommandCode : uint8_t {COMMAND_REJECT = 0x1,CONNECTION_REQUEST = 0x2,CONNECTION_RESPONSE = 0x3,CONFIGURATION_REQUEST = 0x4,CONFIGURATION_RESPONSE = 0x5,DISCONNECTION_REQUEST = 0x6,DISCONNECTION_RESPONSE = 0x7,ECHO_REQUEST = 0x8,ECHO_RESPONSE = 0x9,INFORMATION_REQUEST = 0xa,INFORMATION_RESPONSE = 0xb,CREATE_CHANNEL_REQUEST = 0xc,CREATE_CHANNEL_RESPONSE = 0xd,MOVE_CHANNEL_REQUEST = 0xe,MOVE_CHANNEL_RESPONSE = 0xf,MOVE_CHANNEL_CONFIRMATION_REQUEST = 0x10,MOVE_CHANNEL_CONFIRMATION_RESPONSE = 0x11,FLOW_CONTROL_CREDIT = 0x16,CREDIT_BASED_CONNECTION_REQUEST = 0x17,CREDIT_BASED_CONNECTION_RESPONSE = 0x18,CREDIT_BASED_RECONFIGURE_REQUEST = 0x19,CREDIT_BASED_RECONFIGURE_RESPONSE = 0x1a,};
87
88
89 enum class CommandRejectReason : uint16_t {COMMAND_NOT_UNDERSTOOD = 0x0,SIGNALING_MTU_EXCEEDED = 0x1,INVALID_CID_IN_REQUEST = 0x2,};
90
91
92 enum class ConnectionResponseResult : uint16_t {SUCCESS = 0x0,PENDING = 0x1,PSM_NOT_SUPPORTED = 0x2,SECURITY_BLOCK = 0x3,NO_RESOURCES_AVAILABLE = 0x4,INVALID_CID = 0x6,SOURCE_CID_ALREADY_ALLOCATED = 0x7,};
93
94
95 enum class ConnectionResponseStatus : uint16_t {NO_FURTHER_INFORMATION_AVAILABLE = 0x0,AUTHENTICATION_PENDING = 0x1,AUTHORIZATION_PENDING = 0x2,};
96
97
98 enum class ConfigurationOptionType : uint8_t {MTU = 0x1,FLUSH_TIMEOUT = 0x2,QUALITY_OF_SERVICE = 0x3,RETRANSMISSION_AND_FLOW_CONTROL = 0x4,FRAME_CHECK_SEQUENCE = 0x5,EXTENDED_FLOW_SPECIFICATION = 0x6,EXTENDED_WINDOW_SIZE = 0x7,};
99
100
101 enum class ConfigurationOptionIsHint : uint8_t {OPTION_MUST_BE_RECOGNIZED = 0x0,OPTION_IS_A_HINT = 0x1,};
102
103
104 enum class QosServiceType : uint8_t {NO_TRAFFIC = 0x0,BEST_EFFORT = 0x1,GUARANTEED = 0x2,};
105
106
107 enum class RetransmissionAndFlowControlModeOption : uint8_t {L2CAP_BASIC = 0x0,RETRANSMISSION = 0x1,FLOW_CONTROL = 0x2,ENHANCED_RETRANSMISSION = 0x3,STREAMING = 0x4,};
108
109
110 enum class FcsType : uint8_t {NO_FCS = 0x0,DEFAULT = 0x1,};
111
112
113 enum class ConfigurationResponseResult : uint16_t {SUCCESS = 0x0,UNACCEPTABLE_PARAMETERS = 0x1,REJECTED = 0x2,UNKNOWN_OPTIONS = 0x3,PENDING = 0x4,FLOW_SPEC_REJECTED = 0x5,};
114
115
116 enum class InformationRequestInfoType : uint16_t {CONNECTIONLESS_MTU = 0x1,EXTENDED_FEATURES_SUPPORTED = 0x2,FIXED_CHANNELS_SUPPORTED = 0x3,};
117
118
119 enum class InformationRequestResult : uint16_t {SUCCESS = 0x0,NOT_SUPPORTED = 0x1,};
120
121
122 enum class CreateChannelResponseResult : uint16_t {SUCCESS = 0x0,PENDING = 0x1,PSM_NOT_SUPPORTED = 0x2,SECURITY_BLOCK = 0x3,NO_RESOURCES_AVAILABLE = 0x4,CONTROLLER_ID_NOT_SUPPORTED = 0x5,INVALID_CID = 0x6,SOURCE_CID_ALREADY_ALLOCATED = 0x7,};
123
124
125 enum class CreateChannelResponseStatus : uint16_t {NO_FURTHER_INFORMATION_AVAILABLE = 0x0,AUTHENTICATION_PENDING = 0x1,AUTHORIZATION_PENDING = 0x2,};
126
127
128 enum class MoveChannelResponseResult : uint16_t {SUCCESS = 0x0,PENDING = 0x1,CONTROLLER_ID_NOT_SUPPORTED = 0x2,NEW_CONTROLLER_ID_IS_SAME = 0x3,CONFIGURATION_NOT_SUPPORTED = 0x4,CHANNEL_COLLISION = 0x5,CHANNEL_NOT_ALLOWED_TO_BE_MOVED = 0x6,};
129
130
131 enum class MoveChannelConfirmationResult : uint16_t {SUCCESS = 0x0,FAILURE = 0x1,};
132
133
134 enum class CreditBasedConnectionResponseResult : uint16_t {SUCCESS = 0x0,SPSM_NOT_SUPPORTED = 0x2,SOME_REFUSED_NO_RESOURCES_AVAILABLE = 0x4,ALL_REFUSED_INSUFFICIENT_AUTHENTICATION = 0x5,ALL_REFUSED_INSUFFICIENT_AUTHORIZATION = 0x6,ALL_REFUSED_INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x7,ALL_REFUSED_INSUFFICIENT_ENCRYPTION = 0x8,SOME_REFUSED_INVALID_SOURCE_CID = 0x9,SOME_REFUSED_SOURCE_CID_ALREADY_ALLOCATED = 0xa,ALL_REFUSED_UNACCEPTABLE_PARAMETERS = 0xb,ALL_REFUSED_INVALID_PARAMETERS = 0xc,};
135
136
137 enum class CreditBasedReconfigureResponseResult : uint16_t {SUCCESS = 0x0,MTU_NOT_ALLOWED = 0x1,MPS_NOT_ALLOWED = 0x2,INVALID_DESTINATION_CID = 0x3,UNACCEPTABLE_PARAMETERS = 0x4,};
138
139
140 enum class LeCommandCode : uint8_t {COMMAND_REJECT = 0x1,DISCONNECTION_REQUEST = 0x6,DISCONNECTION_RESPONSE = 0x7,CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12,CONNECTION_PARAMETER_UPDATE_RESPONSE = 0x13,LE_CREDIT_BASED_CONNECTION_REQUEST = 0x14,LE_CREDIT_BASED_CONNECTION_RESPONSE = 0x15,LE_FLOW_CONTROL_CREDIT = 0x16,CREDIT_BASED_CONNECTION_REQUEST = 0x17,CREDIT_BASED_CONNECTION_RESPONSE = 0x18,CREDIT_BASED_RECONFIGURE_REQUEST = 0x19,CREDIT_BASED_RECONFIGURE_RESPONSE = 0x1a,};
141
142
143 enum class ConnectionParameterUpdateResponseResult : uint16_t {ACCEPTED = 0x0,REJECTED = 0x1,};
144
145
146 enum class LeCreditBasedConnectionResponseResult : uint16_t {SUCCESS = 0x0,LE_PSM_NOT_SUPPORTED = 0x2,NO_RESOURCES_AVAILABLE = 0x4,INSUFFICIENT_AUTHENTICATION = 0x5,INSUFFICIENT_AUTHORIZATION = 0x6,INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x7,INSUFFICIENT_ENCRYPTION = 0x8,INVALID_SOURCE_CID = 0x9,SOURCE_CID_ALREADY_ALLOCATED = 0xa,UNACCEPTABLE_PARAMETERS = 0xb,};
147
148
ContinuationText(const Continuation & param)149 inline std::string ContinuationText(const Continuation& param) {std::stringstream builder;switch (param) {case Continuation::END: builder << "END"; break;case Continuation::CONTINUE: builder << "CONTINUE"; break;default: builder << "Unknown Continuation";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
150
151
152
FrameTypeText(const FrameType & param)153 inline std::string FrameTypeText(const FrameType& param) {std::stringstream builder;switch (param) {case FrameType::I_FRAME: builder << "I_FRAME"; break;case FrameType::S_FRAME: builder << "S_FRAME"; break;default: builder << "Unknown FrameType";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
154
155
156
SupervisoryFunctionText(const SupervisoryFunction & param)157 inline std::string SupervisoryFunctionText(const SupervisoryFunction& param) {std::stringstream builder;switch (param) {case SupervisoryFunction::RECEIVER_READY: builder << "RECEIVER_READY"; break;case SupervisoryFunction::REJECT: builder << "REJECT"; break;case SupervisoryFunction::RECEIVER_NOT_READY: builder << "RECEIVER_NOT_READY"; break;case SupervisoryFunction::SELECT_REJECT: builder << "SELECT_REJECT"; break;default: builder << "Unknown SupervisoryFunction";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(2/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
158
159
160
RetransmissionDisableText(const RetransmissionDisable & param)161 inline std::string RetransmissionDisableText(const RetransmissionDisable& param) {std::stringstream builder;switch (param) {case RetransmissionDisable::NORMAL: builder << "NORMAL"; break;case RetransmissionDisable::DISABLE: builder << "DISABLE"; break;default: builder << "Unknown RetransmissionDisable";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
162
163
164
SegmentationAndReassemblyText(const SegmentationAndReassembly & param)165 inline std::string SegmentationAndReassemblyText(const SegmentationAndReassembly& param) {std::stringstream builder;switch (param) {case SegmentationAndReassembly::UNSEGMENTED: builder << "UNSEGMENTED"; break;case SegmentationAndReassembly::START: builder << "START"; break;case SegmentationAndReassembly::END: builder << "END"; break;case SegmentationAndReassembly::CONTINUATION: builder << "CONTINUATION"; break;default: builder << "Unknown SegmentationAndReassembly";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(2/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
166
167
168
PollText(const Poll & param)169 inline std::string PollText(const Poll& param) {std::stringstream builder;switch (param) {case Poll::NOT_SET: builder << "NOT_SET"; break;case Poll::POLL: builder << "POLL"; break;default: builder << "Unknown Poll";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
170
171
172
FinalText(const Final & param)173 inline std::string FinalText(const Final& param) {std::stringstream builder;switch (param) {case Final::NOT_SET: builder << "NOT_SET"; break;case Final::POLL_RESPONSE: builder << "POLL_RESPONSE"; break;default: builder << "Unknown Final";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
174
175
176
CommandCodeText(const CommandCode & param)177 inline std::string CommandCodeText(const CommandCode& param) {std::stringstream builder;switch (param) {case CommandCode::COMMAND_REJECT: builder << "COMMAND_REJECT"; break;case CommandCode::CONNECTION_REQUEST: builder << "CONNECTION_REQUEST"; break;case CommandCode::CONNECTION_RESPONSE: builder << "CONNECTION_RESPONSE"; break;case CommandCode::CONFIGURATION_REQUEST: builder << "CONFIGURATION_REQUEST"; break;case CommandCode::CONFIGURATION_RESPONSE: builder << "CONFIGURATION_RESPONSE"; break;case CommandCode::DISCONNECTION_REQUEST: builder << "DISCONNECTION_REQUEST"; break;case CommandCode::DISCONNECTION_RESPONSE: builder << "DISCONNECTION_RESPONSE"; break;case CommandCode::ECHO_REQUEST: builder << "ECHO_REQUEST"; break;case CommandCode::ECHO_RESPONSE: builder << "ECHO_RESPONSE"; break;case CommandCode::INFORMATION_REQUEST: builder << "INFORMATION_REQUEST"; break;case CommandCode::INFORMATION_RESPONSE: builder << "INFORMATION_RESPONSE"; break;case CommandCode::CREATE_CHANNEL_REQUEST: builder << "CREATE_CHANNEL_REQUEST"; break;case CommandCode::CREATE_CHANNEL_RESPONSE: builder << "CREATE_CHANNEL_RESPONSE"; break;case CommandCode::MOVE_CHANNEL_REQUEST: builder << "MOVE_CHANNEL_REQUEST"; break;case CommandCode::MOVE_CHANNEL_RESPONSE: builder << "MOVE_CHANNEL_RESPONSE"; break;case CommandCode::MOVE_CHANNEL_CONFIRMATION_REQUEST: builder << "MOVE_CHANNEL_CONFIRMATION_REQUEST"; break;case CommandCode::MOVE_CHANNEL_CONFIRMATION_RESPONSE: builder << "MOVE_CHANNEL_CONFIRMATION_RESPONSE"; break;case CommandCode::FLOW_CONTROL_CREDIT: builder << "FLOW_CONTROL_CREDIT"; break;case CommandCode::CREDIT_BASED_CONNECTION_REQUEST: builder << "CREDIT_BASED_CONNECTION_REQUEST"; break;case CommandCode::CREDIT_BASED_CONNECTION_RESPONSE: builder << "CREDIT_BASED_CONNECTION_RESPONSE"; break;case CommandCode::CREDIT_BASED_RECONFIGURE_REQUEST: builder << "CREDIT_BASED_RECONFIGURE_REQUEST"; break;case CommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE: builder << "CREDIT_BASED_RECONFIGURE_RESPONSE"; break;default: builder << "Unknown CommandCode";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(8/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
178
179
180
CommandRejectReasonText(const CommandRejectReason & param)181 inline std::string CommandRejectReasonText(const CommandRejectReason& param) {std::stringstream builder;switch (param) {case CommandRejectReason::COMMAND_NOT_UNDERSTOOD: builder << "COMMAND_NOT_UNDERSTOOD"; break;case CommandRejectReason::SIGNALING_MTU_EXCEEDED: builder << "SIGNALING_MTU_EXCEEDED"; break;case CommandRejectReason::INVALID_CID_IN_REQUEST: builder << "INVALID_CID_IN_REQUEST"; break;default: builder << "Unknown CommandRejectReason";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
182
183
184
ConnectionResponseResultText(const ConnectionResponseResult & param)185 inline std::string ConnectionResponseResultText(const ConnectionResponseResult& param) {std::stringstream builder;switch (param) {case ConnectionResponseResult::SUCCESS: builder << "SUCCESS"; break;case ConnectionResponseResult::PENDING: builder << "PENDING"; break;case ConnectionResponseResult::PSM_NOT_SUPPORTED: builder << "PSM_NOT_SUPPORTED"; break;case ConnectionResponseResult::SECURITY_BLOCK: builder << "SECURITY_BLOCK"; break;case ConnectionResponseResult::NO_RESOURCES_AVAILABLE: builder << "NO_RESOURCES_AVAILABLE"; break;case ConnectionResponseResult::INVALID_CID: builder << "INVALID_CID"; break;case ConnectionResponseResult::SOURCE_CID_ALREADY_ALLOCATED: builder << "SOURCE_CID_ALREADY_ALLOCATED"; break;default: builder << "Unknown ConnectionResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
186
187
188
ConnectionResponseStatusText(const ConnectionResponseStatus & param)189 inline std::string ConnectionResponseStatusText(const ConnectionResponseStatus& param) {std::stringstream builder;switch (param) {case ConnectionResponseStatus::NO_FURTHER_INFORMATION_AVAILABLE: builder << "NO_FURTHER_INFORMATION_AVAILABLE"; break;case ConnectionResponseStatus::AUTHENTICATION_PENDING: builder << "AUTHENTICATION_PENDING"; break;case ConnectionResponseStatus::AUTHORIZATION_PENDING: builder << "AUTHORIZATION_PENDING"; break;default: builder << "Unknown ConnectionResponseStatus";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
190
191
192
ConfigurationOptionTypeText(const ConfigurationOptionType & param)193 inline std::string ConfigurationOptionTypeText(const ConfigurationOptionType& param) {std::stringstream builder;switch (param) {case ConfigurationOptionType::MTU: builder << "MTU"; break;case ConfigurationOptionType::FLUSH_TIMEOUT: builder << "FLUSH_TIMEOUT"; break;case ConfigurationOptionType::QUALITY_OF_SERVICE: builder << "QUALITY_OF_SERVICE"; break;case ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL: builder << "RETRANSMISSION_AND_FLOW_CONTROL"; break;case ConfigurationOptionType::FRAME_CHECK_SEQUENCE: builder << "FRAME_CHECK_SEQUENCE"; break;case ConfigurationOptionType::EXTENDED_FLOW_SPECIFICATION: builder << "EXTENDED_FLOW_SPECIFICATION"; break;case ConfigurationOptionType::EXTENDED_WINDOW_SIZE: builder << "EXTENDED_WINDOW_SIZE"; break;default: builder << "Unknown ConfigurationOptionType";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(7/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
194
195
196
ConfigurationOptionIsHintText(const ConfigurationOptionIsHint & param)197 inline std::string ConfigurationOptionIsHintText(const ConfigurationOptionIsHint& param) {std::stringstream builder;switch (param) {case ConfigurationOptionIsHint::OPTION_MUST_BE_RECOGNIZED: builder << "OPTION_MUST_BE_RECOGNIZED"; break;case ConfigurationOptionIsHint::OPTION_IS_A_HINT: builder << "OPTION_IS_A_HINT"; break;default: builder << "Unknown ConfigurationOptionIsHint";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(1/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
198
199
200
QosServiceTypeText(const QosServiceType & param)201 inline std::string QosServiceTypeText(const QosServiceType& param) {std::stringstream builder;switch (param) {case QosServiceType::NO_TRAFFIC: builder << "NO_TRAFFIC"; break;case QosServiceType::BEST_EFFORT: builder << "BEST_EFFORT"; break;case QosServiceType::GUARANTEED: builder << "GUARANTEED"; break;default: builder << "Unknown QosServiceType";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(8/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
202
203
204
RetransmissionAndFlowControlModeOptionText(const RetransmissionAndFlowControlModeOption & param)205 inline std::string RetransmissionAndFlowControlModeOptionText(const RetransmissionAndFlowControlModeOption& param) {std::stringstream builder;switch (param) {case RetransmissionAndFlowControlModeOption::L2CAP_BASIC: builder << "L2CAP_BASIC"; break;case RetransmissionAndFlowControlModeOption::RETRANSMISSION: builder << "RETRANSMISSION"; break;case RetransmissionAndFlowControlModeOption::FLOW_CONTROL: builder << "FLOW_CONTROL"; break;case RetransmissionAndFlowControlModeOption::ENHANCED_RETRANSMISSION: builder << "ENHANCED_RETRANSMISSION"; break;case RetransmissionAndFlowControlModeOption::STREAMING: builder << "STREAMING"; break;default: builder << "Unknown RetransmissionAndFlowControlModeOption";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(8/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
206
207
208
FcsTypeText(const FcsType & param)209 inline std::string FcsTypeText(const FcsType& param) {std::stringstream builder;switch (param) {case FcsType::NO_FCS: builder << "NO_FCS"; break;case FcsType::DEFAULT: builder << "DEFAULT"; break;default: builder << "Unknown FcsType";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(8/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
210
211
212
ConfigurationResponseResultText(const ConfigurationResponseResult & param)213 inline std::string ConfigurationResponseResultText(const ConfigurationResponseResult& param) {std::stringstream builder;switch (param) {case ConfigurationResponseResult::SUCCESS: builder << "SUCCESS"; break;case ConfigurationResponseResult::UNACCEPTABLE_PARAMETERS: builder << "UNACCEPTABLE_PARAMETERS"; break;case ConfigurationResponseResult::REJECTED: builder << "REJECTED"; break;case ConfigurationResponseResult::UNKNOWN_OPTIONS: builder << "UNKNOWN_OPTIONS"; break;case ConfigurationResponseResult::PENDING: builder << "PENDING"; break;case ConfigurationResponseResult::FLOW_SPEC_REJECTED: builder << "FLOW_SPEC_REJECTED"; break;default: builder << "Unknown ConfigurationResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
214
215
216
InformationRequestInfoTypeText(const InformationRequestInfoType & param)217 inline std::string InformationRequestInfoTypeText(const InformationRequestInfoType& param) {std::stringstream builder;switch (param) {case InformationRequestInfoType::CONNECTIONLESS_MTU: builder << "CONNECTIONLESS_MTU"; break;case InformationRequestInfoType::EXTENDED_FEATURES_SUPPORTED: builder << "EXTENDED_FEATURES_SUPPORTED"; break;case InformationRequestInfoType::FIXED_CHANNELS_SUPPORTED: builder << "FIXED_CHANNELS_SUPPORTED"; break;default: builder << "Unknown InformationRequestInfoType";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
218
219
220
InformationRequestResultText(const InformationRequestResult & param)221 inline std::string InformationRequestResultText(const InformationRequestResult& param) {std::stringstream builder;switch (param) {case InformationRequestResult::SUCCESS: builder << "SUCCESS"; break;case InformationRequestResult::NOT_SUPPORTED: builder << "NOT_SUPPORTED"; break;default: builder << "Unknown InformationRequestResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
222
223
224
CreateChannelResponseResultText(const CreateChannelResponseResult & param)225 inline std::string CreateChannelResponseResultText(const CreateChannelResponseResult& param) {std::stringstream builder;switch (param) {case CreateChannelResponseResult::SUCCESS: builder << "SUCCESS"; break;case CreateChannelResponseResult::PENDING: builder << "PENDING"; break;case CreateChannelResponseResult::PSM_NOT_SUPPORTED: builder << "PSM_NOT_SUPPORTED"; break;case CreateChannelResponseResult::SECURITY_BLOCK: builder << "SECURITY_BLOCK"; break;case CreateChannelResponseResult::NO_RESOURCES_AVAILABLE: builder << "NO_RESOURCES_AVAILABLE"; break;case CreateChannelResponseResult::CONTROLLER_ID_NOT_SUPPORTED: builder << "CONTROLLER_ID_NOT_SUPPORTED"; break;case CreateChannelResponseResult::INVALID_CID: builder << "INVALID_CID"; break;case CreateChannelResponseResult::SOURCE_CID_ALREADY_ALLOCATED: builder << "SOURCE_CID_ALREADY_ALLOCATED"; break;default: builder << "Unknown CreateChannelResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
226
227
228
CreateChannelResponseStatusText(const CreateChannelResponseStatus & param)229 inline std::string CreateChannelResponseStatusText(const CreateChannelResponseStatus& param) {std::stringstream builder;switch (param) {case CreateChannelResponseStatus::NO_FURTHER_INFORMATION_AVAILABLE: builder << "NO_FURTHER_INFORMATION_AVAILABLE"; break;case CreateChannelResponseStatus::AUTHENTICATION_PENDING: builder << "AUTHENTICATION_PENDING"; break;case CreateChannelResponseStatus::AUTHORIZATION_PENDING: builder << "AUTHORIZATION_PENDING"; break;default: builder << "Unknown CreateChannelResponseStatus";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
230
231
232
MoveChannelResponseResultText(const MoveChannelResponseResult & param)233 inline std::string MoveChannelResponseResultText(const MoveChannelResponseResult& param) {std::stringstream builder;switch (param) {case MoveChannelResponseResult::SUCCESS: builder << "SUCCESS"; break;case MoveChannelResponseResult::PENDING: builder << "PENDING"; break;case MoveChannelResponseResult::CONTROLLER_ID_NOT_SUPPORTED: builder << "CONTROLLER_ID_NOT_SUPPORTED"; break;case MoveChannelResponseResult::NEW_CONTROLLER_ID_IS_SAME: builder << "NEW_CONTROLLER_ID_IS_SAME"; break;case MoveChannelResponseResult::CONFIGURATION_NOT_SUPPORTED: builder << "CONFIGURATION_NOT_SUPPORTED"; break;case MoveChannelResponseResult::CHANNEL_COLLISION: builder << "CHANNEL_COLLISION"; break;case MoveChannelResponseResult::CHANNEL_NOT_ALLOWED_TO_BE_MOVED: builder << "CHANNEL_NOT_ALLOWED_TO_BE_MOVED"; break;default: builder << "Unknown MoveChannelResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
234
235
236
MoveChannelConfirmationResultText(const MoveChannelConfirmationResult & param)237 inline std::string MoveChannelConfirmationResultText(const MoveChannelConfirmationResult& param) {std::stringstream builder;switch (param) {case MoveChannelConfirmationResult::SUCCESS: builder << "SUCCESS"; break;case MoveChannelConfirmationResult::FAILURE: builder << "FAILURE"; break;default: builder << "Unknown MoveChannelConfirmationResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
238
239
240
CreditBasedConnectionResponseResultText(const CreditBasedConnectionResponseResult & param)241 inline std::string CreditBasedConnectionResponseResultText(const CreditBasedConnectionResponseResult& param) {std::stringstream builder;switch (param) {case CreditBasedConnectionResponseResult::SUCCESS: builder << "SUCCESS"; break;case CreditBasedConnectionResponseResult::SPSM_NOT_SUPPORTED: builder << "SPSM_NOT_SUPPORTED"; break;case CreditBasedConnectionResponseResult::SOME_REFUSED_NO_RESOURCES_AVAILABLE: builder << "SOME_REFUSED_NO_RESOURCES_AVAILABLE"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_INSUFFICIENT_AUTHENTICATION: builder << "ALL_REFUSED_INSUFFICIENT_AUTHENTICATION"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_INSUFFICIENT_AUTHORIZATION: builder << "ALL_REFUSED_INSUFFICIENT_AUTHORIZATION"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_INSUFFICIENT_ENCRYPTION_KEY_SIZE: builder << "ALL_REFUSED_INSUFFICIENT_ENCRYPTION_KEY_SIZE"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_INSUFFICIENT_ENCRYPTION: builder << "ALL_REFUSED_INSUFFICIENT_ENCRYPTION"; break;case CreditBasedConnectionResponseResult::SOME_REFUSED_INVALID_SOURCE_CID: builder << "SOME_REFUSED_INVALID_SOURCE_CID"; break;case CreditBasedConnectionResponseResult::SOME_REFUSED_SOURCE_CID_ALREADY_ALLOCATED: builder << "SOME_REFUSED_SOURCE_CID_ALREADY_ALLOCATED"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_UNACCEPTABLE_PARAMETERS: builder << "ALL_REFUSED_UNACCEPTABLE_PARAMETERS"; break;case CreditBasedConnectionResponseResult::ALL_REFUSED_INVALID_PARAMETERS: builder << "ALL_REFUSED_INVALID_PARAMETERS"; break;default: builder << "Unknown CreditBasedConnectionResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
242
243
244
CreditBasedReconfigureResponseResultText(const CreditBasedReconfigureResponseResult & param)245 inline std::string CreditBasedReconfigureResponseResultText(const CreditBasedReconfigureResponseResult& param) {std::stringstream builder;switch (param) {case CreditBasedReconfigureResponseResult::SUCCESS: builder << "SUCCESS"; break;case CreditBasedReconfigureResponseResult::MTU_NOT_ALLOWED: builder << "MTU_NOT_ALLOWED"; break;case CreditBasedReconfigureResponseResult::MPS_NOT_ALLOWED: builder << "MPS_NOT_ALLOWED"; break;case CreditBasedReconfigureResponseResult::INVALID_DESTINATION_CID: builder << "INVALID_DESTINATION_CID"; break;case CreditBasedReconfigureResponseResult::UNACCEPTABLE_PARAMETERS: builder << "UNACCEPTABLE_PARAMETERS"; break;default: builder << "Unknown CreditBasedReconfigureResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
246
247
248
LeCommandCodeText(const LeCommandCode & param)249 inline std::string LeCommandCodeText(const LeCommandCode& param) {std::stringstream builder;switch (param) {case LeCommandCode::COMMAND_REJECT: builder << "COMMAND_REJECT"; break;case LeCommandCode::DISCONNECTION_REQUEST: builder << "DISCONNECTION_REQUEST"; break;case LeCommandCode::DISCONNECTION_RESPONSE: builder << "DISCONNECTION_RESPONSE"; break;case LeCommandCode::CONNECTION_PARAMETER_UPDATE_REQUEST: builder << "CONNECTION_PARAMETER_UPDATE_REQUEST"; break;case LeCommandCode::CONNECTION_PARAMETER_UPDATE_RESPONSE: builder << "CONNECTION_PARAMETER_UPDATE_RESPONSE"; break;case LeCommandCode::LE_CREDIT_BASED_CONNECTION_REQUEST: builder << "LE_CREDIT_BASED_CONNECTION_REQUEST"; break;case LeCommandCode::LE_CREDIT_BASED_CONNECTION_RESPONSE: builder << "LE_CREDIT_BASED_CONNECTION_RESPONSE"; break;case LeCommandCode::LE_FLOW_CONTROL_CREDIT: builder << "LE_FLOW_CONTROL_CREDIT"; break;case LeCommandCode::CREDIT_BASED_CONNECTION_REQUEST: builder << "CREDIT_BASED_CONNECTION_REQUEST"; break;case LeCommandCode::CREDIT_BASED_CONNECTION_RESPONSE: builder << "CREDIT_BASED_CONNECTION_RESPONSE"; break;case LeCommandCode::CREDIT_BASED_RECONFIGURE_REQUEST: builder << "CREDIT_BASED_RECONFIGURE_REQUEST"; break;case LeCommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE: builder << "CREDIT_BASED_RECONFIGURE_RESPONSE"; break;default: builder << "Unknown LeCommandCode";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(8/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
250
251
252
ConnectionParameterUpdateResponseResultText(const ConnectionParameterUpdateResponseResult & param)253 inline std::string ConnectionParameterUpdateResponseResultText(const ConnectionParameterUpdateResponseResult& param) {std::stringstream builder;switch (param) {case ConnectionParameterUpdateResponseResult::ACCEPTED: builder << "ACCEPTED"; break;case ConnectionParameterUpdateResponseResult::REJECTED: builder << "REJECTED"; break;default: builder << "Unknown ConnectionParameterUpdateResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
254
255
256
LeCreditBasedConnectionResponseResultText(const LeCreditBasedConnectionResponseResult & param)257 inline std::string LeCreditBasedConnectionResponseResultText(const LeCreditBasedConnectionResponseResult& param) {std::stringstream builder;switch (param) {case LeCreditBasedConnectionResponseResult::SUCCESS: builder << "SUCCESS"; break;case LeCreditBasedConnectionResponseResult::LE_PSM_NOT_SUPPORTED: builder << "LE_PSM_NOT_SUPPORTED"; break;case LeCreditBasedConnectionResponseResult::NO_RESOURCES_AVAILABLE: builder << "NO_RESOURCES_AVAILABLE"; break;case LeCreditBasedConnectionResponseResult::INSUFFICIENT_AUTHENTICATION: builder << "INSUFFICIENT_AUTHENTICATION"; break;case LeCreditBasedConnectionResponseResult::INSUFFICIENT_AUTHORIZATION: builder << "INSUFFICIENT_AUTHORIZATION"; break;case LeCreditBasedConnectionResponseResult::INSUFFICIENT_ENCRYPTION_KEY_SIZE: builder << "INSUFFICIENT_ENCRYPTION_KEY_SIZE"; break;case LeCreditBasedConnectionResponseResult::INSUFFICIENT_ENCRYPTION: builder << "INSUFFICIENT_ENCRYPTION"; break;case LeCreditBasedConnectionResponseResult::INVALID_SOURCE_CID: builder << "INVALID_SOURCE_CID"; break;case LeCreditBasedConnectionResponseResult::SOURCE_CID_ALREADY_ALLOCATED: builder << "SOURCE_CID_ALREADY_ALLOCATED"; break;case LeCreditBasedConnectionResponseResult::UNACCEPTABLE_PARAMETERS: builder << "UNACCEPTABLE_PARAMETERS"; break;default: builder << "Unknown LeCreditBasedConnectionResponseResult";}builder << "(" << std::hex << "0x" << std::setfill('0')<< std::setw(16/4)<< static_cast<uint64_t>(param) << ")";return builder.str();}
258
259
260
261 static_assert(ChecksumTypeChecker<Fcs,uint16_t>::value, "Fcs is not a valid checksum type. Please see README for more details.");
262 /* Done ChecksumChecks */
263
ConfigurationOption()264 class ConfigurationOption : public PacketStruct<kLittleEndian> { public:ConfigurationOption() {}
265 ConfigurationOption(ConfigurationOptionType type, ConfigurationOptionIsHint is_hint)
266 : type_(type), is_hint_(is_hint)
267 {}
268 public:
269 virtual ~ConfigurationOption() = default;
270 protected:void SerializeHeader(BitInserter& i ) const {insert(static_cast<uint8_t>(type_), i, 7);insert(static_cast<uint8_t>(is_hint_), i, 1);body_size_extracted_ = 0;size_t local_size = ConfigurationOption::size();ASSERT((size() - local_size) < (static_cast<size_t>(1) << 8));insert(static_cast<uint8_t>(size() - local_size), i,8);}
271
272 void SerializeFooter(BitInserter&) const {}
273
274 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
275
276 static std::optional<Iterator<kLittleEndian>> Parse(ConfigurationOption* to_fill, Iterator<kLittleEndian> struct_begin_it ) {auto to_bound = struct_begin_it;{if (to_bound.NumBytesRemaining() < 2){ return {};}}{auto type_it = to_bound + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto type_ptr = &to_fill->type_;auto extracted_value = type_it.extract<uint8_t>();extracted_value &= 0x7f;*type_ptr = static_cast<ConfigurationOptionType>(extracted_value);}{auto is_hint_it = to_bound + (/* Bits: */ 7 + /* Dynamic: */ 0) / 8;auto is_hint_ptr = &to_fill->is_hint_;auto extracted_value = is_hint_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*is_hint_ptr = static_cast<ConfigurationOptionIsHint>(extracted_value);}{auto body_size_it = to_bound + (/* Bits: */ 8 + /* Dynamic: */ 0) / 8;auto body_size_ptr = &to_fill->body_size_extracted_;auto extracted_value = body_size_it.extract<uint8_t>();*body_size_ptr = static_cast<uint8_t>(extracted_value);}return struct_begin_it + to_fill->size();}
277 protected:size_t BitsOfHeader() const {return 0 + /* Bits: */ 7 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0;}
278
279 size_t BitsOfFooter() const {return 0;}
280
281 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ body_size_extracted_ + (BitsOfFooter() / 8);}
282
283
284
285 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "ConfigurationOption { ";ss << "type = " << ConfigurationOptionTypeText(type_) << ", is_hint = " << ConfigurationOptionIsHintText(is_hint_) << ", body = " << "BODY REPRESENTATION_UNIMPLEMENTED body_ ";ss << " }";return ss.str();}
286
287 ConfigurationOptionType type_{};ConfigurationOptionIsHint is_hint_{};
288 private:
289 mutable uint8_t body_size_extracted_{0};};
290 std::unique_ptr<ConfigurationOption> ParseConfigurationOption(Iterator<kLittleEndian>it);
291
MtuConfigurationOption()292 class MtuConfigurationOption : public ConfigurationOption { public:MtuConfigurationOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}MtuConfigurationOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::MTU;}
293 MtuConfigurationOption(ConfigurationOptionIsHint is_hint, uint16_t mtu)
294 : ConfigurationOption(/* type */ ConfigurationOptionType::MTU, is_hint), mtu_(mtu)
295 {}
296 public:
297 virtual ~MtuConfigurationOption() = default;
298 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(mtu_, i,16);}
299
300 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
301
302 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
303
304 static Iterator<kLittleEndian> Parse(MtuConfigurationOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 4){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 2){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto mtu_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto mtu_ptr = &to_fill->mtu_;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);}return struct_begin_it + to_fill->size();}
305 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
306
307 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
308
309 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
310
311 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::MTU){ return false;}return true;}
312 static MtuConfigurationOption* Specialize(ConfigurationOption* parent) {ASSERT(MtuConfigurationOption::IsInstance(*parent));return static_cast<MtuConfigurationOption*>(parent);}
313 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "MtuConfigurationOption { ";ss << "mtu = " << static_cast<uint64_t>(mtu_);ss << " }";return ss.str();}
314
315 uint16_t mtu_{};};
316
317
FlushTimeoutConfigurationOption(const ConfigurationOption & parent)318 class FlushTimeoutConfigurationOption : public ConfigurationOption { public:FlushTimeoutConfigurationOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}FlushTimeoutConfigurationOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::FLUSH_TIMEOUT;}
319 FlushTimeoutConfigurationOption(ConfigurationOptionIsHint is_hint, uint16_t flush_timeout)
320 : ConfigurationOption(/* type */ ConfigurationOptionType::FLUSH_TIMEOUT, is_hint), flush_timeout_(flush_timeout)
321 {}
322 public:
323 virtual ~FlushTimeoutConfigurationOption() = default;
324 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(flush_timeout_, i,16);}
325
326 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
327
328 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
329
330 static Iterator<kLittleEndian> Parse(FlushTimeoutConfigurationOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 4){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 2){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto flush_timeout_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto flush_timeout_ptr = &to_fill->flush_timeout_;auto extracted_value = flush_timeout_it.extract<uint16_t>();*flush_timeout_ptr = static_cast<uint16_t>(extracted_value);}return struct_begin_it + to_fill->size();}
331 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
332
333 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
334
335 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
336
337 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::FLUSH_TIMEOUT){ return false;}return true;}
338 static FlushTimeoutConfigurationOption* Specialize(ConfigurationOption* parent) {ASSERT(FlushTimeoutConfigurationOption::IsInstance(*parent));return static_cast<FlushTimeoutConfigurationOption*>(parent);}
339 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "FlushTimeoutConfigurationOption { ";ss << "flush_timeout = " << static_cast<uint64_t>(flush_timeout_);ss << " }";return ss.str();}
340
341 uint16_t flush_timeout_{};};
342
343
QualityOfServiceConfigurationOption()344 class QualityOfServiceConfigurationOption : public ConfigurationOption { public:QualityOfServiceConfigurationOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}QualityOfServiceConfigurationOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::QUALITY_OF_SERVICE;}
345 QualityOfServiceConfigurationOption(ConfigurationOptionIsHint is_hint, QosServiceType service_type, uint32_t token_rate, uint32_t token_bucket_size, uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation)
346 : ConfigurationOption(/* type */ ConfigurationOptionType::QUALITY_OF_SERVICE, is_hint), service_type_(service_type), token_rate_(token_rate), token_bucket_size_(token_bucket_size), peak_bandwidth_(peak_bandwidth), latency_(latency), delay_variation_(delay_variation)
347 {}
348 public:
349 virtual ~QualityOfServiceConfigurationOption() = default;
350 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(static_cast<uint8_t>(0) /* Reserved */, i, 8 );
351 insert(static_cast<uint8_t>(service_type_), i, 8);insert(token_rate_, i,32);insert(token_bucket_size_, i,32);insert(peak_bandwidth_, i,32);insert(latency_, i,32);insert(delay_variation_, i,32);}
352
353 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
354
355 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
356
357 static Iterator<kLittleEndian> Parse(QualityOfServiceConfigurationOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 24){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 21){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto service_type_it = to_bound + (/* Bits: */ 24 + /* Dynamic: */ 0) / 8;auto service_type_ptr = &to_fill->service_type_;auto extracted_value = service_type_it.extract<uint8_t>();*service_type_ptr = static_cast<QosServiceType>(extracted_value);}{auto token_rate_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;auto token_rate_ptr = &to_fill->token_rate_;auto extracted_value = token_rate_it.extract<uint32_t>();*token_rate_ptr = static_cast<uint32_t>(extracted_value);}{auto token_bucket_size_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;auto token_bucket_size_ptr = &to_fill->token_bucket_size_;auto extracted_value = token_bucket_size_it.extract<uint32_t>();*token_bucket_size_ptr = static_cast<uint32_t>(extracted_value);}{auto peak_bandwidth_it = to_bound + (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;auto peak_bandwidth_ptr = &to_fill->peak_bandwidth_;auto extracted_value = peak_bandwidth_it.extract<uint32_t>();*peak_bandwidth_ptr = static_cast<uint32_t>(extracted_value);}{auto latency_it = to_bound + (/* Bits: */ 128 + /* Dynamic: */ 0) / 8;auto latency_ptr = &to_fill->latency_;auto extracted_value = latency_it.extract<uint32_t>();*latency_ptr = static_cast<uint32_t>(extracted_value);}{auto delay_variation_it = to_bound + (/* Bits: */ 160 + /* Dynamic: */ 0) / 8;auto delay_variation_ptr = &to_fill->delay_variation_;auto extracted_value = delay_variation_it.extract<uint32_t>();*delay_variation_ptr = static_cast<uint32_t>(extracted_value);}return struct_begin_it + to_fill->size();}
358 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0;}
359
360 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
361
362 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
363
364 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::QUALITY_OF_SERVICE){ return false;}return true;}
365 static QualityOfServiceConfigurationOption* Specialize(ConfigurationOption* parent) {ASSERT(QualityOfServiceConfigurationOption::IsInstance(*parent));return static_cast<QualityOfServiceConfigurationOption*>(parent);}
366 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "QualityOfServiceConfigurationOption { ";ss << "service_type = " << QosServiceTypeText(service_type_) << ", token_rate = " << static_cast<uint64_t>(token_rate_) << ", token_bucket_size = " << static_cast<uint64_t>(token_bucket_size_) << ", peak_bandwidth = " << static_cast<uint64_t>(peak_bandwidth_) << ", latency = " << static_cast<uint64_t>(latency_) << ", delay_variation = " << static_cast<uint64_t>(delay_variation_);ss << " }";return ss.str();}
367
368 QosServiceType service_type_{};uint32_t token_rate_{};uint32_t token_bucket_size_{};uint32_t peak_bandwidth_{};uint32_t latency_{};uint32_t delay_variation_{};};
369
370
RetransmissionAndFlowControlConfigurationOption(const ConfigurationOption & parent)371 class RetransmissionAndFlowControlConfigurationOption : public ConfigurationOption { public:RetransmissionAndFlowControlConfigurationOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}RetransmissionAndFlowControlConfigurationOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL;}
372 RetransmissionAndFlowControlConfigurationOption(ConfigurationOptionIsHint is_hint, RetransmissionAndFlowControlModeOption mode, uint8_t tx_window_size, uint8_t max_transmit, uint16_t retransmission_time_out, uint16_t monitor_time_out, uint16_t maximum_pdu_size)
373 : ConfigurationOption(/* type */ ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL, is_hint), mode_(mode), tx_window_size_(tx_window_size), max_transmit_(max_transmit), retransmission_time_out_(retransmission_time_out), monitor_time_out_(monitor_time_out), maximum_pdu_size_(maximum_pdu_size)
374 {}
375 public:
376 virtual ~RetransmissionAndFlowControlConfigurationOption() = default;
377 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(static_cast<uint8_t>(mode_), i, 8);i.insert_byte(tx_window_size_);i.insert_byte(max_transmit_);insert(retransmission_time_out_, i,16);insert(monitor_time_out_, i,16);insert(maximum_pdu_size_, i,16);}
378
379 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
380
381 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
382
383 static Iterator<kLittleEndian> Parse(RetransmissionAndFlowControlConfigurationOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 11){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 9){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto mode_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto mode_ptr = &to_fill->mode_;auto extracted_value = mode_it.extract<uint8_t>();*mode_ptr = static_cast<RetransmissionAndFlowControlModeOption>(extracted_value);}{auto tx_window_size_it = to_bound + (/* Bits: */ 24 + /* Dynamic: */ 0) / 8;auto tx_window_size_ptr = &to_fill->tx_window_size_;auto extracted_value = tx_window_size_it.extract<uint8_t>();*tx_window_size_ptr = static_cast<uint8_t>(extracted_value);}{auto max_transmit_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;auto max_transmit_ptr = &to_fill->max_transmit_;auto extracted_value = max_transmit_it.extract<uint8_t>();*max_transmit_ptr = static_cast<uint8_t>(extracted_value);}{auto retransmission_time_out_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;auto retransmission_time_out_ptr = &to_fill->retransmission_time_out_;auto extracted_value = retransmission_time_out_it.extract<uint16_t>();*retransmission_time_out_ptr = static_cast<uint16_t>(extracted_value);}{auto monitor_time_out_it = to_bound + (/* Bits: */ 56 + /* Dynamic: */ 0) / 8;auto monitor_time_out_ptr = &to_fill->monitor_time_out_;auto extracted_value = monitor_time_out_it.extract<uint16_t>();*monitor_time_out_ptr = static_cast<uint16_t>(extracted_value);}{auto maximum_pdu_size_it = to_bound + (/* Bits: */ 72 + /* Dynamic: */ 0) / 8;auto maximum_pdu_size_ptr = &to_fill->maximum_pdu_size_;auto extracted_value = maximum_pdu_size_it.extract<uint16_t>();*maximum_pdu_size_ptr = static_cast<uint16_t>(extracted_value);}return struct_begin_it + to_fill->size();}
384 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
385
386 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
387
388 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
389
390 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::RETRANSMISSION_AND_FLOW_CONTROL){ return false;}return true;}
391 static RetransmissionAndFlowControlConfigurationOption* Specialize(ConfigurationOption* parent) {ASSERT(RetransmissionAndFlowControlConfigurationOption::IsInstance(*parent));return static_cast<RetransmissionAndFlowControlConfigurationOption*>(parent);}
392 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "RetransmissionAndFlowControlConfigurationOption { ";ss << "mode = " << RetransmissionAndFlowControlModeOptionText(mode_) << ", tx_window_size = " << static_cast<uint64_t>(tx_window_size_) << ", max_transmit = " << static_cast<uint64_t>(max_transmit_) << ", retransmission_time_out = " << static_cast<uint64_t>(retransmission_time_out_) << ", monitor_time_out = " << static_cast<uint64_t>(monitor_time_out_) << ", maximum_pdu_size = " << static_cast<uint64_t>(maximum_pdu_size_);ss << " }";return ss.str();}
393
394 RetransmissionAndFlowControlModeOption mode_{};uint8_t tx_window_size_{};uint8_t max_transmit_{};uint16_t retransmission_time_out_{};uint16_t monitor_time_out_{};uint16_t maximum_pdu_size_{};};
395
396
FrameCheckSequenceOption(const ConfigurationOption & parent)397 class FrameCheckSequenceOption : public ConfigurationOption { public:FrameCheckSequenceOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}FrameCheckSequenceOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::FRAME_CHECK_SEQUENCE;}
398 FrameCheckSequenceOption(ConfigurationOptionIsHint is_hint, FcsType fcs_type)
399 : ConfigurationOption(/* type */ ConfigurationOptionType::FRAME_CHECK_SEQUENCE, is_hint), fcs_type_(fcs_type)
400 {}
401 public:
402 virtual ~FrameCheckSequenceOption() = default;
403 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(static_cast<uint8_t>(fcs_type_), i, 8);}
404
405 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
406
407 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
408
409 static Iterator<kLittleEndian> Parse(FrameCheckSequenceOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 3){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 1){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto fcs_type_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto fcs_type_ptr = &to_fill->fcs_type_;auto extracted_value = fcs_type_it.extract<uint8_t>();*fcs_type_ptr = static_cast<FcsType>(extracted_value);}return struct_begin_it + to_fill->size();}
410 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 8 + /* Dynamic: */ 0;}
411
412 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
413
414 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
415
416 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::FRAME_CHECK_SEQUENCE){ return false;}return true;}
417 static FrameCheckSequenceOption* Specialize(ConfigurationOption* parent) {ASSERT(FrameCheckSequenceOption::IsInstance(*parent));return static_cast<FrameCheckSequenceOption*>(parent);}
418 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "FrameCheckSequenceOption { ";ss << "fcs_type = " << FcsTypeText(fcs_type_);ss << " }";return ss.str();}
419
420 FcsType fcs_type_{};};
421
422
ExtendedFlowSpecificationOption()423 class ExtendedFlowSpecificationOption : public ConfigurationOption { public:ExtendedFlowSpecificationOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}ExtendedFlowSpecificationOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::EXTENDED_FLOW_SPECIFICATION;}
424 ExtendedFlowSpecificationOption(ConfigurationOptionIsHint is_hint, uint8_t identifier, QosServiceType service_type, uint16_t maximum_sdu_size, uint32_t sdu_interarrival_time, uint32_t access_latency, uint32_t flush_timeout)
425 : ConfigurationOption(/* type */ ConfigurationOptionType::EXTENDED_FLOW_SPECIFICATION, is_hint), identifier_(identifier), service_type_(service_type), maximum_sdu_size_(maximum_sdu_size), sdu_interarrival_time_(sdu_interarrival_time), access_latency_(access_latency), flush_timeout_(flush_timeout)
426 {}
427 public:
428 virtual ~ExtendedFlowSpecificationOption() = default;
429 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);i.insert_byte(identifier_);insert(static_cast<uint8_t>(service_type_), i, 8);insert(maximum_sdu_size_, i,16);insert(sdu_interarrival_time_, i,32);insert(access_latency_, i,32);insert(flush_timeout_, i,32);}
430
431 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
432
433 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
434
435 static Iterator<kLittleEndian> Parse(ExtendedFlowSpecificationOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 18){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 16){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto identifier_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto identifier_ptr = &to_fill->identifier_;auto extracted_value = identifier_it.extract<uint8_t>();*identifier_ptr = static_cast<uint8_t>(extracted_value);}{auto service_type_it = to_bound + (/* Bits: */ 24 + /* Dynamic: */ 0) / 8;auto service_type_ptr = &to_fill->service_type_;auto extracted_value = service_type_it.extract<uint8_t>();*service_type_ptr = static_cast<QosServiceType>(extracted_value);}{auto maximum_sdu_size_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;auto maximum_sdu_size_ptr = &to_fill->maximum_sdu_size_;auto extracted_value = maximum_sdu_size_it.extract<uint16_t>();*maximum_sdu_size_ptr = static_cast<uint16_t>(extracted_value);}{auto sdu_interarrival_time_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;auto sdu_interarrival_time_ptr = &to_fill->sdu_interarrival_time_;auto extracted_value = sdu_interarrival_time_it.extract<uint32_t>();*sdu_interarrival_time_ptr = static_cast<uint32_t>(extracted_value);}{auto access_latency_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;auto access_latency_ptr = &to_fill->access_latency_;auto extracted_value = access_latency_it.extract<uint32_t>();*access_latency_ptr = static_cast<uint32_t>(extracted_value);}{auto flush_timeout_it = to_bound + (/* Bits: */ 112 + /* Dynamic: */ 0) / 8;auto flush_timeout_ptr = &to_fill->flush_timeout_;auto extracted_value = flush_timeout_it.extract<uint32_t>();*flush_timeout_ptr = static_cast<uint32_t>(extracted_value);}return struct_begin_it + to_fill->size();}
436 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0 + /* Bits: */ 32 + /* Dynamic: */ 0;}
437
438 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
439
440 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
441
442 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::EXTENDED_FLOW_SPECIFICATION){ return false;}return true;}
443 static ExtendedFlowSpecificationOption* Specialize(ConfigurationOption* parent) {ASSERT(ExtendedFlowSpecificationOption::IsInstance(*parent));return static_cast<ExtendedFlowSpecificationOption*>(parent);}
444 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "ExtendedFlowSpecificationOption { ";ss << "identifier = " << static_cast<uint64_t>(identifier_) << ", service_type = " << QosServiceTypeText(service_type_) << ", maximum_sdu_size = " << static_cast<uint64_t>(maximum_sdu_size_) << ", sdu_interarrival_time = " << static_cast<uint64_t>(sdu_interarrival_time_) << ", access_latency = " << static_cast<uint64_t>(access_latency_) << ", flush_timeout = " << static_cast<uint64_t>(flush_timeout_);ss << " }";return ss.str();}
445
446 uint8_t identifier_{};QosServiceType service_type_{};uint16_t maximum_sdu_size_{};uint32_t sdu_interarrival_time_{};uint32_t access_latency_{};uint32_t flush_timeout_{};};
447
448
ExtendedWindowSizeOption(const ConfigurationOption & parent)449 class ExtendedWindowSizeOption : public ConfigurationOption { public:ExtendedWindowSizeOption(const ConfigurationOption& parent) : ConfigurationOption(parent) {}ExtendedWindowSizeOption() : ConfigurationOption() {ConfigurationOption::type_ = ConfigurationOptionType::EXTENDED_WINDOW_SIZE;}
450 ExtendedWindowSizeOption(ConfigurationOptionIsHint is_hint, uint16_t max_window_size)
451 : ConfigurationOption(/* type */ ConfigurationOptionType::EXTENDED_WINDOW_SIZE, is_hint), max_window_size_(max_window_size)
452 {}
453 public:
454 virtual ~ExtendedWindowSizeOption() = default;
455 protected:void SerializeHeader(BitInserter& i ) const {ConfigurationOption::SerializeHeader(i);insert(max_window_size_, i,16);}
456
457 void SerializeFooter(BitInserter& i ) const {ConfigurationOption::SerializeFooter(i);}
458
459 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
460
461 static Iterator<kLittleEndian> Parse(ExtendedWindowSizeOption* to_fill, Iterator<kLittleEndian> struct_begin_it , bool fill_parent = true) {auto to_bound = struct_begin_it;if (fill_parent) {auto parent_optional_it = ConfigurationOption::Parse(to_fill, to_bound);ASSERT(parent_optional_it.has_value());}size_t end_index = struct_begin_it.NumBytesRemaining();if (end_index < 4){ return struct_begin_it.Subrange(0,0);}{if (to_bound.NumBytesRemaining() < 2){ return to_bound.Subrange(to_bound.NumBytesRemaining(),0);}}{auto max_window_size_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto max_window_size_ptr = &to_fill->max_window_size_;auto extracted_value = max_window_size_it.extract<uint16_t>();*max_window_size_ptr = static_cast<uint16_t>(extracted_value);}return struct_begin_it + to_fill->size();}
462 protected:size_t BitsOfHeader() const {return 0 + ConfigurationOption::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
463
464 size_t BitsOfFooter() const {return 0 + ConfigurationOption::BitsOfFooter() ;}
465
466 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
467
468 static bool IsInstance(const ConfigurationOption& parent) {if (parent.type_ != ConfigurationOptionType::EXTENDED_WINDOW_SIZE){ return false;}return true;}
469 static ExtendedWindowSizeOption* Specialize(ConfigurationOption* parent) {ASSERT(ExtendedWindowSizeOption::IsInstance(*parent));return static_cast<ExtendedWindowSizeOption*>(parent);}
470 std::string ToString() const {std::stringstream ss;ss << std::hex << std::showbase << "ExtendedWindowSizeOption { ";ss << "max_window_size = " << static_cast<uint64_t>(max_window_size_);ss << " }";return ss.str();}
471
472 uint16_t max_window_size_{};};
473
474
ParseConfigurationOption(Iterator<kLittleEndian> to_bound)475 inline std::unique_ptr<ConfigurationOption> ParseConfigurationOption(Iterator<kLittleEndian> to_bound) {std::unique_ptr<ConfigurationOption> ConfigurationOption_parse_value = std::make_unique<ConfigurationOption>();auto ConfigurationOption_parse_it = to_bound;auto parent_optional_it = ConfigurationOption::Parse( ConfigurationOption_parse_value.get(), ConfigurationOption_parse_it);if (parent_optional_it) {ConfigurationOption_parse_it = *parent_optional_it;} else { return nullptr; }bool ConfigurationOption_parse_child_found = false; /* Greedy match */if (!ConfigurationOption_parse_child_found && MtuConfigurationOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<MtuConfigurationOption> MtuConfigurationOption_parse_value;MtuConfigurationOption_parse_value.reset(new MtuConfigurationOption(*ConfigurationOption_parse_value));MtuConfigurationOption::Parse( MtuConfigurationOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(MtuConfigurationOption_parse_value); }if (!ConfigurationOption_parse_child_found && FlushTimeoutConfigurationOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<FlushTimeoutConfigurationOption> FlushTimeoutConfigurationOption_parse_value;FlushTimeoutConfigurationOption_parse_value.reset(new FlushTimeoutConfigurationOption(*ConfigurationOption_parse_value));FlushTimeoutConfigurationOption::Parse( FlushTimeoutConfigurationOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(FlushTimeoutConfigurationOption_parse_value); }if (!ConfigurationOption_parse_child_found && QualityOfServiceConfigurationOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<QualityOfServiceConfigurationOption> QualityOfServiceConfigurationOption_parse_value;QualityOfServiceConfigurationOption_parse_value.reset(new QualityOfServiceConfigurationOption(*ConfigurationOption_parse_value));QualityOfServiceConfigurationOption::Parse( QualityOfServiceConfigurationOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(QualityOfServiceConfigurationOption_parse_value); }if (!ConfigurationOption_parse_child_found && RetransmissionAndFlowControlConfigurationOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<RetransmissionAndFlowControlConfigurationOption> RetransmissionAndFlowControlConfigurationOption_parse_value;RetransmissionAndFlowControlConfigurationOption_parse_value.reset(new RetransmissionAndFlowControlConfigurationOption(*ConfigurationOption_parse_value));RetransmissionAndFlowControlConfigurationOption::Parse( RetransmissionAndFlowControlConfigurationOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(RetransmissionAndFlowControlConfigurationOption_parse_value); }if (!ConfigurationOption_parse_child_found && FrameCheckSequenceOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<FrameCheckSequenceOption> FrameCheckSequenceOption_parse_value;FrameCheckSequenceOption_parse_value.reset(new FrameCheckSequenceOption(*ConfigurationOption_parse_value));FrameCheckSequenceOption::Parse( FrameCheckSequenceOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(FrameCheckSequenceOption_parse_value); }if (!ConfigurationOption_parse_child_found && ExtendedFlowSpecificationOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<ExtendedFlowSpecificationOption> ExtendedFlowSpecificationOption_parse_value;ExtendedFlowSpecificationOption_parse_value.reset(new ExtendedFlowSpecificationOption(*ConfigurationOption_parse_value));ExtendedFlowSpecificationOption::Parse( ExtendedFlowSpecificationOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(ExtendedFlowSpecificationOption_parse_value); }if (!ConfigurationOption_parse_child_found && ExtendedWindowSizeOption::IsInstance(*ConfigurationOption_parse_value.get())) {ConfigurationOption_parse_child_found = true;std::unique_ptr<ExtendedWindowSizeOption> ExtendedWindowSizeOption_parse_value;ExtendedWindowSizeOption_parse_value.reset(new ExtendedWindowSizeOption(*ConfigurationOption_parse_value));ExtendedWindowSizeOption::Parse( ExtendedWindowSizeOption_parse_value.get(), to_bound, false);ConfigurationOption_parse_value = std::move(ExtendedWindowSizeOption_parse_value); }return ConfigurationOption_parse_value; }
476
CreateOptional(PacketView<kLittleEndian> packet)477 class BasicFrameView : public PacketView<kLittleEndian> { public:static BasicFrameView Create(PacketView<kLittleEndian> packet){ return BasicFrameView(std::move(packet)); }static std::optional<BasicFrameView> CreateOptional(PacketView<kLittleEndian> packet){ auto to_validate = BasicFrameView::Create(std::move(packet));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
478 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
479 static BasicFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return BasicFrameView::Create(PacketView<kLittleEndian>(vec));}
480 #endif
481 protected:uint16_t GetPayloadSize() const {ASSERT(was_validated_);auto to_bound = begin();auto payload_size_it = to_bound + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;uint16_t payload_size_value{};uint16_t* payload_size_ptr = &payload_size_value;auto extracted_value = payload_size_it.extract<uint16_t>();*payload_size_ptr = static_cast<uint16_t>(extracted_value);return payload_size_value;}public:
482
483 uint16_t GetChannelId() const {ASSERT(was_validated_);auto to_bound = begin();auto channel_id_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;uint16_t channel_id_value{};uint16_t* channel_id_ptr = &channel_id_value;auto extracted_value = channel_id_it.extract<uint16_t>();*channel_id_ptr = static_cast<uint16_t>(extracted_value);return channel_id_value;}
484 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;size_t field_sized_end = field_begin + (/* Bits: */ 0 + /* Dynamic: */ (GetPayloadSize() * 8)) / 8;if (field_sized_end < field_end) { field_end = field_sized_end; }auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
485
486
487 bool IsValid() {
488 if (was_validated_) {
489 return true;
490 } else {
491 was_validated_ = true;
492 return (was_validated_ = Validate());
493 }
494 }
495 protected:
496 virtual bool Validate() const {
497 auto it = begin() + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;it += ((GetPayloadSize() * 8)) / 8;if (it > end()) return false;
498
499
500 return true;}
501 bool was_validated_{false};
502
503 public:virtual std::string ToString() const {std::stringstream ss;ss << std::showbase << std::hex << "BasicFrame { ";ss << "" << "payload_size = " << GetPayloadSize() << ", channel_id = " << static_cast<uint64_t>(GetChannelId()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
504
505 protected:
506 explicit BasicFrameView(PacketView<kLittleEndian> packet) : PacketView<kLittleEndian>(packet) { was_validated_ = false;}};
507
508
CreateOptional(PacketView<kLittleEndian> packet)509 class BasicFrameWithFcsView : public PacketView<kLittleEndian> { public:static BasicFrameWithFcsView Create(PacketView<kLittleEndian> packet){ return BasicFrameWithFcsView(std::move(packet)); }static std::optional<BasicFrameWithFcsView> CreateOptional(PacketView<kLittleEndian> packet){ auto to_validate = BasicFrameWithFcsView::Create(std::move(packet));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
510 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
511 static BasicFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec));}
512 #endif
513
514 protected:uint16_t GetPayloadSize() const {ASSERT(was_validated_);auto to_bound = begin();auto payload_size_it = to_bound + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;uint16_t payload_size_value{};uint16_t* payload_size_ptr = &payload_size_value;auto extracted_value = payload_size_it.extract<uint16_t>();*payload_size_ptr = static_cast<uint16_t>(extracted_value);return payload_size_value;}public:
515
516 uint16_t GetChannelId() const {ASSERT(was_validated_);auto to_bound = begin();auto channel_id_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;uint16_t channel_id_value{};uint16_t* channel_id_ptr = &channel_id_value;auto extracted_value = channel_id_it.extract<uint16_t>();*channel_id_ptr = static_cast<uint16_t>(extracted_value);return channel_id_value;}
517 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;size_t field_sized_end = field_begin + (/* Bits: */ 0 + /* Dynamic: */ (GetPayloadSize() * 8)- (2 * 8)) / 8;if (field_sized_end < field_end) { field_end = field_sized_end; }auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
518
519
520
521 bool IsValid() {
522 if (was_validated_) {
523 return true;
524 } else {
525 was_validated_ = true;
526 return (was_validated_ = Validate());
527 }
528 }
529 protected:
530 virtual bool Validate() const {
531 auto it = begin() + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;it += 6 /* Total size of the fixed fields */;if (it > end()) return false;size_t sum_index = (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;size_t end_sum_index = (/* Bits: */ 32 + /* Dynamic: */ (GetPayloadSize() * 8)- (2 * 8)) / 8;if (end_sum_index >= size()) { return false; }auto checksum_view = GetLittleEndianSubview(sum_index, end_sum_index);Fcs checksum;checksum.Initialize();for (uint8_t byte : checksum_view) { checksum.AddByte(byte);}if (checksum.GetChecksum() != (begin() + end_sum_index).extract<uint16_t>()) { return false; }it += ((GetPayloadSize() * 8)- (2 * 8)) / 8;if (it > end()) return false;
532
533
534
535
536 return true;}
537 bool was_validated_{false};
538
539 public:virtual std::string ToString() const {std::stringstream ss;ss << std::showbase << std::hex << "BasicFrameWithFcs { ";ss << "" << "payload_size = " << GetPayloadSize() << ", channel_id = " << static_cast<uint64_t>(GetChannelId()) << ", payload = " << "PAYLOAD[]" << ", fcs = " << "CHECKSUM";ss << " }";return ss.str();}
540
541 protected:
542 explicit BasicFrameWithFcsView(PacketView<kLittleEndian> packet) : PacketView<kLittleEndian>(packet) { was_validated_ = false;}};
543
544
CreateOptional(BasicFrameView parent)545 class GroupFrameView : public BasicFrameView { public:static GroupFrameView Create(BasicFrameView parent){ return GroupFrameView(std::move(parent)); }static std::optional<GroupFrameView> CreateOptional(BasicFrameView parent){ auto to_validate = GroupFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
546 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
547 static GroupFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return GroupFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)));}
548 #endif
549 uint16_t GetPsm() const {ASSERT(was_validated_);auto to_bound = begin();auto psm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t psm_value{};uint16_t* psm_ptr = &psm_value;auto extracted_value = psm_it.extract<uint16_t>();*psm_ptr = static_cast<uint16_t>(extracted_value);return psm_value;}
550 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
551
552
553 protected:
554 bool Validate() const override {
555 if (!BasicFrameView::Validate()) {
556 return false;
557 }
558 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetChannelId() != 2) return false;
559
560 return true;}
561
562 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "GroupFrame { ";ss << "" << "psm = " << static_cast<uint64_t>(GetPsm()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
563
564 protected:
565 explicit GroupFrameView(BasicFrameView parent) : BasicFrameView(std::move(parent)) { was_validated_ = false; }};
566
567
CreateOptional(BasicFrameView parent)568 class StandardFrameView : public BasicFrameView { public:static StandardFrameView Create(BasicFrameView parent){ return StandardFrameView(std::move(parent)); }static std::optional<StandardFrameView> CreateOptional(BasicFrameView parent){ auto to_validate = StandardFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
569 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
570 static StandardFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)));}
571 #endif
572 FrameType GetFrameType() const {ASSERT(was_validated_);auto to_bound = begin();auto frame_type_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;FrameType frame_type_value{};FrameType* frame_type_ptr = &frame_type_value;auto extracted_value = frame_type_it.extract<uint8_t>();extracted_value &= 0x1;*frame_type_ptr = static_cast<FrameType>(extracted_value);return frame_type_value;}
573
574 protected:
575 bool Validate() const override {
576 if (!BasicFrameView::Validate()) {
577 return false;
578 }
579 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 1 /* Total size of the fixed fields */;if (it > end()) return false;
580
581 return true;}
582
583 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardFrame { ";ss << "" << "frame_type = " << FrameTypeText(GetFrameType()) << ", body = " << "BODY REPRESENTATION_UNIMPLEMENTED () ";ss << " }";return ss.str();}
584
585 protected:
586 explicit StandardFrameView(BasicFrameView parent) : BasicFrameView(std::move(parent)) { was_validated_ = false; }};
587
588
CreateOptional(BasicFrameWithFcsView parent)589 class StandardFrameWithFcsView : public BasicFrameWithFcsView { public:static StandardFrameWithFcsView Create(BasicFrameWithFcsView parent){ return StandardFrameWithFcsView(std::move(parent)); }static std::optional<StandardFrameWithFcsView> CreateOptional(BasicFrameWithFcsView parent){ auto to_validate = StandardFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
590 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
591 static StandardFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec)));}
592 #endif
593 FrameType GetFrameType() const {ASSERT(was_validated_);auto to_bound = begin();auto frame_type_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;FrameType frame_type_value{};FrameType* frame_type_ptr = &frame_type_value;auto extracted_value = frame_type_it.extract<uint8_t>();extracted_value &= 0x1;*frame_type_ptr = static_cast<FrameType>(extracted_value);return frame_type_value;}
594
595 protected:
596 bool Validate() const override {
597 if (!BasicFrameWithFcsView::Validate()) {
598 return false;
599 }
600 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 1 /* Total size of the fixed fields */;if (it > end()) return false;
601
602 return true;}
603
604 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardFrameWithFcs { ";ss << "" << "frame_type = " << FrameTypeText(GetFrameType()) << ", body = " << "BODY REPRESENTATION_UNIMPLEMENTED () ";ss << " }";return ss.str();}
605
606 protected:
607 explicit StandardFrameWithFcsView(BasicFrameWithFcsView parent) : BasicFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
608
609
CreateOptional(StandardFrameView parent)610 class StandardSupervisoryFrameView : public StandardFrameView { public:static StandardSupervisoryFrameView Create(StandardFrameView parent){ return StandardSupervisoryFrameView(std::move(parent)); }static std::optional<StandardSupervisoryFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = StandardSupervisoryFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
611 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
612 static StandardSupervisoryFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardSupervisoryFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
613 #endif
614 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
615
616 RetransmissionDisable GetR() const {ASSERT(was_validated_);auto to_bound = begin();auto r_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;RetransmissionDisable r_value{};RetransmissionDisable* r_ptr = &r_value;auto extracted_value = r_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*r_ptr = static_cast<RetransmissionDisable>(extracted_value);return r_value;}
617 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
618
619 protected:
620 bool Validate() const override {
621 if (!StandardFrameView::Validate()) {
622 return false;
623 }
624 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;if (GetFixedScalar0() != 0) return false;
625
626
627
628
629
630 return true;}
631
632 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardSupervisoryFrame { ";ss << "" << "s = " << SupervisoryFunctionText(GetS()) << ", r = " << RetransmissionDisableText(GetR()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq());ss << " }";return ss.str();}
633
634 protected:
635 explicit StandardSupervisoryFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; } private:
636 protected:uint8_t GetFixedScalar0() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_scalar0_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t fixed_scalar0_value{};uint8_t* fixed_scalar0_ptr = &fixed_scalar0_value;auto extracted_value = fixed_scalar0_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*fixed_scalar0_ptr = static_cast<uint8_t>(extracted_value);return fixed_scalar0_value;}public:
637
638 };
639
640
CreateOptional(StandardFrameWithFcsView parent)641 class StandardSupervisoryFrameWithFcsView : public StandardFrameWithFcsView { public:static StandardSupervisoryFrameWithFcsView Create(StandardFrameWithFcsView parent){ return StandardSupervisoryFrameWithFcsView(std::move(parent)); }static std::optional<StandardSupervisoryFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = StandardSupervisoryFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
642 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
643 static StandardSupervisoryFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardSupervisoryFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
644 #endif
645 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
646
647 RetransmissionDisable GetR() const {ASSERT(was_validated_);auto to_bound = begin();auto r_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;RetransmissionDisable r_value{};RetransmissionDisable* r_ptr = &r_value;auto extracted_value = r_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*r_ptr = static_cast<RetransmissionDisable>(extracted_value);return r_value;}
648 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
649
650 protected:
651 bool Validate() const override {
652 if (!StandardFrameWithFcsView::Validate()) {
653 return false;
654 }
655 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;if (GetFixedScalar0() != 0) return false;
656
657
658
659
660
661 return true;}
662
663 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardSupervisoryFrameWithFcs { ";ss << "" << "s = " << SupervisoryFunctionText(GetS()) << ", r = " << RetransmissionDisableText(GetR()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq());ss << " }";return ss.str();}
664
665 protected:
666 explicit StandardSupervisoryFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; } private:
667 protected:uint8_t GetFixedScalar0() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_scalar0_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t fixed_scalar0_value{};uint8_t* fixed_scalar0_ptr = &fixed_scalar0_value;auto extracted_value = fixed_scalar0_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*fixed_scalar0_ptr = static_cast<uint8_t>(extracted_value);return fixed_scalar0_value;}public:
668
669 };
670
671
CreateOptional(StandardFrameView parent)672 class StandardInformationFrameView : public StandardFrameView { public:static StandardInformationFrameView Create(StandardFrameView parent){ return StandardInformationFrameView(std::move(parent)); }static std::optional<StandardInformationFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = StandardInformationFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
673 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
674 static StandardInformationFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
675 #endif
676 uint8_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t tx_seq_value{};uint8_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x3f;*tx_seq_ptr = static_cast<uint8_t>(extracted_value);return tx_seq_value;}
677 RetransmissionDisable GetR() const {ASSERT(was_validated_);auto to_bound = begin();auto r_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;RetransmissionDisable r_value{};RetransmissionDisable* r_ptr = &r_value;auto extracted_value = r_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*r_ptr = static_cast<RetransmissionDisable>(extracted_value);return r_value;}
678 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
679 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 46 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value >>= 6;extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
680 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
681
682
683 protected:
684 bool Validate() const override {
685 if (!StandardFrameView::Validate()) {
686 return false;
687 }
688 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
689
690
691
692
693 return true;}
694
695 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardInformationFrame { ";ss << "" << "tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", r = " << RetransmissionDisableText(GetR()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
696
697 protected:
698 explicit StandardInformationFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; }};
699
700
CreateOptional(StandardFrameWithFcsView parent)701 class StandardInformationFrameWithFcsView : public StandardFrameWithFcsView { public:static StandardInformationFrameWithFcsView Create(StandardFrameWithFcsView parent){ return StandardInformationFrameWithFcsView(std::move(parent)); }static std::optional<StandardInformationFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = StandardInformationFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
702 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
703 static StandardInformationFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
704 #endif
705 uint8_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t tx_seq_value{};uint8_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x3f;*tx_seq_ptr = static_cast<uint8_t>(extracted_value);return tx_seq_value;}
706 RetransmissionDisable GetR() const {ASSERT(was_validated_);auto to_bound = begin();auto r_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;RetransmissionDisable r_value{};RetransmissionDisable* r_ptr = &r_value;auto extracted_value = r_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*r_ptr = static_cast<RetransmissionDisable>(extracted_value);return r_value;}
707 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
708 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 46 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value >>= 6;extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
709 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
710
711
712 protected:
713 bool Validate() const override {
714 if (!StandardFrameWithFcsView::Validate()) {
715 return false;
716 }
717 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
718
719
720
721
722 return true;}
723
724 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardInformationFrameWithFcs { ";ss << "" << "tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", r = " << RetransmissionDisableText(GetR()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
725
726 protected:
727 explicit StandardInformationFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
728
729
CreateOptional(StandardInformationFrameView parent)730 class StandardInformationStartFrameView : public StandardInformationFrameView { public:static StandardInformationStartFrameView Create(StandardInformationFrameView parent){ return StandardInformationStartFrameView(std::move(parent)); }static std::optional<StandardInformationStartFrameView> CreateOptional(StandardInformationFrameView parent){ auto to_validate = StandardInformationStartFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
731 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
732 static StandardInformationStartFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardInformationStartFrameView::Create(StandardInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)))));}
733 #endif
734 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
735 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
736
737
738 protected:
739 bool Validate() const override {
740 if (!StandardInformationFrameView::Validate()) {
741 return false;
742 }
743 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
744
745 return true;}
746
747 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardInformationStartFrame { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
748
749 protected:
750 explicit StandardInformationStartFrameView(StandardInformationFrameView parent) : StandardInformationFrameView(std::move(parent)) { was_validated_ = false; }};
751
752
CreateOptional(StandardInformationFrameWithFcsView parent)753 class StandardInformationStartFrameWithFcsView : public StandardInformationFrameWithFcsView { public:static StandardInformationStartFrameWithFcsView Create(StandardInformationFrameWithFcsView parent){ return StandardInformationStartFrameWithFcsView(std::move(parent)); }static std::optional<StandardInformationStartFrameWithFcsView> CreateOptional(StandardInformationFrameWithFcsView parent){ auto to_validate = StandardInformationStartFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
754 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
755 static StandardInformationStartFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return StandardInformationStartFrameWithFcsView::Create(StandardInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec)))));}
756 #endif
757 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
758 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
759
760
761 protected:
762 bool Validate() const override {
763 if (!StandardInformationFrameWithFcsView::Validate()) {
764 return false;
765 }
766 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
767
768 return true;}
769
770 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "StandardInformationStartFrameWithFcs { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
771
772 protected:
773 explicit StandardInformationStartFrameWithFcsView(StandardInformationFrameWithFcsView parent) : StandardInformationFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
774
775
CreateOptional(StandardFrameView parent)776 class EnhancedSupervisoryFrameView : public StandardFrameView { public:static EnhancedSupervisoryFrameView Create(StandardFrameView parent){ return EnhancedSupervisoryFrameView(std::move(parent)); }static std::optional<EnhancedSupervisoryFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = EnhancedSupervisoryFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
777 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
778 static EnhancedSupervisoryFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedSupervisoryFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
779 #endif
780 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
781 Poll GetP() const {ASSERT(was_validated_);auto to_bound = begin();auto p_it = to_bound + (/* Bits: */ 36 + /* Dynamic: */ 0) / 8;Poll p_value{};Poll* p_ptr = &p_value;auto extracted_value = p_it.extract<uint8_t>();extracted_value >>= 4;extracted_value &= 0x1;*p_ptr = static_cast<Poll>(extracted_value);return p_value;}
782
783 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
784 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
785
786 protected:
787 bool Validate() const override {
788 if (!StandardFrameView::Validate()) {
789 return false;
790 }
791 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;if (GetFixedScalar1() != 0) return false;
792
793
794
795
796
797
798 return true;}
799
800 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedSupervisoryFrame { ";ss << "" << "s = " << SupervisoryFunctionText(GetS()) << ", p = " << PollText(GetP()) << ", f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq());ss << " }";return ss.str();}
801
802 protected:
803 explicit EnhancedSupervisoryFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; } private:
804 protected:uint8_t GetFixedScalar1() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_scalar1_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t fixed_scalar1_value{};uint8_t* fixed_scalar1_ptr = &fixed_scalar1_value;auto extracted_value = fixed_scalar1_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*fixed_scalar1_ptr = static_cast<uint8_t>(extracted_value);return fixed_scalar1_value;}public:
805
806 };
807
808
CreateOptional(StandardFrameWithFcsView parent)809 class EnhancedSupervisoryFrameWithFcsView : public StandardFrameWithFcsView { public:static EnhancedSupervisoryFrameWithFcsView Create(StandardFrameWithFcsView parent){ return EnhancedSupervisoryFrameWithFcsView(std::move(parent)); }static std::optional<EnhancedSupervisoryFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = EnhancedSupervisoryFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
810 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
811 static EnhancedSupervisoryFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedSupervisoryFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
812 #endif
813 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
814 Poll GetP() const {ASSERT(was_validated_);auto to_bound = begin();auto p_it = to_bound + (/* Bits: */ 36 + /* Dynamic: */ 0) / 8;Poll p_value{};Poll* p_ptr = &p_value;auto extracted_value = p_it.extract<uint8_t>();extracted_value >>= 4;extracted_value &= 0x1;*p_ptr = static_cast<Poll>(extracted_value);return p_value;}
815
816 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
817 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
818
819 protected:
820 bool Validate() const override {
821 if (!StandardFrameWithFcsView::Validate()) {
822 return false;
823 }
824 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;if (GetFixedScalar1() != 0) return false;
825
826
827
828
829
830
831 return true;}
832
833 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedSupervisoryFrameWithFcs { ";ss << "" << "s = " << SupervisoryFunctionText(GetS()) << ", p = " << PollText(GetP()) << ", f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq());ss << " }";return ss.str();}
834
835 protected:
836 explicit EnhancedSupervisoryFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; } private:
837 protected:uint8_t GetFixedScalar1() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_scalar1_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t fixed_scalar1_value{};uint8_t* fixed_scalar1_ptr = &fixed_scalar1_value;auto extracted_value = fixed_scalar1_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*fixed_scalar1_ptr = static_cast<uint8_t>(extracted_value);return fixed_scalar1_value;}public:
838
839 };
840
841
CreateOptional(StandardFrameView parent)842 class EnhancedInformationFrameView : public StandardFrameView { public:static EnhancedInformationFrameView Create(StandardFrameView parent){ return EnhancedInformationFrameView(std::move(parent)); }static std::optional<EnhancedInformationFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = EnhancedInformationFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
843 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
844 static EnhancedInformationFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
845 #endif
846 uint8_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t tx_seq_value{};uint8_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x3f;*tx_seq_ptr = static_cast<uint8_t>(extracted_value);return tx_seq_value;}
847 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
848 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
849 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 46 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value >>= 6;extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
850 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
851
852
853 protected:
854 bool Validate() const override {
855 if (!StandardFrameView::Validate()) {
856 return false;
857 }
858 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
859
860
861
862
863 return true;}
864
865 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedInformationFrame { ";ss << "" << "tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
866
867 protected:
868 explicit EnhancedInformationFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; }};
869
870
CreateOptional(StandardFrameWithFcsView parent)871 class EnhancedInformationFrameWithFcsView : public StandardFrameWithFcsView { public:static EnhancedInformationFrameWithFcsView Create(StandardFrameWithFcsView parent){ return EnhancedInformationFrameWithFcsView(std::move(parent)); }static std::optional<EnhancedInformationFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = EnhancedInformationFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
872 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
873 static EnhancedInformationFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
874 #endif
875 uint8_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;uint8_t tx_seq_value{};uint8_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x3f;*tx_seq_ptr = static_cast<uint8_t>(extracted_value);return tx_seq_value;}
876 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 39 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
877 uint8_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 40 + /* Dynamic: */ 0) / 8;uint8_t req_seq_value{};uint8_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint8_t>();extracted_value &= 0x3f;*req_seq_ptr = static_cast<uint8_t>(extracted_value);return req_seq_value;}
878 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 46 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value >>= 6;extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
879 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
880
881
882 protected:
883 bool Validate() const override {
884 if (!StandardFrameWithFcsView::Validate()) {
885 return false;
886 }
887 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
888
889
890
891
892 return true;}
893
894 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedInformationFrameWithFcs { ";ss << "" << "tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
895
896 protected:
897 explicit EnhancedInformationFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
898
899
CreateOptional(EnhancedInformationFrameView parent)900 class EnhancedInformationStartFrameView : public EnhancedInformationFrameView { public:static EnhancedInformationStartFrameView Create(EnhancedInformationFrameView parent){ return EnhancedInformationStartFrameView(std::move(parent)); }static std::optional<EnhancedInformationStartFrameView> CreateOptional(EnhancedInformationFrameView parent){ auto to_validate = EnhancedInformationStartFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
901 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
902 static EnhancedInformationStartFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedInformationStartFrameView::Create(EnhancedInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)))));}
903 #endif
904 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
905 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
906
907
908 protected:
909 bool Validate() const override {
910 if (!EnhancedInformationFrameView::Validate()) {
911 return false;
912 }
913 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
914
915 return true;}
916
917 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedInformationStartFrame { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
918
919 protected:
920 explicit EnhancedInformationStartFrameView(EnhancedInformationFrameView parent) : EnhancedInformationFrameView(std::move(parent)) { was_validated_ = false; }};
921
922
CreateOptional(EnhancedInformationFrameWithFcsView parent)923 class EnhancedInformationStartFrameWithFcsView : public EnhancedInformationFrameWithFcsView { public:static EnhancedInformationStartFrameWithFcsView Create(EnhancedInformationFrameWithFcsView parent){ return EnhancedInformationStartFrameWithFcsView(std::move(parent)); }static std::optional<EnhancedInformationStartFrameWithFcsView> CreateOptional(EnhancedInformationFrameWithFcsView parent){ auto to_validate = EnhancedInformationStartFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
924 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
925 static EnhancedInformationStartFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EnhancedInformationStartFrameWithFcsView::Create(EnhancedInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec)))));}
926 #endif
927 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
928 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
929
930
931 protected:
932 bool Validate() const override {
933 if (!EnhancedInformationFrameWithFcsView::Validate()) {
934 return false;
935 }
936 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
937
938 return true;}
939
940 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EnhancedInformationStartFrameWithFcs { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
941
942 protected:
943 explicit EnhancedInformationStartFrameWithFcsView(EnhancedInformationFrameWithFcsView parent) : EnhancedInformationFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
944
945
CreateOptional(StandardFrameView parent)946 class ExtendedSupervisoryFrameView : public StandardFrameView { public:static ExtendedSupervisoryFrameView Create(StandardFrameView parent){ return ExtendedSupervisoryFrameView(std::move(parent)); }static std::optional<ExtendedSupervisoryFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = ExtendedSupervisoryFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
947 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
948 static ExtendedSupervisoryFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedSupervisoryFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
949 #endif
950 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
951 uint16_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;uint16_t req_seq_value{};uint16_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*req_seq_ptr = static_cast<uint16_t>(extracted_value);return req_seq_value;}
952 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
953 Poll GetP() const {ASSERT(was_validated_);auto to_bound = begin();auto p_it = to_bound + (/* Bits: */ 50 + /* Dynamic: */ 0) / 8;Poll p_value{};Poll* p_ptr = &p_value;auto extracted_value = p_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x1;*p_ptr = static_cast<Poll>(extracted_value);return p_value;}
954
955
956 protected:
957 bool Validate() const override {
958 if (!StandardFrameView::Validate()) {
959 return false;
960 }
961 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;
962
963
964
965
966
967 return true;}
968
969 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedSupervisoryFrame { ";ss << "" << "f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", s = " << SupervisoryFunctionText(GetS()) << ", p = " << PollText(GetP());ss << " }";return ss.str();}
970
971 protected:
972 explicit ExtendedSupervisoryFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; }};
973
974
CreateOptional(StandardFrameWithFcsView parent)975 class ExtendedSupervisoryFrameWithFcsView : public StandardFrameWithFcsView { public:static ExtendedSupervisoryFrameWithFcsView Create(StandardFrameWithFcsView parent){ return ExtendedSupervisoryFrameWithFcsView(std::move(parent)); }static std::optional<ExtendedSupervisoryFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = ExtendedSupervisoryFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
976 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
977 static ExtendedSupervisoryFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedSupervisoryFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
978 #endif
979 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
980 uint16_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;uint16_t req_seq_value{};uint16_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*req_seq_ptr = static_cast<uint16_t>(extracted_value);return req_seq_value;}
981 SupervisoryFunction GetS() const {ASSERT(was_validated_);auto to_bound = begin();auto s_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;SupervisoryFunction s_value{};SupervisoryFunction* s_ptr = &s_value;auto extracted_value = s_it.extract<uint8_t>();extracted_value &= 0x3;*s_ptr = static_cast<SupervisoryFunction>(extracted_value);return s_value;}
982 Poll GetP() const {ASSERT(was_validated_);auto to_bound = begin();auto p_it = to_bound + (/* Bits: */ 50 + /* Dynamic: */ 0) / 8;Poll p_value{};Poll* p_ptr = &p_value;auto extracted_value = p_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x1;*p_ptr = static_cast<Poll>(extracted_value);return p_value;}
983
984
985 protected:
986 bool Validate() const override {
987 if (!StandardFrameWithFcsView::Validate()) {
988 return false;
989 }
990 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::S_FRAME) return false;
991
992
993
994
995
996 return true;}
997
998 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedSupervisoryFrameWithFcs { ";ss << "" << "f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", s = " << SupervisoryFunctionText(GetS()) << ", p = " << PollText(GetP());ss << " }";return ss.str();}
999
1000 protected:
1001 explicit ExtendedSupervisoryFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
1002
1003
CreateOptional(StandardFrameView parent)1004 class ExtendedInformationFrameView : public StandardFrameView { public:static ExtendedInformationFrameView Create(StandardFrameView parent){ return ExtendedInformationFrameView(std::move(parent)); }static std::optional<ExtendedInformationFrameView> CreateOptional(StandardFrameView parent){ auto to_validate = ExtendedInformationFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1005 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1006 static ExtendedInformationFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec))));}
1007 #endif
1008 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
1009 uint16_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;uint16_t req_seq_value{};uint16_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*req_seq_ptr = static_cast<uint16_t>(extracted_value);return req_seq_value;}
1010 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
1011 uint16_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 50 + /* Dynamic: */ 0) / 8;uint16_t tx_seq_value{};uint16_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*tx_seq_ptr = static_cast<uint16_t>(extracted_value);return tx_seq_value;}
1012 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1013
1014
1015 protected:
1016 bool Validate() const override {
1017 if (!StandardFrameView::Validate()) {
1018 return false;
1019 }
1020 auto it = begin() + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
1021
1022
1023
1024
1025 return true;}
1026
1027 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedInformationFrame { ";ss << "" << "f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1028
1029 protected:
1030 explicit ExtendedInformationFrameView(StandardFrameView parent) : StandardFrameView(std::move(parent)) { was_validated_ = false; }};
1031
1032
CreateOptional(StandardFrameWithFcsView parent)1033 class ExtendedInformationFrameWithFcsView : public StandardFrameWithFcsView { public:static ExtendedInformationFrameWithFcsView Create(StandardFrameWithFcsView parent){ return ExtendedInformationFrameWithFcsView(std::move(parent)); }static std::optional<ExtendedInformationFrameWithFcsView> CreateOptional(StandardFrameWithFcsView parent){ auto to_validate = ExtendedInformationFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1034 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1035 static ExtendedInformationFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec))));}
1036 #endif
1037 Final GetF() const {ASSERT(was_validated_);auto to_bound = begin();auto f_it = to_bound + (/* Bits: */ 33 + /* Dynamic: */ 0) / 8;Final f_value{};Final* f_ptr = &f_value;auto extracted_value = f_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*f_ptr = static_cast<Final>(extracted_value);return f_value;}
1038 uint16_t GetReqSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto req_seq_it = to_bound + (/* Bits: */ 34 + /* Dynamic: */ 0) / 8;uint16_t req_seq_value{};uint16_t* req_seq_ptr = &req_seq_value;auto extracted_value = req_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*req_seq_ptr = static_cast<uint16_t>(extracted_value);return req_seq_value;}
1039 SegmentationAndReassembly GetSar() const {ASSERT(was_validated_);auto to_bound = begin();auto sar_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;SegmentationAndReassembly sar_value{};SegmentationAndReassembly* sar_ptr = &sar_value;auto extracted_value = sar_it.extract<uint8_t>();extracted_value &= 0x3;*sar_ptr = static_cast<SegmentationAndReassembly>(extracted_value);return sar_value;}
1040 uint16_t GetTxSeq() const {ASSERT(was_validated_);auto to_bound = begin();auto tx_seq_it = to_bound + (/* Bits: */ 50 + /* Dynamic: */ 0) / 8;uint16_t tx_seq_value{};uint16_t* tx_seq_ptr = &tx_seq_value;auto extracted_value = tx_seq_it.extract<uint16_t>();extracted_value >>= 2;extracted_value &= 0x3fff;*tx_seq_ptr = static_cast<uint16_t>(extracted_value);return tx_seq_value;}
1041 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1042
1043
1044 protected:
1045 bool Validate() const override {
1046 if (!StandardFrameWithFcsView::Validate()) {
1047 return false;
1048 }
1049 auto it = begin() + (/* Bits: */ 49 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetFrameType() != FrameType::I_FRAME) return false;
1050
1051
1052
1053
1054 return true;}
1055
1056 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedInformationFrameWithFcs { ";ss << "" << "f = " << FinalText(GetF()) << ", req_seq = " << static_cast<uint64_t>(GetReqSeq()) << ", sar = " << SegmentationAndReassemblyText(GetSar()) << ", tx_seq = " << static_cast<uint64_t>(GetTxSeq()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1057
1058 protected:
1059 explicit ExtendedInformationFrameWithFcsView(StandardFrameWithFcsView parent) : StandardFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
1060
1061
CreateOptional(ExtendedInformationFrameView parent)1062 class ExtendedInformationStartFrameView : public ExtendedInformationFrameView { public:static ExtendedInformationStartFrameView Create(ExtendedInformationFrameView parent){ return ExtendedInformationStartFrameView(std::move(parent)); }static std::optional<ExtendedInformationStartFrameView> CreateOptional(ExtendedInformationFrameView parent){ auto to_validate = ExtendedInformationStartFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1063 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1064 static ExtendedInformationStartFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedInformationStartFrameView::Create(ExtendedInformationFrameView::Create(StandardFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)))));}
1065 #endif
1066 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
1067 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1068
1069
1070 protected:
1071 bool Validate() const override {
1072 if (!ExtendedInformationFrameView::Validate()) {
1073 return false;
1074 }
1075 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
1076
1077 return true;}
1078
1079 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedInformationStartFrame { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1080
1081 protected:
1082 explicit ExtendedInformationStartFrameView(ExtendedInformationFrameView parent) : ExtendedInformationFrameView(std::move(parent)) { was_validated_ = false; }};
1083
1084
CreateOptional(ExtendedInformationFrameWithFcsView parent)1085 class ExtendedInformationStartFrameWithFcsView : public ExtendedInformationFrameWithFcsView { public:static ExtendedInformationStartFrameWithFcsView Create(ExtendedInformationFrameWithFcsView parent){ return ExtendedInformationStartFrameWithFcsView(std::move(parent)); }static std::optional<ExtendedInformationStartFrameWithFcsView> CreateOptional(ExtendedInformationFrameWithFcsView parent){ auto to_validate = ExtendedInformationStartFrameWithFcsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1086 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1087 static ExtendedInformationStartFrameWithFcsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ExtendedInformationStartFrameWithFcsView::Create(ExtendedInformationFrameWithFcsView::Create(StandardFrameWithFcsView::Create(BasicFrameWithFcsView::Create(PacketView<kLittleEndian>(vec)))));}
1088 #endif
1089 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
1090 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1091
1092
1093 protected:
1094 bool Validate() const override {
1095 if (!ExtendedInformationFrameWithFcsView::Validate()) {
1096 return false;
1097 }
1098 auto it = begin() + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetSar() != SegmentationAndReassembly::START) return false;
1099
1100 return true;}
1101
1102 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ExtendedInformationStartFrameWithFcs { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1103
1104 protected:
1105 explicit ExtendedInformationStartFrameWithFcsView(ExtendedInformationFrameWithFcsView parent) : ExtendedInformationFrameWithFcsView(std::move(parent)) { was_validated_ = false; }};
1106
1107
CreateOptional(BasicFrameView parent)1108 class FirstLeInformationFrameView : public BasicFrameView { public:static FirstLeInformationFrameView Create(BasicFrameView parent){ return FirstLeInformationFrameView(std::move(parent)); }static std::optional<FirstLeInformationFrameView> CreateOptional(BasicFrameView parent){ auto to_validate = FirstLeInformationFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1109 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1110 static FirstLeInformationFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return FirstLeInformationFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)));}
1111 #endif
1112 uint16_t GetL2capSduLength() const {ASSERT(was_validated_);auto to_bound = begin();auto l2cap_sdu_length_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t l2cap_sdu_length_value{};uint16_t* l2cap_sdu_length_ptr = &l2cap_sdu_length_value;auto extracted_value = l2cap_sdu_length_it.extract<uint16_t>();*l2cap_sdu_length_ptr = static_cast<uint16_t>(extracted_value);return l2cap_sdu_length_value;}
1113 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1114
1115
1116 protected:
1117 bool Validate() const override {
1118 if (!BasicFrameView::Validate()) {
1119 return false;
1120 }
1121 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;
1122
1123 return true;}
1124
1125 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "FirstLeInformationFrame { ";ss << "" << "l2cap_sdu_length = " << static_cast<uint64_t>(GetL2capSduLength()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1126
1127 protected:
1128 explicit FirstLeInformationFrameView(BasicFrameView parent) : BasicFrameView(std::move(parent)) { was_validated_ = false; }};
1129
1130
CreateOptional(BasicFrameView parent)1131 class ControlFrameView : public BasicFrameView { public:static ControlFrameView Create(BasicFrameView parent){ return ControlFrameView(std::move(parent)); }static std::optional<ControlFrameView> CreateOptional(BasicFrameView parent){ auto to_validate = ControlFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1132 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1133 static ControlFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ControlFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)));}
1134 #endif
1135 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1136
1137
1138 protected:
1139 bool Validate() const override {
1140 if (!BasicFrameView::Validate()) {
1141 return false;
1142 }
1143 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetChannelId() != 1) return false;
1144 return true;}
1145
1146 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ControlFrame { ";ss << "" << "payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1147
1148 protected:
1149 explicit ControlFrameView(BasicFrameView parent) : BasicFrameView(std::move(parent)) { was_validated_ = false; }};
1150
1151
CreateOptional(PacketView<kLittleEndian> packet)1152 class ControlView : public PacketView<kLittleEndian> { public:static ControlView Create(PacketView<kLittleEndian> packet){ return ControlView(std::move(packet)); }static std::optional<ControlView> CreateOptional(PacketView<kLittleEndian> packet){ auto to_validate = ControlView::Create(std::move(packet));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1153 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1154 static ControlView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ControlView::Create(PacketView<kLittleEndian>(vec));}
1155 #endif
1156 CommandCode GetCode() const {ASSERT(was_validated_);auto to_bound = begin();auto code_it = to_bound + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;CommandCode code_value{};CommandCode* code_ptr = &code_value;auto extracted_value = code_it.extract<uint8_t>();*code_ptr = static_cast<CommandCode>(extracted_value);return code_value;}
1157 uint8_t GetIdentifier() const {ASSERT(was_validated_);auto to_bound = begin();auto identifier_it = to_bound + (/* Bits: */ 8 + /* Dynamic: */ 0) / 8;uint8_t identifier_value{};uint8_t* identifier_ptr = &identifier_value;auto extracted_value = identifier_it.extract<uint8_t>();*identifier_ptr = static_cast<uint8_t>(extracted_value);return identifier_value;}
1158 protected:uint16_t GetPayloadSize() const {ASSERT(was_validated_);auto to_bound = begin();auto payload_size_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;uint16_t payload_size_value{};uint16_t* payload_size_ptr = &payload_size_value;auto extracted_value = payload_size_it.extract<uint16_t>();*payload_size_ptr = static_cast<uint16_t>(extracted_value);return payload_size_value;}public:
1159
1160 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;size_t field_sized_end = field_begin + (/* Bits: */ 0 + /* Dynamic: */ (GetPayloadSize() * 8)) / 8;if (field_sized_end < field_end) { field_end = field_sized_end; }auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1161
1162
1163 bool IsValid() {
1164 if (was_validated_) {
1165 return true;
1166 } else {
1167 was_validated_ = true;
1168 return (was_validated_ = Validate());
1169 }
1170 }
1171 protected:
1172 virtual bool Validate() const {
1173 auto it = begin() + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;it += ((GetPayloadSize() * 8)) / 8;if (it > end()) return false;
1174
1175
1176
1177 return true;}
1178 bool was_validated_{false};
1179
1180 public:virtual std::string ToString() const {std::stringstream ss;ss << std::showbase << std::hex << "Control { ";ss << "" << "code = " << CommandCodeText(GetCode()) << ", identifier = " << static_cast<uint64_t>(GetIdentifier()) << ", payload_size = " << GetPayloadSize() << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1181
1182 protected:
1183 explicit ControlView(PacketView<kLittleEndian> packet) : PacketView<kLittleEndian>(packet) { was_validated_ = false;}};
1184
1185
CreateOptional(ControlView parent)1186 class CommandRejectView : public ControlView { public:static CommandRejectView Create(ControlView parent){ return CommandRejectView(std::move(parent)); }static std::optional<CommandRejectView> CreateOptional(ControlView parent){ auto to_validate = CommandRejectView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1187 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1188 static CommandRejectView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CommandRejectView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1189 #endif
1190 CommandRejectReason GetReason() const {ASSERT(was_validated_);auto to_bound = begin();auto reason_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;CommandRejectReason reason_value{};CommandRejectReason* reason_ptr = &reason_value;auto extracted_value = reason_it.extract<uint16_t>();*reason_ptr = static_cast<CommandRejectReason>(extracted_value);return reason_value;}
1191
1192 protected:
1193 bool Validate() const override {
1194 if (!ControlView::Validate()) {
1195 return false;
1196 }
1197 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::COMMAND_REJECT) return false;
1198
1199 return true;}
1200
1201 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CommandReject { ";ss << "" << "reason = " << CommandRejectReasonText(GetReason()) << ", body = " << "BODY REPRESENTATION_UNIMPLEMENTED () ";ss << " }";return ss.str();}
1202
1203 protected:
1204 explicit CommandRejectView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1205
1206
CreateOptional(CommandRejectView parent)1207 class CommandRejectNotUnderstoodView : public CommandRejectView { public:static CommandRejectNotUnderstoodView Create(CommandRejectView parent){ return CommandRejectNotUnderstoodView(std::move(parent)); }static std::optional<CommandRejectNotUnderstoodView> CreateOptional(CommandRejectView parent){ auto to_validate = CommandRejectNotUnderstoodView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1208 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1209 static CommandRejectNotUnderstoodView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CommandRejectNotUnderstoodView::Create(CommandRejectView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1210 #endif
1211 protected:
1212 bool Validate() const override {
1213 if (!CommandRejectView::Validate()) {
1214 return false;
1215 }
1216 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::COMMAND_NOT_UNDERSTOOD) return false;return true;}
1217
1218 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CommandRejectNotUnderstood { ";ss << " }";return ss.str();}
1219
1220 protected:
1221 explicit CommandRejectNotUnderstoodView(CommandRejectView parent) : CommandRejectView(std::move(parent)) { was_validated_ = false; }};
1222
1223
CreateOptional(CommandRejectView parent)1224 class CommandRejectMtuExceededView : public CommandRejectView { public:static CommandRejectMtuExceededView Create(CommandRejectView parent){ return CommandRejectMtuExceededView(std::move(parent)); }static std::optional<CommandRejectMtuExceededView> CreateOptional(CommandRejectView parent){ auto to_validate = CommandRejectMtuExceededView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1225 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1226 static CommandRejectMtuExceededView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CommandRejectMtuExceededView::Create(CommandRejectView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1227 #endif
1228 uint16_t GetActualMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto actual_mtu_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t actual_mtu_value{};uint16_t* actual_mtu_ptr = &actual_mtu_value;auto extracted_value = actual_mtu_it.extract<uint16_t>();*actual_mtu_ptr = static_cast<uint16_t>(extracted_value);return actual_mtu_value;}
1229 protected:
1230 bool Validate() const override {
1231 if (!CommandRejectView::Validate()) {
1232 return false;
1233 }
1234 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::SIGNALING_MTU_EXCEEDED) return false;
1235 return true;}
1236
1237 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CommandRejectMtuExceeded { ";ss << "" << "actual_mtu = " << static_cast<uint64_t>(GetActualMtu());ss << " }";return ss.str();}
1238
1239 protected:
1240 explicit CommandRejectMtuExceededView(CommandRejectView parent) : CommandRejectView(std::move(parent)) { was_validated_ = false; }};
1241
1242
CreateOptional(CommandRejectView parent)1243 class CommandRejectInvalidCidView : public CommandRejectView { public:static CommandRejectInvalidCidView Create(CommandRejectView parent){ return CommandRejectInvalidCidView(std::move(parent)); }static std::optional<CommandRejectInvalidCidView> CreateOptional(CommandRejectView parent){ auto to_validate = CommandRejectInvalidCidView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1244 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1245 static CommandRejectInvalidCidView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CommandRejectInvalidCidView::Create(CommandRejectView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1246 #endif
1247 uint16_t GetLocalChannel() const {ASSERT(was_validated_);auto to_bound = begin();auto local_channel_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t local_channel_value{};uint16_t* local_channel_ptr = &local_channel_value;auto extracted_value = local_channel_it.extract<uint16_t>();*local_channel_ptr = static_cast<uint16_t>(extracted_value);return local_channel_value;}
1248 uint16_t GetRemoteChannel() const {ASSERT(was_validated_);auto to_bound = begin();auto remote_channel_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t remote_channel_value{};uint16_t* remote_channel_ptr = &remote_channel_value;auto extracted_value = remote_channel_it.extract<uint16_t>();*remote_channel_ptr = static_cast<uint16_t>(extracted_value);return remote_channel_value;}
1249 protected:
1250 bool Validate() const override {
1251 if (!CommandRejectView::Validate()) {
1252 return false;
1253 }
1254 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::INVALID_CID_IN_REQUEST) return false;
1255
1256 return true;}
1257
1258 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CommandRejectInvalidCid { ";ss << "" << "local_channel = " << static_cast<uint64_t>(GetLocalChannel()) << ", remote_channel = " << static_cast<uint64_t>(GetRemoteChannel());ss << " }";return ss.str();}
1259
1260 protected:
1261 explicit CommandRejectInvalidCidView(CommandRejectView parent) : CommandRejectView(std::move(parent)) { was_validated_ = false; }};
1262
1263
CreateOptional(ControlView parent)1264 class ConnectionRequestView : public ControlView { public:static ConnectionRequestView Create(ControlView parent){ return ConnectionRequestView(std::move(parent)); }static std::optional<ConnectionRequestView> CreateOptional(ControlView parent){ auto to_validate = ConnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1265 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1266 static ConnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConnectionRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1267 #endif
1268 uint16_t GetPsm() const {ASSERT(was_validated_);auto to_bound = begin();auto psm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t psm_value{};uint16_t* psm_ptr = &psm_value;auto extracted_value = psm_it.extract<uint16_t>();*psm_ptr = static_cast<uint16_t>(extracted_value);return psm_value;}
1269 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1270 protected:
1271 bool Validate() const override {
1272 if (!ControlView::Validate()) {
1273 return false;
1274 }
1275 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CONNECTION_REQUEST) return false;
1276
1277 return true;}
1278
1279 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConnectionRequest { ";ss << "" << "psm = " << static_cast<uint64_t>(GetPsm()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid());ss << " }";return ss.str();}
1280
1281 protected:
1282 explicit ConnectionRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1283
1284
CreateOptional(ControlView parent)1285 class ConnectionResponseView : public ControlView { public:static ConnectionResponseView Create(ControlView parent){ return ConnectionResponseView(std::move(parent)); }static std::optional<ConnectionResponseView> CreateOptional(ControlView parent){ auto to_validate = ConnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1286 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1287 static ConnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConnectionResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1288 #endif
1289 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1290 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1291 ConnectionResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;ConnectionResponseResult result_value{};ConnectionResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<ConnectionResponseResult>(extracted_value);return result_value;}
1292 ConnectionResponseStatus GetStatus() const {ASSERT(was_validated_);auto to_bound = begin();auto status_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;ConnectionResponseStatus status_value{};ConnectionResponseStatus* status_ptr = &status_value;auto extracted_value = status_it.extract<uint16_t>();*status_ptr = static_cast<ConnectionResponseStatus>(extracted_value);return status_value;}
1293 protected:
1294 bool Validate() const override {
1295 if (!ControlView::Validate()) {
1296 return false;
1297 }
1298 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CONNECTION_RESPONSE) return false;
1299
1300
1301
1302 return true;}
1303
1304 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConnectionResponse { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid()) << ", result = " << ConnectionResponseResultText(GetResult()) << ", status = " << ConnectionResponseStatusText(GetStatus());ss << " }";return ss.str();}
1305
1306 protected:
1307 explicit ConnectionResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1308
1309
CreateOptional(ControlView parent)1310 class ConfigurationRequestView : public ControlView { public:static ConfigurationRequestView Create(ControlView parent){ return ConfigurationRequestView(std::move(parent)); }static std::optional<ConfigurationRequestView> CreateOptional(ControlView parent){ auto to_validate = ConfigurationRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1311 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1312 static ConfigurationRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConfigurationRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1313 #endif
1314 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1315 Continuation GetContinuation() const {ASSERT(was_validated_);auto to_bound = begin();auto continuation_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;Continuation continuation_value{};Continuation* continuation_ptr = &continuation_value;auto extracted_value = continuation_it.extract<uint8_t>();extracted_value &= 0x1;*continuation_ptr = static_cast<Continuation>(extracted_value);return continuation_value;}
1316
1317 std::vector<std::unique_ptr<ConfigurationOption>> GetConfig() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto config_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<std::unique_ptr<ConfigurationOption>> config_value{};std::vector<std::unique_ptr<ConfigurationOption>>* config_ptr = &config_value;auto val_it = config_it;while (val_it.NumBytesRemaining() > 0) {std::unique_ptr<ConfigurationOption> val_ptr;val_ptr = ParseConfigurationOption(val_it);if (val_ptr != nullptr) {val_it = val_it + val_ptr->size();} else {val_it = val_it + val_it.NumBytesRemaining();}if (val_ptr != nullptr) { config_ptr->push_back(std::move(val_ptr));}}return config_value;}
1318
1319 protected:
1320 bool Validate() const override {
1321 if (!ControlView::Validate()) {
1322 return false;
1323 }
1324 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CONFIGURATION_REQUEST) return false;
1325
1326
1327
1328 return true;}
1329
1330 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConfigurationRequest { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", continuation = " << ContinuationText(GetContinuation()) << ", config = " << "VECTOR[";for (size_t index = 0; index < GetConfig().size(); index++) {ss << ((index == 0) ? "" : ", ") << "REPRESENTATION_UNIMPLEMENTED VariableLengthStructField (GetConfig()[index])";}ss << "]";ss << " }";return ss.str();}
1331
1332 protected:
1333 explicit ConfigurationRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1334
1335
CreateOptional(ControlView parent)1336 class ConfigurationResponseView : public ControlView { public:static ConfigurationResponseView Create(ControlView parent){ return ConfigurationResponseView(std::move(parent)); }static std::optional<ConfigurationResponseView> CreateOptional(ControlView parent){ auto to_validate = ConfigurationResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1337 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1338 static ConfigurationResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConfigurationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1339 #endif
1340 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1341 Continuation GetContinuation() const {ASSERT(was_validated_);auto to_bound = begin();auto continuation_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;Continuation continuation_value{};Continuation* continuation_ptr = &continuation_value;auto extracted_value = continuation_it.extract<uint8_t>();extracted_value &= 0x1;*continuation_ptr = static_cast<Continuation>(extracted_value);return continuation_value;}
1342
1343 ConfigurationResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;ConfigurationResponseResult result_value{};ConfigurationResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<ConfigurationResponseResult>(extracted_value);return result_value;}
1344 std::vector<std::unique_ptr<ConfigurationOption>> GetConfig() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto config_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<std::unique_ptr<ConfigurationOption>> config_value{};std::vector<std::unique_ptr<ConfigurationOption>>* config_ptr = &config_value;auto val_it = config_it;while (val_it.NumBytesRemaining() > 0) {std::unique_ptr<ConfigurationOption> val_ptr;val_ptr = ParseConfigurationOption(val_it);if (val_ptr != nullptr) {val_it = val_it + val_ptr->size();} else {val_it = val_it + val_it.NumBytesRemaining();}if (val_ptr != nullptr) { config_ptr->push_back(std::move(val_ptr));}}return config_value;}
1345
1346 protected:
1347 bool Validate() const override {
1348 if (!ControlView::Validate()) {
1349 return false;
1350 }
1351 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 6 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CONFIGURATION_RESPONSE) return false;
1352
1353
1354
1355
1356 return true;}
1357
1358 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConfigurationResponse { ";ss << "" << "source_cid = " << static_cast<uint64_t>(GetSourceCid()) << ", continuation = " << ContinuationText(GetContinuation()) << ", result = " << ConfigurationResponseResultText(GetResult()) << ", config = " << "VECTOR[";for (size_t index = 0; index < GetConfig().size(); index++) {ss << ((index == 0) ? "" : ", ") << "REPRESENTATION_UNIMPLEMENTED VariableLengthStructField (GetConfig()[index])";}ss << "]";ss << " }";return ss.str();}
1359
1360 protected:
1361 explicit ConfigurationResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1362
1363
CreateOptional(ControlView parent)1364 class DisconnectionRequestView : public ControlView { public:static DisconnectionRequestView Create(ControlView parent){ return DisconnectionRequestView(std::move(parent)); }static std::optional<DisconnectionRequestView> CreateOptional(ControlView parent){ auto to_validate = DisconnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1365 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1366 static DisconnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return DisconnectionRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1367 #endif
1368 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1369 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1370 protected:
1371 bool Validate() const override {
1372 if (!ControlView::Validate()) {
1373 return false;
1374 }
1375 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::DISCONNECTION_REQUEST) return false;
1376
1377 return true;}
1378
1379 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "DisconnectionRequest { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid());ss << " }";return ss.str();}
1380
1381 protected:
1382 explicit DisconnectionRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1383
1384
CreateOptional(ControlView parent)1385 class DisconnectionResponseView : public ControlView { public:static DisconnectionResponseView Create(ControlView parent){ return DisconnectionResponseView(std::move(parent)); }static std::optional<DisconnectionResponseView> CreateOptional(ControlView parent){ auto to_validate = DisconnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1386 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1387 static DisconnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return DisconnectionResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1388 #endif
1389 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1390 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1391 protected:
1392 bool Validate() const override {
1393 if (!ControlView::Validate()) {
1394 return false;
1395 }
1396 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::DISCONNECTION_RESPONSE) return false;
1397
1398 return true;}
1399
1400 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "DisconnectionResponse { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid());ss << " }";return ss.str();}
1401
1402 protected:
1403 explicit DisconnectionResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1404
1405
CreateOptional(ControlView parent)1406 class EchoRequestView : public ControlView { public:static EchoRequestView Create(ControlView parent){ return EchoRequestView(std::move(parent)); }static std::optional<EchoRequestView> CreateOptional(ControlView parent){ auto to_validate = EchoRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1407 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1408 static EchoRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EchoRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1409 #endif
1410 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1411
1412
1413 protected:
1414 bool Validate() const override {
1415 if (!ControlView::Validate()) {
1416 return false;
1417 }
1418 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::ECHO_REQUEST) return false;
1419 return true;}
1420
1421 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EchoRequest { ";ss << "" << "payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1422
1423 protected:
1424 explicit EchoRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1425
1426
CreateOptional(ControlView parent)1427 class EchoResponseView : public ControlView { public:static EchoResponseView Create(ControlView parent){ return EchoResponseView(std::move(parent)); }static std::optional<EchoResponseView> CreateOptional(ControlView parent){ auto to_validate = EchoResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1428 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1429 static EchoResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return EchoResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1430 #endif
1431 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1432
1433
1434 protected:
1435 bool Validate() const override {
1436 if (!ControlView::Validate()) {
1437 return false;
1438 }
1439 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::ECHO_RESPONSE) return false;
1440 return true;}
1441
1442 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "EchoResponse { ";ss << "" << "payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1443
1444 protected:
1445 explicit EchoResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1446
1447
CreateOptional(ControlView parent)1448 class InformationRequestView : public ControlView { public:static InformationRequestView Create(ControlView parent){ return InformationRequestView(std::move(parent)); }static std::optional<InformationRequestView> CreateOptional(ControlView parent){ auto to_validate = InformationRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1449 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1450 static InformationRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return InformationRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1451 #endif
1452 InformationRequestInfoType GetInfoType() const {ASSERT(was_validated_);auto to_bound = begin();auto info_type_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;InformationRequestInfoType info_type_value{};InformationRequestInfoType* info_type_ptr = &info_type_value;auto extracted_value = info_type_it.extract<uint16_t>();*info_type_ptr = static_cast<InformationRequestInfoType>(extracted_value);return info_type_value;}
1453 protected:
1454 bool Validate() const override {
1455 if (!ControlView::Validate()) {
1456 return false;
1457 }
1458 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::INFORMATION_REQUEST) return false;
1459 return true;}
1460
1461 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "InformationRequest { ";ss << "" << "info_type = " << InformationRequestInfoTypeText(GetInfoType());ss << " }";return ss.str();}
1462
1463 protected:
1464 explicit InformationRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1465
1466
CreateOptional(ControlView parent)1467 class InformationResponseView : public ControlView { public:static InformationResponseView Create(ControlView parent){ return InformationResponseView(std::move(parent)); }static std::optional<InformationResponseView> CreateOptional(ControlView parent){ auto to_validate = InformationResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1468 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1469 static InformationResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return InformationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1470 #endif
1471 InformationRequestInfoType GetInfoType() const {ASSERT(was_validated_);auto to_bound = begin();auto info_type_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;InformationRequestInfoType info_type_value{};InformationRequestInfoType* info_type_ptr = &info_type_value;auto extracted_value = info_type_it.extract<uint16_t>();*info_type_ptr = static_cast<InformationRequestInfoType>(extracted_value);return info_type_value;}
1472 InformationRequestResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;InformationRequestResult result_value{};InformationRequestResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<InformationRequestResult>(extracted_value);return result_value;}
1473
1474 protected:
1475 bool Validate() const override {
1476 if (!ControlView::Validate()) {
1477 return false;
1478 }
1479 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::INFORMATION_RESPONSE) return false;
1480
1481
1482 return true;}
1483
1484 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "InformationResponse { ";ss << "" << "info_type = " << InformationRequestInfoTypeText(GetInfoType()) << ", result = " << InformationRequestResultText(GetResult()) << ", body = " << "BODY REPRESENTATION_UNIMPLEMENTED () ";ss << " }";return ss.str();}
1485
1486 protected:
1487 explicit InformationResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1488
1489
CreateOptional(InformationResponseView parent)1490 class InformationResponseConnectionlessMtuView : public InformationResponseView { public:static InformationResponseConnectionlessMtuView Create(InformationResponseView parent){ return InformationResponseConnectionlessMtuView(std::move(parent)); }static std::optional<InformationResponseConnectionlessMtuView> CreateOptional(InformationResponseView parent){ auto to_validate = InformationResponseConnectionlessMtuView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1491 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1492 static InformationResponseConnectionlessMtuView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return InformationResponseConnectionlessMtuView::Create(InformationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1493 #endif
1494 uint16_t GetConnectionlessMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto connectionless_mtu_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t connectionless_mtu_value{};uint16_t* connectionless_mtu_ptr = &connectionless_mtu_value;auto extracted_value = connectionless_mtu_it.extract<uint16_t>();*connectionless_mtu_ptr = static_cast<uint16_t>(extracted_value);return connectionless_mtu_value;}
1495 protected:
1496 bool Validate() const override {
1497 if (!InformationResponseView::Validate()) {
1498 return false;
1499 }
1500 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetInfoType() != InformationRequestInfoType::CONNECTIONLESS_MTU) return false;
1501 return true;}
1502
1503 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "InformationResponseConnectionlessMtu { ";ss << "" << "connectionless_mtu = " << static_cast<uint64_t>(GetConnectionlessMtu());ss << " }";return ss.str();}
1504
1505 protected:
1506 explicit InformationResponseConnectionlessMtuView(InformationResponseView parent) : InformationResponseView(std::move(parent)) { was_validated_ = false; }};
1507
1508
CreateOptional(InformationResponseView parent)1509 class InformationResponseExtendedFeaturesView : public InformationResponseView { public:static InformationResponseExtendedFeaturesView Create(InformationResponseView parent){ return InformationResponseExtendedFeaturesView(std::move(parent)); }static std::optional<InformationResponseExtendedFeaturesView> CreateOptional(InformationResponseView parent){ auto to_validate = InformationResponseExtendedFeaturesView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1510 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1511 static InformationResponseExtendedFeaturesView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return InformationResponseExtendedFeaturesView::Create(InformationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1512 #endif
1513 uint8_t GetFlowControlMode() const {ASSERT(was_validated_);auto to_bound = begin();auto flow_control_mode_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint8_t flow_control_mode_value{};uint8_t* flow_control_mode_ptr = &flow_control_mode_value;auto extracted_value = flow_control_mode_it.extract<uint8_t>();extracted_value &= 0x1;*flow_control_mode_ptr = static_cast<uint8_t>(extracted_value);return flow_control_mode_value;}
1514 uint8_t GetRetransmissionMode() const {ASSERT(was_validated_);auto to_bound = begin();auto retransmission_mode_it = to_bound + (/* Bits: */ 65 + /* Dynamic: */ 0) / 8;uint8_t retransmission_mode_value{};uint8_t* retransmission_mode_ptr = &retransmission_mode_value;auto extracted_value = retransmission_mode_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*retransmission_mode_ptr = static_cast<uint8_t>(extracted_value);return retransmission_mode_value;}
1515 uint8_t GetBiDirectionalQoS() const {ASSERT(was_validated_);auto to_bound = begin();auto bi_directional_qoS_it = to_bound + (/* Bits: */ 66 + /* Dynamic: */ 0) / 8;uint8_t bi_directional_qoS_value{};uint8_t* bi_directional_qoS_ptr = &bi_directional_qoS_value;auto extracted_value = bi_directional_qoS_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x1;*bi_directional_qoS_ptr = static_cast<uint8_t>(extracted_value);return bi_directional_qoS_value;}
1516 uint8_t GetEnhancedRetransmissionMode() const {ASSERT(was_validated_);auto to_bound = begin();auto enhanced_retransmission_mode_it = to_bound + (/* Bits: */ 67 + /* Dynamic: */ 0) / 8;uint8_t enhanced_retransmission_mode_value{};uint8_t* enhanced_retransmission_mode_ptr = &enhanced_retransmission_mode_value;auto extracted_value = enhanced_retransmission_mode_it.extract<uint8_t>();extracted_value >>= 3;extracted_value &= 0x1;*enhanced_retransmission_mode_ptr = static_cast<uint8_t>(extracted_value);return enhanced_retransmission_mode_value;}
1517 uint8_t GetStreamingMode() const {ASSERT(was_validated_);auto to_bound = begin();auto streaming_mode_it = to_bound + (/* Bits: */ 68 + /* Dynamic: */ 0) / 8;uint8_t streaming_mode_value{};uint8_t* streaming_mode_ptr = &streaming_mode_value;auto extracted_value = streaming_mode_it.extract<uint8_t>();extracted_value >>= 4;extracted_value &= 0x1;*streaming_mode_ptr = static_cast<uint8_t>(extracted_value);return streaming_mode_value;}
1518 uint8_t GetFcsOption() const {ASSERT(was_validated_);auto to_bound = begin();auto fcs_option_it = to_bound + (/* Bits: */ 69 + /* Dynamic: */ 0) / 8;uint8_t fcs_option_value{};uint8_t* fcs_option_ptr = &fcs_option_value;auto extracted_value = fcs_option_it.extract<uint8_t>();extracted_value >>= 5;extracted_value &= 0x1;*fcs_option_ptr = static_cast<uint8_t>(extracted_value);return fcs_option_value;}
1519 uint8_t GetExtendedFlowSpecificationForBrEdr() const {ASSERT(was_validated_);auto to_bound = begin();auto extended_flow_specification_for_br_edr_it = to_bound + (/* Bits: */ 70 + /* Dynamic: */ 0) / 8;uint8_t extended_flow_specification_for_br_edr_value{};uint8_t* extended_flow_specification_for_br_edr_ptr = &extended_flow_specification_for_br_edr_value;auto extracted_value = extended_flow_specification_for_br_edr_it.extract<uint8_t>();extracted_value >>= 6;extracted_value &= 0x1;*extended_flow_specification_for_br_edr_ptr = static_cast<uint8_t>(extracted_value);return extended_flow_specification_for_br_edr_value;}
1520 uint8_t GetFixedChannels() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_channels_it = to_bound + (/* Bits: */ 71 + /* Dynamic: */ 0) / 8;uint8_t fixed_channels_value{};uint8_t* fixed_channels_ptr = &fixed_channels_value;auto extracted_value = fixed_channels_it.extract<uint8_t>();extracted_value >>= 7;extracted_value &= 0x1;*fixed_channels_ptr = static_cast<uint8_t>(extracted_value);return fixed_channels_value;}
1521 uint8_t GetExtendedWindowSize() const {ASSERT(was_validated_);auto to_bound = begin();auto extended_window_size_it = to_bound + (/* Bits: */ 72 + /* Dynamic: */ 0) / 8;uint8_t extended_window_size_value{};uint8_t* extended_window_size_ptr = &extended_window_size_value;auto extracted_value = extended_window_size_it.extract<uint8_t>();extracted_value &= 0x1;*extended_window_size_ptr = static_cast<uint8_t>(extracted_value);return extended_window_size_value;}
1522 uint8_t GetUnicastConnectionlessDataReception() const {ASSERT(was_validated_);auto to_bound = begin();auto unicast_connectionless_data_reception_it = to_bound + (/* Bits: */ 73 + /* Dynamic: */ 0) / 8;uint8_t unicast_connectionless_data_reception_value{};uint8_t* unicast_connectionless_data_reception_ptr = &unicast_connectionless_data_reception_value;auto extracted_value = unicast_connectionless_data_reception_it.extract<uint8_t>();extracted_value >>= 1;extracted_value &= 0x1;*unicast_connectionless_data_reception_ptr = static_cast<uint8_t>(extracted_value);return unicast_connectionless_data_reception_value;}
1523 uint8_t GetEnhancedCreditBasedFlowControlMode() const {ASSERT(was_validated_);auto to_bound = begin();auto enhanced_credit_based_flow_control_mode_it = to_bound + (/* Bits: */ 74 + /* Dynamic: */ 0) / 8;uint8_t enhanced_credit_based_flow_control_mode_value{};uint8_t* enhanced_credit_based_flow_control_mode_ptr = &enhanced_credit_based_flow_control_mode_value;auto extracted_value = enhanced_credit_based_flow_control_mode_it.extract<uint8_t>();extracted_value >>= 2;extracted_value &= 0x1;*enhanced_credit_based_flow_control_mode_ptr = static_cast<uint8_t>(extracted_value);return enhanced_credit_based_flow_control_mode_value;}
1524
1525 protected:
1526 bool Validate() const override {
1527 if (!InformationResponseView::Validate()) {
1528 return false;
1529 }
1530 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetInfoType() != InformationRequestInfoType::EXTENDED_FEATURES_SUPPORTED) return false;
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542 return true;}
1543
1544 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "InformationResponseExtendedFeatures { ";ss << "" << "flow_control_mode = " << static_cast<uint64_t>(GetFlowControlMode()) << ", retransmission_mode = " << static_cast<uint64_t>(GetRetransmissionMode()) << ", bi_directional_qoS = " << static_cast<uint64_t>(GetBiDirectionalQoS()) << ", enhanced_retransmission_mode = " << static_cast<uint64_t>(GetEnhancedRetransmissionMode()) << ", streaming_mode = " << static_cast<uint64_t>(GetStreamingMode()) << ", fcs_option = " << static_cast<uint64_t>(GetFcsOption()) << ", extended_flow_specification_for_br_edr = " << static_cast<uint64_t>(GetExtendedFlowSpecificationForBrEdr()) << ", fixed_channels = " << static_cast<uint64_t>(GetFixedChannels()) << ", extended_window_size = " << static_cast<uint64_t>(GetExtendedWindowSize()) << ", unicast_connectionless_data_reception = " << static_cast<uint64_t>(GetUnicastConnectionlessDataReception()) << ", enhanced_credit_based_flow_control_mode = " << static_cast<uint64_t>(GetEnhancedCreditBasedFlowControlMode());ss << " }";return ss.str();}
1545
1546 protected:
1547 explicit InformationResponseExtendedFeaturesView(InformationResponseView parent) : InformationResponseView(std::move(parent)) { was_validated_ = false; }};
1548
1549
CreateOptional(InformationResponseView parent)1550 class InformationResponseFixedChannelsView : public InformationResponseView { public:static InformationResponseFixedChannelsView Create(InformationResponseView parent){ return InformationResponseFixedChannelsView(std::move(parent)); }static std::optional<InformationResponseFixedChannelsView> CreateOptional(InformationResponseView parent){ auto to_validate = InformationResponseFixedChannelsView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1551 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1552 static InformationResponseFixedChannelsView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return InformationResponseFixedChannelsView::Create(InformationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec))));}
1553 #endif
1554 uint64_t GetFixedChannels() const {ASSERT(was_validated_);auto to_bound = begin();auto fixed_channels_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint64_t fixed_channels_value{};uint64_t* fixed_channels_ptr = &fixed_channels_value;auto extracted_value = fixed_channels_it.extract<uint64_t>();*fixed_channels_ptr = static_cast<uint64_t>(extracted_value);return fixed_channels_value;}
1555 protected:
1556 bool Validate() const override {
1557 if (!InformationResponseView::Validate()) {
1558 return false;
1559 }
1560 auto it = begin() + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetInfoType() != InformationRequestInfoType::FIXED_CHANNELS_SUPPORTED) return false;
1561 return true;}
1562
1563 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "InformationResponseFixedChannels { ";ss << "" << "fixed_channels = " << static_cast<uint64_t>(GetFixedChannels());ss << " }";return ss.str();}
1564
1565 protected:
1566 explicit InformationResponseFixedChannelsView(InformationResponseView parent) : InformationResponseView(std::move(parent)) { was_validated_ = false; }};
1567
1568
CreateOptional(ControlView parent)1569 class CreateChannelRequestView : public ControlView { public:static CreateChannelRequestView Create(ControlView parent){ return CreateChannelRequestView(std::move(parent)); }static std::optional<CreateChannelRequestView> CreateOptional(ControlView parent){ auto to_validate = CreateChannelRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1570 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1571 static CreateChannelRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreateChannelRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1572 #endif
1573 uint16_t GetPsm() const {ASSERT(was_validated_);auto to_bound = begin();auto psm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t psm_value{};uint16_t* psm_ptr = &psm_value;auto extracted_value = psm_it.extract<uint16_t>();*psm_ptr = static_cast<uint16_t>(extracted_value);return psm_value;}
1574 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1575 uint8_t GetControllerId() const {ASSERT(was_validated_);auto to_bound = begin();auto controller_id_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint8_t controller_id_value{};uint8_t* controller_id_ptr = &controller_id_value;auto extracted_value = controller_id_it.extract<uint8_t>();*controller_id_ptr = static_cast<uint8_t>(extracted_value);return controller_id_value;}
1576 protected:
1577 bool Validate() const override {
1578 if (!ControlView::Validate()) {
1579 return false;
1580 }
1581 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 5 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREATE_CHANNEL_REQUEST) return false;
1582
1583
1584 return true;}
1585
1586 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreateChannelRequest { ";ss << "" << "psm = " << static_cast<uint64_t>(GetPsm()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid()) << ", controller_id = " << static_cast<uint64_t>(GetControllerId());ss << " }";return ss.str();}
1587
1588 protected:
1589 explicit CreateChannelRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1590
1591
CreateOptional(ControlView parent)1592 class CreateChannelResponseView : public ControlView { public:static CreateChannelResponseView Create(ControlView parent){ return CreateChannelResponseView(std::move(parent)); }static std::optional<CreateChannelResponseView> CreateOptional(ControlView parent){ auto to_validate = CreateChannelResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1593 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1594 static CreateChannelResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreateChannelResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1595 #endif
1596 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1597 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1598 CreateChannelResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;CreateChannelResponseResult result_value{};CreateChannelResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<CreateChannelResponseResult>(extracted_value);return result_value;}
1599 CreateChannelResponseStatus GetStatus() const {ASSERT(was_validated_);auto to_bound = begin();auto status_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;CreateChannelResponseStatus status_value{};CreateChannelResponseStatus* status_ptr = &status_value;auto extracted_value = status_it.extract<uint16_t>();*status_ptr = static_cast<CreateChannelResponseStatus>(extracted_value);return status_value;}
1600 protected:
1601 bool Validate() const override {
1602 if (!ControlView::Validate()) {
1603 return false;
1604 }
1605 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREATE_CHANNEL_RESPONSE) return false;
1606
1607
1608
1609 return true;}
1610
1611 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreateChannelResponse { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid()) << ", result = " << CreateChannelResponseResultText(GetResult()) << ", status = " << CreateChannelResponseStatusText(GetStatus());ss << " }";return ss.str();}
1612
1613 protected:
1614 explicit CreateChannelResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1615
1616
CreateOptional(ControlView parent)1617 class MoveChannelRequestView : public ControlView { public:static MoveChannelRequestView Create(ControlView parent){ return MoveChannelRequestView(std::move(parent)); }static std::optional<MoveChannelRequestView> CreateOptional(ControlView parent){ auto to_validate = MoveChannelRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1618 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1619 static MoveChannelRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return MoveChannelRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1620 #endif
1621 uint16_t GetInitiatorCid() const {ASSERT(was_validated_);auto to_bound = begin();auto initiator_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t initiator_cid_value{};uint16_t* initiator_cid_ptr = &initiator_cid_value;auto extracted_value = initiator_cid_it.extract<uint16_t>();*initiator_cid_ptr = static_cast<uint16_t>(extracted_value);return initiator_cid_value;}
1622 uint8_t GetDestControllerId() const {ASSERT(was_validated_);auto to_bound = begin();auto dest_controller_id_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint8_t dest_controller_id_value{};uint8_t* dest_controller_id_ptr = &dest_controller_id_value;auto extracted_value = dest_controller_id_it.extract<uint8_t>();*dest_controller_id_ptr = static_cast<uint8_t>(extracted_value);return dest_controller_id_value;}
1623 protected:
1624 bool Validate() const override {
1625 if (!ControlView::Validate()) {
1626 return false;
1627 }
1628 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 3 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::MOVE_CHANNEL_REQUEST) return false;
1629
1630 return true;}
1631
1632 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "MoveChannelRequest { ";ss << "" << "initiator_cid = " << static_cast<uint64_t>(GetInitiatorCid()) << ", dest_controller_id = " << static_cast<uint64_t>(GetDestControllerId());ss << " }";return ss.str();}
1633
1634 protected:
1635 explicit MoveChannelRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1636
1637
CreateOptional(ControlView parent)1638 class MoveChannelResponseView : public ControlView { public:static MoveChannelResponseView Create(ControlView parent){ return MoveChannelResponseView(std::move(parent)); }static std::optional<MoveChannelResponseView> CreateOptional(ControlView parent){ auto to_validate = MoveChannelResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1639 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1640 static MoveChannelResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return MoveChannelResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1641 #endif
1642 uint16_t GetInitiatorCid() const {ASSERT(was_validated_);auto to_bound = begin();auto initiator_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t initiator_cid_value{};uint16_t* initiator_cid_ptr = &initiator_cid_value;auto extracted_value = initiator_cid_it.extract<uint16_t>();*initiator_cid_ptr = static_cast<uint16_t>(extracted_value);return initiator_cid_value;}
1643 MoveChannelResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;MoveChannelResponseResult result_value{};MoveChannelResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<MoveChannelResponseResult>(extracted_value);return result_value;}
1644 protected:
1645 bool Validate() const override {
1646 if (!ControlView::Validate()) {
1647 return false;
1648 }
1649 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::MOVE_CHANNEL_RESPONSE) return false;
1650
1651 return true;}
1652
1653 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "MoveChannelResponse { ";ss << "" << "initiator_cid = " << static_cast<uint64_t>(GetInitiatorCid()) << ", result = " << MoveChannelResponseResultText(GetResult());ss << " }";return ss.str();}
1654
1655 protected:
1656 explicit MoveChannelResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1657
1658
CreateOptional(ControlView parent)1659 class MoveChannelConfirmationRequestView : public ControlView { public:static MoveChannelConfirmationRequestView Create(ControlView parent){ return MoveChannelConfirmationRequestView(std::move(parent)); }static std::optional<MoveChannelConfirmationRequestView> CreateOptional(ControlView parent){ auto to_validate = MoveChannelConfirmationRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1660 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1661 static MoveChannelConfirmationRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return MoveChannelConfirmationRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1662 #endif
1663 uint16_t GetInitiatorCid() const {ASSERT(was_validated_);auto to_bound = begin();auto initiator_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t initiator_cid_value{};uint16_t* initiator_cid_ptr = &initiator_cid_value;auto extracted_value = initiator_cid_it.extract<uint16_t>();*initiator_cid_ptr = static_cast<uint16_t>(extracted_value);return initiator_cid_value;}
1664 MoveChannelConfirmationResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;MoveChannelConfirmationResult result_value{};MoveChannelConfirmationResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<MoveChannelConfirmationResult>(extracted_value);return result_value;}
1665 protected:
1666 bool Validate() const override {
1667 if (!ControlView::Validate()) {
1668 return false;
1669 }
1670 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::MOVE_CHANNEL_CONFIRMATION_REQUEST) return false;
1671
1672 return true;}
1673
1674 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "MoveChannelConfirmationRequest { ";ss << "" << "initiator_cid = " << static_cast<uint64_t>(GetInitiatorCid()) << ", result = " << MoveChannelConfirmationResultText(GetResult());ss << " }";return ss.str();}
1675
1676 protected:
1677 explicit MoveChannelConfirmationRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1678
1679
CreateOptional(ControlView parent)1680 class MoveChannelConfirmationResponseView : public ControlView { public:static MoveChannelConfirmationResponseView Create(ControlView parent){ return MoveChannelConfirmationResponseView(std::move(parent)); }static std::optional<MoveChannelConfirmationResponseView> CreateOptional(ControlView parent){ auto to_validate = MoveChannelConfirmationResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1681 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1682 static MoveChannelConfirmationResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return MoveChannelConfirmationResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1683 #endif
1684 uint16_t GetInitiatorCid() const {ASSERT(was_validated_);auto to_bound = begin();auto initiator_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t initiator_cid_value{};uint16_t* initiator_cid_ptr = &initiator_cid_value;auto extracted_value = initiator_cid_it.extract<uint16_t>();*initiator_cid_ptr = static_cast<uint16_t>(extracted_value);return initiator_cid_value;}
1685 protected:
1686 bool Validate() const override {
1687 if (!ControlView::Validate()) {
1688 return false;
1689 }
1690 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::MOVE_CHANNEL_CONFIRMATION_RESPONSE) return false;
1691 return true;}
1692
1693 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "MoveChannelConfirmationResponse { ";ss << "" << "initiator_cid = " << static_cast<uint64_t>(GetInitiatorCid());ss << " }";return ss.str();}
1694
1695 protected:
1696 explicit MoveChannelConfirmationResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1697
1698
CreateOptional(ControlView parent)1699 class FlowControlCreditView : public ControlView { public:static FlowControlCreditView Create(ControlView parent){ return FlowControlCreditView(std::move(parent)); }static std::optional<FlowControlCreditView> CreateOptional(ControlView parent){ auto to_validate = FlowControlCreditView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1700 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1701 static FlowControlCreditView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return FlowControlCreditView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1702 #endif
1703 uint16_t GetCid() const {ASSERT(was_validated_);auto to_bound = begin();auto cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t cid_value{};uint16_t* cid_ptr = &cid_value;auto extracted_value = cid_it.extract<uint16_t>();*cid_ptr = static_cast<uint16_t>(extracted_value);return cid_value;}
1704 uint16_t GetCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto credits_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t credits_value{};uint16_t* credits_ptr = &credits_value;auto extracted_value = credits_it.extract<uint16_t>();*credits_ptr = static_cast<uint16_t>(extracted_value);return credits_value;}
1705 protected:
1706 bool Validate() const override {
1707 if (!ControlView::Validate()) {
1708 return false;
1709 }
1710 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::FLOW_CONTROL_CREDIT) return false;
1711
1712 return true;}
1713
1714 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "FlowControlCredit { ";ss << "" << "cid = " << static_cast<uint64_t>(GetCid()) << ", credits = " << static_cast<uint64_t>(GetCredits());ss << " }";return ss.str();}
1715
1716 protected:
1717 explicit FlowControlCreditView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1718
1719
CreateOptional(ControlView parent)1720 class CreditBasedConnectionRequestView : public ControlView { public:static CreditBasedConnectionRequestView Create(ControlView parent){ return CreditBasedConnectionRequestView(std::move(parent)); }static std::optional<CreditBasedConnectionRequestView> CreateOptional(ControlView parent){ auto to_validate = CreditBasedConnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1721 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1722 static CreditBasedConnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreditBasedConnectionRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1723 #endif
1724 uint16_t GetSpsm() const {ASSERT(was_validated_);auto to_bound = begin();auto spsm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t spsm_value{};uint16_t* spsm_ptr = &spsm_value;auto extracted_value = spsm_it.extract<uint16_t>();*spsm_ptr = static_cast<uint16_t>(extracted_value);return spsm_value;}
1725 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
1726 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
1727 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
1728 std::vector<uint16_t> GetSourceCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto source_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> source_cid_value{};std::vector<uint16_t>* source_cid_ptr = &source_cid_value;auto val_it = source_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { source_cid_ptr->push_back(val_value);}}return source_cid_value;}
1729
1730 protected:
1731 bool Validate() const override {
1732 if (!ControlView::Validate()) {
1733 return false;
1734 }
1735 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREDIT_BASED_CONNECTION_REQUEST) return false;
1736
1737
1738
1739
1740 return true;}
1741
1742 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreditBasedConnectionRequest { ";ss << "" << "spsm = " << static_cast<uint64_t>(GetSpsm()) << ", mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits()) << ", source_cid = " << "VECTOR[";for (size_t index = 0; index < GetSourceCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetSourceCid()[index]));}ss << "]";ss << " }";return ss.str();}
1743
1744 protected:
1745 explicit CreditBasedConnectionRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1746
1747
CreateOptional(ControlView parent)1748 class CreditBasedConnectionResponseView : public ControlView { public:static CreditBasedConnectionResponseView Create(ControlView parent){ return CreditBasedConnectionResponseView(std::move(parent)); }static std::optional<CreditBasedConnectionResponseView> CreateOptional(ControlView parent){ auto to_validate = CreditBasedConnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1749 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1750 static CreditBasedConnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreditBasedConnectionResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1751 #endif
1752 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
1753 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
1754 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
1755 CreditBasedConnectionResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;CreditBasedConnectionResponseResult result_value{};CreditBasedConnectionResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<CreditBasedConnectionResponseResult>(extracted_value);return result_value;}
1756 std::vector<uint16_t> GetDestinationCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto destination_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> destination_cid_value{};std::vector<uint16_t>* destination_cid_ptr = &destination_cid_value;auto val_it = destination_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { destination_cid_ptr->push_back(val_value);}}return destination_cid_value;}
1757
1758 protected:
1759 bool Validate() const override {
1760 if (!ControlView::Validate()) {
1761 return false;
1762 }
1763 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREDIT_BASED_CONNECTION_RESPONSE) return false;
1764
1765
1766
1767
1768 return true;}
1769
1770 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreditBasedConnectionResponse { ";ss << "" << "mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits()) << ", result = " << CreditBasedConnectionResponseResultText(GetResult()) << ", destination_cid = " << "VECTOR[";for (size_t index = 0; index < GetDestinationCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetDestinationCid()[index]));}ss << "]";ss << " }";return ss.str();}
1771
1772 protected:
1773 explicit CreditBasedConnectionResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1774
1775
CreateOptional(ControlView parent)1776 class CreditBasedReconfigureRequestView : public ControlView { public:static CreditBasedReconfigureRequestView Create(ControlView parent){ return CreditBasedReconfigureRequestView(std::move(parent)); }static std::optional<CreditBasedReconfigureRequestView> CreateOptional(ControlView parent){ auto to_validate = CreditBasedReconfigureRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1777 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1778 static CreditBasedReconfigureRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreditBasedReconfigureRequestView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1779 #endif
1780 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
1781 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
1782 std::vector<uint16_t> GetDestinationCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto destination_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> destination_cid_value{};std::vector<uint16_t>* destination_cid_ptr = &destination_cid_value;auto val_it = destination_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { destination_cid_ptr->push_back(val_value);}}return destination_cid_value;}
1783
1784 protected:
1785 bool Validate() const override {
1786 if (!ControlView::Validate()) {
1787 return false;
1788 }
1789 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREDIT_BASED_RECONFIGURE_REQUEST) return false;
1790
1791
1792 return true;}
1793
1794 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreditBasedReconfigureRequest { ";ss << "" << "mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", destination_cid = " << "VECTOR[";for (size_t index = 0; index < GetDestinationCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetDestinationCid()[index]));}ss << "]";ss << " }";return ss.str();}
1795
1796 protected:
1797 explicit CreditBasedReconfigureRequestView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1798
1799
CreateOptional(ControlView parent)1800 class CreditBasedReconfigureResponseView : public ControlView { public:static CreditBasedReconfigureResponseView Create(ControlView parent){ return CreditBasedReconfigureResponseView(std::move(parent)); }static std::optional<CreditBasedReconfigureResponseView> CreateOptional(ControlView parent){ auto to_validate = CreditBasedReconfigureResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1801 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1802 static CreditBasedReconfigureResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return CreditBasedReconfigureResponseView::Create(ControlView::Create(PacketView<kLittleEndian>(vec)));}
1803 #endif
1804 CreditBasedReconfigureResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;CreditBasedReconfigureResponseResult result_value{};CreditBasedReconfigureResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<CreditBasedReconfigureResponseResult>(extracted_value);return result_value;}
1805 protected:
1806 bool Validate() const override {
1807 if (!ControlView::Validate()) {
1808 return false;
1809 }
1810 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != CommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE) return false;
1811 return true;}
1812
1813 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "CreditBasedReconfigureResponse { ";ss << "" << "result = " << CreditBasedReconfigureResponseResultText(GetResult());ss << " }";return ss.str();}
1814
1815 protected:
1816 explicit CreditBasedReconfigureResponseView(ControlView parent) : ControlView(std::move(parent)) { was_validated_ = false; }};
1817
1818
CreateOptional(BasicFrameView parent)1819 class LeControlFrameView : public BasicFrameView { public:static LeControlFrameView Create(BasicFrameView parent){ return LeControlFrameView(std::move(parent)); }static std::optional<LeControlFrameView> CreateOptional(BasicFrameView parent){ auto to_validate = LeControlFrameView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1820 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1821 static LeControlFrameView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeControlFrameView::Create(BasicFrameView::Create(PacketView<kLittleEndian>(vec)));}
1822 #endif
1823 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1824
1825
1826 protected:
1827 bool Validate() const override {
1828 if (!BasicFrameView::Validate()) {
1829 return false;
1830 }
1831 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetChannelId() != 5) return false;
1832 return true;}
1833
1834 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeControlFrame { ";ss << "" << "payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1835
1836 protected:
1837 explicit LeControlFrameView(BasicFrameView parent) : BasicFrameView(std::move(parent)) { was_validated_ = false; }};
1838
1839
CreateOptional(PacketView<kLittleEndian> packet)1840 class LeControlView : public PacketView<kLittleEndian> { public:static LeControlView Create(PacketView<kLittleEndian> packet){ return LeControlView(std::move(packet)); }static std::optional<LeControlView> CreateOptional(PacketView<kLittleEndian> packet){ auto to_validate = LeControlView::Create(std::move(packet));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1841 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1842 static LeControlView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeControlView::Create(PacketView<kLittleEndian>(vec));}
1843 #endif
1844 LeCommandCode GetCode() const {ASSERT(was_validated_);auto to_bound = begin();auto code_it = to_bound + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;LeCommandCode code_value{};LeCommandCode* code_ptr = &code_value;auto extracted_value = code_it.extract<uint8_t>();*code_ptr = static_cast<LeCommandCode>(extracted_value);return code_value;}
1845 uint8_t GetIdentifier() const {ASSERT(was_validated_);auto to_bound = begin();auto identifier_it = to_bound + (/* Bits: */ 8 + /* Dynamic: */ 0) / 8;uint8_t identifier_value{};uint8_t* identifier_ptr = &identifier_value;auto extracted_value = identifier_it.extract<uint8_t>();*identifier_ptr = static_cast<uint8_t>(extracted_value);return identifier_value;}
1846 protected:uint16_t GetPayloadSize() const {ASSERT(was_validated_);auto to_bound = begin();auto payload_size_it = to_bound + (/* Bits: */ 16 + /* Dynamic: */ 0) / 8;uint16_t payload_size_value{};uint16_t* payload_size_ptr = &payload_size_value;auto extracted_value = payload_size_it.extract<uint16_t>();*payload_size_ptr = static_cast<uint16_t>(extracted_value);return payload_size_value;}public:
1847
1848 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;size_t field_sized_end = field_begin + (/* Bits: */ 0 + /* Dynamic: */ (GetPayloadSize() * 8)) / 8;if (field_sized_end < field_end) { field_end = field_sized_end; }auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1849
1850
1851 bool IsValid() {
1852 if (was_validated_) {
1853 return true;
1854 } else {
1855 was_validated_ = true;
1856 return (was_validated_ = Validate());
1857 }
1858 }
1859 protected:
1860 virtual bool Validate() const {
1861 auto it = begin() + (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;it += ((GetPayloadSize() * 8)) / 8;if (it > end()) return false;
1862
1863
1864
1865 return true;}
1866 bool was_validated_{false};
1867
1868 public:virtual std::string ToString() const {std::stringstream ss;ss << std::showbase << std::hex << "LeControl { ";ss << "" << "code = " << LeCommandCodeText(GetCode()) << ", identifier = " << static_cast<uint64_t>(GetIdentifier()) << ", payload_size = " << GetPayloadSize() << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1869
1870 protected:
1871 explicit LeControlView(PacketView<kLittleEndian> packet) : PacketView<kLittleEndian>(packet) { was_validated_ = false;}};
1872
1873
CreateOptional(LeControlView parent)1874 class LeCommandRejectView : public LeControlView { public:static LeCommandRejectView Create(LeControlView parent){ return LeCommandRejectView(std::move(parent)); }static std::optional<LeCommandRejectView> CreateOptional(LeControlView parent){ auto to_validate = LeCommandRejectView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1875 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1876 static LeCommandRejectView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCommandRejectView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
1877 #endif
1878 CommandRejectReason GetReason() const {ASSERT(was_validated_);auto to_bound = begin();auto reason_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;CommandRejectReason reason_value{};CommandRejectReason* reason_ptr = &reason_value;auto extracted_value = reason_it.extract<uint16_t>();*reason_ptr = static_cast<CommandRejectReason>(extracted_value);return reason_value;}
1879 PacketView<kLittleEndian> GetPayload() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto payload_it = to_bound.Subrange(field_begin, field_end - field_begin); return GetLittleEndianSubview(field_begin, field_end);}
1880
1881
1882 protected:
1883 bool Validate() const override {
1884 if (!LeControlView::Validate()) {
1885 return false;
1886 }
1887 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::COMMAND_REJECT) return false;
1888
1889 return true;}
1890
1891 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCommandReject { ";ss << "" << "reason = " << CommandRejectReasonText(GetReason()) << ", payload = " << "PAYLOAD[]";ss << " }";return ss.str();}
1892
1893 protected:
1894 explicit LeCommandRejectView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
1895
1896
CreateOptional(LeCommandRejectView parent)1897 class LeCommandRejectNotUnderstoodView : public LeCommandRejectView { public:static LeCommandRejectNotUnderstoodView Create(LeCommandRejectView parent){ return LeCommandRejectNotUnderstoodView(std::move(parent)); }static std::optional<LeCommandRejectNotUnderstoodView> CreateOptional(LeCommandRejectView parent){ auto to_validate = LeCommandRejectNotUnderstoodView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1898 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1899 static LeCommandRejectNotUnderstoodView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCommandRejectNotUnderstoodView::Create(LeCommandRejectView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec))));}
1900 #endif
1901 protected:
1902 bool Validate() const override {
1903 if (!LeCommandRejectView::Validate()) {
1904 return false;
1905 }
1906 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 0 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::COMMAND_NOT_UNDERSTOOD) return false;return true;}
1907
1908 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCommandRejectNotUnderstood { ";ss << " }";return ss.str();}
1909
1910 protected:
1911 explicit LeCommandRejectNotUnderstoodView(LeCommandRejectView parent) : LeCommandRejectView(std::move(parent)) { was_validated_ = false; }};
1912
1913
CreateOptional(LeCommandRejectView parent)1914 class LeCommandRejectMtuExceededView : public LeCommandRejectView { public:static LeCommandRejectMtuExceededView Create(LeCommandRejectView parent){ return LeCommandRejectMtuExceededView(std::move(parent)); }static std::optional<LeCommandRejectMtuExceededView> CreateOptional(LeCommandRejectView parent){ auto to_validate = LeCommandRejectMtuExceededView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1915 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1916 static LeCommandRejectMtuExceededView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCommandRejectMtuExceededView::Create(LeCommandRejectView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec))));}
1917 #endif
1918 uint16_t GetActualMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto actual_mtu_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t actual_mtu_value{};uint16_t* actual_mtu_ptr = &actual_mtu_value;auto extracted_value = actual_mtu_it.extract<uint16_t>();*actual_mtu_ptr = static_cast<uint16_t>(extracted_value);return actual_mtu_value;}
1919 protected:
1920 bool Validate() const override {
1921 if (!LeCommandRejectView::Validate()) {
1922 return false;
1923 }
1924 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::SIGNALING_MTU_EXCEEDED) return false;
1925 return true;}
1926
1927 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCommandRejectMtuExceeded { ";ss << "" << "actual_mtu = " << static_cast<uint64_t>(GetActualMtu());ss << " }";return ss.str();}
1928
1929 protected:
1930 explicit LeCommandRejectMtuExceededView(LeCommandRejectView parent) : LeCommandRejectView(std::move(parent)) { was_validated_ = false; }};
1931
1932
CreateOptional(LeCommandRejectView parent)1933 class LeCommandRejectInvalidCidView : public LeCommandRejectView { public:static LeCommandRejectInvalidCidView Create(LeCommandRejectView parent){ return LeCommandRejectInvalidCidView(std::move(parent)); }static std::optional<LeCommandRejectInvalidCidView> CreateOptional(LeCommandRejectView parent){ auto to_validate = LeCommandRejectInvalidCidView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1934 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1935 static LeCommandRejectInvalidCidView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCommandRejectInvalidCidView::Create(LeCommandRejectView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec))));}
1936 #endif
1937 uint16_t GetLocalChannel() const {ASSERT(was_validated_);auto to_bound = begin();auto local_channel_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t local_channel_value{};uint16_t* local_channel_ptr = &local_channel_value;auto extracted_value = local_channel_it.extract<uint16_t>();*local_channel_ptr = static_cast<uint16_t>(extracted_value);return local_channel_value;}
1938 uint16_t GetRemoteChannel() const {ASSERT(was_validated_);auto to_bound = begin();auto remote_channel_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t remote_channel_value{};uint16_t* remote_channel_ptr = &remote_channel_value;auto extracted_value = remote_channel_it.extract<uint16_t>();*remote_channel_ptr = static_cast<uint16_t>(extracted_value);return remote_channel_value;}
1939 protected:
1940 bool Validate() const override {
1941 if (!LeCommandRejectView::Validate()) {
1942 return false;
1943 }
1944 auto it = begin() + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetReason() != CommandRejectReason::INVALID_CID_IN_REQUEST) return false;
1945
1946 return true;}
1947
1948 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCommandRejectInvalidCid { ";ss << "" << "local_channel = " << static_cast<uint64_t>(GetLocalChannel()) << ", remote_channel = " << static_cast<uint64_t>(GetRemoteChannel());ss << " }";return ss.str();}
1949
1950 protected:
1951 explicit LeCommandRejectInvalidCidView(LeCommandRejectView parent) : LeCommandRejectView(std::move(parent)) { was_validated_ = false; }};
1952
1953
CreateOptional(LeControlView parent)1954 class LeDisconnectionRequestView : public LeControlView { public:static LeDisconnectionRequestView Create(LeControlView parent){ return LeDisconnectionRequestView(std::move(parent)); }static std::optional<LeDisconnectionRequestView> CreateOptional(LeControlView parent){ auto to_validate = LeDisconnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1955 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1956 static LeDisconnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeDisconnectionRequestView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
1957 #endif
1958 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1959 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1960 protected:
1961 bool Validate() const override {
1962 if (!LeControlView::Validate()) {
1963 return false;
1964 }
1965 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::DISCONNECTION_REQUEST) return false;
1966
1967 return true;}
1968
1969 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeDisconnectionRequest { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid());ss << " }";return ss.str();}
1970
1971 protected:
1972 explicit LeDisconnectionRequestView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
1973
1974
CreateOptional(LeControlView parent)1975 class LeDisconnectionResponseView : public LeControlView { public:static LeDisconnectionResponseView Create(LeControlView parent){ return LeDisconnectionResponseView(std::move(parent)); }static std::optional<LeDisconnectionResponseView> CreateOptional(LeControlView parent){ auto to_validate = LeDisconnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1976 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1977 static LeDisconnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeDisconnectionResponseView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
1978 #endif
1979 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
1980 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
1981 protected:
1982 bool Validate() const override {
1983 if (!LeControlView::Validate()) {
1984 return false;
1985 }
1986 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::DISCONNECTION_RESPONSE) return false;
1987
1988 return true;}
1989
1990 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeDisconnectionResponse { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid());ss << " }";return ss.str();}
1991
1992 protected:
1993 explicit LeDisconnectionResponseView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
1994
1995
CreateOptional(LeControlView parent)1996 class ConnectionParameterUpdateRequestView : public LeControlView { public:static ConnectionParameterUpdateRequestView Create(LeControlView parent){ return ConnectionParameterUpdateRequestView(std::move(parent)); }static std::optional<ConnectionParameterUpdateRequestView> CreateOptional(LeControlView parent){ auto to_validate = ConnectionParameterUpdateRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
1997 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
1998 static ConnectionParameterUpdateRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConnectionParameterUpdateRequestView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
1999 #endif
2000 uint16_t GetIntervalMin() const {ASSERT(was_validated_);auto to_bound = begin();auto interval_min_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t interval_min_value{};uint16_t* interval_min_ptr = &interval_min_value;auto extracted_value = interval_min_it.extract<uint16_t>();*interval_min_ptr = static_cast<uint16_t>(extracted_value);return interval_min_value;}
2001 uint16_t GetIntervalMax() const {ASSERT(was_validated_);auto to_bound = begin();auto interval_max_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t interval_max_value{};uint16_t* interval_max_ptr = &interval_max_value;auto extracted_value = interval_max_it.extract<uint16_t>();*interval_max_ptr = static_cast<uint16_t>(extracted_value);return interval_max_value;}
2002 uint16_t GetPeripheralLatency() const {ASSERT(was_validated_);auto to_bound = begin();auto peripheral_latency_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t peripheral_latency_value{};uint16_t* peripheral_latency_ptr = &peripheral_latency_value;auto extracted_value = peripheral_latency_it.extract<uint16_t>();*peripheral_latency_ptr = static_cast<uint16_t>(extracted_value);return peripheral_latency_value;}
2003 uint16_t GetTimeoutMultiplier() const {ASSERT(was_validated_);auto to_bound = begin();auto timeout_multiplier_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;uint16_t timeout_multiplier_value{};uint16_t* timeout_multiplier_ptr = &timeout_multiplier_value;auto extracted_value = timeout_multiplier_it.extract<uint16_t>();*timeout_multiplier_ptr = static_cast<uint16_t>(extracted_value);return timeout_multiplier_value;}
2004 protected:
2005 bool Validate() const override {
2006 if (!LeControlView::Validate()) {
2007 return false;
2008 }
2009 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CONNECTION_PARAMETER_UPDATE_REQUEST) return false;
2010
2011
2012
2013 return true;}
2014
2015 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConnectionParameterUpdateRequest { ";ss << "" << "interval_min = " << static_cast<uint64_t>(GetIntervalMin()) << ", interval_max = " << static_cast<uint64_t>(GetIntervalMax()) << ", peripheral_latency = " << static_cast<uint64_t>(GetPeripheralLatency()) << ", timeout_multiplier = " << static_cast<uint64_t>(GetTimeoutMultiplier());ss << " }";return ss.str();}
2016
2017 protected:
2018 explicit ConnectionParameterUpdateRequestView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2019
2020
CreateOptional(LeControlView parent)2021 class ConnectionParameterUpdateResponseView : public LeControlView { public:static ConnectionParameterUpdateResponseView Create(LeControlView parent){ return ConnectionParameterUpdateResponseView(std::move(parent)); }static std::optional<ConnectionParameterUpdateResponseView> CreateOptional(LeControlView parent){ auto to_validate = ConnectionParameterUpdateResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2022 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2023 static ConnectionParameterUpdateResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return ConnectionParameterUpdateResponseView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2024 #endif
2025 ConnectionParameterUpdateResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;ConnectionParameterUpdateResponseResult result_value{};ConnectionParameterUpdateResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<ConnectionParameterUpdateResponseResult>(extracted_value);return result_value;}
2026 protected:
2027 bool Validate() const override {
2028 if (!LeControlView::Validate()) {
2029 return false;
2030 }
2031 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CONNECTION_PARAMETER_UPDATE_RESPONSE) return false;
2032 return true;}
2033
2034 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "ConnectionParameterUpdateResponse { ";ss << "" << "result = " << ConnectionParameterUpdateResponseResultText(GetResult());ss << " }";return ss.str();}
2035
2036 protected:
2037 explicit ConnectionParameterUpdateResponseView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2038
2039
CreateOptional(LeControlView parent)2040 class LeCreditBasedConnectionRequestView : public LeControlView { public:static LeCreditBasedConnectionRequestView Create(LeControlView parent){ return LeCreditBasedConnectionRequestView(std::move(parent)); }static std::optional<LeCreditBasedConnectionRequestView> CreateOptional(LeControlView parent){ auto to_validate = LeCreditBasedConnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2041 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2042 static LeCreditBasedConnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCreditBasedConnectionRequestView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2043 #endif
2044 uint16_t GetLePsm() const {ASSERT(was_validated_);auto to_bound = begin();auto le_psm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t le_psm_value{};uint16_t* le_psm_ptr = &le_psm_value;auto extracted_value = le_psm_it.extract<uint16_t>();*le_psm_ptr = static_cast<uint16_t>(extracted_value);return le_psm_value;}
2045 uint16_t GetSourceCid() const {ASSERT(was_validated_);auto to_bound = begin();auto source_cid_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t source_cid_value{};uint16_t* source_cid_ptr = &source_cid_value;auto extracted_value = source_cid_it.extract<uint16_t>();*source_cid_ptr = static_cast<uint16_t>(extracted_value);return source_cid_value;}
2046 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
2047 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
2048 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
2049 protected:
2050 bool Validate() const override {
2051 if (!LeControlView::Validate()) {
2052 return false;
2053 }
2054 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 10 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::LE_CREDIT_BASED_CONNECTION_REQUEST) return false;
2055
2056
2057
2058
2059 return true;}
2060
2061 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCreditBasedConnectionRequest { ";ss << "" << "le_psm = " << static_cast<uint64_t>(GetLePsm()) << ", source_cid = " << static_cast<uint64_t>(GetSourceCid()) << ", mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits());ss << " }";return ss.str();}
2062
2063 protected:
2064 explicit LeCreditBasedConnectionRequestView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2065
2066
CreateOptional(LeControlView parent)2067 class LeCreditBasedConnectionResponseView : public LeControlView { public:static LeCreditBasedConnectionResponseView Create(LeControlView parent){ return LeCreditBasedConnectionResponseView(std::move(parent)); }static std::optional<LeCreditBasedConnectionResponseView> CreateOptional(LeControlView parent){ auto to_validate = LeCreditBasedConnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2068 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2069 static LeCreditBasedConnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeCreditBasedConnectionResponseView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2070 #endif
2071 uint16_t GetDestinationCid() const {ASSERT(was_validated_);auto to_bound = begin();auto destination_cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t destination_cid_value{};uint16_t* destination_cid_ptr = &destination_cid_value;auto extracted_value = destination_cid_it.extract<uint16_t>();*destination_cid_ptr = static_cast<uint16_t>(extracted_value);return destination_cid_value;}
2072 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
2073 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
2074 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
2075 LeCreditBasedConnectionResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;LeCreditBasedConnectionResponseResult result_value{};LeCreditBasedConnectionResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<LeCreditBasedConnectionResponseResult>(extracted_value);return result_value;}
2076 protected:
2077 bool Validate() const override {
2078 if (!LeControlView::Validate()) {
2079 return false;
2080 }
2081 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 10 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::LE_CREDIT_BASED_CONNECTION_RESPONSE) return false;
2082
2083
2084
2085
2086 return true;}
2087
2088 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeCreditBasedConnectionResponse { ";ss << "" << "destination_cid = " << static_cast<uint64_t>(GetDestinationCid()) << ", mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits()) << ", result = " << LeCreditBasedConnectionResponseResultText(GetResult());ss << " }";return ss.str();}
2089
2090 protected:
2091 explicit LeCreditBasedConnectionResponseView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2092
2093
CreateOptional(LeControlView parent)2094 class LeFlowControlCreditView : public LeControlView { public:static LeFlowControlCreditView Create(LeControlView parent){ return LeFlowControlCreditView(std::move(parent)); }static std::optional<LeFlowControlCreditView> CreateOptional(LeControlView parent){ auto to_validate = LeFlowControlCreditView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2095 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2096 static LeFlowControlCreditView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeFlowControlCreditView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2097 #endif
2098 uint16_t GetCid() const {ASSERT(was_validated_);auto to_bound = begin();auto cid_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t cid_value{};uint16_t* cid_ptr = &cid_value;auto extracted_value = cid_it.extract<uint16_t>();*cid_ptr = static_cast<uint16_t>(extracted_value);return cid_value;}
2099 uint16_t GetCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto credits_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t credits_value{};uint16_t* credits_ptr = &credits_value;auto extracted_value = credits_it.extract<uint16_t>();*credits_ptr = static_cast<uint16_t>(extracted_value);return credits_value;}
2100 protected:
2101 bool Validate() const override {
2102 if (!LeControlView::Validate()) {
2103 return false;
2104 }
2105 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::LE_FLOW_CONTROL_CREDIT) return false;
2106
2107 return true;}
2108
2109 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeFlowControlCredit { ";ss << "" << "cid = " << static_cast<uint64_t>(GetCid()) << ", credits = " << static_cast<uint64_t>(GetCredits());ss << " }";return ss.str();}
2110
2111 protected:
2112 explicit LeFlowControlCreditView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2113
2114
CreateOptional(LeControlView parent)2115 class LeEnhancedCreditBasedConnectionRequestView : public LeControlView { public:static LeEnhancedCreditBasedConnectionRequestView Create(LeControlView parent){ return LeEnhancedCreditBasedConnectionRequestView(std::move(parent)); }static std::optional<LeEnhancedCreditBasedConnectionRequestView> CreateOptional(LeControlView parent){ auto to_validate = LeEnhancedCreditBasedConnectionRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2116 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2117 static LeEnhancedCreditBasedConnectionRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeEnhancedCreditBasedConnectionRequestView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2118 #endif
2119 uint16_t GetSpsm() const {ASSERT(was_validated_);auto to_bound = begin();auto spsm_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t spsm_value{};uint16_t* spsm_ptr = &spsm_value;auto extracted_value = spsm_it.extract<uint16_t>();*spsm_ptr = static_cast<uint16_t>(extracted_value);return spsm_value;}
2120 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
2121 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
2122 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
2123 std::vector<uint16_t> GetSourceCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto source_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> source_cid_value{};std::vector<uint16_t>* source_cid_ptr = &source_cid_value;auto val_it = source_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { source_cid_ptr->push_back(val_value);}}return source_cid_value;}
2124
2125 protected:
2126 bool Validate() const override {
2127 if (!LeControlView::Validate()) {
2128 return false;
2129 }
2130 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CREDIT_BASED_CONNECTION_REQUEST) return false;
2131
2132
2133
2134
2135 return true;}
2136
2137 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeEnhancedCreditBasedConnectionRequest { ";ss << "" << "spsm = " << static_cast<uint64_t>(GetSpsm()) << ", mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits()) << ", source_cid = " << "VECTOR[";for (size_t index = 0; index < GetSourceCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetSourceCid()[index]));}ss << "]";ss << " }";return ss.str();}
2138
2139 protected:
2140 explicit LeEnhancedCreditBasedConnectionRequestView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2141
2142
CreateOptional(LeControlView parent)2143 class LeEnhancedCreditBasedConnectionResponseView : public LeControlView { public:static LeEnhancedCreditBasedConnectionResponseView Create(LeControlView parent){ return LeEnhancedCreditBasedConnectionResponseView(std::move(parent)); }static std::optional<LeEnhancedCreditBasedConnectionResponseView> CreateOptional(LeControlView parent){ auto to_validate = LeEnhancedCreditBasedConnectionResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2144 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2145 static LeEnhancedCreditBasedConnectionResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeEnhancedCreditBasedConnectionResponseView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2146 #endif
2147 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
2148 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
2149 uint16_t GetInitialCredits() const {ASSERT(was_validated_);auto to_bound = begin();auto initial_credits_it = to_bound + (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;uint16_t initial_credits_value{};uint16_t* initial_credits_ptr = &initial_credits_value;auto extracted_value = initial_credits_it.extract<uint16_t>();*initial_credits_ptr = static_cast<uint16_t>(extracted_value);return initial_credits_value;}
2150 CreditBasedConnectionResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 80 + /* Dynamic: */ 0) / 8;CreditBasedConnectionResponseResult result_value{};CreditBasedConnectionResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<CreditBasedConnectionResponseResult>(extracted_value);return result_value;}
2151 std::vector<uint16_t> GetDestinationCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 96 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto destination_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> destination_cid_value{};std::vector<uint16_t>* destination_cid_ptr = &destination_cid_value;auto val_it = destination_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { destination_cid_ptr->push_back(val_value);}}return destination_cid_value;}
2152
2153 protected:
2154 bool Validate() const override {
2155 if (!LeControlView::Validate()) {
2156 return false;
2157 }
2158 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 8 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CREDIT_BASED_CONNECTION_RESPONSE) return false;
2159
2160
2161
2162
2163 return true;}
2164
2165 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeEnhancedCreditBasedConnectionResponse { ";ss << "" << "mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", initial_credits = " << static_cast<uint64_t>(GetInitialCredits()) << ", result = " << CreditBasedConnectionResponseResultText(GetResult()) << ", destination_cid = " << "VECTOR[";for (size_t index = 0; index < GetDestinationCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetDestinationCid()[index]));}ss << "]";ss << " }";return ss.str();}
2166
2167 protected:
2168 explicit LeEnhancedCreditBasedConnectionResponseView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2169
2170
CreateOptional(LeControlView parent)2171 class LeEnhancedCreditBasedReconfigureRequestView : public LeControlView { public:static LeEnhancedCreditBasedReconfigureRequestView Create(LeControlView parent){ return LeEnhancedCreditBasedReconfigureRequestView(std::move(parent)); }static std::optional<LeEnhancedCreditBasedReconfigureRequestView> CreateOptional(LeControlView parent){ auto to_validate = LeEnhancedCreditBasedReconfigureRequestView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2172 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2173 static LeEnhancedCreditBasedReconfigureRequestView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeEnhancedCreditBasedReconfigureRequestView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2174 #endif
2175 uint16_t GetMtu() const {ASSERT(was_validated_);auto to_bound = begin();auto mtu_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;uint16_t mtu_value{};uint16_t* mtu_ptr = &mtu_value;auto extracted_value = mtu_it.extract<uint16_t>();*mtu_ptr = static_cast<uint16_t>(extracted_value);return mtu_value;}
2176 uint16_t GetMps() const {ASSERT(was_validated_);auto to_bound = begin();auto mps_it = to_bound + (/* Bits: */ 48 + /* Dynamic: */ 0) / 8;uint16_t mps_value{};uint16_t* mps_ptr = &mps_value;auto extracted_value = mps_it.extract<uint16_t>();*mps_ptr = static_cast<uint16_t>(extracted_value);return mps_value;}
2177 std::vector<uint16_t> GetDestinationCid() const {ASSERT(was_validated_);size_t end_index = size();auto to_bound = begin();size_t field_begin = (/* Bits: */ 64 + /* Dynamic: */ 0) / 8;size_t field_end = end_index - (/* Bits: */ 0 + /* Dynamic: */ 0) / 8;auto destination_cid_it = to_bound.Subrange(field_begin, field_end - field_begin); std::vector<uint16_t> destination_cid_value{};std::vector<uint16_t>* destination_cid_ptr = &destination_cid_value;auto val_it = destination_cid_it;while (val_it.NumBytesRemaining() >= 2) {uint16_t val_value;uint16_t* val_ptr = &val_value;auto extracted_value = val_it.extract<uint16_t>();*val_ptr = static_cast<uint16_t>(extracted_value);if (val_ptr != nullptr) { destination_cid_ptr->push_back(val_value);}}return destination_cid_value;}
2178
2179 protected:
2180 bool Validate() const override {
2181 if (!LeControlView::Validate()) {
2182 return false;
2183 }
2184 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 4 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CREDIT_BASED_RECONFIGURE_REQUEST) return false;
2185
2186
2187 return true;}
2188
2189 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeEnhancedCreditBasedReconfigureRequest { ";ss << "" << "mtu = " << static_cast<uint64_t>(GetMtu()) << ", mps = " << static_cast<uint64_t>(GetMps()) << ", destination_cid = " << "VECTOR[";for (size_t index = 0; index < GetDestinationCid().size(); index++) {ss << ((index == 0) ? "" : ", ") << static_cast<uint64_t>((GetDestinationCid()[index]));}ss << "]";ss << " }";return ss.str();}
2190
2191 protected:
2192 explicit LeEnhancedCreditBasedReconfigureRequestView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2193
2194
CreateOptional(LeControlView parent)2195 class LeEnhancedCreditBasedReconfigureResponseView : public LeControlView { public:static LeEnhancedCreditBasedReconfigureResponseView Create(LeControlView parent){ return LeEnhancedCreditBasedReconfigureResponseView(std::move(parent)); }static std::optional<LeEnhancedCreditBasedReconfigureResponseView> CreateOptional(LeControlView parent){ auto to_validate = LeEnhancedCreditBasedReconfigureResponseView::Create(std::move(parent));if (to_validate.IsValid()) { return to_validate; }else {return {};}}
2196 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2197 static LeEnhancedCreditBasedReconfigureResponseView FromBytes(std::vector<uint8_t> bytes) {auto vec = std::make_shared<std::vector<uint8_t>>(bytes);return LeEnhancedCreditBasedReconfigureResponseView::Create(LeControlView::Create(PacketView<kLittleEndian>(vec)));}
2198 #endif
2199 CreditBasedReconfigureResponseResult GetResult() const {ASSERT(was_validated_);auto to_bound = begin();auto result_it = to_bound + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;CreditBasedReconfigureResponseResult result_value{};CreditBasedReconfigureResponseResult* result_ptr = &result_value;auto extracted_value = result_it.extract<uint16_t>();*result_ptr = static_cast<CreditBasedReconfigureResponseResult>(extracted_value);return result_value;}
2200 protected:
2201 bool Validate() const override {
2202 if (!LeControlView::Validate()) {
2203 return false;
2204 }
2205 auto it = begin() + (/* Bits: */ 32 + /* Dynamic: */ 0) / 8;it += 2 /* Total size of the fixed fields */;if (it > end()) return false;if (GetCode() != LeCommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE) return false;
2206 return true;}
2207
2208 public:virtual std::string ToString() const override {std::stringstream ss;ss << std::showbase << std::hex << "LeEnhancedCreditBasedReconfigureResponse { ";ss << "" << "result = " << CreditBasedReconfigureResponseResultText(GetResult());ss << " }";return ss.str();}
2209
2210 protected:
2211 explicit LeEnhancedCreditBasedReconfigureResponseView(LeControlView parent) : LeControlView(std::move(parent)) { was_validated_ = false; }};
2212
2213
Create(uint16_t channel_id,std::unique_ptr<BasePacketBuilder> payload)2214 class BasicFrameBuilder : public PacketBuilder<kLittleEndian> { public: virtual ~BasicFrameBuilder() = default;static std::unique_ptr<BasicFrameBuilder> Create(uint16_t channel_id, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<BasicFrameBuilder>(new BasicFrameBuilder(channel_id));builder->payload_ = std::move(payload);return builder;}
2215
2216 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2217 static std::unique_ptr<BasicFrameBuilder> FromView(BasicFrameView view) {if (!view.IsValid()) return nullptr;return BasicFrameBuilder::Create(view.GetChannelId(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2218 #endif
2219
2220 protected:void SerializeHeader(BitInserter& i ) const {size_t payload_bytes = GetPayloadSize();ASSERT(payload_bytes < (static_cast<size_t>(1) << 16));insert(static_cast<uint16_t>(payload_bytes), i,16);insert(channel_id_, i,16);}
2221
2222 void SerializeFooter(BitInserter&) const {}
2223
2224 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2225
2226 protected:size_t BitsOfHeader() const {return 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
2227
2228 size_t BitsOfFooter() const {return 0;}
2229
2230 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2231
2232 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2233
2234 protected:
2235 explicit BasicFrameBuilder(uint16_t channel_id) :channel_id_(channel_id) {}
2236
2237
2238 uint16_t channel_id_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2239 #ifdef PACKET_TESTING
2240 #define DEFINE_AND_INSTANTIATE_BasicFrameReflectionTest(...)class BasicFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {BasicFrameView view = BasicFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = BasicFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(BasicFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(BasicFrame_reflection, BasicFrameReflectionTest, testing::Values(__VA_ARGS__))
2241 #endif
2242 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2243 #define DEFINE_BasicFrameReflectionFuzzTest() void RunBasicFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);BasicFrameView view = BasicFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = BasicFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2244 #endif
2245
2246 #ifdef PACKET_FUZZ_TESTING
2247 #define DEFINE_AND_REGISTER_BasicFrameReflectionFuzzTest(REGISTRY) DEFINE_BasicFrameReflectionFuzzTest(); class BasicFrameReflectionFuzzTestRegistrant {public: explicit BasicFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunBasicFrameReflectionFuzzTest);}}; BasicFrameReflectionFuzzTestRegistrant BasicFrame_reflection_fuzz_test_registrant(REGISTRY);
2248 #endif
2249
2250
Create(uint16_t channel_id,std::unique_ptr<BasePacketBuilder> payload)2251 class BasicFrameWithFcsBuilder : public PacketBuilder<kLittleEndian> { public: virtual ~BasicFrameWithFcsBuilder() = default;static std::unique_ptr<BasicFrameWithFcsBuilder> Create(uint16_t channel_id, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<BasicFrameWithFcsBuilder>(new BasicFrameWithFcsBuilder(channel_id));builder->payload_ = std::move(payload);return builder;}
2252
2253 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2254 static std::unique_ptr<BasicFrameWithFcsBuilder> FromView(BasicFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return BasicFrameWithFcsBuilder::Create(view.GetChannelId(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2255 #endif
2256
2257 protected:void SerializeHeader(BitInserter& i ) const {auto shared_checksum_ptr = std::make_shared<Fcs>();shared_checksum_ptr->Initialize();i.RegisterObserver(packet::ByteObserver([shared_checksum_ptr](uint8_t byte){ shared_checksum_ptr->AddByte(byte);},[shared_checksum_ptr](){ return static_cast<uint64_t>(shared_checksum_ptr->GetChecksum());}));size_t payload_bytes = GetPayloadSize();payload_bytes = payload_bytes + 2;ASSERT(payload_bytes < (static_cast<size_t>(1) << 16));insert(static_cast<uint16_t>(payload_bytes), i,16);insert(channel_id_, i,16);}
2258
2259 void SerializeFooter(BitInserter& i ) const {packet::ByteObserver observer = i.UnregisterObserver();insert(static_cast<uint16_t>(observer.GetValue()), i);}
2260
2261 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2262
2263 protected:size_t BitsOfHeader() const {return 0 + /* Bits: */ 0 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
2264
2265 size_t BitsOfFooter() const {return 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
2266
2267 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2268
2269 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2270
2271 protected:
2272 explicit BasicFrameWithFcsBuilder(uint16_t channel_id) :channel_id_(channel_id) {}
2273
2274
2275 uint16_t channel_id_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2276 #ifdef PACKET_TESTING
2277 #define DEFINE_AND_INSTANTIATE_BasicFrameWithFcsReflectionTest(...)class BasicFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {BasicFrameWithFcsView view = BasicFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = BasicFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(BasicFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(BasicFrameWithFcs_reflection, BasicFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2278 #endif
2279 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2280 #define DEFINE_BasicFrameWithFcsReflectionFuzzTest() void RunBasicFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);BasicFrameWithFcsView view = BasicFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = BasicFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2281 #endif
2282
2283 #ifdef PACKET_FUZZ_TESTING
2284 #define DEFINE_AND_REGISTER_BasicFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_BasicFrameWithFcsReflectionFuzzTest(); class BasicFrameWithFcsReflectionFuzzTestRegistrant {public: explicit BasicFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunBasicFrameWithFcsReflectionFuzzTest);}}; BasicFrameWithFcsReflectionFuzzTestRegistrant BasicFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2285 #endif
2286
2287
Create(uint16_t psm,std::unique_ptr<BasePacketBuilder> payload)2288 class GroupFrameBuilder : public BasicFrameBuilder { public: virtual ~GroupFrameBuilder() = default;static std::unique_ptr<GroupFrameBuilder> Create(uint16_t psm, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<GroupFrameBuilder>(new GroupFrameBuilder(psm));builder->payload_ = std::move(payload);return builder;}
2289
2290 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2291 static std::unique_ptr<GroupFrameBuilder> FromView(GroupFrameView view) {if (!view.IsValid()) return nullptr;return GroupFrameBuilder::Create(view.GetPsm(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2292 #endif
2293
2294 protected:void SerializeHeader(BitInserter& i ) const {BasicFrameBuilder::SerializeHeader(i);insert(psm_, i,16);}
2295
2296 void SerializeFooter(BitInserter& i ) const {BasicFrameBuilder::SerializeFooter(i);}
2297
2298 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2299
2300 protected:size_t BitsOfHeader() const {return 0 + BasicFrameBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
2301
2302 size_t BitsOfFooter() const {return 0 + BasicFrameBuilder::BitsOfFooter() ;}
2303
2304 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2305
2306 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2307
2308 protected:
2309 explicit GroupFrameBuilder(uint16_t psm) :BasicFrameBuilder(2/* channel_id_ */) ,psm_(psm) {}
2310
2311
2312 uint16_t psm_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2313 #ifdef PACKET_TESTING
2314 #define DEFINE_AND_INSTANTIATE_GroupFrameReflectionTest(...)class GroupFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {GroupFrameView view = GroupFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = GroupFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(GroupFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(GroupFrame_reflection, GroupFrameReflectionTest, testing::Values(__VA_ARGS__))
2315 #endif
2316 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2317 #define DEFINE_GroupFrameReflectionFuzzTest() void RunGroupFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);GroupFrameView view = GroupFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = GroupFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2318 #endif
2319
2320 #ifdef PACKET_FUZZ_TESTING
2321 #define DEFINE_AND_REGISTER_GroupFrameReflectionFuzzTest(REGISTRY) DEFINE_GroupFrameReflectionFuzzTest(); class GroupFrameReflectionFuzzTestRegistrant {public: explicit GroupFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunGroupFrameReflectionFuzzTest);}}; GroupFrameReflectionFuzzTestRegistrant GroupFrame_reflection_fuzz_test_registrant(REGISTRY);
2322 #endif
2323
2324
SerializeHeader(BitInserter & i)2325 class StandardFrameBuilder : public BasicFrameBuilder { public: virtual ~StandardFrameBuilder() = default;protected:void SerializeHeader(BitInserter& i ) const {BasicFrameBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(frame_type_), i, 1);}
2326
2327 void SerializeFooter(BitInserter& i ) const {BasicFrameBuilder::SerializeFooter(i);}
2328
2329 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2330
2331 protected:size_t BitsOfHeader() const {return 0 + BasicFrameBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0;}
2332
2333 size_t BitsOfFooter() const {return 0 + BasicFrameBuilder::BitsOfFooter() ;}
2334
2335 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2336
2337 protected:
2338 explicit StandardFrameBuilder(uint16_t channel_id, FrameType frame_type) :BasicFrameBuilder(channel_id) ,frame_type_(frame_type) {}
2339
2340
2341 FrameType frame_type_{};};
2342 #ifdef PACKET_TESTING
2343 #define DEFINE_AND_INSTANTIATE_StandardFrameReflectionTest(...)class StandardFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardFrameView view = StandardFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardFrame_reflection, StandardFrameReflectionTest, testing::Values(__VA_ARGS__))
2344 #endif
2345 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2346 #define DEFINE_StandardFrameReflectionFuzzTest() void RunStandardFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardFrameView view = StandardFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2347 #endif
2348
2349 #ifdef PACKET_FUZZ_TESTING
2350 #define DEFINE_AND_REGISTER_StandardFrameReflectionFuzzTest(REGISTRY) DEFINE_StandardFrameReflectionFuzzTest(); class StandardFrameReflectionFuzzTestRegistrant {public: explicit StandardFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardFrameReflectionFuzzTest);}}; StandardFrameReflectionFuzzTestRegistrant StandardFrame_reflection_fuzz_test_registrant(REGISTRY);
2351 #endif
2352
2353
SerializeHeader(BitInserter & i)2354 class StandardFrameWithFcsBuilder : public BasicFrameWithFcsBuilder { public: virtual ~StandardFrameWithFcsBuilder() = default;protected:void SerializeHeader(BitInserter& i ) const {BasicFrameWithFcsBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(frame_type_), i, 1);}
2355
2356 void SerializeFooter(BitInserter& i ) const {BasicFrameWithFcsBuilder::SerializeFooter(i);}
2357
2358 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2359
2360 protected:size_t BitsOfHeader() const {return 0 + BasicFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0;}
2361
2362 size_t BitsOfFooter() const {return 0 + BasicFrameWithFcsBuilder::BitsOfFooter() ;}
2363
2364 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2365
2366 protected:
2367 explicit StandardFrameWithFcsBuilder(uint16_t channel_id, FrameType frame_type) :BasicFrameWithFcsBuilder(channel_id) ,frame_type_(frame_type) {}
2368
2369
2370 FrameType frame_type_{};};
2371 #ifdef PACKET_TESTING
2372 #define DEFINE_AND_INSTANTIATE_StandardFrameWithFcsReflectionTest(...)class StandardFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardFrameWithFcsView view = StandardFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardFrameWithFcs_reflection, StandardFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2373 #endif
2374 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2375 #define DEFINE_StandardFrameWithFcsReflectionFuzzTest() void RunStandardFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardFrameWithFcsView view = StandardFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2376 #endif
2377
2378 #ifdef PACKET_FUZZ_TESTING
2379 #define DEFINE_AND_REGISTER_StandardFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_StandardFrameWithFcsReflectionFuzzTest(); class StandardFrameWithFcsReflectionFuzzTestRegistrant {public: explicit StandardFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardFrameWithFcsReflectionFuzzTest);}}; StandardFrameWithFcsReflectionFuzzTestRegistrant StandardFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2380 #endif
2381
2382
Create(uint16_t channel_id,SupervisoryFunction s,RetransmissionDisable r,uint8_t req_seq)2383 class StandardSupervisoryFrameBuilder : public StandardFrameBuilder { public: virtual ~StandardSupervisoryFrameBuilder() = default;static std::unique_ptr<StandardSupervisoryFrameBuilder> Create(uint16_t channel_id, SupervisoryFunction s, RetransmissionDisable r, uint8_t req_seq) {auto builder = std::unique_ptr<StandardSupervisoryFrameBuilder>(new StandardSupervisoryFrameBuilder(channel_id, s, r, req_seq));return builder;}
2384
2385 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2386 static std::unique_ptr<StandardSupervisoryFrameBuilder> FromView(StandardSupervisoryFrameView view) {if (!view.IsValid()) return nullptr;return StandardSupervisoryFrameBuilder::Create(view.GetChannelId(), view.GetS(), view.GetR(), view.GetReqSeq());}
2387 #endif
2388
2389 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(0, i , 1);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(0) /* Reserved */, i, 3 );
2390 insert(static_cast<uint8_t>(r_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2391 }
2392
2393 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2394
2395 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2396
2397 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 3 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2398
2399 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2400
2401 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2402
2403 protected:
2404 explicit StandardSupervisoryFrameBuilder(uint16_t channel_id, SupervisoryFunction s, RetransmissionDisable r, uint8_t req_seq) :StandardFrameBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,s_(s),r_(r),req_seq_(req_seq) {CheckParameterValues(req_seq_);}
2405
2406 void CheckParameterValues(uint8_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2407
2408 SupervisoryFunction s_{};RetransmissionDisable r_{};uint8_t req_seq_{};};
2409 #ifdef PACKET_TESTING
2410 #define DEFINE_AND_INSTANTIATE_StandardSupervisoryFrameReflectionTest(...)class StandardSupervisoryFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardSupervisoryFrameView view = StandardSupervisoryFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardSupervisoryFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardSupervisoryFrame_reflection, StandardSupervisoryFrameReflectionTest, testing::Values(__VA_ARGS__))
2411 #endif
2412 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2413 #define DEFINE_StandardSupervisoryFrameReflectionFuzzTest() void RunStandardSupervisoryFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardSupervisoryFrameView view = StandardSupervisoryFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2414 #endif
2415
2416 #ifdef PACKET_FUZZ_TESTING
2417 #define DEFINE_AND_REGISTER_StandardSupervisoryFrameReflectionFuzzTest(REGISTRY) DEFINE_StandardSupervisoryFrameReflectionFuzzTest(); class StandardSupervisoryFrameReflectionFuzzTestRegistrant {public: explicit StandardSupervisoryFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardSupervisoryFrameReflectionFuzzTest);}}; StandardSupervisoryFrameReflectionFuzzTestRegistrant StandardSupervisoryFrame_reflection_fuzz_test_registrant(REGISTRY);
2418 #endif
2419
2420
Create(uint16_t channel_id,SupervisoryFunction s,RetransmissionDisable r,uint8_t req_seq)2421 class StandardSupervisoryFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~StandardSupervisoryFrameWithFcsBuilder() = default;static std::unique_ptr<StandardSupervisoryFrameWithFcsBuilder> Create(uint16_t channel_id, SupervisoryFunction s, RetransmissionDisable r, uint8_t req_seq) {auto builder = std::unique_ptr<StandardSupervisoryFrameWithFcsBuilder>(new StandardSupervisoryFrameWithFcsBuilder(channel_id, s, r, req_seq));return builder;}
2422
2423 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2424 static std::unique_ptr<StandardSupervisoryFrameWithFcsBuilder> FromView(StandardSupervisoryFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return StandardSupervisoryFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetS(), view.GetR(), view.GetReqSeq());}
2425 #endif
2426
2427 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(0, i , 1);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(0) /* Reserved */, i, 3 );
2428 insert(static_cast<uint8_t>(r_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2429 }
2430
2431 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2432
2433 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2434
2435 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 3 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2436
2437 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2438
2439 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2440
2441 protected:
2442 explicit StandardSupervisoryFrameWithFcsBuilder(uint16_t channel_id, SupervisoryFunction s, RetransmissionDisable r, uint8_t req_seq) :StandardFrameWithFcsBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,s_(s),r_(r),req_seq_(req_seq) {CheckParameterValues(req_seq_);}
2443
2444 void CheckParameterValues(uint8_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2445
2446 SupervisoryFunction s_{};RetransmissionDisable r_{};uint8_t req_seq_{};};
2447 #ifdef PACKET_TESTING
2448 #define DEFINE_AND_INSTANTIATE_StandardSupervisoryFrameWithFcsReflectionTest(...)class StandardSupervisoryFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardSupervisoryFrameWithFcsView view = StandardSupervisoryFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardSupervisoryFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardSupervisoryFrameWithFcs_reflection, StandardSupervisoryFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2449 #endif
2450 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2451 #define DEFINE_StandardSupervisoryFrameWithFcsReflectionFuzzTest() void RunStandardSupervisoryFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardSupervisoryFrameWithFcsView view = StandardSupervisoryFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2452 #endif
2453
2454 #ifdef PACKET_FUZZ_TESTING
2455 #define DEFINE_AND_REGISTER_StandardSupervisoryFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_StandardSupervisoryFrameWithFcsReflectionFuzzTest(); class StandardSupervisoryFrameWithFcsReflectionFuzzTestRegistrant {public: explicit StandardSupervisoryFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardSupervisoryFrameWithFcsReflectionFuzzTest);}}; StandardSupervisoryFrameWithFcsReflectionFuzzTestRegistrant StandardSupervisoryFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2456 #endif
2457
2458
Create(uint16_t channel_id,uint8_t tx_seq,RetransmissionDisable r,uint8_t req_seq,SegmentationAndReassembly sar,std::unique_ptr<BasePacketBuilder> payload)2459 class StandardInformationFrameBuilder : public StandardFrameBuilder { public: virtual ~StandardInformationFrameBuilder() = default;static std::unique_ptr<StandardInformationFrameBuilder> Create(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, SegmentationAndReassembly sar, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<StandardInformationFrameBuilder>(new StandardInformationFrameBuilder(channel_id, tx_seq, r, req_seq, sar));builder->payload_ = std::move(payload);return builder;}
2460
2461 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2462 static std::unique_ptr<StandardInformationFrameBuilder> FromView(StandardInformationFrameView view) {if (!view.IsValid()) return nullptr;return StandardInformationFrameBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetR(), view.GetReqSeq(), view.GetSar(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2463 #endif
2464
2465 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(tx_seq_, i,6);insert(static_cast<uint8_t>(r_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(sar_), i, 2);}
2466
2467 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2468
2469 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2470
2471 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2472
2473 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2474
2475 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2476
2477 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2478
2479 protected:
2480 explicit StandardInformationFrameBuilder(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, SegmentationAndReassembly sar) :StandardFrameBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,tx_seq_(tx_seq),r_(r),req_seq_(req_seq),sar_(sar) {CheckParameterValues(tx_seq_, req_seq_);}
2481
2482 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2483
2484 uint8_t tx_seq_{};RetransmissionDisable r_{};uint8_t req_seq_{};SegmentationAndReassembly sar_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2485 #ifdef PACKET_TESTING
2486 #define DEFINE_AND_INSTANTIATE_StandardInformationFrameReflectionTest(...)class StandardInformationFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardInformationFrameView view = StandardInformationFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardInformationFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardInformationFrame_reflection, StandardInformationFrameReflectionTest, testing::Values(__VA_ARGS__))
2487 #endif
2488 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2489 #define DEFINE_StandardInformationFrameReflectionFuzzTest() void RunStandardInformationFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardInformationFrameView view = StandardInformationFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2490 #endif
2491
2492 #ifdef PACKET_FUZZ_TESTING
2493 #define DEFINE_AND_REGISTER_StandardInformationFrameReflectionFuzzTest(REGISTRY) DEFINE_StandardInformationFrameReflectionFuzzTest(); class StandardInformationFrameReflectionFuzzTestRegistrant {public: explicit StandardInformationFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardInformationFrameReflectionFuzzTest);}}; StandardInformationFrameReflectionFuzzTestRegistrant StandardInformationFrame_reflection_fuzz_test_registrant(REGISTRY);
2494 #endif
2495
2496
Create(uint16_t channel_id,uint8_t tx_seq,RetransmissionDisable r,uint8_t req_seq,SegmentationAndReassembly sar,std::unique_ptr<BasePacketBuilder> payload)2497 class StandardInformationFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~StandardInformationFrameWithFcsBuilder() = default;static std::unique_ptr<StandardInformationFrameWithFcsBuilder> Create(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, SegmentationAndReassembly sar, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<StandardInformationFrameWithFcsBuilder>(new StandardInformationFrameWithFcsBuilder(channel_id, tx_seq, r, req_seq, sar));builder->payload_ = std::move(payload);return builder;}
2498
2499 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2500 static std::unique_ptr<StandardInformationFrameWithFcsBuilder> FromView(StandardInformationFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return StandardInformationFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetR(), view.GetReqSeq(), view.GetSar(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2501 #endif
2502
2503 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(tx_seq_, i,6);insert(static_cast<uint8_t>(r_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(sar_), i, 2);}
2504
2505 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2506
2507 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2508
2509 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2510
2511 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2512
2513 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2514
2515 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2516
2517 protected:
2518 explicit StandardInformationFrameWithFcsBuilder(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, SegmentationAndReassembly sar) :StandardFrameWithFcsBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,tx_seq_(tx_seq),r_(r),req_seq_(req_seq),sar_(sar) {CheckParameterValues(tx_seq_, req_seq_);}
2519
2520 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2521
2522 uint8_t tx_seq_{};RetransmissionDisable r_{};uint8_t req_seq_{};SegmentationAndReassembly sar_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2523 #ifdef PACKET_TESTING
2524 #define DEFINE_AND_INSTANTIATE_StandardInformationFrameWithFcsReflectionTest(...)class StandardInformationFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardInformationFrameWithFcsView view = StandardInformationFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardInformationFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardInformationFrameWithFcs_reflection, StandardInformationFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2525 #endif
2526 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2527 #define DEFINE_StandardInformationFrameWithFcsReflectionFuzzTest() void RunStandardInformationFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardInformationFrameWithFcsView view = StandardInformationFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2528 #endif
2529
2530 #ifdef PACKET_FUZZ_TESTING
2531 #define DEFINE_AND_REGISTER_StandardInformationFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_StandardInformationFrameWithFcsReflectionFuzzTest(); class StandardInformationFrameWithFcsReflectionFuzzTestRegistrant {public: explicit StandardInformationFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardInformationFrameWithFcsReflectionFuzzTest);}}; StandardInformationFrameWithFcsReflectionFuzzTestRegistrant StandardInformationFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2532 #endif
2533
2534
Create(uint16_t channel_id,uint8_t tx_seq,RetransmissionDisable r,uint8_t req_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)2535 class StandardInformationStartFrameBuilder : public StandardInformationFrameBuilder { public: virtual ~StandardInformationStartFrameBuilder() = default;static std::unique_ptr<StandardInformationStartFrameBuilder> Create(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<StandardInformationStartFrameBuilder>(new StandardInformationStartFrameBuilder(channel_id, tx_seq, r, req_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
2536
2537 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2538 static std::unique_ptr<StandardInformationStartFrameBuilder> FromView(StandardInformationStartFrameView view) {if (!view.IsValid()) return nullptr;return StandardInformationStartFrameBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetR(), view.GetReqSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2539 #endif
2540
2541 protected:void SerializeHeader(BitInserter& i ) const {StandardInformationFrameBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
2542
2543 void SerializeFooter(BitInserter& i ) const {StandardInformationFrameBuilder::SerializeFooter(i);}
2544
2545 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2546
2547 protected:size_t BitsOfHeader() const {return 0 + StandardInformationFrameBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
2548
2549 size_t BitsOfFooter() const {return 0 + StandardInformationFrameBuilder::BitsOfFooter() ;}
2550
2551 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2552
2553 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2554
2555 protected:
2556 explicit StandardInformationStartFrameBuilder(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, uint16_t l2cap_sdu_length) :StandardInformationFrameBuilder(channel_id, tx_seq, r, req_seq, SegmentationAndReassembly::START/* sar_ */) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(tx_seq_, req_seq_);}
2557
2558 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2559
2560 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2561 #ifdef PACKET_TESTING
2562 #define DEFINE_AND_INSTANTIATE_StandardInformationStartFrameReflectionTest(...)class StandardInformationStartFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardInformationStartFrameView view = StandardInformationStartFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardInformationStartFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardInformationStartFrame_reflection, StandardInformationStartFrameReflectionTest, testing::Values(__VA_ARGS__))
2563 #endif
2564 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2565 #define DEFINE_StandardInformationStartFrameReflectionFuzzTest() void RunStandardInformationStartFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardInformationStartFrameView view = StandardInformationStartFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2566 #endif
2567
2568 #ifdef PACKET_FUZZ_TESTING
2569 #define DEFINE_AND_REGISTER_StandardInformationStartFrameReflectionFuzzTest(REGISTRY) DEFINE_StandardInformationStartFrameReflectionFuzzTest(); class StandardInformationStartFrameReflectionFuzzTestRegistrant {public: explicit StandardInformationStartFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardInformationStartFrameReflectionFuzzTest);}}; StandardInformationStartFrameReflectionFuzzTestRegistrant StandardInformationStartFrame_reflection_fuzz_test_registrant(REGISTRY);
2570 #endif
2571
2572
Create(uint16_t channel_id,uint8_t tx_seq,RetransmissionDisable r,uint8_t req_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)2573 class StandardInformationStartFrameWithFcsBuilder : public StandardInformationFrameWithFcsBuilder { public: virtual ~StandardInformationStartFrameWithFcsBuilder() = default;static std::unique_ptr<StandardInformationStartFrameWithFcsBuilder> Create(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<StandardInformationStartFrameWithFcsBuilder>(new StandardInformationStartFrameWithFcsBuilder(channel_id, tx_seq, r, req_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
2574
2575 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2576 static std::unique_ptr<StandardInformationStartFrameWithFcsBuilder> FromView(StandardInformationStartFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return StandardInformationStartFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetR(), view.GetReqSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2577 #endif
2578
2579 protected:void SerializeHeader(BitInserter& i ) const {StandardInformationFrameWithFcsBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
2580
2581 void SerializeFooter(BitInserter& i ) const {StandardInformationFrameWithFcsBuilder::SerializeFooter(i);}
2582
2583 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2584
2585 protected:size_t BitsOfHeader() const {return 0 + StandardInformationFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
2586
2587 size_t BitsOfFooter() const {return 0 + StandardInformationFrameWithFcsBuilder::BitsOfFooter() ;}
2588
2589 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2590
2591 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2592
2593 protected:
2594 explicit StandardInformationStartFrameWithFcsBuilder(uint16_t channel_id, uint8_t tx_seq, RetransmissionDisable r, uint8_t req_seq, uint16_t l2cap_sdu_length) :StandardInformationFrameWithFcsBuilder(channel_id, tx_seq, r, req_seq, SegmentationAndReassembly::START/* sar_ */) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(tx_seq_, req_seq_);}
2595
2596 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2597
2598 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2599 #ifdef PACKET_TESTING
2600 #define DEFINE_AND_INSTANTIATE_StandardInformationStartFrameWithFcsReflectionTest(...)class StandardInformationStartFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {StandardInformationStartFrameWithFcsView view = StandardInformationStartFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = StandardInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(StandardInformationStartFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(StandardInformationStartFrameWithFcs_reflection, StandardInformationStartFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2601 #endif
2602 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2603 #define DEFINE_StandardInformationStartFrameWithFcsReflectionFuzzTest() void RunStandardInformationStartFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);StandardInformationStartFrameWithFcsView view = StandardInformationStartFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = StandardInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2604 #endif
2605
2606 #ifdef PACKET_FUZZ_TESTING
2607 #define DEFINE_AND_REGISTER_StandardInformationStartFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_StandardInformationStartFrameWithFcsReflectionFuzzTest(); class StandardInformationStartFrameWithFcsReflectionFuzzTestRegistrant {public: explicit StandardInformationStartFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunStandardInformationStartFrameWithFcsReflectionFuzzTest);}}; StandardInformationStartFrameWithFcsReflectionFuzzTestRegistrant StandardInformationStartFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2608 #endif
2609
2610
Create(uint16_t channel_id,SupervisoryFunction s,Poll p,Final f,uint8_t req_seq)2611 class EnhancedSupervisoryFrameBuilder : public StandardFrameBuilder { public: virtual ~EnhancedSupervisoryFrameBuilder() = default;static std::unique_ptr<EnhancedSupervisoryFrameBuilder> Create(uint16_t channel_id, SupervisoryFunction s, Poll p, Final f, uint8_t req_seq) {auto builder = std::unique_ptr<EnhancedSupervisoryFrameBuilder>(new EnhancedSupervisoryFrameBuilder(channel_id, s, p, f, req_seq));return builder;}
2612
2613 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2614 static std::unique_ptr<EnhancedSupervisoryFrameBuilder> FromView(EnhancedSupervisoryFrameView view) {if (!view.IsValid()) return nullptr;return EnhancedSupervisoryFrameBuilder::Create(view.GetChannelId(), view.GetS(), view.GetP(), view.GetF(), view.GetReqSeq());}
2615 #endif
2616
2617 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(0, i , 1);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(p_), i, 1);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2618 insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2619 }
2620
2621 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2622
2623 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2624
2625 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2626
2627 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2628
2629 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2630
2631 protected:
2632 explicit EnhancedSupervisoryFrameBuilder(uint16_t channel_id, SupervisoryFunction s, Poll p, Final f, uint8_t req_seq) :StandardFrameBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,s_(s),p_(p),f_(f),req_seq_(req_seq) {CheckParameterValues(req_seq_);}
2633
2634 void CheckParameterValues(uint8_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2635
2636 SupervisoryFunction s_{};Poll p_{};Final f_{};uint8_t req_seq_{};};
2637 #ifdef PACKET_TESTING
2638 #define DEFINE_AND_INSTANTIATE_EnhancedSupervisoryFrameReflectionTest(...)class EnhancedSupervisoryFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedSupervisoryFrameView view = EnhancedSupervisoryFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedSupervisoryFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedSupervisoryFrame_reflection, EnhancedSupervisoryFrameReflectionTest, testing::Values(__VA_ARGS__))
2639 #endif
2640 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2641 #define DEFINE_EnhancedSupervisoryFrameReflectionFuzzTest() void RunEnhancedSupervisoryFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedSupervisoryFrameView view = EnhancedSupervisoryFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2642 #endif
2643
2644 #ifdef PACKET_FUZZ_TESTING
2645 #define DEFINE_AND_REGISTER_EnhancedSupervisoryFrameReflectionFuzzTest(REGISTRY) DEFINE_EnhancedSupervisoryFrameReflectionFuzzTest(); class EnhancedSupervisoryFrameReflectionFuzzTestRegistrant {public: explicit EnhancedSupervisoryFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedSupervisoryFrameReflectionFuzzTest);}}; EnhancedSupervisoryFrameReflectionFuzzTestRegistrant EnhancedSupervisoryFrame_reflection_fuzz_test_registrant(REGISTRY);
2646 #endif
2647
2648
Create(uint16_t channel_id,SupervisoryFunction s,Poll p,Final f,uint8_t req_seq)2649 class EnhancedSupervisoryFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~EnhancedSupervisoryFrameWithFcsBuilder() = default;static std::unique_ptr<EnhancedSupervisoryFrameWithFcsBuilder> Create(uint16_t channel_id, SupervisoryFunction s, Poll p, Final f, uint8_t req_seq) {auto builder = std::unique_ptr<EnhancedSupervisoryFrameWithFcsBuilder>(new EnhancedSupervisoryFrameWithFcsBuilder(channel_id, s, p, f, req_seq));return builder;}
2650
2651 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2652 static std::unique_ptr<EnhancedSupervisoryFrameWithFcsBuilder> FromView(EnhancedSupervisoryFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return EnhancedSupervisoryFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetS(), view.GetP(), view.GetF(), view.GetReqSeq());}
2653 #endif
2654
2655 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(0, i , 1);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(p_), i, 1);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2656 insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(0) /* Reserved */, i, 2 );
2657 }
2658
2659 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2660
2661 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2662
2663 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2664
2665 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2666
2667 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2668
2669 protected:
2670 explicit EnhancedSupervisoryFrameWithFcsBuilder(uint16_t channel_id, SupervisoryFunction s, Poll p, Final f, uint8_t req_seq) :StandardFrameWithFcsBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,s_(s),p_(p),f_(f),req_seq_(req_seq) {CheckParameterValues(req_seq_);}
2671
2672 void CheckParameterValues(uint8_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2673
2674 SupervisoryFunction s_{};Poll p_{};Final f_{};uint8_t req_seq_{};};
2675 #ifdef PACKET_TESTING
2676 #define DEFINE_AND_INSTANTIATE_EnhancedSupervisoryFrameWithFcsReflectionTest(...)class EnhancedSupervisoryFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedSupervisoryFrameWithFcsView view = EnhancedSupervisoryFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedSupervisoryFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedSupervisoryFrameWithFcs_reflection, EnhancedSupervisoryFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2677 #endif
2678 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2679 #define DEFINE_EnhancedSupervisoryFrameWithFcsReflectionFuzzTest() void RunEnhancedSupervisoryFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedSupervisoryFrameWithFcsView view = EnhancedSupervisoryFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2680 #endif
2681
2682 #ifdef PACKET_FUZZ_TESTING
2683 #define DEFINE_AND_REGISTER_EnhancedSupervisoryFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_EnhancedSupervisoryFrameWithFcsReflectionFuzzTest(); class EnhancedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant {public: explicit EnhancedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedSupervisoryFrameWithFcsReflectionFuzzTest);}}; EnhancedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant EnhancedSupervisoryFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2684 #endif
2685
2686
Create(uint16_t channel_id,uint8_t tx_seq,Final f,uint8_t req_seq,SegmentationAndReassembly sar,std::unique_ptr<BasePacketBuilder> payload)2687 class EnhancedInformationFrameBuilder : public StandardFrameBuilder { public: virtual ~EnhancedInformationFrameBuilder() = default;static std::unique_ptr<EnhancedInformationFrameBuilder> Create(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, SegmentationAndReassembly sar, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EnhancedInformationFrameBuilder>(new EnhancedInformationFrameBuilder(channel_id, tx_seq, f, req_seq, sar));builder->payload_ = std::move(payload);return builder;}
2688
2689 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2690 static std::unique_ptr<EnhancedInformationFrameBuilder> FromView(EnhancedInformationFrameView view) {if (!view.IsValid()) return nullptr;return EnhancedInformationFrameBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetF(), view.GetReqSeq(), view.GetSar(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2691 #endif
2692
2693 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(tx_seq_, i,6);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(sar_), i, 2);}
2694
2695 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2696
2697 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2698
2699 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2700
2701 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2702
2703 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2704
2705 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2706
2707 protected:
2708 explicit EnhancedInformationFrameBuilder(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, SegmentationAndReassembly sar) :StandardFrameBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,tx_seq_(tx_seq),f_(f),req_seq_(req_seq),sar_(sar) {CheckParameterValues(tx_seq_, req_seq_);}
2709
2710 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2711
2712 uint8_t tx_seq_{};Final f_{};uint8_t req_seq_{};SegmentationAndReassembly sar_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2713 #ifdef PACKET_TESTING
2714 #define DEFINE_AND_INSTANTIATE_EnhancedInformationFrameReflectionTest(...)class EnhancedInformationFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedInformationFrameView view = EnhancedInformationFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedInformationFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedInformationFrame_reflection, EnhancedInformationFrameReflectionTest, testing::Values(__VA_ARGS__))
2715 #endif
2716 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2717 #define DEFINE_EnhancedInformationFrameReflectionFuzzTest() void RunEnhancedInformationFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedInformationFrameView view = EnhancedInformationFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2718 #endif
2719
2720 #ifdef PACKET_FUZZ_TESTING
2721 #define DEFINE_AND_REGISTER_EnhancedInformationFrameReflectionFuzzTest(REGISTRY) DEFINE_EnhancedInformationFrameReflectionFuzzTest(); class EnhancedInformationFrameReflectionFuzzTestRegistrant {public: explicit EnhancedInformationFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedInformationFrameReflectionFuzzTest);}}; EnhancedInformationFrameReflectionFuzzTestRegistrant EnhancedInformationFrame_reflection_fuzz_test_registrant(REGISTRY);
2722 #endif
2723
2724
Create(uint16_t channel_id,uint8_t tx_seq,Final f,uint8_t req_seq,SegmentationAndReassembly sar,std::unique_ptr<BasePacketBuilder> payload)2725 class EnhancedInformationFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~EnhancedInformationFrameWithFcsBuilder() = default;static std::unique_ptr<EnhancedInformationFrameWithFcsBuilder> Create(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, SegmentationAndReassembly sar, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EnhancedInformationFrameWithFcsBuilder>(new EnhancedInformationFrameWithFcsBuilder(channel_id, tx_seq, f, req_seq, sar));builder->payload_ = std::move(payload);return builder;}
2726
2727 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2728 static std::unique_ptr<EnhancedInformationFrameWithFcsBuilder> FromView(EnhancedInformationFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return EnhancedInformationFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetF(), view.GetReqSeq(), view.GetSar(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2729 #endif
2730
2731 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(tx_seq_, i,6);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,6);insert(static_cast<uint8_t>(sar_), i, 2);}
2732
2733 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2734
2735 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2736
2737 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 6 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0;}
2738
2739 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2740
2741 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2742
2743 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2744
2745 protected:
2746 explicit EnhancedInformationFrameWithFcsBuilder(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, SegmentationAndReassembly sar) :StandardFrameWithFcsBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,tx_seq_(tx_seq),f_(f),req_seq_(req_seq),sar_(sar) {CheckParameterValues(tx_seq_, req_seq_);}
2747
2748 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2749
2750 uint8_t tx_seq_{};Final f_{};uint8_t req_seq_{};SegmentationAndReassembly sar_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2751 #ifdef PACKET_TESTING
2752 #define DEFINE_AND_INSTANTIATE_EnhancedInformationFrameWithFcsReflectionTest(...)class EnhancedInformationFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedInformationFrameWithFcsView view = EnhancedInformationFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedInformationFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedInformationFrameWithFcs_reflection, EnhancedInformationFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2753 #endif
2754 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2755 #define DEFINE_EnhancedInformationFrameWithFcsReflectionFuzzTest() void RunEnhancedInformationFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedInformationFrameWithFcsView view = EnhancedInformationFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2756 #endif
2757
2758 #ifdef PACKET_FUZZ_TESTING
2759 #define DEFINE_AND_REGISTER_EnhancedInformationFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_EnhancedInformationFrameWithFcsReflectionFuzzTest(); class EnhancedInformationFrameWithFcsReflectionFuzzTestRegistrant {public: explicit EnhancedInformationFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedInformationFrameWithFcsReflectionFuzzTest);}}; EnhancedInformationFrameWithFcsReflectionFuzzTestRegistrant EnhancedInformationFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2760 #endif
2761
2762
Create(uint16_t channel_id,uint8_t tx_seq,Final f,uint8_t req_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)2763 class EnhancedInformationStartFrameBuilder : public EnhancedInformationFrameBuilder { public: virtual ~EnhancedInformationStartFrameBuilder() = default;static std::unique_ptr<EnhancedInformationStartFrameBuilder> Create(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EnhancedInformationStartFrameBuilder>(new EnhancedInformationStartFrameBuilder(channel_id, tx_seq, f, req_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
2764
2765 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2766 static std::unique_ptr<EnhancedInformationStartFrameBuilder> FromView(EnhancedInformationStartFrameView view) {if (!view.IsValid()) return nullptr;return EnhancedInformationStartFrameBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetF(), view.GetReqSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2767 #endif
2768
2769 protected:void SerializeHeader(BitInserter& i ) const {EnhancedInformationFrameBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
2770
2771 void SerializeFooter(BitInserter& i ) const {EnhancedInformationFrameBuilder::SerializeFooter(i);}
2772
2773 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2774
2775 protected:size_t BitsOfHeader() const {return 0 + EnhancedInformationFrameBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
2776
2777 size_t BitsOfFooter() const {return 0 + EnhancedInformationFrameBuilder::BitsOfFooter() ;}
2778
2779 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2780
2781 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2782
2783 protected:
2784 explicit EnhancedInformationStartFrameBuilder(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, uint16_t l2cap_sdu_length) :EnhancedInformationFrameBuilder(channel_id, tx_seq, f, req_seq, SegmentationAndReassembly::START/* sar_ */) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(tx_seq_, req_seq_);}
2785
2786 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2787
2788 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2789 #ifdef PACKET_TESTING
2790 #define DEFINE_AND_INSTANTIATE_EnhancedInformationStartFrameReflectionTest(...)class EnhancedInformationStartFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedInformationStartFrameView view = EnhancedInformationStartFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedInformationStartFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedInformationStartFrame_reflection, EnhancedInformationStartFrameReflectionTest, testing::Values(__VA_ARGS__))
2791 #endif
2792 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2793 #define DEFINE_EnhancedInformationStartFrameReflectionFuzzTest() void RunEnhancedInformationStartFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedInformationStartFrameView view = EnhancedInformationStartFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2794 #endif
2795
2796 #ifdef PACKET_FUZZ_TESTING
2797 #define DEFINE_AND_REGISTER_EnhancedInformationStartFrameReflectionFuzzTest(REGISTRY) DEFINE_EnhancedInformationStartFrameReflectionFuzzTest(); class EnhancedInformationStartFrameReflectionFuzzTestRegistrant {public: explicit EnhancedInformationStartFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedInformationStartFrameReflectionFuzzTest);}}; EnhancedInformationStartFrameReflectionFuzzTestRegistrant EnhancedInformationStartFrame_reflection_fuzz_test_registrant(REGISTRY);
2798 #endif
2799
2800
Create(uint16_t channel_id,uint8_t tx_seq,Final f,uint8_t req_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)2801 class EnhancedInformationStartFrameWithFcsBuilder : public EnhancedInformationFrameWithFcsBuilder { public: virtual ~EnhancedInformationStartFrameWithFcsBuilder() = default;static std::unique_ptr<EnhancedInformationStartFrameWithFcsBuilder> Create(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EnhancedInformationStartFrameWithFcsBuilder>(new EnhancedInformationStartFrameWithFcsBuilder(channel_id, tx_seq, f, req_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
2802
2803 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2804 static std::unique_ptr<EnhancedInformationStartFrameWithFcsBuilder> FromView(EnhancedInformationStartFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return EnhancedInformationStartFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetTxSeq(), view.GetF(), view.GetReqSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2805 #endif
2806
2807 protected:void SerializeHeader(BitInserter& i ) const {EnhancedInformationFrameWithFcsBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
2808
2809 void SerializeFooter(BitInserter& i ) const {EnhancedInformationFrameWithFcsBuilder::SerializeFooter(i);}
2810
2811 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2812
2813 protected:size_t BitsOfHeader() const {return 0 + EnhancedInformationFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
2814
2815 size_t BitsOfFooter() const {return 0 + EnhancedInformationFrameWithFcsBuilder::BitsOfFooter() ;}
2816
2817 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2818
2819 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2820
2821 protected:
2822 explicit EnhancedInformationStartFrameWithFcsBuilder(uint16_t channel_id, uint8_t tx_seq, Final f, uint8_t req_seq, uint16_t l2cap_sdu_length) :EnhancedInformationFrameWithFcsBuilder(channel_id, tx_seq, f, req_seq, SegmentationAndReassembly::START/* sar_ */) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(tx_seq_, req_seq_);}
2823
2824 void CheckParameterValues(uint8_t tx_seq, uint8_t req_seq) {ASSERT(tx_seq < (static_cast<uint64_t>(1) << 6));ASSERT(req_seq < (static_cast<uint64_t>(1) << 6));}
2825
2826 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2827 #ifdef PACKET_TESTING
2828 #define DEFINE_AND_INSTANTIATE_EnhancedInformationStartFrameWithFcsReflectionTest(...)class EnhancedInformationStartFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EnhancedInformationStartFrameWithFcsView view = EnhancedInformationStartFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EnhancedInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EnhancedInformationStartFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EnhancedInformationStartFrameWithFcs_reflection, EnhancedInformationStartFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2829 #endif
2830 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2831 #define DEFINE_EnhancedInformationStartFrameWithFcsReflectionFuzzTest() void RunEnhancedInformationStartFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EnhancedInformationStartFrameWithFcsView view = EnhancedInformationStartFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EnhancedInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2832 #endif
2833
2834 #ifdef PACKET_FUZZ_TESTING
2835 #define DEFINE_AND_REGISTER_EnhancedInformationStartFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_EnhancedInformationStartFrameWithFcsReflectionFuzzTest(); class EnhancedInformationStartFrameWithFcsReflectionFuzzTestRegistrant {public: explicit EnhancedInformationStartFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEnhancedInformationStartFrameWithFcsReflectionFuzzTest);}}; EnhancedInformationStartFrameWithFcsReflectionFuzzTestRegistrant EnhancedInformationStartFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2836 #endif
2837
2838
Create(uint16_t channel_id,Final f,uint16_t req_seq,SupervisoryFunction s,Poll p)2839 class ExtendedSupervisoryFrameBuilder : public StandardFrameBuilder { public: virtual ~ExtendedSupervisoryFrameBuilder() = default;static std::unique_ptr<ExtendedSupervisoryFrameBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, SupervisoryFunction s, Poll p) {auto builder = std::unique_ptr<ExtendedSupervisoryFrameBuilder>(new ExtendedSupervisoryFrameBuilder(channel_id, f, req_seq, s, p));return builder;}
2840
2841 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2842 static std::unique_ptr<ExtendedSupervisoryFrameBuilder> FromView(ExtendedSupervisoryFrameView view) {if (!view.IsValid()) return nullptr;return ExtendedSupervisoryFrameBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetS(), view.GetP());}
2843 #endif
2844
2845 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,14);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(p_), i, 1);insert(static_cast<uint8_t>(0) /* Reserved */, i, 5 );
2846 insert(static_cast<uint8_t>(0) /* Reserved */, i, 8 );
2847 }
2848
2849 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2850
2851 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2852
2853 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 5 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0;}
2854
2855 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2856
2857 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2858
2859 protected:
2860 explicit ExtendedSupervisoryFrameBuilder(uint16_t channel_id, Final f, uint16_t req_seq, SupervisoryFunction s, Poll p) :StandardFrameBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,f_(f),req_seq_(req_seq),s_(s),p_(p) {CheckParameterValues(req_seq_);}
2861
2862 void CheckParameterValues(uint16_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));}
2863
2864 Final f_{};uint16_t req_seq_{};SupervisoryFunction s_{};Poll p_{};};
2865 #ifdef PACKET_TESTING
2866 #define DEFINE_AND_INSTANTIATE_ExtendedSupervisoryFrameReflectionTest(...)class ExtendedSupervisoryFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedSupervisoryFrameView view = ExtendedSupervisoryFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedSupervisoryFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedSupervisoryFrame_reflection, ExtendedSupervisoryFrameReflectionTest, testing::Values(__VA_ARGS__))
2867 #endif
2868 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2869 #define DEFINE_ExtendedSupervisoryFrameReflectionFuzzTest() void RunExtendedSupervisoryFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedSupervisoryFrameView view = ExtendedSupervisoryFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedSupervisoryFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2870 #endif
2871
2872 #ifdef PACKET_FUZZ_TESTING
2873 #define DEFINE_AND_REGISTER_ExtendedSupervisoryFrameReflectionFuzzTest(REGISTRY) DEFINE_ExtendedSupervisoryFrameReflectionFuzzTest(); class ExtendedSupervisoryFrameReflectionFuzzTestRegistrant {public: explicit ExtendedSupervisoryFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedSupervisoryFrameReflectionFuzzTest);}}; ExtendedSupervisoryFrameReflectionFuzzTestRegistrant ExtendedSupervisoryFrame_reflection_fuzz_test_registrant(REGISTRY);
2874 #endif
2875
2876
Create(uint16_t channel_id,Final f,uint16_t req_seq,SupervisoryFunction s,Poll p)2877 class ExtendedSupervisoryFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~ExtendedSupervisoryFrameWithFcsBuilder() = default;static std::unique_ptr<ExtendedSupervisoryFrameWithFcsBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, SupervisoryFunction s, Poll p) {auto builder = std::unique_ptr<ExtendedSupervisoryFrameWithFcsBuilder>(new ExtendedSupervisoryFrameWithFcsBuilder(channel_id, f, req_seq, s, p));return builder;}
2878
2879 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2880 static std::unique_ptr<ExtendedSupervisoryFrameWithFcsBuilder> FromView(ExtendedSupervisoryFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return ExtendedSupervisoryFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetS(), view.GetP());}
2881 #endif
2882
2883 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,14);insert(static_cast<uint8_t>(s_), i, 2);insert(static_cast<uint8_t>(p_), i, 1);insert(static_cast<uint8_t>(0) /* Reserved */, i, 5 );
2884 insert(static_cast<uint8_t>(0) /* Reserved */, i, 8 );
2885 }
2886
2887 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2888
2889 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
2890
2891 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 5 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0;}
2892
2893 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2894
2895 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
2896
2897 protected:
2898 explicit ExtendedSupervisoryFrameWithFcsBuilder(uint16_t channel_id, Final f, uint16_t req_seq, SupervisoryFunction s, Poll p) :StandardFrameWithFcsBuilder(channel_id, FrameType::S_FRAME/* frame_type_ */) ,f_(f),req_seq_(req_seq),s_(s),p_(p) {CheckParameterValues(req_seq_);}
2899
2900 void CheckParameterValues(uint16_t req_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));}
2901
2902 Final f_{};uint16_t req_seq_{};SupervisoryFunction s_{};Poll p_{};};
2903 #ifdef PACKET_TESTING
2904 #define DEFINE_AND_INSTANTIATE_ExtendedSupervisoryFrameWithFcsReflectionTest(...)class ExtendedSupervisoryFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedSupervisoryFrameWithFcsView view = ExtendedSupervisoryFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedSupervisoryFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedSupervisoryFrameWithFcs_reflection, ExtendedSupervisoryFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2905 #endif
2906 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2907 #define DEFINE_ExtendedSupervisoryFrameWithFcsReflectionFuzzTest() void RunExtendedSupervisoryFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedSupervisoryFrameWithFcsView view = ExtendedSupervisoryFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedSupervisoryFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2908 #endif
2909
2910 #ifdef PACKET_FUZZ_TESTING
2911 #define DEFINE_AND_REGISTER_ExtendedSupervisoryFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_ExtendedSupervisoryFrameWithFcsReflectionFuzzTest(); class ExtendedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant {public: explicit ExtendedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedSupervisoryFrameWithFcsReflectionFuzzTest);}}; ExtendedSupervisoryFrameWithFcsReflectionFuzzTestRegistrant ExtendedSupervisoryFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2912 #endif
2913
2914
Create(uint16_t channel_id,Final f,uint16_t req_seq,SegmentationAndReassembly sar,uint16_t tx_seq,std::unique_ptr<BasePacketBuilder> payload)2915 class ExtendedInformationFrameBuilder : public StandardFrameBuilder { public: virtual ~ExtendedInformationFrameBuilder() = default;static std::unique_ptr<ExtendedInformationFrameBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, SegmentationAndReassembly sar, uint16_t tx_seq, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ExtendedInformationFrameBuilder>(new ExtendedInformationFrameBuilder(channel_id, f, req_seq, sar, tx_seq));builder->payload_ = std::move(payload);return builder;}
2916
2917 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2918 static std::unique_ptr<ExtendedInformationFrameBuilder> FromView(ExtendedInformationFrameView view) {if (!view.IsValid()) return nullptr;return ExtendedInformationFrameBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetSar(), view.GetTxSeq(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2919 #endif
2920
2921 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,14);insert(static_cast<uint8_t>(sar_), i, 2);insert(tx_seq_, i,14);}
2922
2923 void SerializeFooter(BitInserter& i ) const {StandardFrameBuilder::SerializeFooter(i);}
2924
2925 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2926
2927 protected:size_t BitsOfHeader() const {return 0 + StandardFrameBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0;}
2928
2929 size_t BitsOfFooter() const {return 0 + StandardFrameBuilder::BitsOfFooter() ;}
2930
2931 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2932
2933 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2934
2935 protected:
2936 explicit ExtendedInformationFrameBuilder(uint16_t channel_id, Final f, uint16_t req_seq, SegmentationAndReassembly sar, uint16_t tx_seq) :StandardFrameBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,f_(f),req_seq_(req_seq),sar_(sar),tx_seq_(tx_seq) {CheckParameterValues(req_seq_, tx_seq_);}
2937
2938 void CheckParameterValues(uint16_t req_seq, uint16_t tx_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));ASSERT(tx_seq < (static_cast<uint64_t>(1) << 14));}
2939
2940 Final f_{};uint16_t req_seq_{};SegmentationAndReassembly sar_{};uint16_t tx_seq_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2941 #ifdef PACKET_TESTING
2942 #define DEFINE_AND_INSTANTIATE_ExtendedInformationFrameReflectionTest(...)class ExtendedInformationFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedInformationFrameView view = ExtendedInformationFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedInformationFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedInformationFrame_reflection, ExtendedInformationFrameReflectionTest, testing::Values(__VA_ARGS__))
2943 #endif
2944 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2945 #define DEFINE_ExtendedInformationFrameReflectionFuzzTest() void RunExtendedInformationFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedInformationFrameView view = ExtendedInformationFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2946 #endif
2947
2948 #ifdef PACKET_FUZZ_TESTING
2949 #define DEFINE_AND_REGISTER_ExtendedInformationFrameReflectionFuzzTest(REGISTRY) DEFINE_ExtendedInformationFrameReflectionFuzzTest(); class ExtendedInformationFrameReflectionFuzzTestRegistrant {public: explicit ExtendedInformationFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedInformationFrameReflectionFuzzTest);}}; ExtendedInformationFrameReflectionFuzzTestRegistrant ExtendedInformationFrame_reflection_fuzz_test_registrant(REGISTRY);
2950 #endif
2951
2952
Create(uint16_t channel_id,Final f,uint16_t req_seq,SegmentationAndReassembly sar,uint16_t tx_seq,std::unique_ptr<BasePacketBuilder> payload)2953 class ExtendedInformationFrameWithFcsBuilder : public StandardFrameWithFcsBuilder { public: virtual ~ExtendedInformationFrameWithFcsBuilder() = default;static std::unique_ptr<ExtendedInformationFrameWithFcsBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, SegmentationAndReassembly sar, uint16_t tx_seq, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ExtendedInformationFrameWithFcsBuilder>(new ExtendedInformationFrameWithFcsBuilder(channel_id, f, req_seq, sar, tx_seq));builder->payload_ = std::move(payload);return builder;}
2954
2955 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2956 static std::unique_ptr<ExtendedInformationFrameWithFcsBuilder> FromView(ExtendedInformationFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return ExtendedInformationFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetSar(), view.GetTxSeq(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2957 #endif
2958
2959 protected:void SerializeHeader(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeHeader(i);insert(static_cast<uint8_t>(f_), i, 1);insert(req_seq_, i,14);insert(static_cast<uint8_t>(sar_), i, 2);insert(tx_seq_, i,14);}
2960
2961 void SerializeFooter(BitInserter& i ) const {StandardFrameWithFcsBuilder::SerializeFooter(i);}
2962
2963 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
2964
2965 protected:size_t BitsOfHeader() const {return 0 + StandardFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0 + /* Bits: */ 2 + /* Dynamic: */ 0 + /* Bits: */ 14 + /* Dynamic: */ 0;}
2966
2967 size_t BitsOfFooter() const {return 0 + StandardFrameWithFcsBuilder::BitsOfFooter() ;}
2968
2969 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
2970
2971 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
2972
2973 protected:
2974 explicit ExtendedInformationFrameWithFcsBuilder(uint16_t channel_id, Final f, uint16_t req_seq, SegmentationAndReassembly sar, uint16_t tx_seq) :StandardFrameWithFcsBuilder(channel_id, FrameType::I_FRAME/* frame_type_ */) ,f_(f),req_seq_(req_seq),sar_(sar),tx_seq_(tx_seq) {CheckParameterValues(req_seq_, tx_seq_);}
2975
2976 void CheckParameterValues(uint16_t req_seq, uint16_t tx_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));ASSERT(tx_seq < (static_cast<uint64_t>(1) << 14));}
2977
2978 Final f_{};uint16_t req_seq_{};SegmentationAndReassembly sar_{};uint16_t tx_seq_{};std::unique_ptr<BasePacketBuilder> payload_{};};
2979 #ifdef PACKET_TESTING
2980 #define DEFINE_AND_INSTANTIATE_ExtendedInformationFrameWithFcsReflectionTest(...)class ExtendedInformationFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedInformationFrameWithFcsView view = ExtendedInformationFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedInformationFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedInformationFrameWithFcs_reflection, ExtendedInformationFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
2981 #endif
2982 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
2983 #define DEFINE_ExtendedInformationFrameWithFcsReflectionFuzzTest() void RunExtendedInformationFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedInformationFrameWithFcsView view = ExtendedInformationFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedInformationFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
2984 #endif
2985
2986 #ifdef PACKET_FUZZ_TESTING
2987 #define DEFINE_AND_REGISTER_ExtendedInformationFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_ExtendedInformationFrameWithFcsReflectionFuzzTest(); class ExtendedInformationFrameWithFcsReflectionFuzzTestRegistrant {public: explicit ExtendedInformationFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedInformationFrameWithFcsReflectionFuzzTest);}}; ExtendedInformationFrameWithFcsReflectionFuzzTestRegistrant ExtendedInformationFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
2988 #endif
2989
2990
Create(uint16_t channel_id,Final f,uint16_t req_seq,uint16_t tx_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)2991 class ExtendedInformationStartFrameBuilder : public ExtendedInformationFrameBuilder { public: virtual ~ExtendedInformationStartFrameBuilder() = default;static std::unique_ptr<ExtendedInformationStartFrameBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, uint16_t tx_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ExtendedInformationStartFrameBuilder>(new ExtendedInformationStartFrameBuilder(channel_id, f, req_seq, tx_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
2992
2993 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
2994 static std::unique_ptr<ExtendedInformationStartFrameBuilder> FromView(ExtendedInformationStartFrameView view) {if (!view.IsValid()) return nullptr;return ExtendedInformationStartFrameBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetTxSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
2995 #endif
2996
2997 protected:void SerializeHeader(BitInserter& i ) const {ExtendedInformationFrameBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
2998
2999 void SerializeFooter(BitInserter& i ) const {ExtendedInformationFrameBuilder::SerializeFooter(i);}
3000
3001 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3002
3003 protected:size_t BitsOfHeader() const {return 0 + ExtendedInformationFrameBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3004
3005 size_t BitsOfFooter() const {return 0 + ExtendedInformationFrameBuilder::BitsOfFooter() ;}
3006
3007 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3008
3009 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3010
3011 protected:
3012 explicit ExtendedInformationStartFrameBuilder(uint16_t channel_id, Final f, uint16_t req_seq, uint16_t tx_seq, uint16_t l2cap_sdu_length) :ExtendedInformationFrameBuilder(channel_id, f, req_seq, SegmentationAndReassembly::START/* sar_ */, tx_seq) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(req_seq_, tx_seq_);}
3013
3014 void CheckParameterValues(uint16_t req_seq, uint16_t tx_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));ASSERT(tx_seq < (static_cast<uint64_t>(1) << 14));}
3015
3016 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
3017 #ifdef PACKET_TESTING
3018 #define DEFINE_AND_INSTANTIATE_ExtendedInformationStartFrameReflectionTest(...)class ExtendedInformationStartFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedInformationStartFrameView view = ExtendedInformationStartFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedInformationStartFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedInformationStartFrame_reflection, ExtendedInformationStartFrameReflectionTest, testing::Values(__VA_ARGS__))
3019 #endif
3020 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3021 #define DEFINE_ExtendedInformationStartFrameReflectionFuzzTest() void RunExtendedInformationStartFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedInformationStartFrameView view = ExtendedInformationStartFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedInformationStartFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3022 #endif
3023
3024 #ifdef PACKET_FUZZ_TESTING
3025 #define DEFINE_AND_REGISTER_ExtendedInformationStartFrameReflectionFuzzTest(REGISTRY) DEFINE_ExtendedInformationStartFrameReflectionFuzzTest(); class ExtendedInformationStartFrameReflectionFuzzTestRegistrant {public: explicit ExtendedInformationStartFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedInformationStartFrameReflectionFuzzTest);}}; ExtendedInformationStartFrameReflectionFuzzTestRegistrant ExtendedInformationStartFrame_reflection_fuzz_test_registrant(REGISTRY);
3026 #endif
3027
3028
Create(uint16_t channel_id,Final f,uint16_t req_seq,uint16_t tx_seq,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)3029 class ExtendedInformationStartFrameWithFcsBuilder : public ExtendedInformationFrameWithFcsBuilder { public: virtual ~ExtendedInformationStartFrameWithFcsBuilder() = default;static std::unique_ptr<ExtendedInformationStartFrameWithFcsBuilder> Create(uint16_t channel_id, Final f, uint16_t req_seq, uint16_t tx_seq, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ExtendedInformationStartFrameWithFcsBuilder>(new ExtendedInformationStartFrameWithFcsBuilder(channel_id, f, req_seq, tx_seq, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
3030
3031 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3032 static std::unique_ptr<ExtendedInformationStartFrameWithFcsBuilder> FromView(ExtendedInformationStartFrameWithFcsView view) {if (!view.IsValid()) return nullptr;return ExtendedInformationStartFrameWithFcsBuilder::Create(view.GetChannelId(), view.GetF(), view.GetReqSeq(), view.GetTxSeq(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3033 #endif
3034
3035 protected:void SerializeHeader(BitInserter& i ) const {ExtendedInformationFrameWithFcsBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
3036
3037 void SerializeFooter(BitInserter& i ) const {ExtendedInformationFrameWithFcsBuilder::SerializeFooter(i);}
3038
3039 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3040
3041 protected:size_t BitsOfHeader() const {return 0 + ExtendedInformationFrameWithFcsBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3042
3043 size_t BitsOfFooter() const {return 0 + ExtendedInformationFrameWithFcsBuilder::BitsOfFooter() ;}
3044
3045 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3046
3047 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3048
3049 protected:
3050 explicit ExtendedInformationStartFrameWithFcsBuilder(uint16_t channel_id, Final f, uint16_t req_seq, uint16_t tx_seq, uint16_t l2cap_sdu_length) :ExtendedInformationFrameWithFcsBuilder(channel_id, f, req_seq, SegmentationAndReassembly::START/* sar_ */, tx_seq) ,l2cap_sdu_length_(l2cap_sdu_length) {CheckParameterValues(req_seq_, tx_seq_);}
3051
3052 void CheckParameterValues(uint16_t req_seq, uint16_t tx_seq) {ASSERT(req_seq < (static_cast<uint64_t>(1) << 14));ASSERT(tx_seq < (static_cast<uint64_t>(1) << 14));}
3053
3054 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
3055 #ifdef PACKET_TESTING
3056 #define DEFINE_AND_INSTANTIATE_ExtendedInformationStartFrameWithFcsReflectionTest(...)class ExtendedInformationStartFrameWithFcsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ExtendedInformationStartFrameWithFcsView view = ExtendedInformationStartFrameWithFcsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ExtendedInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ExtendedInformationStartFrameWithFcsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ExtendedInformationStartFrameWithFcs_reflection, ExtendedInformationStartFrameWithFcsReflectionTest, testing::Values(__VA_ARGS__))
3057 #endif
3058 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3059 #define DEFINE_ExtendedInformationStartFrameWithFcsReflectionFuzzTest() void RunExtendedInformationStartFrameWithFcsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ExtendedInformationStartFrameWithFcsView view = ExtendedInformationStartFrameWithFcsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ExtendedInformationStartFrameWithFcsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3060 #endif
3061
3062 #ifdef PACKET_FUZZ_TESTING
3063 #define DEFINE_AND_REGISTER_ExtendedInformationStartFrameWithFcsReflectionFuzzTest(REGISTRY) DEFINE_ExtendedInformationStartFrameWithFcsReflectionFuzzTest(); class ExtendedInformationStartFrameWithFcsReflectionFuzzTestRegistrant {public: explicit ExtendedInformationStartFrameWithFcsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunExtendedInformationStartFrameWithFcsReflectionFuzzTest);}}; ExtendedInformationStartFrameWithFcsReflectionFuzzTestRegistrant ExtendedInformationStartFrameWithFcs_reflection_fuzz_test_registrant(REGISTRY);
3064 #endif
3065
3066
Create(uint16_t channel_id,uint16_t l2cap_sdu_length,std::unique_ptr<BasePacketBuilder> payload)3067 class FirstLeInformationFrameBuilder : public BasicFrameBuilder { public: virtual ~FirstLeInformationFrameBuilder() = default;static std::unique_ptr<FirstLeInformationFrameBuilder> Create(uint16_t channel_id, uint16_t l2cap_sdu_length, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<FirstLeInformationFrameBuilder>(new FirstLeInformationFrameBuilder(channel_id, l2cap_sdu_length));builder->payload_ = std::move(payload);return builder;}
3068
3069 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3070 static std::unique_ptr<FirstLeInformationFrameBuilder> FromView(FirstLeInformationFrameView view) {if (!view.IsValid()) return nullptr;return FirstLeInformationFrameBuilder::Create(view.GetChannelId(), view.GetL2capSduLength(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3071 #endif
3072
3073 protected:void SerializeHeader(BitInserter& i ) const {BasicFrameBuilder::SerializeHeader(i);insert(l2cap_sdu_length_, i,16);}
3074
3075 void SerializeFooter(BitInserter& i ) const {BasicFrameBuilder::SerializeFooter(i);}
3076
3077 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3078
3079 protected:size_t BitsOfHeader() const {return 0 + BasicFrameBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3080
3081 size_t BitsOfFooter() const {return 0 + BasicFrameBuilder::BitsOfFooter() ;}
3082
3083 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3084
3085 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3086
3087 protected:
3088 explicit FirstLeInformationFrameBuilder(uint16_t channel_id, uint16_t l2cap_sdu_length) :BasicFrameBuilder(channel_id) ,l2cap_sdu_length_(l2cap_sdu_length) {}
3089
3090
3091 uint16_t l2cap_sdu_length_{};std::unique_ptr<BasePacketBuilder> payload_{};};
3092 #ifdef PACKET_TESTING
3093 #define DEFINE_AND_INSTANTIATE_FirstLeInformationFrameReflectionTest(...)class FirstLeInformationFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {FirstLeInformationFrameView view = FirstLeInformationFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = FirstLeInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(FirstLeInformationFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(FirstLeInformationFrame_reflection, FirstLeInformationFrameReflectionTest, testing::Values(__VA_ARGS__))
3094 #endif
3095 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3096 #define DEFINE_FirstLeInformationFrameReflectionFuzzTest() void RunFirstLeInformationFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);FirstLeInformationFrameView view = FirstLeInformationFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = FirstLeInformationFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3097 #endif
3098
3099 #ifdef PACKET_FUZZ_TESTING
3100 #define DEFINE_AND_REGISTER_FirstLeInformationFrameReflectionFuzzTest(REGISTRY) DEFINE_FirstLeInformationFrameReflectionFuzzTest(); class FirstLeInformationFrameReflectionFuzzTestRegistrant {public: explicit FirstLeInformationFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunFirstLeInformationFrameReflectionFuzzTest);}}; FirstLeInformationFrameReflectionFuzzTestRegistrant FirstLeInformationFrame_reflection_fuzz_test_registrant(REGISTRY);
3101 #endif
3102
3103
Create(std::unique_ptr<BasePacketBuilder> payload)3104 class ControlFrameBuilder : public BasicFrameBuilder { public: virtual ~ControlFrameBuilder() = default;static std::unique_ptr<ControlFrameBuilder> Create(std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ControlFrameBuilder>(new ControlFrameBuilder());builder->payload_ = std::move(payload);return builder;}
3105
3106 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3107 static std::unique_ptr<ControlFrameBuilder> FromView(ControlFrameView view) {if (!view.IsValid()) return nullptr;return ControlFrameBuilder::Create(std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3108 #endif
3109
3110 protected:void SerializeHeader(BitInserter& i ) const {BasicFrameBuilder::SerializeHeader(i);}
3111
3112 void SerializeFooter(BitInserter& i ) const {BasicFrameBuilder::SerializeFooter(i);}
3113
3114 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3115
3116 protected:size_t BitsOfHeader() const {return 0 + BasicFrameBuilder::BitsOfHeader() ;}
3117
3118 size_t BitsOfFooter() const {return 0 + BasicFrameBuilder::BitsOfFooter() ;}
3119
3120 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3121
3122 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3123
3124 protected:
3125 explicit ControlFrameBuilder() :BasicFrameBuilder(1/* channel_id_ */) {}
3126
3127
3128 std::unique_ptr<BasePacketBuilder> payload_{};};
3129 #ifdef PACKET_TESTING
3130 #define DEFINE_AND_INSTANTIATE_ControlFrameReflectionTest(...)class ControlFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ControlFrameView view = ControlFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ControlFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ControlFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ControlFrame_reflection, ControlFrameReflectionTest, testing::Values(__VA_ARGS__))
3131 #endif
3132 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3133 #define DEFINE_ControlFrameReflectionFuzzTest() void RunControlFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ControlFrameView view = ControlFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ControlFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3134 #endif
3135
3136 #ifdef PACKET_FUZZ_TESTING
3137 #define DEFINE_AND_REGISTER_ControlFrameReflectionFuzzTest(REGISTRY) DEFINE_ControlFrameReflectionFuzzTest(); class ControlFrameReflectionFuzzTestRegistrant {public: explicit ControlFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunControlFrameReflectionFuzzTest);}}; ControlFrameReflectionFuzzTestRegistrant ControlFrame_reflection_fuzz_test_registrant(REGISTRY);
3138 #endif
3139
3140
Create(CommandCode code,uint8_t identifier,std::unique_ptr<BasePacketBuilder> payload)3141 class ControlBuilder : public PacketBuilder<kLittleEndian> { public: virtual ~ControlBuilder() = default;static std::unique_ptr<ControlBuilder> Create(CommandCode code, uint8_t identifier, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<ControlBuilder>(new ControlBuilder(code, identifier));builder->payload_ = std::move(payload);return builder;}
3142
3143 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3144 static std::unique_ptr<ControlBuilder> FromView(ControlView view) {if (!view.IsValid()) return nullptr;return ControlBuilder::Create(view.GetCode(), view.GetIdentifier(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3145 #endif
3146
3147 protected:void SerializeHeader(BitInserter& i ) const {insert(static_cast<uint8_t>(code_), i, 8);i.insert_byte(identifier_);size_t payload_bytes = GetPayloadSize();ASSERT(payload_bytes < (static_cast<size_t>(1) << 16));insert(static_cast<uint16_t>(payload_bytes), i,16);}
3148
3149 void SerializeFooter(BitInserter&) const {}
3150
3151 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3152
3153 protected:size_t BitsOfHeader() const {return 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3154
3155 size_t BitsOfFooter() const {return 0;}
3156
3157 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3158
3159 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3160
3161 protected:
3162 explicit ControlBuilder(CommandCode code, uint8_t identifier) :code_(code),identifier_(identifier) {}
3163
3164
3165 CommandCode code_{};uint8_t identifier_{};std::unique_ptr<BasePacketBuilder> payload_{};};
3166 #ifdef PACKET_TESTING
3167 #define DEFINE_AND_INSTANTIATE_ControlReflectionTest(...)class ControlReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ControlView view = ControlView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ControlBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ControlReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(Control_reflection, ControlReflectionTest, testing::Values(__VA_ARGS__))
3168 #endif
3169 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3170 #define DEFINE_ControlReflectionFuzzTest() void RunControlReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ControlView view = ControlView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ControlBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3171 #endif
3172
3173 #ifdef PACKET_FUZZ_TESTING
3174 #define DEFINE_AND_REGISTER_ControlReflectionFuzzTest(REGISTRY) DEFINE_ControlReflectionFuzzTest(); class ControlReflectionFuzzTestRegistrant {public: explicit ControlReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunControlReflectionFuzzTest);}}; ControlReflectionFuzzTestRegistrant Control_reflection_fuzz_test_registrant(REGISTRY);
3175 #endif
3176
3177
SerializeHeader(BitInserter & i)3178 class CommandRejectBuilder : public ControlBuilder { public: virtual ~CommandRejectBuilder() = default;protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(reason_), i, 16);}
3179
3180 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3181
3182 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3183
3184 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3185
3186 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3187
3188 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3189
3190 protected:
3191 explicit CommandRejectBuilder(uint8_t identifier, CommandRejectReason reason) :ControlBuilder(CommandCode::COMMAND_REJECT/* code_ */, identifier) ,reason_(reason) {}
3192
3193
3194 CommandRejectReason reason_{};};
3195 #ifdef PACKET_TESTING
3196 #define DEFINE_AND_INSTANTIATE_CommandRejectReflectionTest(...)class CommandRejectReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CommandRejectView view = CommandRejectView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CommandRejectBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CommandRejectReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CommandReject_reflection, CommandRejectReflectionTest, testing::Values(__VA_ARGS__))
3197 #endif
3198 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3199 #define DEFINE_CommandRejectReflectionFuzzTest() void RunCommandRejectReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CommandRejectView view = CommandRejectView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CommandRejectBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3200 #endif
3201
3202 #ifdef PACKET_FUZZ_TESTING
3203 #define DEFINE_AND_REGISTER_CommandRejectReflectionFuzzTest(REGISTRY) DEFINE_CommandRejectReflectionFuzzTest(); class CommandRejectReflectionFuzzTestRegistrant {public: explicit CommandRejectReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCommandRejectReflectionFuzzTest);}}; CommandRejectReflectionFuzzTestRegistrant CommandReject_reflection_fuzz_test_registrant(REGISTRY);
3204 #endif
3205
3206
Create(uint8_t identifier)3207 class CommandRejectNotUnderstoodBuilder : public CommandRejectBuilder { public: virtual ~CommandRejectNotUnderstoodBuilder() = default;static std::unique_ptr<CommandRejectNotUnderstoodBuilder> Create(uint8_t identifier) {auto builder = std::unique_ptr<CommandRejectNotUnderstoodBuilder>(new CommandRejectNotUnderstoodBuilder(identifier));return builder;}
3208
3209 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3210 static std::unique_ptr<CommandRejectNotUnderstoodBuilder> FromView(CommandRejectNotUnderstoodView view) {if (!view.IsValid()) return nullptr;return CommandRejectNotUnderstoodBuilder::Create(view.GetIdentifier());}
3211 #endif
3212
3213 protected:void SerializeHeader(BitInserter& i ) const {CommandRejectBuilder::SerializeHeader(i);}
3214
3215 void SerializeFooter(BitInserter& i ) const {CommandRejectBuilder::SerializeFooter(i);}
3216
3217 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3218
3219 protected:size_t BitsOfHeader() const {return 0 + CommandRejectBuilder::BitsOfHeader() ;}
3220
3221 size_t BitsOfFooter() const {return 0 + CommandRejectBuilder::BitsOfFooter() ;}
3222
3223 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3224
3225 protected:
3226 explicit CommandRejectNotUnderstoodBuilder(uint8_t identifier) :CommandRejectBuilder(identifier, CommandRejectReason::COMMAND_NOT_UNDERSTOOD/* reason_ */) {}
3227
3228
3229 };
3230 #ifdef PACKET_TESTING
3231 #define DEFINE_AND_INSTANTIATE_CommandRejectNotUnderstoodReflectionTest(...)class CommandRejectNotUnderstoodReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CommandRejectNotUnderstoodView view = CommandRejectNotUnderstoodView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CommandRejectNotUnderstoodBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CommandRejectNotUnderstoodReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CommandRejectNotUnderstood_reflection, CommandRejectNotUnderstoodReflectionTest, testing::Values(__VA_ARGS__))
3232 #endif
3233 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3234 #define DEFINE_CommandRejectNotUnderstoodReflectionFuzzTest() void RunCommandRejectNotUnderstoodReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CommandRejectNotUnderstoodView view = CommandRejectNotUnderstoodView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CommandRejectNotUnderstoodBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3235 #endif
3236
3237 #ifdef PACKET_FUZZ_TESTING
3238 #define DEFINE_AND_REGISTER_CommandRejectNotUnderstoodReflectionFuzzTest(REGISTRY) DEFINE_CommandRejectNotUnderstoodReflectionFuzzTest(); class CommandRejectNotUnderstoodReflectionFuzzTestRegistrant {public: explicit CommandRejectNotUnderstoodReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCommandRejectNotUnderstoodReflectionFuzzTest);}}; CommandRejectNotUnderstoodReflectionFuzzTestRegistrant CommandRejectNotUnderstood_reflection_fuzz_test_registrant(REGISTRY);
3239 #endif
3240
3241
Create(uint8_t identifier,uint16_t actual_mtu)3242 class CommandRejectMtuExceededBuilder : public CommandRejectBuilder { public: virtual ~CommandRejectMtuExceededBuilder() = default;static std::unique_ptr<CommandRejectMtuExceededBuilder> Create(uint8_t identifier, uint16_t actual_mtu) {auto builder = std::unique_ptr<CommandRejectMtuExceededBuilder>(new CommandRejectMtuExceededBuilder(identifier, actual_mtu));return builder;}
3243
3244 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3245 static std::unique_ptr<CommandRejectMtuExceededBuilder> FromView(CommandRejectMtuExceededView view) {if (!view.IsValid()) return nullptr;return CommandRejectMtuExceededBuilder::Create(view.GetIdentifier(), view.GetActualMtu());}
3246 #endif
3247
3248 protected:void SerializeHeader(BitInserter& i ) const {CommandRejectBuilder::SerializeHeader(i);insert(actual_mtu_, i,16);}
3249
3250 void SerializeFooter(BitInserter& i ) const {CommandRejectBuilder::SerializeFooter(i);}
3251
3252 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3253
3254 protected:size_t BitsOfHeader() const {return 0 + CommandRejectBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3255
3256 size_t BitsOfFooter() const {return 0 + CommandRejectBuilder::BitsOfFooter() ;}
3257
3258 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3259
3260 protected:
3261 explicit CommandRejectMtuExceededBuilder(uint8_t identifier, uint16_t actual_mtu) :CommandRejectBuilder(identifier, CommandRejectReason::SIGNALING_MTU_EXCEEDED/* reason_ */) ,actual_mtu_(actual_mtu) {}
3262
3263
3264 uint16_t actual_mtu_{};};
3265 #ifdef PACKET_TESTING
3266 #define DEFINE_AND_INSTANTIATE_CommandRejectMtuExceededReflectionTest(...)class CommandRejectMtuExceededReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CommandRejectMtuExceededView view = CommandRejectMtuExceededView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CommandRejectMtuExceededBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CommandRejectMtuExceededReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CommandRejectMtuExceeded_reflection, CommandRejectMtuExceededReflectionTest, testing::Values(__VA_ARGS__))
3267 #endif
3268 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3269 #define DEFINE_CommandRejectMtuExceededReflectionFuzzTest() void RunCommandRejectMtuExceededReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CommandRejectMtuExceededView view = CommandRejectMtuExceededView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CommandRejectMtuExceededBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3270 #endif
3271
3272 #ifdef PACKET_FUZZ_TESTING
3273 #define DEFINE_AND_REGISTER_CommandRejectMtuExceededReflectionFuzzTest(REGISTRY) DEFINE_CommandRejectMtuExceededReflectionFuzzTest(); class CommandRejectMtuExceededReflectionFuzzTestRegistrant {public: explicit CommandRejectMtuExceededReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCommandRejectMtuExceededReflectionFuzzTest);}}; CommandRejectMtuExceededReflectionFuzzTestRegistrant CommandRejectMtuExceeded_reflection_fuzz_test_registrant(REGISTRY);
3274 #endif
3275
3276
Create(uint8_t identifier,uint16_t local_channel,uint16_t remote_channel)3277 class CommandRejectInvalidCidBuilder : public CommandRejectBuilder { public: virtual ~CommandRejectInvalidCidBuilder() = default;static std::unique_ptr<CommandRejectInvalidCidBuilder> Create(uint8_t identifier, uint16_t local_channel, uint16_t remote_channel) {auto builder = std::unique_ptr<CommandRejectInvalidCidBuilder>(new CommandRejectInvalidCidBuilder(identifier, local_channel, remote_channel));return builder;}
3278
3279 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3280 static std::unique_ptr<CommandRejectInvalidCidBuilder> FromView(CommandRejectInvalidCidView view) {if (!view.IsValid()) return nullptr;return CommandRejectInvalidCidBuilder::Create(view.GetIdentifier(), view.GetLocalChannel(), view.GetRemoteChannel());}
3281 #endif
3282
3283 protected:void SerializeHeader(BitInserter& i ) const {CommandRejectBuilder::SerializeHeader(i);insert(local_channel_, i,16);insert(remote_channel_, i,16);}
3284
3285 void SerializeFooter(BitInserter& i ) const {CommandRejectBuilder::SerializeFooter(i);}
3286
3287 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3288
3289 protected:size_t BitsOfHeader() const {return 0 + CommandRejectBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3290
3291 size_t BitsOfFooter() const {return 0 + CommandRejectBuilder::BitsOfFooter() ;}
3292
3293 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3294
3295 protected:
3296 explicit CommandRejectInvalidCidBuilder(uint8_t identifier, uint16_t local_channel, uint16_t remote_channel) :CommandRejectBuilder(identifier, CommandRejectReason::INVALID_CID_IN_REQUEST/* reason_ */) ,local_channel_(local_channel),remote_channel_(remote_channel) {}
3297
3298
3299 uint16_t local_channel_{};uint16_t remote_channel_{};};
3300 #ifdef PACKET_TESTING
3301 #define DEFINE_AND_INSTANTIATE_CommandRejectInvalidCidReflectionTest(...)class CommandRejectInvalidCidReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CommandRejectInvalidCidView view = CommandRejectInvalidCidView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CommandRejectInvalidCidBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CommandRejectInvalidCidReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CommandRejectInvalidCid_reflection, CommandRejectInvalidCidReflectionTest, testing::Values(__VA_ARGS__))
3302 #endif
3303 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3304 #define DEFINE_CommandRejectInvalidCidReflectionFuzzTest() void RunCommandRejectInvalidCidReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CommandRejectInvalidCidView view = CommandRejectInvalidCidView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CommandRejectInvalidCidBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3305 #endif
3306
3307 #ifdef PACKET_FUZZ_TESTING
3308 #define DEFINE_AND_REGISTER_CommandRejectInvalidCidReflectionFuzzTest(REGISTRY) DEFINE_CommandRejectInvalidCidReflectionFuzzTest(); class CommandRejectInvalidCidReflectionFuzzTestRegistrant {public: explicit CommandRejectInvalidCidReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCommandRejectInvalidCidReflectionFuzzTest);}}; CommandRejectInvalidCidReflectionFuzzTestRegistrant CommandRejectInvalidCid_reflection_fuzz_test_registrant(REGISTRY);
3309 #endif
3310
3311
Create(uint8_t identifier,uint16_t psm,uint16_t source_cid)3312 class ConnectionRequestBuilder : public ControlBuilder { public: virtual ~ConnectionRequestBuilder() = default;static std::unique_ptr<ConnectionRequestBuilder> Create(uint8_t identifier, uint16_t psm, uint16_t source_cid) {auto builder = std::unique_ptr<ConnectionRequestBuilder>(new ConnectionRequestBuilder(identifier, psm, source_cid));return builder;}
3313
3314 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3315 static std::unique_ptr<ConnectionRequestBuilder> FromView(ConnectionRequestView view) {if (!view.IsValid()) return nullptr;return ConnectionRequestBuilder::Create(view.GetIdentifier(), view.GetPsm(), view.GetSourceCid());}
3316 #endif
3317
3318 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(psm_, i,16);insert(source_cid_, i,16);}
3319
3320 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3321
3322 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3323
3324 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3325
3326 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3327
3328 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3329
3330 protected:
3331 explicit ConnectionRequestBuilder(uint8_t identifier, uint16_t psm, uint16_t source_cid) :ControlBuilder(CommandCode::CONNECTION_REQUEST/* code_ */, identifier) ,psm_(psm),source_cid_(source_cid) {}
3332
3333
3334 uint16_t psm_{};uint16_t source_cid_{};};
3335 #ifdef PACKET_TESTING
3336 #define DEFINE_AND_INSTANTIATE_ConnectionRequestReflectionTest(...)class ConnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConnectionRequestView view = ConnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConnectionRequest_reflection, ConnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
3337 #endif
3338 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3339 #define DEFINE_ConnectionRequestReflectionFuzzTest() void RunConnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConnectionRequestView view = ConnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3340 #endif
3341
3342 #ifdef PACKET_FUZZ_TESTING
3343 #define DEFINE_AND_REGISTER_ConnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_ConnectionRequestReflectionFuzzTest(); class ConnectionRequestReflectionFuzzTestRegistrant {public: explicit ConnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConnectionRequestReflectionFuzzTest);}}; ConnectionRequestReflectionFuzzTestRegistrant ConnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
3344 #endif
3345
3346
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid,ConnectionResponseResult result,ConnectionResponseStatus status)3347 class ConnectionResponseBuilder : public ControlBuilder { public: virtual ~ConnectionResponseBuilder() = default;static std::unique_ptr<ConnectionResponseBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid, ConnectionResponseResult result, ConnectionResponseStatus status) {auto builder = std::unique_ptr<ConnectionResponseBuilder>(new ConnectionResponseBuilder(identifier, destination_cid, source_cid, result, status));return builder;}
3348
3349 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3350 static std::unique_ptr<ConnectionResponseBuilder> FromView(ConnectionResponseView view) {if (!view.IsValid()) return nullptr;return ConnectionResponseBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid(), view.GetResult(), view.GetStatus());}
3351 #endif
3352
3353 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);insert(static_cast<uint16_t>(result_), i, 16);insert(static_cast<uint16_t>(status_), i, 16);}
3354
3355 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3356
3357 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3358
3359 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3360
3361 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3362
3363 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3364
3365 protected:
3366 explicit ConnectionResponseBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid, ConnectionResponseResult result, ConnectionResponseStatus status) :ControlBuilder(CommandCode::CONNECTION_RESPONSE/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid),result_(result),status_(status) {}
3367
3368
3369 uint16_t destination_cid_{};uint16_t source_cid_{};ConnectionResponseResult result_{};ConnectionResponseStatus status_{};};
3370 #ifdef PACKET_TESTING
3371 #define DEFINE_AND_INSTANTIATE_ConnectionResponseReflectionTest(...)class ConnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConnectionResponseView view = ConnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConnectionResponse_reflection, ConnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
3372 #endif
3373 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3374 #define DEFINE_ConnectionResponseReflectionFuzzTest() void RunConnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConnectionResponseView view = ConnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3375 #endif
3376
3377 #ifdef PACKET_FUZZ_TESTING
3378 #define DEFINE_AND_REGISTER_ConnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_ConnectionResponseReflectionFuzzTest(); class ConnectionResponseReflectionFuzzTestRegistrant {public: explicit ConnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConnectionResponseReflectionFuzzTest);}}; ConnectionResponseReflectionFuzzTestRegistrant ConnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
3379 #endif
3380
3381
Create(uint8_t identifier,uint16_t destination_cid,Continuation continuation,std::vector<std::unique_ptr<ConfigurationOption>> config)3382 class ConfigurationRequestBuilder : public ControlBuilder { public: virtual ~ConfigurationRequestBuilder() = default;static std::unique_ptr<ConfigurationRequestBuilder> Create(uint8_t identifier, uint16_t destination_cid, Continuation continuation, std::vector<std::unique_ptr<ConfigurationOption>> config) {auto builder = std::unique_ptr<ConfigurationRequestBuilder>(new ConfigurationRequestBuilder(identifier, destination_cid, continuation, std::move(config)));return builder;}
3383
3384 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3385 static std::unique_ptr<ConfigurationRequestBuilder> FromView(ConfigurationRequestView view) {if (!view.IsValid()) return nullptr;return ConfigurationRequestBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetContinuation(), view.GetConfig());}
3386 #endif
3387
3388 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(static_cast<uint8_t>(continuation_), i, 1);insert(static_cast<uint16_t>(0) /* Reserved */, i, 15 );
3389 for (const auto& val_ : config_) {val_->Serialize(i);}
3390 }
3391
3392 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3393
3394 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3395
3396 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 15 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ [this](){ size_t length = 0; for (const auto& elem : config_) { length += elem->size() * 8; } return length; }();}
3397
3398 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3399
3400 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3401
3402 protected:
3403 explicit ConfigurationRequestBuilder(uint8_t identifier, uint16_t destination_cid, Continuation continuation, std::vector<std::unique_ptr<ConfigurationOption>> config) :ControlBuilder(CommandCode::CONFIGURATION_REQUEST/* code_ */, identifier) ,destination_cid_(destination_cid),continuation_(continuation),config_(std::move(config)) {}
3404
3405
3406 uint16_t destination_cid_{};Continuation continuation_{};std::vector<std::unique_ptr<ConfigurationOption>> config_{};};
3407 #ifdef PACKET_TESTING
3408 #define DEFINE_AND_INSTANTIATE_ConfigurationRequestReflectionTest(...)class ConfigurationRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConfigurationRequestView view = ConfigurationRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConfigurationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConfigurationRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConfigurationRequest_reflection, ConfigurationRequestReflectionTest, testing::Values(__VA_ARGS__))
3409 #endif
3410 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3411 #define DEFINE_ConfigurationRequestReflectionFuzzTest() void RunConfigurationRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConfigurationRequestView view = ConfigurationRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConfigurationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3412 #endif
3413
3414 #ifdef PACKET_FUZZ_TESTING
3415 #define DEFINE_AND_REGISTER_ConfigurationRequestReflectionFuzzTest(REGISTRY) DEFINE_ConfigurationRequestReflectionFuzzTest(); class ConfigurationRequestReflectionFuzzTestRegistrant {public: explicit ConfigurationRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConfigurationRequestReflectionFuzzTest);}}; ConfigurationRequestReflectionFuzzTestRegistrant ConfigurationRequest_reflection_fuzz_test_registrant(REGISTRY);
3416 #endif
3417
3418
Create(uint8_t identifier,uint16_t source_cid,Continuation continuation,ConfigurationResponseResult result,std::vector<std::unique_ptr<ConfigurationOption>> config)3419 class ConfigurationResponseBuilder : public ControlBuilder { public: virtual ~ConfigurationResponseBuilder() = default;static std::unique_ptr<ConfigurationResponseBuilder> Create(uint8_t identifier, uint16_t source_cid, Continuation continuation, ConfigurationResponseResult result, std::vector<std::unique_ptr<ConfigurationOption>> config) {auto builder = std::unique_ptr<ConfigurationResponseBuilder>(new ConfigurationResponseBuilder(identifier, source_cid, continuation, result, std::move(config)));return builder;}
3420
3421 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3422 static std::unique_ptr<ConfigurationResponseBuilder> FromView(ConfigurationResponseView view) {if (!view.IsValid()) return nullptr;return ConfigurationResponseBuilder::Create(view.GetIdentifier(), view.GetSourceCid(), view.GetContinuation(), view.GetResult(), view.GetConfig());}
3423 #endif
3424
3425 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(source_cid_, i,16);insert(static_cast<uint8_t>(continuation_), i, 1);insert(static_cast<uint16_t>(0) /* Reserved */, i, 15 );
3426 insert(static_cast<uint16_t>(result_), i, 16);for (const auto& val_ : config_) {val_->Serialize(i);}
3427 }
3428
3429 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3430
3431 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3432
3433 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 15 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ [this](){ size_t length = 0; for (const auto& elem : config_) { length += elem->size() * 8; } return length; }();}
3434
3435 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3436
3437 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3438
3439 protected:
3440 explicit ConfigurationResponseBuilder(uint8_t identifier, uint16_t source_cid, Continuation continuation, ConfigurationResponseResult result, std::vector<std::unique_ptr<ConfigurationOption>> config) :ControlBuilder(CommandCode::CONFIGURATION_RESPONSE/* code_ */, identifier) ,source_cid_(source_cid),continuation_(continuation),result_(result),config_(std::move(config)) {}
3441
3442
3443 uint16_t source_cid_{};Continuation continuation_{};ConfigurationResponseResult result_{};std::vector<std::unique_ptr<ConfigurationOption>> config_{};};
3444 #ifdef PACKET_TESTING
3445 #define DEFINE_AND_INSTANTIATE_ConfigurationResponseReflectionTest(...)class ConfigurationResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConfigurationResponseView view = ConfigurationResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConfigurationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConfigurationResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConfigurationResponse_reflection, ConfigurationResponseReflectionTest, testing::Values(__VA_ARGS__))
3446 #endif
3447 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3448 #define DEFINE_ConfigurationResponseReflectionFuzzTest() void RunConfigurationResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConfigurationResponseView view = ConfigurationResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConfigurationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3449 #endif
3450
3451 #ifdef PACKET_FUZZ_TESTING
3452 #define DEFINE_AND_REGISTER_ConfigurationResponseReflectionFuzzTest(REGISTRY) DEFINE_ConfigurationResponseReflectionFuzzTest(); class ConfigurationResponseReflectionFuzzTestRegistrant {public: explicit ConfigurationResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConfigurationResponseReflectionFuzzTest);}}; ConfigurationResponseReflectionFuzzTestRegistrant ConfigurationResponse_reflection_fuzz_test_registrant(REGISTRY);
3453 #endif
3454
3455
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid)3456 class DisconnectionRequestBuilder : public ControlBuilder { public: virtual ~DisconnectionRequestBuilder() = default;static std::unique_ptr<DisconnectionRequestBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) {auto builder = std::unique_ptr<DisconnectionRequestBuilder>(new DisconnectionRequestBuilder(identifier, destination_cid, source_cid));return builder;}
3457
3458 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3459 static std::unique_ptr<DisconnectionRequestBuilder> FromView(DisconnectionRequestView view) {if (!view.IsValid()) return nullptr;return DisconnectionRequestBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid());}
3460 #endif
3461
3462 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);}
3463
3464 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3465
3466 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3467
3468 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3469
3470 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3471
3472 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3473
3474 protected:
3475 explicit DisconnectionRequestBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) :ControlBuilder(CommandCode::DISCONNECTION_REQUEST/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid) {}
3476
3477
3478 uint16_t destination_cid_{};uint16_t source_cid_{};};
3479 #ifdef PACKET_TESTING
3480 #define DEFINE_AND_INSTANTIATE_DisconnectionRequestReflectionTest(...)class DisconnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {DisconnectionRequestView view = DisconnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = DisconnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(DisconnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(DisconnectionRequest_reflection, DisconnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
3481 #endif
3482 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3483 #define DEFINE_DisconnectionRequestReflectionFuzzTest() void RunDisconnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);DisconnectionRequestView view = DisconnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = DisconnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3484 #endif
3485
3486 #ifdef PACKET_FUZZ_TESTING
3487 #define DEFINE_AND_REGISTER_DisconnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_DisconnectionRequestReflectionFuzzTest(); class DisconnectionRequestReflectionFuzzTestRegistrant {public: explicit DisconnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunDisconnectionRequestReflectionFuzzTest);}}; DisconnectionRequestReflectionFuzzTestRegistrant DisconnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
3488 #endif
3489
3490
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid)3491 class DisconnectionResponseBuilder : public ControlBuilder { public: virtual ~DisconnectionResponseBuilder() = default;static std::unique_ptr<DisconnectionResponseBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) {auto builder = std::unique_ptr<DisconnectionResponseBuilder>(new DisconnectionResponseBuilder(identifier, destination_cid, source_cid));return builder;}
3492
3493 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3494 static std::unique_ptr<DisconnectionResponseBuilder> FromView(DisconnectionResponseView view) {if (!view.IsValid()) return nullptr;return DisconnectionResponseBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid());}
3495 #endif
3496
3497 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);}
3498
3499 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3500
3501 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3502
3503 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3504
3505 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3506
3507 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3508
3509 protected:
3510 explicit DisconnectionResponseBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) :ControlBuilder(CommandCode::DISCONNECTION_RESPONSE/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid) {}
3511
3512
3513 uint16_t destination_cid_{};uint16_t source_cid_{};};
3514 #ifdef PACKET_TESTING
3515 #define DEFINE_AND_INSTANTIATE_DisconnectionResponseReflectionTest(...)class DisconnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {DisconnectionResponseView view = DisconnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = DisconnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(DisconnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(DisconnectionResponse_reflection, DisconnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
3516 #endif
3517 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3518 #define DEFINE_DisconnectionResponseReflectionFuzzTest() void RunDisconnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);DisconnectionResponseView view = DisconnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = DisconnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3519 #endif
3520
3521 #ifdef PACKET_FUZZ_TESTING
3522 #define DEFINE_AND_REGISTER_DisconnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_DisconnectionResponseReflectionFuzzTest(); class DisconnectionResponseReflectionFuzzTestRegistrant {public: explicit DisconnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunDisconnectionResponseReflectionFuzzTest);}}; DisconnectionResponseReflectionFuzzTestRegistrant DisconnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
3523 #endif
3524
3525
Create(uint8_t identifier,std::unique_ptr<BasePacketBuilder> payload)3526 class EchoRequestBuilder : public ControlBuilder { public: virtual ~EchoRequestBuilder() = default;static std::unique_ptr<EchoRequestBuilder> Create(uint8_t identifier, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EchoRequestBuilder>(new EchoRequestBuilder(identifier));builder->payload_ = std::move(payload);return builder;}
3527
3528 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3529 static std::unique_ptr<EchoRequestBuilder> FromView(EchoRequestView view) {if (!view.IsValid()) return nullptr;return EchoRequestBuilder::Create(view.GetIdentifier(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3530 #endif
3531
3532 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);}
3533
3534 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3535
3536 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3537
3538 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() ;}
3539
3540 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3541
3542 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3543
3544 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3545
3546 protected:
3547 explicit EchoRequestBuilder(uint8_t identifier) :ControlBuilder(CommandCode::ECHO_REQUEST/* code_ */, identifier) {}
3548
3549
3550 std::unique_ptr<BasePacketBuilder> payload_{};};
3551 #ifdef PACKET_TESTING
3552 #define DEFINE_AND_INSTANTIATE_EchoRequestReflectionTest(...)class EchoRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EchoRequestView view = EchoRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EchoRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EchoRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EchoRequest_reflection, EchoRequestReflectionTest, testing::Values(__VA_ARGS__))
3553 #endif
3554 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3555 #define DEFINE_EchoRequestReflectionFuzzTest() void RunEchoRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EchoRequestView view = EchoRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EchoRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3556 #endif
3557
3558 #ifdef PACKET_FUZZ_TESTING
3559 #define DEFINE_AND_REGISTER_EchoRequestReflectionFuzzTest(REGISTRY) DEFINE_EchoRequestReflectionFuzzTest(); class EchoRequestReflectionFuzzTestRegistrant {public: explicit EchoRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEchoRequestReflectionFuzzTest);}}; EchoRequestReflectionFuzzTestRegistrant EchoRequest_reflection_fuzz_test_registrant(REGISTRY);
3560 #endif
3561
3562
Create(uint8_t identifier,std::unique_ptr<BasePacketBuilder> payload)3563 class EchoResponseBuilder : public ControlBuilder { public: virtual ~EchoResponseBuilder() = default;static std::unique_ptr<EchoResponseBuilder> Create(uint8_t identifier, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<EchoResponseBuilder>(new EchoResponseBuilder(identifier));builder->payload_ = std::move(payload);return builder;}
3564
3565 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3566 static std::unique_ptr<EchoResponseBuilder> FromView(EchoResponseView view) {if (!view.IsValid()) return nullptr;return EchoResponseBuilder::Create(view.GetIdentifier(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
3567 #endif
3568
3569 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);}
3570
3571 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3572
3573 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
3574
3575 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() ;}
3576
3577 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3578
3579 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
3580
3581 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
3582
3583 protected:
3584 explicit EchoResponseBuilder(uint8_t identifier) :ControlBuilder(CommandCode::ECHO_RESPONSE/* code_ */, identifier) {}
3585
3586
3587 std::unique_ptr<BasePacketBuilder> payload_{};};
3588 #ifdef PACKET_TESTING
3589 #define DEFINE_AND_INSTANTIATE_EchoResponseReflectionTest(...)class EchoResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {EchoResponseView view = EchoResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = EchoResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(EchoResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(EchoResponse_reflection, EchoResponseReflectionTest, testing::Values(__VA_ARGS__))
3590 #endif
3591 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3592 #define DEFINE_EchoResponseReflectionFuzzTest() void RunEchoResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);EchoResponseView view = EchoResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = EchoResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3593 #endif
3594
3595 #ifdef PACKET_FUZZ_TESTING
3596 #define DEFINE_AND_REGISTER_EchoResponseReflectionFuzzTest(REGISTRY) DEFINE_EchoResponseReflectionFuzzTest(); class EchoResponseReflectionFuzzTestRegistrant {public: explicit EchoResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunEchoResponseReflectionFuzzTest);}}; EchoResponseReflectionFuzzTestRegistrant EchoResponse_reflection_fuzz_test_registrant(REGISTRY);
3597 #endif
3598
3599
Create(uint8_t identifier,InformationRequestInfoType info_type)3600 class InformationRequestBuilder : public ControlBuilder { public: virtual ~InformationRequestBuilder() = default;static std::unique_ptr<InformationRequestBuilder> Create(uint8_t identifier, InformationRequestInfoType info_type) {auto builder = std::unique_ptr<InformationRequestBuilder>(new InformationRequestBuilder(identifier, info_type));return builder;}
3601
3602 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3603 static std::unique_ptr<InformationRequestBuilder> FromView(InformationRequestView view) {if (!view.IsValid()) return nullptr;return InformationRequestBuilder::Create(view.GetIdentifier(), view.GetInfoType());}
3604 #endif
3605
3606 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(info_type_), i, 16);}
3607
3608 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3609
3610 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3611
3612 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3613
3614 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3615
3616 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3617
3618 protected:
3619 explicit InformationRequestBuilder(uint8_t identifier, InformationRequestInfoType info_type) :ControlBuilder(CommandCode::INFORMATION_REQUEST/* code_ */, identifier) ,info_type_(info_type) {}
3620
3621
3622 InformationRequestInfoType info_type_{};};
3623 #ifdef PACKET_TESTING
3624 #define DEFINE_AND_INSTANTIATE_InformationRequestReflectionTest(...)class InformationRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {InformationRequestView view = InformationRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = InformationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(InformationRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(InformationRequest_reflection, InformationRequestReflectionTest, testing::Values(__VA_ARGS__))
3625 #endif
3626 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3627 #define DEFINE_InformationRequestReflectionFuzzTest() void RunInformationRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);InformationRequestView view = InformationRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = InformationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3628 #endif
3629
3630 #ifdef PACKET_FUZZ_TESTING
3631 #define DEFINE_AND_REGISTER_InformationRequestReflectionFuzzTest(REGISTRY) DEFINE_InformationRequestReflectionFuzzTest(); class InformationRequestReflectionFuzzTestRegistrant {public: explicit InformationRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunInformationRequestReflectionFuzzTest);}}; InformationRequestReflectionFuzzTestRegistrant InformationRequest_reflection_fuzz_test_registrant(REGISTRY);
3632 #endif
3633
3634
SerializeHeader(BitInserter & i)3635 class InformationResponseBuilder : public ControlBuilder { public: virtual ~InformationResponseBuilder() = default;protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(info_type_), i, 16);insert(static_cast<uint16_t>(result_), i, 16);}
3636
3637 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3638
3639 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3640
3641 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3642
3643 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3644
3645 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3646
3647 protected:
3648 explicit InformationResponseBuilder(uint8_t identifier, InformationRequestInfoType info_type, InformationRequestResult result) :ControlBuilder(CommandCode::INFORMATION_RESPONSE/* code_ */, identifier) ,info_type_(info_type),result_(result) {}
3649
3650
3651 InformationRequestInfoType info_type_{};InformationRequestResult result_{};};
3652 #ifdef PACKET_TESTING
3653 #define DEFINE_AND_INSTANTIATE_InformationResponseReflectionTest(...)class InformationResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {InformationResponseView view = InformationResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = InformationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(InformationResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(InformationResponse_reflection, InformationResponseReflectionTest, testing::Values(__VA_ARGS__))
3654 #endif
3655 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3656 #define DEFINE_InformationResponseReflectionFuzzTest() void RunInformationResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);InformationResponseView view = InformationResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = InformationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3657 #endif
3658
3659 #ifdef PACKET_FUZZ_TESTING
3660 #define DEFINE_AND_REGISTER_InformationResponseReflectionFuzzTest(REGISTRY) DEFINE_InformationResponseReflectionFuzzTest(); class InformationResponseReflectionFuzzTestRegistrant {public: explicit InformationResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunInformationResponseReflectionFuzzTest);}}; InformationResponseReflectionFuzzTestRegistrant InformationResponse_reflection_fuzz_test_registrant(REGISTRY);
3661 #endif
3662
3663
Create(uint8_t identifier,InformationRequestResult result,uint16_t connectionless_mtu)3664 class InformationResponseConnectionlessMtuBuilder : public InformationResponseBuilder { public: virtual ~InformationResponseConnectionlessMtuBuilder() = default;static std::unique_ptr<InformationResponseConnectionlessMtuBuilder> Create(uint8_t identifier, InformationRequestResult result, uint16_t connectionless_mtu) {auto builder = std::unique_ptr<InformationResponseConnectionlessMtuBuilder>(new InformationResponseConnectionlessMtuBuilder(identifier, result, connectionless_mtu));return builder;}
3665
3666 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3667 static std::unique_ptr<InformationResponseConnectionlessMtuBuilder> FromView(InformationResponseConnectionlessMtuView view) {if (!view.IsValid()) return nullptr;return InformationResponseConnectionlessMtuBuilder::Create(view.GetIdentifier(), view.GetResult(), view.GetConnectionlessMtu());}
3668 #endif
3669
3670 protected:void SerializeHeader(BitInserter& i ) const {InformationResponseBuilder::SerializeHeader(i);insert(connectionless_mtu_, i,16);}
3671
3672 void SerializeFooter(BitInserter& i ) const {InformationResponseBuilder::SerializeFooter(i);}
3673
3674 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3675
3676 protected:size_t BitsOfHeader() const {return 0 + InformationResponseBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3677
3678 size_t BitsOfFooter() const {return 0 + InformationResponseBuilder::BitsOfFooter() ;}
3679
3680 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3681
3682 protected:
3683 explicit InformationResponseConnectionlessMtuBuilder(uint8_t identifier, InformationRequestResult result, uint16_t connectionless_mtu) :InformationResponseBuilder(identifier, InformationRequestInfoType::CONNECTIONLESS_MTU/* info_type_ */, result) ,connectionless_mtu_(connectionless_mtu) {}
3684
3685
3686 uint16_t connectionless_mtu_{};};
3687 #ifdef PACKET_TESTING
3688 #define DEFINE_AND_INSTANTIATE_InformationResponseConnectionlessMtuReflectionTest(...)class InformationResponseConnectionlessMtuReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {InformationResponseConnectionlessMtuView view = InformationResponseConnectionlessMtuView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = InformationResponseConnectionlessMtuBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(InformationResponseConnectionlessMtuReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(InformationResponseConnectionlessMtu_reflection, InformationResponseConnectionlessMtuReflectionTest, testing::Values(__VA_ARGS__))
3689 #endif
3690 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3691 #define DEFINE_InformationResponseConnectionlessMtuReflectionFuzzTest() void RunInformationResponseConnectionlessMtuReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);InformationResponseConnectionlessMtuView view = InformationResponseConnectionlessMtuView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = InformationResponseConnectionlessMtuBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3692 #endif
3693
3694 #ifdef PACKET_FUZZ_TESTING
3695 #define DEFINE_AND_REGISTER_InformationResponseConnectionlessMtuReflectionFuzzTest(REGISTRY) DEFINE_InformationResponseConnectionlessMtuReflectionFuzzTest(); class InformationResponseConnectionlessMtuReflectionFuzzTestRegistrant {public: explicit InformationResponseConnectionlessMtuReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunInformationResponseConnectionlessMtuReflectionFuzzTest);}}; InformationResponseConnectionlessMtuReflectionFuzzTestRegistrant InformationResponseConnectionlessMtu_reflection_fuzz_test_registrant(REGISTRY);
3696 #endif
3697
3698
Create(uint8_t identifier,InformationRequestResult result,uint8_t flow_control_mode,uint8_t retransmission_mode,uint8_t bi_directional_qoS,uint8_t enhanced_retransmission_mode,uint8_t streaming_mode,uint8_t fcs_option,uint8_t extended_flow_specification_for_br_edr,uint8_t fixed_channels,uint8_t extended_window_size,uint8_t unicast_connectionless_data_reception,uint8_t enhanced_credit_based_flow_control_mode)3699 class InformationResponseExtendedFeaturesBuilder : public InformationResponseBuilder { public: virtual ~InformationResponseExtendedFeaturesBuilder() = default;static std::unique_ptr<InformationResponseExtendedFeaturesBuilder> Create(uint8_t identifier, InformationRequestResult result, uint8_t flow_control_mode, uint8_t retransmission_mode, uint8_t bi_directional_qoS, uint8_t enhanced_retransmission_mode, uint8_t streaming_mode, uint8_t fcs_option, uint8_t extended_flow_specification_for_br_edr, uint8_t fixed_channels, uint8_t extended_window_size, uint8_t unicast_connectionless_data_reception, uint8_t enhanced_credit_based_flow_control_mode) {auto builder = std::unique_ptr<InformationResponseExtendedFeaturesBuilder>(new InformationResponseExtendedFeaturesBuilder(identifier, result, flow_control_mode, retransmission_mode, bi_directional_qoS, enhanced_retransmission_mode, streaming_mode, fcs_option, extended_flow_specification_for_br_edr, fixed_channels, extended_window_size, unicast_connectionless_data_reception, enhanced_credit_based_flow_control_mode));return builder;}
3700
3701 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3702 static std::unique_ptr<InformationResponseExtendedFeaturesBuilder> FromView(InformationResponseExtendedFeaturesView view) {if (!view.IsValid()) return nullptr;return InformationResponseExtendedFeaturesBuilder::Create(view.GetIdentifier(), view.GetResult(), view.GetFlowControlMode(), view.GetRetransmissionMode(), view.GetBiDirectionalQoS(), view.GetEnhancedRetransmissionMode(), view.GetStreamingMode(), view.GetFcsOption(), view.GetExtendedFlowSpecificationForBrEdr(), view.GetFixedChannels(), view.GetExtendedWindowSize(), view.GetUnicastConnectionlessDataReception(), view.GetEnhancedCreditBasedFlowControlMode());}
3703 #endif
3704
3705 protected:void SerializeHeader(BitInserter& i ) const {InformationResponseBuilder::SerializeHeader(i);insert(flow_control_mode_, i,1);insert(retransmission_mode_, i,1);insert(bi_directional_qoS_, i,1);insert(enhanced_retransmission_mode_, i,1);insert(streaming_mode_, i,1);insert(fcs_option_, i,1);insert(extended_flow_specification_for_br_edr_, i,1);insert(fixed_channels_, i,1);insert(extended_window_size_, i,1);insert(unicast_connectionless_data_reception_, i,1);insert(enhanced_credit_based_flow_control_mode_, i,1);insert(static_cast<uint32_t>(0) /* Reserved */, i, 21 );
3706 }
3707
3708 void SerializeFooter(BitInserter& i ) const {InformationResponseBuilder::SerializeFooter(i);}
3709
3710 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3711
3712 protected:size_t BitsOfHeader() const {return 0 + InformationResponseBuilder::BitsOfHeader() + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 1 + /* Dynamic: */ 0 + /* Bits: */ 21 + /* Dynamic: */ 0;}
3713
3714 size_t BitsOfFooter() const {return 0 + InformationResponseBuilder::BitsOfFooter() ;}
3715
3716 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3717
3718 protected:
3719 explicit InformationResponseExtendedFeaturesBuilder(uint8_t identifier, InformationRequestResult result, uint8_t flow_control_mode, uint8_t retransmission_mode, uint8_t bi_directional_qoS, uint8_t enhanced_retransmission_mode, uint8_t streaming_mode, uint8_t fcs_option, uint8_t extended_flow_specification_for_br_edr, uint8_t fixed_channels, uint8_t extended_window_size, uint8_t unicast_connectionless_data_reception, uint8_t enhanced_credit_based_flow_control_mode) :InformationResponseBuilder(identifier, InformationRequestInfoType::EXTENDED_FEATURES_SUPPORTED/* info_type_ */, result) ,flow_control_mode_(flow_control_mode),retransmission_mode_(retransmission_mode),bi_directional_qoS_(bi_directional_qoS),enhanced_retransmission_mode_(enhanced_retransmission_mode),streaming_mode_(streaming_mode),fcs_option_(fcs_option),extended_flow_specification_for_br_edr_(extended_flow_specification_for_br_edr),fixed_channels_(fixed_channels),extended_window_size_(extended_window_size),unicast_connectionless_data_reception_(unicast_connectionless_data_reception),enhanced_credit_based_flow_control_mode_(enhanced_credit_based_flow_control_mode) {CheckParameterValues(flow_control_mode_, retransmission_mode_, bi_directional_qoS_, enhanced_retransmission_mode_, streaming_mode_, fcs_option_, extended_flow_specification_for_br_edr_, fixed_channels_, extended_window_size_, unicast_connectionless_data_reception_, enhanced_credit_based_flow_control_mode_);}
3720
3721 void CheckParameterValues(uint8_t flow_control_mode, uint8_t retransmission_mode, uint8_t bi_directional_qoS, uint8_t enhanced_retransmission_mode, uint8_t streaming_mode, uint8_t fcs_option, uint8_t extended_flow_specification_for_br_edr, uint8_t fixed_channels, uint8_t extended_window_size, uint8_t unicast_connectionless_data_reception, uint8_t enhanced_credit_based_flow_control_mode) {ASSERT(flow_control_mode < (static_cast<uint64_t>(1) << 1));ASSERT(retransmission_mode < (static_cast<uint64_t>(1) << 1));ASSERT(bi_directional_qoS < (static_cast<uint64_t>(1) << 1));ASSERT(enhanced_retransmission_mode < (static_cast<uint64_t>(1) << 1));ASSERT(streaming_mode < (static_cast<uint64_t>(1) << 1));ASSERT(fcs_option < (static_cast<uint64_t>(1) << 1));ASSERT(extended_flow_specification_for_br_edr < (static_cast<uint64_t>(1) << 1));ASSERT(fixed_channels < (static_cast<uint64_t>(1) << 1));ASSERT(extended_window_size < (static_cast<uint64_t>(1) << 1));ASSERT(unicast_connectionless_data_reception < (static_cast<uint64_t>(1) << 1));ASSERT(enhanced_credit_based_flow_control_mode < (static_cast<uint64_t>(1) << 1));}
3722
3723 uint8_t flow_control_mode_{};uint8_t retransmission_mode_{};uint8_t bi_directional_qoS_{};uint8_t enhanced_retransmission_mode_{};uint8_t streaming_mode_{};uint8_t fcs_option_{};uint8_t extended_flow_specification_for_br_edr_{};uint8_t fixed_channels_{};uint8_t extended_window_size_{};uint8_t unicast_connectionless_data_reception_{};uint8_t enhanced_credit_based_flow_control_mode_{};};
3724 #ifdef PACKET_TESTING
3725 #define DEFINE_AND_INSTANTIATE_InformationResponseExtendedFeaturesReflectionTest(...)class InformationResponseExtendedFeaturesReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {InformationResponseExtendedFeaturesView view = InformationResponseExtendedFeaturesView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = InformationResponseExtendedFeaturesBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(InformationResponseExtendedFeaturesReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(InformationResponseExtendedFeatures_reflection, InformationResponseExtendedFeaturesReflectionTest, testing::Values(__VA_ARGS__))
3726 #endif
3727 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3728 #define DEFINE_InformationResponseExtendedFeaturesReflectionFuzzTest() void RunInformationResponseExtendedFeaturesReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);InformationResponseExtendedFeaturesView view = InformationResponseExtendedFeaturesView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = InformationResponseExtendedFeaturesBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3729 #endif
3730
3731 #ifdef PACKET_FUZZ_TESTING
3732 #define DEFINE_AND_REGISTER_InformationResponseExtendedFeaturesReflectionFuzzTest(REGISTRY) DEFINE_InformationResponseExtendedFeaturesReflectionFuzzTest(); class InformationResponseExtendedFeaturesReflectionFuzzTestRegistrant {public: explicit InformationResponseExtendedFeaturesReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunInformationResponseExtendedFeaturesReflectionFuzzTest);}}; InformationResponseExtendedFeaturesReflectionFuzzTestRegistrant InformationResponseExtendedFeatures_reflection_fuzz_test_registrant(REGISTRY);
3733 #endif
3734
3735
Create(uint8_t identifier,InformationRequestResult result,uint64_t fixed_channels)3736 class InformationResponseFixedChannelsBuilder : public InformationResponseBuilder { public: virtual ~InformationResponseFixedChannelsBuilder() = default;static std::unique_ptr<InformationResponseFixedChannelsBuilder> Create(uint8_t identifier, InformationRequestResult result, uint64_t fixed_channels) {auto builder = std::unique_ptr<InformationResponseFixedChannelsBuilder>(new InformationResponseFixedChannelsBuilder(identifier, result, fixed_channels));return builder;}
3737
3738 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3739 static std::unique_ptr<InformationResponseFixedChannelsBuilder> FromView(InformationResponseFixedChannelsView view) {if (!view.IsValid()) return nullptr;return InformationResponseFixedChannelsBuilder::Create(view.GetIdentifier(), view.GetResult(), view.GetFixedChannels());}
3740 #endif
3741
3742 protected:void SerializeHeader(BitInserter& i ) const {InformationResponseBuilder::SerializeHeader(i);insert(fixed_channels_, i,64);}
3743
3744 void SerializeFooter(BitInserter& i ) const {InformationResponseBuilder::SerializeFooter(i);}
3745
3746 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3747
3748 protected:size_t BitsOfHeader() const {return 0 + InformationResponseBuilder::BitsOfHeader() + /* Bits: */ 64 + /* Dynamic: */ 0;}
3749
3750 size_t BitsOfFooter() const {return 0 + InformationResponseBuilder::BitsOfFooter() ;}
3751
3752 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3753
3754 protected:
3755 explicit InformationResponseFixedChannelsBuilder(uint8_t identifier, InformationRequestResult result, uint64_t fixed_channels) :InformationResponseBuilder(identifier, InformationRequestInfoType::FIXED_CHANNELS_SUPPORTED/* info_type_ */, result) ,fixed_channels_(fixed_channels) {}
3756
3757
3758 uint64_t fixed_channels_{};};
3759 #ifdef PACKET_TESTING
3760 #define DEFINE_AND_INSTANTIATE_InformationResponseFixedChannelsReflectionTest(...)class InformationResponseFixedChannelsReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {InformationResponseFixedChannelsView view = InformationResponseFixedChannelsView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = InformationResponseFixedChannelsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(InformationResponseFixedChannelsReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(InformationResponseFixedChannels_reflection, InformationResponseFixedChannelsReflectionTest, testing::Values(__VA_ARGS__))
3761 #endif
3762 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3763 #define DEFINE_InformationResponseFixedChannelsReflectionFuzzTest() void RunInformationResponseFixedChannelsReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);InformationResponseFixedChannelsView view = InformationResponseFixedChannelsView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = InformationResponseFixedChannelsBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3764 #endif
3765
3766 #ifdef PACKET_FUZZ_TESTING
3767 #define DEFINE_AND_REGISTER_InformationResponseFixedChannelsReflectionFuzzTest(REGISTRY) DEFINE_InformationResponseFixedChannelsReflectionFuzzTest(); class InformationResponseFixedChannelsReflectionFuzzTestRegistrant {public: explicit InformationResponseFixedChannelsReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunInformationResponseFixedChannelsReflectionFuzzTest);}}; InformationResponseFixedChannelsReflectionFuzzTestRegistrant InformationResponseFixedChannels_reflection_fuzz_test_registrant(REGISTRY);
3768 #endif
3769
3770
Create(uint8_t identifier,uint16_t psm,uint16_t source_cid,uint8_t controller_id)3771 class CreateChannelRequestBuilder : public ControlBuilder { public: virtual ~CreateChannelRequestBuilder() = default;static std::unique_ptr<CreateChannelRequestBuilder> Create(uint8_t identifier, uint16_t psm, uint16_t source_cid, uint8_t controller_id) {auto builder = std::unique_ptr<CreateChannelRequestBuilder>(new CreateChannelRequestBuilder(identifier, psm, source_cid, controller_id));return builder;}
3772
3773 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3774 static std::unique_ptr<CreateChannelRequestBuilder> FromView(CreateChannelRequestView view) {if (!view.IsValid()) return nullptr;return CreateChannelRequestBuilder::Create(view.GetIdentifier(), view.GetPsm(), view.GetSourceCid(), view.GetControllerId());}
3775 #endif
3776
3777 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(psm_, i,16);insert(source_cid_, i,16);i.insert_byte(controller_id_);}
3778
3779 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3780
3781 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3782
3783 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0;}
3784
3785 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3786
3787 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3788
3789 protected:
3790 explicit CreateChannelRequestBuilder(uint8_t identifier, uint16_t psm, uint16_t source_cid, uint8_t controller_id) :ControlBuilder(CommandCode::CREATE_CHANNEL_REQUEST/* code_ */, identifier) ,psm_(psm),source_cid_(source_cid),controller_id_(controller_id) {}
3791
3792
3793 uint16_t psm_{};uint16_t source_cid_{};uint8_t controller_id_{};};
3794 #ifdef PACKET_TESTING
3795 #define DEFINE_AND_INSTANTIATE_CreateChannelRequestReflectionTest(...)class CreateChannelRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreateChannelRequestView view = CreateChannelRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreateChannelRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreateChannelRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreateChannelRequest_reflection, CreateChannelRequestReflectionTest, testing::Values(__VA_ARGS__))
3796 #endif
3797 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3798 #define DEFINE_CreateChannelRequestReflectionFuzzTest() void RunCreateChannelRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreateChannelRequestView view = CreateChannelRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreateChannelRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3799 #endif
3800
3801 #ifdef PACKET_FUZZ_TESTING
3802 #define DEFINE_AND_REGISTER_CreateChannelRequestReflectionFuzzTest(REGISTRY) DEFINE_CreateChannelRequestReflectionFuzzTest(); class CreateChannelRequestReflectionFuzzTestRegistrant {public: explicit CreateChannelRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreateChannelRequestReflectionFuzzTest);}}; CreateChannelRequestReflectionFuzzTestRegistrant CreateChannelRequest_reflection_fuzz_test_registrant(REGISTRY);
3803 #endif
3804
3805
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid,CreateChannelResponseResult result,CreateChannelResponseStatus status)3806 class CreateChannelResponseBuilder : public ControlBuilder { public: virtual ~CreateChannelResponseBuilder() = default;static std::unique_ptr<CreateChannelResponseBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid, CreateChannelResponseResult result, CreateChannelResponseStatus status) {auto builder = std::unique_ptr<CreateChannelResponseBuilder>(new CreateChannelResponseBuilder(identifier, destination_cid, source_cid, result, status));return builder;}
3807
3808 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3809 static std::unique_ptr<CreateChannelResponseBuilder> FromView(CreateChannelResponseView view) {if (!view.IsValid()) return nullptr;return CreateChannelResponseBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid(), view.GetResult(), view.GetStatus());}
3810 #endif
3811
3812 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);insert(static_cast<uint16_t>(result_), i, 16);insert(static_cast<uint16_t>(status_), i, 16);}
3813
3814 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3815
3816 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3817
3818 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3819
3820 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3821
3822 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3823
3824 protected:
3825 explicit CreateChannelResponseBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid, CreateChannelResponseResult result, CreateChannelResponseStatus status) :ControlBuilder(CommandCode::CREATE_CHANNEL_RESPONSE/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid),result_(result),status_(status) {}
3826
3827
3828 uint16_t destination_cid_{};uint16_t source_cid_{};CreateChannelResponseResult result_{};CreateChannelResponseStatus status_{};};
3829 #ifdef PACKET_TESTING
3830 #define DEFINE_AND_INSTANTIATE_CreateChannelResponseReflectionTest(...)class CreateChannelResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreateChannelResponseView view = CreateChannelResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreateChannelResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreateChannelResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreateChannelResponse_reflection, CreateChannelResponseReflectionTest, testing::Values(__VA_ARGS__))
3831 #endif
3832 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3833 #define DEFINE_CreateChannelResponseReflectionFuzzTest() void RunCreateChannelResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreateChannelResponseView view = CreateChannelResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreateChannelResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3834 #endif
3835
3836 #ifdef PACKET_FUZZ_TESTING
3837 #define DEFINE_AND_REGISTER_CreateChannelResponseReflectionFuzzTest(REGISTRY) DEFINE_CreateChannelResponseReflectionFuzzTest(); class CreateChannelResponseReflectionFuzzTestRegistrant {public: explicit CreateChannelResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreateChannelResponseReflectionFuzzTest);}}; CreateChannelResponseReflectionFuzzTestRegistrant CreateChannelResponse_reflection_fuzz_test_registrant(REGISTRY);
3838 #endif
3839
3840
Create(uint8_t identifier,uint16_t initiator_cid,uint8_t dest_controller_id)3841 class MoveChannelRequestBuilder : public ControlBuilder { public: virtual ~MoveChannelRequestBuilder() = default;static std::unique_ptr<MoveChannelRequestBuilder> Create(uint8_t identifier, uint16_t initiator_cid, uint8_t dest_controller_id) {auto builder = std::unique_ptr<MoveChannelRequestBuilder>(new MoveChannelRequestBuilder(identifier, initiator_cid, dest_controller_id));return builder;}
3842
3843 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3844 static std::unique_ptr<MoveChannelRequestBuilder> FromView(MoveChannelRequestView view) {if (!view.IsValid()) return nullptr;return MoveChannelRequestBuilder::Create(view.GetIdentifier(), view.GetInitiatorCid(), view.GetDestControllerId());}
3845 #endif
3846
3847 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(initiator_cid_, i,16);i.insert_byte(dest_controller_id_);}
3848
3849 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3850
3851 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3852
3853 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0;}
3854
3855 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3856
3857 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3858
3859 protected:
3860 explicit MoveChannelRequestBuilder(uint8_t identifier, uint16_t initiator_cid, uint8_t dest_controller_id) :ControlBuilder(CommandCode::MOVE_CHANNEL_REQUEST/* code_ */, identifier) ,initiator_cid_(initiator_cid),dest_controller_id_(dest_controller_id) {}
3861
3862
3863 uint16_t initiator_cid_{};uint8_t dest_controller_id_{};};
3864 #ifdef PACKET_TESTING
3865 #define DEFINE_AND_INSTANTIATE_MoveChannelRequestReflectionTest(...)class MoveChannelRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {MoveChannelRequestView view = MoveChannelRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = MoveChannelRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(MoveChannelRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(MoveChannelRequest_reflection, MoveChannelRequestReflectionTest, testing::Values(__VA_ARGS__))
3866 #endif
3867 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3868 #define DEFINE_MoveChannelRequestReflectionFuzzTest() void RunMoveChannelRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);MoveChannelRequestView view = MoveChannelRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = MoveChannelRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3869 #endif
3870
3871 #ifdef PACKET_FUZZ_TESTING
3872 #define DEFINE_AND_REGISTER_MoveChannelRequestReflectionFuzzTest(REGISTRY) DEFINE_MoveChannelRequestReflectionFuzzTest(); class MoveChannelRequestReflectionFuzzTestRegistrant {public: explicit MoveChannelRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunMoveChannelRequestReflectionFuzzTest);}}; MoveChannelRequestReflectionFuzzTestRegistrant MoveChannelRequest_reflection_fuzz_test_registrant(REGISTRY);
3873 #endif
3874
3875
Create(uint8_t identifier,uint16_t initiator_cid,MoveChannelResponseResult result)3876 class MoveChannelResponseBuilder : public ControlBuilder { public: virtual ~MoveChannelResponseBuilder() = default;static std::unique_ptr<MoveChannelResponseBuilder> Create(uint8_t identifier, uint16_t initiator_cid, MoveChannelResponseResult result) {auto builder = std::unique_ptr<MoveChannelResponseBuilder>(new MoveChannelResponseBuilder(identifier, initiator_cid, result));return builder;}
3877
3878 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3879 static std::unique_ptr<MoveChannelResponseBuilder> FromView(MoveChannelResponseView view) {if (!view.IsValid()) return nullptr;return MoveChannelResponseBuilder::Create(view.GetIdentifier(), view.GetInitiatorCid(), view.GetResult());}
3880 #endif
3881
3882 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(initiator_cid_, i,16);insert(static_cast<uint16_t>(result_), i, 16);}
3883
3884 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3885
3886 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3887
3888 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3889
3890 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3891
3892 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3893
3894 protected:
3895 explicit MoveChannelResponseBuilder(uint8_t identifier, uint16_t initiator_cid, MoveChannelResponseResult result) :ControlBuilder(CommandCode::MOVE_CHANNEL_RESPONSE/* code_ */, identifier) ,initiator_cid_(initiator_cid),result_(result) {}
3896
3897
3898 uint16_t initiator_cid_{};MoveChannelResponseResult result_{};};
3899 #ifdef PACKET_TESTING
3900 #define DEFINE_AND_INSTANTIATE_MoveChannelResponseReflectionTest(...)class MoveChannelResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {MoveChannelResponseView view = MoveChannelResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = MoveChannelResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(MoveChannelResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(MoveChannelResponse_reflection, MoveChannelResponseReflectionTest, testing::Values(__VA_ARGS__))
3901 #endif
3902 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3903 #define DEFINE_MoveChannelResponseReflectionFuzzTest() void RunMoveChannelResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);MoveChannelResponseView view = MoveChannelResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = MoveChannelResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3904 #endif
3905
3906 #ifdef PACKET_FUZZ_TESTING
3907 #define DEFINE_AND_REGISTER_MoveChannelResponseReflectionFuzzTest(REGISTRY) DEFINE_MoveChannelResponseReflectionFuzzTest(); class MoveChannelResponseReflectionFuzzTestRegistrant {public: explicit MoveChannelResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunMoveChannelResponseReflectionFuzzTest);}}; MoveChannelResponseReflectionFuzzTestRegistrant MoveChannelResponse_reflection_fuzz_test_registrant(REGISTRY);
3908 #endif
3909
3910
Create(uint8_t identifier,uint16_t initiator_cid,MoveChannelConfirmationResult result)3911 class MoveChannelConfirmationRequestBuilder : public ControlBuilder { public: virtual ~MoveChannelConfirmationRequestBuilder() = default;static std::unique_ptr<MoveChannelConfirmationRequestBuilder> Create(uint8_t identifier, uint16_t initiator_cid, MoveChannelConfirmationResult result) {auto builder = std::unique_ptr<MoveChannelConfirmationRequestBuilder>(new MoveChannelConfirmationRequestBuilder(identifier, initiator_cid, result));return builder;}
3912
3913 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3914 static std::unique_ptr<MoveChannelConfirmationRequestBuilder> FromView(MoveChannelConfirmationRequestView view) {if (!view.IsValid()) return nullptr;return MoveChannelConfirmationRequestBuilder::Create(view.GetIdentifier(), view.GetInitiatorCid(), view.GetResult());}
3915 #endif
3916
3917 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(initiator_cid_, i,16);insert(static_cast<uint16_t>(result_), i, 16);}
3918
3919 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3920
3921 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3922
3923 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3924
3925 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3926
3927 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3928
3929 protected:
3930 explicit MoveChannelConfirmationRequestBuilder(uint8_t identifier, uint16_t initiator_cid, MoveChannelConfirmationResult result) :ControlBuilder(CommandCode::MOVE_CHANNEL_CONFIRMATION_REQUEST/* code_ */, identifier) ,initiator_cid_(initiator_cid),result_(result) {}
3931
3932
3933 uint16_t initiator_cid_{};MoveChannelConfirmationResult result_{};};
3934 #ifdef PACKET_TESTING
3935 #define DEFINE_AND_INSTANTIATE_MoveChannelConfirmationRequestReflectionTest(...)class MoveChannelConfirmationRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {MoveChannelConfirmationRequestView view = MoveChannelConfirmationRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = MoveChannelConfirmationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(MoveChannelConfirmationRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(MoveChannelConfirmationRequest_reflection, MoveChannelConfirmationRequestReflectionTest, testing::Values(__VA_ARGS__))
3936 #endif
3937 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3938 #define DEFINE_MoveChannelConfirmationRequestReflectionFuzzTest() void RunMoveChannelConfirmationRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);MoveChannelConfirmationRequestView view = MoveChannelConfirmationRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = MoveChannelConfirmationRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3939 #endif
3940
3941 #ifdef PACKET_FUZZ_TESTING
3942 #define DEFINE_AND_REGISTER_MoveChannelConfirmationRequestReflectionFuzzTest(REGISTRY) DEFINE_MoveChannelConfirmationRequestReflectionFuzzTest(); class MoveChannelConfirmationRequestReflectionFuzzTestRegistrant {public: explicit MoveChannelConfirmationRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunMoveChannelConfirmationRequestReflectionFuzzTest);}}; MoveChannelConfirmationRequestReflectionFuzzTestRegistrant MoveChannelConfirmationRequest_reflection_fuzz_test_registrant(REGISTRY);
3943 #endif
3944
3945
Create(uint8_t identifier,uint16_t initiator_cid)3946 class MoveChannelConfirmationResponseBuilder : public ControlBuilder { public: virtual ~MoveChannelConfirmationResponseBuilder() = default;static std::unique_ptr<MoveChannelConfirmationResponseBuilder> Create(uint8_t identifier, uint16_t initiator_cid) {auto builder = std::unique_ptr<MoveChannelConfirmationResponseBuilder>(new MoveChannelConfirmationResponseBuilder(identifier, initiator_cid));return builder;}
3947
3948 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3949 static std::unique_ptr<MoveChannelConfirmationResponseBuilder> FromView(MoveChannelConfirmationResponseView view) {if (!view.IsValid()) return nullptr;return MoveChannelConfirmationResponseBuilder::Create(view.GetIdentifier(), view.GetInitiatorCid());}
3950 #endif
3951
3952 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(initiator_cid_, i,16);}
3953
3954 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3955
3956 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3957
3958 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
3959
3960 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3961
3962 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3963
3964 protected:
3965 explicit MoveChannelConfirmationResponseBuilder(uint8_t identifier, uint16_t initiator_cid) :ControlBuilder(CommandCode::MOVE_CHANNEL_CONFIRMATION_RESPONSE/* code_ */, identifier) ,initiator_cid_(initiator_cid) {}
3966
3967
3968 uint16_t initiator_cid_{};};
3969 #ifdef PACKET_TESTING
3970 #define DEFINE_AND_INSTANTIATE_MoveChannelConfirmationResponseReflectionTest(...)class MoveChannelConfirmationResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {MoveChannelConfirmationResponseView view = MoveChannelConfirmationResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = MoveChannelConfirmationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(MoveChannelConfirmationResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(MoveChannelConfirmationResponse_reflection, MoveChannelConfirmationResponseReflectionTest, testing::Values(__VA_ARGS__))
3971 #endif
3972 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
3973 #define DEFINE_MoveChannelConfirmationResponseReflectionFuzzTest() void RunMoveChannelConfirmationResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);MoveChannelConfirmationResponseView view = MoveChannelConfirmationResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = MoveChannelConfirmationResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
3974 #endif
3975
3976 #ifdef PACKET_FUZZ_TESTING
3977 #define DEFINE_AND_REGISTER_MoveChannelConfirmationResponseReflectionFuzzTest(REGISTRY) DEFINE_MoveChannelConfirmationResponseReflectionFuzzTest(); class MoveChannelConfirmationResponseReflectionFuzzTestRegistrant {public: explicit MoveChannelConfirmationResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunMoveChannelConfirmationResponseReflectionFuzzTest);}}; MoveChannelConfirmationResponseReflectionFuzzTestRegistrant MoveChannelConfirmationResponse_reflection_fuzz_test_registrant(REGISTRY);
3978 #endif
3979
3980
Create(uint8_t identifier,uint16_t cid,uint16_t credits)3981 class FlowControlCreditBuilder : public ControlBuilder { public: virtual ~FlowControlCreditBuilder() = default;static std::unique_ptr<FlowControlCreditBuilder> Create(uint8_t identifier, uint16_t cid, uint16_t credits) {auto builder = std::unique_ptr<FlowControlCreditBuilder>(new FlowControlCreditBuilder(identifier, cid, credits));return builder;}
3982
3983 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
3984 static std::unique_ptr<FlowControlCreditBuilder> FromView(FlowControlCreditView view) {if (!view.IsValid()) return nullptr;return FlowControlCreditBuilder::Create(view.GetIdentifier(), view.GetCid(), view.GetCredits());}
3985 #endif
3986
3987 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(cid_, i,16);insert(credits_, i,16);}
3988
3989 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
3990
3991 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
3992
3993 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
3994
3995 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
3996
3997 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
3998
3999 protected:
4000 explicit FlowControlCreditBuilder(uint8_t identifier, uint16_t cid, uint16_t credits) :ControlBuilder(CommandCode::FLOW_CONTROL_CREDIT/* code_ */, identifier) ,cid_(cid),credits_(credits) {}
4001
4002
4003 uint16_t cid_{};uint16_t credits_{};};
4004 #ifdef PACKET_TESTING
4005 #define DEFINE_AND_INSTANTIATE_FlowControlCreditReflectionTest(...)class FlowControlCreditReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {FlowControlCreditView view = FlowControlCreditView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = FlowControlCreditBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(FlowControlCreditReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(FlowControlCredit_reflection, FlowControlCreditReflectionTest, testing::Values(__VA_ARGS__))
4006 #endif
4007 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4008 #define DEFINE_FlowControlCreditReflectionFuzzTest() void RunFlowControlCreditReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);FlowControlCreditView view = FlowControlCreditView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = FlowControlCreditBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4009 #endif
4010
4011 #ifdef PACKET_FUZZ_TESTING
4012 #define DEFINE_AND_REGISTER_FlowControlCreditReflectionFuzzTest(REGISTRY) DEFINE_FlowControlCreditReflectionFuzzTest(); class FlowControlCreditReflectionFuzzTestRegistrant {public: explicit FlowControlCreditReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunFlowControlCreditReflectionFuzzTest);}}; FlowControlCreditReflectionFuzzTestRegistrant FlowControlCredit_reflection_fuzz_test_registrant(REGISTRY);
4013 #endif
4014
4015
Create(uint8_t identifier,uint16_t spsm,uint16_t mtu,uint16_t mps,uint16_t initial_credits,const std::vector<uint16_t> & source_cid)4016 class CreditBasedConnectionRequestBuilder : public ControlBuilder { public: virtual ~CreditBasedConnectionRequestBuilder() = default;static std::unique_ptr<CreditBasedConnectionRequestBuilder> Create(uint8_t identifier, uint16_t spsm, uint16_t mtu, uint16_t mps, uint16_t initial_credits, const std::vector<uint16_t>& source_cid) {auto builder = std::unique_ptr<CreditBasedConnectionRequestBuilder>(new CreditBasedConnectionRequestBuilder(identifier, spsm, mtu, mps, initial_credits, source_cid));return builder;}
4017
4018 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4019 static std::unique_ptr<CreditBasedConnectionRequestBuilder> FromView(CreditBasedConnectionRequestView view) {if (!view.IsValid()) return nullptr;return CreditBasedConnectionRequestBuilder::Create(view.GetIdentifier(), view.GetSpsm(), view.GetMtu(), view.GetMps(), view.GetInitialCredits(), view.GetSourceCid());}
4020 #endif
4021
4022 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(spsm_, i,16);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);for (const auto& val_ : source_cid_) {insert(val_, i,16);}
4023 }
4024
4025 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
4026
4027 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4028
4029 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(source_cid_.size()) * 16);}
4030
4031 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
4032
4033 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4034
4035 protected:
4036 explicit CreditBasedConnectionRequestBuilder(uint8_t identifier, uint16_t spsm, uint16_t mtu, uint16_t mps, uint16_t initial_credits, const std::vector<uint16_t>& source_cid) :ControlBuilder(CommandCode::CREDIT_BASED_CONNECTION_REQUEST/* code_ */, identifier) ,spsm_(spsm),mtu_(mtu),mps_(mps),initial_credits_(initial_credits),source_cid_(source_cid) {}
4037
4038
4039 uint16_t spsm_{};uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};std::vector<uint16_t> source_cid_{};};
4040 #ifdef PACKET_TESTING
4041 #define DEFINE_AND_INSTANTIATE_CreditBasedConnectionRequestReflectionTest(...)class CreditBasedConnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreditBasedConnectionRequestView view = CreditBasedConnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreditBasedConnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreditBasedConnectionRequest_reflection, CreditBasedConnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
4042 #endif
4043 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4044 #define DEFINE_CreditBasedConnectionRequestReflectionFuzzTest() void RunCreditBasedConnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreditBasedConnectionRequestView view = CreditBasedConnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4045 #endif
4046
4047 #ifdef PACKET_FUZZ_TESTING
4048 #define DEFINE_AND_REGISTER_CreditBasedConnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_CreditBasedConnectionRequestReflectionFuzzTest(); class CreditBasedConnectionRequestReflectionFuzzTestRegistrant {public: explicit CreditBasedConnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreditBasedConnectionRequestReflectionFuzzTest);}}; CreditBasedConnectionRequestReflectionFuzzTestRegistrant CreditBasedConnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
4049 #endif
4050
4051
Create(uint8_t identifier,uint16_t mtu,uint16_t mps,uint16_t initial_credits,CreditBasedConnectionResponseResult result,const std::vector<uint16_t> & destination_cid)4052 class CreditBasedConnectionResponseBuilder : public ControlBuilder { public: virtual ~CreditBasedConnectionResponseBuilder() = default;static std::unique_ptr<CreditBasedConnectionResponseBuilder> Create(uint8_t identifier, uint16_t mtu, uint16_t mps, uint16_t initial_credits, CreditBasedConnectionResponseResult result, const std::vector<uint16_t>& destination_cid) {auto builder = std::unique_ptr<CreditBasedConnectionResponseBuilder>(new CreditBasedConnectionResponseBuilder(identifier, mtu, mps, initial_credits, result, destination_cid));return builder;}
4053
4054 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4055 static std::unique_ptr<CreditBasedConnectionResponseBuilder> FromView(CreditBasedConnectionResponseView view) {if (!view.IsValid()) return nullptr;return CreditBasedConnectionResponseBuilder::Create(view.GetIdentifier(), view.GetMtu(), view.GetMps(), view.GetInitialCredits(), view.GetResult(), view.GetDestinationCid());}
4056 #endif
4057
4058 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);insert(static_cast<uint16_t>(result_), i, 16);for (const auto& val_ : destination_cid_) {insert(val_, i,16);}
4059 }
4060
4061 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
4062
4063 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4064
4065 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(destination_cid_.size()) * 16);}
4066
4067 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
4068
4069 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4070
4071 protected:
4072 explicit CreditBasedConnectionResponseBuilder(uint8_t identifier, uint16_t mtu, uint16_t mps, uint16_t initial_credits, CreditBasedConnectionResponseResult result, const std::vector<uint16_t>& destination_cid) :ControlBuilder(CommandCode::CREDIT_BASED_CONNECTION_RESPONSE/* code_ */, identifier) ,mtu_(mtu),mps_(mps),initial_credits_(initial_credits),result_(result),destination_cid_(destination_cid) {}
4073
4074
4075 uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};CreditBasedConnectionResponseResult result_{};std::vector<uint16_t> destination_cid_{};};
4076 #ifdef PACKET_TESTING
4077 #define DEFINE_AND_INSTANTIATE_CreditBasedConnectionResponseReflectionTest(...)class CreditBasedConnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreditBasedConnectionResponseView view = CreditBasedConnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreditBasedConnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreditBasedConnectionResponse_reflection, CreditBasedConnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
4078 #endif
4079 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4080 #define DEFINE_CreditBasedConnectionResponseReflectionFuzzTest() void RunCreditBasedConnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreditBasedConnectionResponseView view = CreditBasedConnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4081 #endif
4082
4083 #ifdef PACKET_FUZZ_TESTING
4084 #define DEFINE_AND_REGISTER_CreditBasedConnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_CreditBasedConnectionResponseReflectionFuzzTest(); class CreditBasedConnectionResponseReflectionFuzzTestRegistrant {public: explicit CreditBasedConnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreditBasedConnectionResponseReflectionFuzzTest);}}; CreditBasedConnectionResponseReflectionFuzzTestRegistrant CreditBasedConnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
4085 #endif
4086
4087
Create(uint8_t identifier,uint16_t mtu,uint16_t mps,const std::vector<uint16_t> & destination_cid)4088 class CreditBasedReconfigureRequestBuilder : public ControlBuilder { public: virtual ~CreditBasedReconfigureRequestBuilder() = default;static std::unique_ptr<CreditBasedReconfigureRequestBuilder> Create(uint8_t identifier, uint16_t mtu, uint16_t mps, const std::vector<uint16_t>& destination_cid) {auto builder = std::unique_ptr<CreditBasedReconfigureRequestBuilder>(new CreditBasedReconfigureRequestBuilder(identifier, mtu, mps, destination_cid));return builder;}
4089
4090 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4091 static std::unique_ptr<CreditBasedReconfigureRequestBuilder> FromView(CreditBasedReconfigureRequestView view) {if (!view.IsValid()) return nullptr;return CreditBasedReconfigureRequestBuilder::Create(view.GetIdentifier(), view.GetMtu(), view.GetMps(), view.GetDestinationCid());}
4092 #endif
4093
4094 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(mtu_, i,16);insert(mps_, i,16);for (const auto& val_ : destination_cid_) {insert(val_, i,16);}
4095 }
4096
4097 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
4098
4099 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4100
4101 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(destination_cid_.size()) * 16);}
4102
4103 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
4104
4105 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4106
4107 protected:
4108 explicit CreditBasedReconfigureRequestBuilder(uint8_t identifier, uint16_t mtu, uint16_t mps, const std::vector<uint16_t>& destination_cid) :ControlBuilder(CommandCode::CREDIT_BASED_RECONFIGURE_REQUEST/* code_ */, identifier) ,mtu_(mtu),mps_(mps),destination_cid_(destination_cid) {}
4109
4110
4111 uint16_t mtu_{};uint16_t mps_{};std::vector<uint16_t> destination_cid_{};};
4112 #ifdef PACKET_TESTING
4113 #define DEFINE_AND_INSTANTIATE_CreditBasedReconfigureRequestReflectionTest(...)class CreditBasedReconfigureRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreditBasedReconfigureRequestView view = CreditBasedReconfigureRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreditBasedReconfigureRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreditBasedReconfigureRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreditBasedReconfigureRequest_reflection, CreditBasedReconfigureRequestReflectionTest, testing::Values(__VA_ARGS__))
4114 #endif
4115 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4116 #define DEFINE_CreditBasedReconfigureRequestReflectionFuzzTest() void RunCreditBasedReconfigureRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreditBasedReconfigureRequestView view = CreditBasedReconfigureRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreditBasedReconfigureRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4117 #endif
4118
4119 #ifdef PACKET_FUZZ_TESTING
4120 #define DEFINE_AND_REGISTER_CreditBasedReconfigureRequestReflectionFuzzTest(REGISTRY) DEFINE_CreditBasedReconfigureRequestReflectionFuzzTest(); class CreditBasedReconfigureRequestReflectionFuzzTestRegistrant {public: explicit CreditBasedReconfigureRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreditBasedReconfigureRequestReflectionFuzzTest);}}; CreditBasedReconfigureRequestReflectionFuzzTestRegistrant CreditBasedReconfigureRequest_reflection_fuzz_test_registrant(REGISTRY);
4121 #endif
4122
4123
Create(uint8_t identifier,CreditBasedReconfigureResponseResult result)4124 class CreditBasedReconfigureResponseBuilder : public ControlBuilder { public: virtual ~CreditBasedReconfigureResponseBuilder() = default;static std::unique_ptr<CreditBasedReconfigureResponseBuilder> Create(uint8_t identifier, CreditBasedReconfigureResponseResult result) {auto builder = std::unique_ptr<CreditBasedReconfigureResponseBuilder>(new CreditBasedReconfigureResponseBuilder(identifier, result));return builder;}
4125
4126 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4127 static std::unique_ptr<CreditBasedReconfigureResponseBuilder> FromView(CreditBasedReconfigureResponseView view) {if (!view.IsValid()) return nullptr;return CreditBasedReconfigureResponseBuilder::Create(view.GetIdentifier(), view.GetResult());}
4128 #endif
4129
4130 protected:void SerializeHeader(BitInserter& i ) const {ControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(result_), i, 16);}
4131
4132 void SerializeFooter(BitInserter& i ) const {ControlBuilder::SerializeFooter(i);}
4133
4134 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4135
4136 protected:size_t BitsOfHeader() const {return 0 + ControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
4137
4138 size_t BitsOfFooter() const {return 0 + ControlBuilder::BitsOfFooter() ;}
4139
4140 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4141
4142 protected:
4143 explicit CreditBasedReconfigureResponseBuilder(uint8_t identifier, CreditBasedReconfigureResponseResult result) :ControlBuilder(CommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE/* code_ */, identifier) ,result_(result) {}
4144
4145
4146 CreditBasedReconfigureResponseResult result_{};};
4147 #ifdef PACKET_TESTING
4148 #define DEFINE_AND_INSTANTIATE_CreditBasedReconfigureResponseReflectionTest(...)class CreditBasedReconfigureResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {CreditBasedReconfigureResponseView view = CreditBasedReconfigureResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = CreditBasedReconfigureResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(CreditBasedReconfigureResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(CreditBasedReconfigureResponse_reflection, CreditBasedReconfigureResponseReflectionTest, testing::Values(__VA_ARGS__))
4149 #endif
4150 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4151 #define DEFINE_CreditBasedReconfigureResponseReflectionFuzzTest() void RunCreditBasedReconfigureResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);CreditBasedReconfigureResponseView view = CreditBasedReconfigureResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = CreditBasedReconfigureResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4152 #endif
4153
4154 #ifdef PACKET_FUZZ_TESTING
4155 #define DEFINE_AND_REGISTER_CreditBasedReconfigureResponseReflectionFuzzTest(REGISTRY) DEFINE_CreditBasedReconfigureResponseReflectionFuzzTest(); class CreditBasedReconfigureResponseReflectionFuzzTestRegistrant {public: explicit CreditBasedReconfigureResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunCreditBasedReconfigureResponseReflectionFuzzTest);}}; CreditBasedReconfigureResponseReflectionFuzzTestRegistrant CreditBasedReconfigureResponse_reflection_fuzz_test_registrant(REGISTRY);
4156 #endif
4157
4158
Create(std::unique_ptr<BasePacketBuilder> payload)4159 class LeControlFrameBuilder : public BasicFrameBuilder { public: virtual ~LeControlFrameBuilder() = default;static std::unique_ptr<LeControlFrameBuilder> Create(std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<LeControlFrameBuilder>(new LeControlFrameBuilder());builder->payload_ = std::move(payload);return builder;}
4160
4161 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4162 static std::unique_ptr<LeControlFrameBuilder> FromView(LeControlFrameView view) {if (!view.IsValid()) return nullptr;return LeControlFrameBuilder::Create(std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
4163 #endif
4164
4165 protected:void SerializeHeader(BitInserter& i ) const {BasicFrameBuilder::SerializeHeader(i);}
4166
4167 void SerializeFooter(BitInserter& i ) const {BasicFrameBuilder::SerializeFooter(i);}
4168
4169 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
4170
4171 protected:size_t BitsOfHeader() const {return 0 + BasicFrameBuilder::BitsOfHeader() ;}
4172
4173 size_t BitsOfFooter() const {return 0 + BasicFrameBuilder::BitsOfFooter() ;}
4174
4175 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
4176
4177 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
4178
4179 protected:
4180 explicit LeControlFrameBuilder() :BasicFrameBuilder(5/* channel_id_ */) {}
4181
4182
4183 std::unique_ptr<BasePacketBuilder> payload_{};};
4184 #ifdef PACKET_TESTING
4185 #define DEFINE_AND_INSTANTIATE_LeControlFrameReflectionTest(...)class LeControlFrameReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeControlFrameView view = LeControlFrameView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeControlFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeControlFrameReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeControlFrame_reflection, LeControlFrameReflectionTest, testing::Values(__VA_ARGS__))
4186 #endif
4187 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4188 #define DEFINE_LeControlFrameReflectionFuzzTest() void RunLeControlFrameReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeControlFrameView view = LeControlFrameView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeControlFrameBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4189 #endif
4190
4191 #ifdef PACKET_FUZZ_TESTING
4192 #define DEFINE_AND_REGISTER_LeControlFrameReflectionFuzzTest(REGISTRY) DEFINE_LeControlFrameReflectionFuzzTest(); class LeControlFrameReflectionFuzzTestRegistrant {public: explicit LeControlFrameReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeControlFrameReflectionFuzzTest);}}; LeControlFrameReflectionFuzzTestRegistrant LeControlFrame_reflection_fuzz_test_registrant(REGISTRY);
4193 #endif
4194
4195
Create(LeCommandCode code,uint8_t identifier,std::unique_ptr<BasePacketBuilder> payload)4196 class LeControlBuilder : public PacketBuilder<kLittleEndian> { public: virtual ~LeControlBuilder() = default;static std::unique_ptr<LeControlBuilder> Create(LeCommandCode code, uint8_t identifier, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<LeControlBuilder>(new LeControlBuilder(code, identifier));builder->payload_ = std::move(payload);return builder;}
4197
4198 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4199 static std::unique_ptr<LeControlBuilder> FromView(LeControlView view) {if (!view.IsValid()) return nullptr;return LeControlBuilder::Create(view.GetCode(), view.GetIdentifier(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
4200 #endif
4201
4202 protected:void SerializeHeader(BitInserter& i ) const {insert(static_cast<uint8_t>(code_), i, 8);i.insert_byte(identifier_);size_t payload_bytes = GetPayloadSize();ASSERT(payload_bytes < (static_cast<size_t>(1) << 16));insert(static_cast<uint16_t>(payload_bytes), i,16);}
4203
4204 void SerializeFooter(BitInserter&) const {}
4205
4206 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
4207
4208 protected:size_t BitsOfHeader() const {return 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 8 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4209
4210 size_t BitsOfFooter() const {return 0;}
4211
4212 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
4213
4214 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
4215
4216 protected:
4217 explicit LeControlBuilder(LeCommandCode code, uint8_t identifier) :code_(code),identifier_(identifier) {}
4218
4219
4220 LeCommandCode code_{};uint8_t identifier_{};std::unique_ptr<BasePacketBuilder> payload_{};};
4221 #ifdef PACKET_TESTING
4222 #define DEFINE_AND_INSTANTIATE_LeControlReflectionTest(...)class LeControlReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeControlView view = LeControlView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeControlBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeControlReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeControl_reflection, LeControlReflectionTest, testing::Values(__VA_ARGS__))
4223 #endif
4224 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4225 #define DEFINE_LeControlReflectionFuzzTest() void RunLeControlReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeControlView view = LeControlView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeControlBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4226 #endif
4227
4228 #ifdef PACKET_FUZZ_TESTING
4229 #define DEFINE_AND_REGISTER_LeControlReflectionFuzzTest(REGISTRY) DEFINE_LeControlReflectionFuzzTest(); class LeControlReflectionFuzzTestRegistrant {public: explicit LeControlReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeControlReflectionFuzzTest);}}; LeControlReflectionFuzzTestRegistrant LeControl_reflection_fuzz_test_registrant(REGISTRY);
4230 #endif
4231
4232
Create(uint8_t identifier,CommandRejectReason reason,std::unique_ptr<BasePacketBuilder> payload)4233 class LeCommandRejectBuilder : public LeControlBuilder { public: virtual ~LeCommandRejectBuilder() = default;static std::unique_ptr<LeCommandRejectBuilder> Create(uint8_t identifier, CommandRejectReason reason, std::unique_ptr<BasePacketBuilder> payload) {auto builder = std::unique_ptr<LeCommandRejectBuilder>(new LeCommandRejectBuilder(identifier, reason));builder->payload_ = std::move(payload);return builder;}
4234
4235 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4236 static std::unique_ptr<LeCommandRejectBuilder> FromView(LeCommandRejectView view) {if (!view.IsValid()) return nullptr;return LeCommandRejectBuilder::Create(view.GetIdentifier(), view.GetReason(), std::make_unique<RawBuilder>(std::vector<uint8_t>(view.GetPayload().begin(), view.GetPayload().end())));}
4237 #endif
4238
4239 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(reason_), i, 16);}
4240
4241 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4242
4243 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);payload_->Serialize(i);SerializeFooter(i);}
4244
4245 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
4246
4247 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4248
4249 size_t GetPayloadSize() const {if (payload_ != nullptr) {return payload_->size();}else { return size() - (BitsOfHeader() + BitsOfFooter()) / 8;};}
4250
4251 public:virtual size_t size() const override {return (BitsOfHeader() / 8)+ payload_->size() + (BitsOfFooter() / 8);}
4252
4253 protected:
4254 explicit LeCommandRejectBuilder(uint8_t identifier, CommandRejectReason reason) :LeControlBuilder(LeCommandCode::COMMAND_REJECT/* code_ */, identifier) ,reason_(reason) {}
4255
4256
4257 CommandRejectReason reason_{};std::unique_ptr<BasePacketBuilder> payload_{};};
4258 #ifdef PACKET_TESTING
4259 #define DEFINE_AND_INSTANTIATE_LeCommandRejectReflectionTest(...)class LeCommandRejectReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCommandRejectView view = LeCommandRejectView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCommandRejectBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCommandRejectReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCommandReject_reflection, LeCommandRejectReflectionTest, testing::Values(__VA_ARGS__))
4260 #endif
4261 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4262 #define DEFINE_LeCommandRejectReflectionFuzzTest() void RunLeCommandRejectReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCommandRejectView view = LeCommandRejectView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCommandRejectBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4263 #endif
4264
4265 #ifdef PACKET_FUZZ_TESTING
4266 #define DEFINE_AND_REGISTER_LeCommandRejectReflectionFuzzTest(REGISTRY) DEFINE_LeCommandRejectReflectionFuzzTest(); class LeCommandRejectReflectionFuzzTestRegistrant {public: explicit LeCommandRejectReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCommandRejectReflectionFuzzTest);}}; LeCommandRejectReflectionFuzzTestRegistrant LeCommandReject_reflection_fuzz_test_registrant(REGISTRY);
4267 #endif
4268
4269
Create(uint8_t identifier)4270 class LeCommandRejectNotUnderstoodBuilder : public LeCommandRejectBuilder { public: virtual ~LeCommandRejectNotUnderstoodBuilder() = default;static std::unique_ptr<LeCommandRejectNotUnderstoodBuilder> Create(uint8_t identifier) {auto builder = std::unique_ptr<LeCommandRejectNotUnderstoodBuilder>(new LeCommandRejectNotUnderstoodBuilder(identifier));return builder;}
4271
4272 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4273 static std::unique_ptr<LeCommandRejectNotUnderstoodBuilder> FromView(LeCommandRejectNotUnderstoodView view) {if (!view.IsValid()) return nullptr;return LeCommandRejectNotUnderstoodBuilder::Create(view.GetIdentifier());}
4274 #endif
4275
4276 protected:void SerializeHeader(BitInserter& i ) const {LeCommandRejectBuilder::SerializeHeader(i);}
4277
4278 void SerializeFooter(BitInserter& i ) const {LeCommandRejectBuilder::SerializeFooter(i);}
4279
4280 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4281
4282 protected:size_t BitsOfHeader() const {return 0 + LeCommandRejectBuilder::BitsOfHeader() ;}
4283
4284 size_t BitsOfFooter() const {return 0 + LeCommandRejectBuilder::BitsOfFooter() ;}
4285
4286 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4287
4288 protected:
4289 explicit LeCommandRejectNotUnderstoodBuilder(uint8_t identifier) :LeCommandRejectBuilder(identifier, CommandRejectReason::COMMAND_NOT_UNDERSTOOD/* reason_ */) {}
4290
4291
4292 };
4293 #ifdef PACKET_TESTING
4294 #define DEFINE_AND_INSTANTIATE_LeCommandRejectNotUnderstoodReflectionTest(...)class LeCommandRejectNotUnderstoodReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCommandRejectNotUnderstoodView view = LeCommandRejectNotUnderstoodView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCommandRejectNotUnderstoodBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCommandRejectNotUnderstoodReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCommandRejectNotUnderstood_reflection, LeCommandRejectNotUnderstoodReflectionTest, testing::Values(__VA_ARGS__))
4295 #endif
4296 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4297 #define DEFINE_LeCommandRejectNotUnderstoodReflectionFuzzTest() void RunLeCommandRejectNotUnderstoodReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCommandRejectNotUnderstoodView view = LeCommandRejectNotUnderstoodView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCommandRejectNotUnderstoodBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4298 #endif
4299
4300 #ifdef PACKET_FUZZ_TESTING
4301 #define DEFINE_AND_REGISTER_LeCommandRejectNotUnderstoodReflectionFuzzTest(REGISTRY) DEFINE_LeCommandRejectNotUnderstoodReflectionFuzzTest(); class LeCommandRejectNotUnderstoodReflectionFuzzTestRegistrant {public: explicit LeCommandRejectNotUnderstoodReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCommandRejectNotUnderstoodReflectionFuzzTest);}}; LeCommandRejectNotUnderstoodReflectionFuzzTestRegistrant LeCommandRejectNotUnderstood_reflection_fuzz_test_registrant(REGISTRY);
4302 #endif
4303
4304
Create(uint8_t identifier,uint16_t actual_mtu)4305 class LeCommandRejectMtuExceededBuilder : public LeCommandRejectBuilder { public: virtual ~LeCommandRejectMtuExceededBuilder() = default;static std::unique_ptr<LeCommandRejectMtuExceededBuilder> Create(uint8_t identifier, uint16_t actual_mtu) {auto builder = std::unique_ptr<LeCommandRejectMtuExceededBuilder>(new LeCommandRejectMtuExceededBuilder(identifier, actual_mtu));return builder;}
4306
4307 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4308 static std::unique_ptr<LeCommandRejectMtuExceededBuilder> FromView(LeCommandRejectMtuExceededView view) {if (!view.IsValid()) return nullptr;return LeCommandRejectMtuExceededBuilder::Create(view.GetIdentifier(), view.GetActualMtu());}
4309 #endif
4310
4311 protected:void SerializeHeader(BitInserter& i ) const {LeCommandRejectBuilder::SerializeHeader(i);insert(actual_mtu_, i,16);}
4312
4313 void SerializeFooter(BitInserter& i ) const {LeCommandRejectBuilder::SerializeFooter(i);}
4314
4315 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4316
4317 protected:size_t BitsOfHeader() const {return 0 + LeCommandRejectBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
4318
4319 size_t BitsOfFooter() const {return 0 + LeCommandRejectBuilder::BitsOfFooter() ;}
4320
4321 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4322
4323 protected:
4324 explicit LeCommandRejectMtuExceededBuilder(uint8_t identifier, uint16_t actual_mtu) :LeCommandRejectBuilder(identifier, CommandRejectReason::SIGNALING_MTU_EXCEEDED/* reason_ */) ,actual_mtu_(actual_mtu) {}
4325
4326
4327 uint16_t actual_mtu_{};};
4328 #ifdef PACKET_TESTING
4329 #define DEFINE_AND_INSTANTIATE_LeCommandRejectMtuExceededReflectionTest(...)class LeCommandRejectMtuExceededReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCommandRejectMtuExceededView view = LeCommandRejectMtuExceededView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCommandRejectMtuExceededBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCommandRejectMtuExceededReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCommandRejectMtuExceeded_reflection, LeCommandRejectMtuExceededReflectionTest, testing::Values(__VA_ARGS__))
4330 #endif
4331 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4332 #define DEFINE_LeCommandRejectMtuExceededReflectionFuzzTest() void RunLeCommandRejectMtuExceededReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCommandRejectMtuExceededView view = LeCommandRejectMtuExceededView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCommandRejectMtuExceededBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4333 #endif
4334
4335 #ifdef PACKET_FUZZ_TESTING
4336 #define DEFINE_AND_REGISTER_LeCommandRejectMtuExceededReflectionFuzzTest(REGISTRY) DEFINE_LeCommandRejectMtuExceededReflectionFuzzTest(); class LeCommandRejectMtuExceededReflectionFuzzTestRegistrant {public: explicit LeCommandRejectMtuExceededReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCommandRejectMtuExceededReflectionFuzzTest);}}; LeCommandRejectMtuExceededReflectionFuzzTestRegistrant LeCommandRejectMtuExceeded_reflection_fuzz_test_registrant(REGISTRY);
4337 #endif
4338
4339
Create(uint8_t identifier,uint16_t local_channel,uint16_t remote_channel)4340 class LeCommandRejectInvalidCidBuilder : public LeCommandRejectBuilder { public: virtual ~LeCommandRejectInvalidCidBuilder() = default;static std::unique_ptr<LeCommandRejectInvalidCidBuilder> Create(uint8_t identifier, uint16_t local_channel, uint16_t remote_channel) {auto builder = std::unique_ptr<LeCommandRejectInvalidCidBuilder>(new LeCommandRejectInvalidCidBuilder(identifier, local_channel, remote_channel));return builder;}
4341
4342 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4343 static std::unique_ptr<LeCommandRejectInvalidCidBuilder> FromView(LeCommandRejectInvalidCidView view) {if (!view.IsValid()) return nullptr;return LeCommandRejectInvalidCidBuilder::Create(view.GetIdentifier(), view.GetLocalChannel(), view.GetRemoteChannel());}
4344 #endif
4345
4346 protected:void SerializeHeader(BitInserter& i ) const {LeCommandRejectBuilder::SerializeHeader(i);insert(local_channel_, i,16);insert(remote_channel_, i,16);}
4347
4348 void SerializeFooter(BitInserter& i ) const {LeCommandRejectBuilder::SerializeFooter(i);}
4349
4350 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4351
4352 protected:size_t BitsOfHeader() const {return 0 + LeCommandRejectBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4353
4354 size_t BitsOfFooter() const {return 0 + LeCommandRejectBuilder::BitsOfFooter() ;}
4355
4356 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4357
4358 protected:
4359 explicit LeCommandRejectInvalidCidBuilder(uint8_t identifier, uint16_t local_channel, uint16_t remote_channel) :LeCommandRejectBuilder(identifier, CommandRejectReason::INVALID_CID_IN_REQUEST/* reason_ */) ,local_channel_(local_channel),remote_channel_(remote_channel) {}
4360
4361
4362 uint16_t local_channel_{};uint16_t remote_channel_{};};
4363 #ifdef PACKET_TESTING
4364 #define DEFINE_AND_INSTANTIATE_LeCommandRejectInvalidCidReflectionTest(...)class LeCommandRejectInvalidCidReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCommandRejectInvalidCidView view = LeCommandRejectInvalidCidView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCommandRejectInvalidCidBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCommandRejectInvalidCidReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCommandRejectInvalidCid_reflection, LeCommandRejectInvalidCidReflectionTest, testing::Values(__VA_ARGS__))
4365 #endif
4366 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4367 #define DEFINE_LeCommandRejectInvalidCidReflectionFuzzTest() void RunLeCommandRejectInvalidCidReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCommandRejectInvalidCidView view = LeCommandRejectInvalidCidView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCommandRejectInvalidCidBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4368 #endif
4369
4370 #ifdef PACKET_FUZZ_TESTING
4371 #define DEFINE_AND_REGISTER_LeCommandRejectInvalidCidReflectionFuzzTest(REGISTRY) DEFINE_LeCommandRejectInvalidCidReflectionFuzzTest(); class LeCommandRejectInvalidCidReflectionFuzzTestRegistrant {public: explicit LeCommandRejectInvalidCidReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCommandRejectInvalidCidReflectionFuzzTest);}}; LeCommandRejectInvalidCidReflectionFuzzTestRegistrant LeCommandRejectInvalidCid_reflection_fuzz_test_registrant(REGISTRY);
4372 #endif
4373
4374
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid)4375 class LeDisconnectionRequestBuilder : public LeControlBuilder { public: virtual ~LeDisconnectionRequestBuilder() = default;static std::unique_ptr<LeDisconnectionRequestBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) {auto builder = std::unique_ptr<LeDisconnectionRequestBuilder>(new LeDisconnectionRequestBuilder(identifier, destination_cid, source_cid));return builder;}
4376
4377 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4378 static std::unique_ptr<LeDisconnectionRequestBuilder> FromView(LeDisconnectionRequestView view) {if (!view.IsValid()) return nullptr;return LeDisconnectionRequestBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid());}
4379 #endif
4380
4381 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);}
4382
4383 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4384
4385 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4386
4387 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4388
4389 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4390
4391 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4392
4393 protected:
4394 explicit LeDisconnectionRequestBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) :LeControlBuilder(LeCommandCode::DISCONNECTION_REQUEST/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid) {}
4395
4396
4397 uint16_t destination_cid_{};uint16_t source_cid_{};};
4398 #ifdef PACKET_TESTING
4399 #define DEFINE_AND_INSTANTIATE_LeDisconnectionRequestReflectionTest(...)class LeDisconnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeDisconnectionRequestView view = LeDisconnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeDisconnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeDisconnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeDisconnectionRequest_reflection, LeDisconnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
4400 #endif
4401 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4402 #define DEFINE_LeDisconnectionRequestReflectionFuzzTest() void RunLeDisconnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeDisconnectionRequestView view = LeDisconnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeDisconnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4403 #endif
4404
4405 #ifdef PACKET_FUZZ_TESTING
4406 #define DEFINE_AND_REGISTER_LeDisconnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_LeDisconnectionRequestReflectionFuzzTest(); class LeDisconnectionRequestReflectionFuzzTestRegistrant {public: explicit LeDisconnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeDisconnectionRequestReflectionFuzzTest);}}; LeDisconnectionRequestReflectionFuzzTestRegistrant LeDisconnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
4407 #endif
4408
4409
Create(uint8_t identifier,uint16_t destination_cid,uint16_t source_cid)4410 class LeDisconnectionResponseBuilder : public LeControlBuilder { public: virtual ~LeDisconnectionResponseBuilder() = default;static std::unique_ptr<LeDisconnectionResponseBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) {auto builder = std::unique_ptr<LeDisconnectionResponseBuilder>(new LeDisconnectionResponseBuilder(identifier, destination_cid, source_cid));return builder;}
4411
4412 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4413 static std::unique_ptr<LeDisconnectionResponseBuilder> FromView(LeDisconnectionResponseView view) {if (!view.IsValid()) return nullptr;return LeDisconnectionResponseBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetSourceCid());}
4414 #endif
4415
4416 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(source_cid_, i,16);}
4417
4418 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4419
4420 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4421
4422 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4423
4424 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4425
4426 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4427
4428 protected:
4429 explicit LeDisconnectionResponseBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t source_cid) :LeControlBuilder(LeCommandCode::DISCONNECTION_RESPONSE/* code_ */, identifier) ,destination_cid_(destination_cid),source_cid_(source_cid) {}
4430
4431
4432 uint16_t destination_cid_{};uint16_t source_cid_{};};
4433 #ifdef PACKET_TESTING
4434 #define DEFINE_AND_INSTANTIATE_LeDisconnectionResponseReflectionTest(...)class LeDisconnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeDisconnectionResponseView view = LeDisconnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeDisconnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeDisconnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeDisconnectionResponse_reflection, LeDisconnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
4435 #endif
4436 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4437 #define DEFINE_LeDisconnectionResponseReflectionFuzzTest() void RunLeDisconnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeDisconnectionResponseView view = LeDisconnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeDisconnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4438 #endif
4439
4440 #ifdef PACKET_FUZZ_TESTING
4441 #define DEFINE_AND_REGISTER_LeDisconnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_LeDisconnectionResponseReflectionFuzzTest(); class LeDisconnectionResponseReflectionFuzzTestRegistrant {public: explicit LeDisconnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeDisconnectionResponseReflectionFuzzTest);}}; LeDisconnectionResponseReflectionFuzzTestRegistrant LeDisconnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
4442 #endif
4443
4444
Create(uint8_t identifier,uint16_t interval_min,uint16_t interval_max,uint16_t peripheral_latency,uint16_t timeout_multiplier)4445 class ConnectionParameterUpdateRequestBuilder : public LeControlBuilder { public: virtual ~ConnectionParameterUpdateRequestBuilder() = default;static std::unique_ptr<ConnectionParameterUpdateRequestBuilder> Create(uint8_t identifier, uint16_t interval_min, uint16_t interval_max, uint16_t peripheral_latency, uint16_t timeout_multiplier) {auto builder = std::unique_ptr<ConnectionParameterUpdateRequestBuilder>(new ConnectionParameterUpdateRequestBuilder(identifier, interval_min, interval_max, peripheral_latency, timeout_multiplier));return builder;}
4446
4447 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4448 static std::unique_ptr<ConnectionParameterUpdateRequestBuilder> FromView(ConnectionParameterUpdateRequestView view) {if (!view.IsValid()) return nullptr;return ConnectionParameterUpdateRequestBuilder::Create(view.GetIdentifier(), view.GetIntervalMin(), view.GetIntervalMax(), view.GetPeripheralLatency(), view.GetTimeoutMultiplier());}
4449 #endif
4450
4451 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(interval_min_, i,16);insert(interval_max_, i,16);insert(peripheral_latency_, i,16);insert(timeout_multiplier_, i,16);}
4452
4453 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4454
4455 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4456
4457 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4458
4459 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4460
4461 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4462
4463 protected:
4464 explicit ConnectionParameterUpdateRequestBuilder(uint8_t identifier, uint16_t interval_min, uint16_t interval_max, uint16_t peripheral_latency, uint16_t timeout_multiplier) :LeControlBuilder(LeCommandCode::CONNECTION_PARAMETER_UPDATE_REQUEST/* code_ */, identifier) ,interval_min_(interval_min),interval_max_(interval_max),peripheral_latency_(peripheral_latency),timeout_multiplier_(timeout_multiplier) {}
4465
4466
4467 uint16_t interval_min_{};uint16_t interval_max_{};uint16_t peripheral_latency_{};uint16_t timeout_multiplier_{};};
4468 #ifdef PACKET_TESTING
4469 #define DEFINE_AND_INSTANTIATE_ConnectionParameterUpdateRequestReflectionTest(...)class ConnectionParameterUpdateRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConnectionParameterUpdateRequestView view = ConnectionParameterUpdateRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConnectionParameterUpdateRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConnectionParameterUpdateRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConnectionParameterUpdateRequest_reflection, ConnectionParameterUpdateRequestReflectionTest, testing::Values(__VA_ARGS__))
4470 #endif
4471 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4472 #define DEFINE_ConnectionParameterUpdateRequestReflectionFuzzTest() void RunConnectionParameterUpdateRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConnectionParameterUpdateRequestView view = ConnectionParameterUpdateRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConnectionParameterUpdateRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4473 #endif
4474
4475 #ifdef PACKET_FUZZ_TESTING
4476 #define DEFINE_AND_REGISTER_ConnectionParameterUpdateRequestReflectionFuzzTest(REGISTRY) DEFINE_ConnectionParameterUpdateRequestReflectionFuzzTest(); class ConnectionParameterUpdateRequestReflectionFuzzTestRegistrant {public: explicit ConnectionParameterUpdateRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConnectionParameterUpdateRequestReflectionFuzzTest);}}; ConnectionParameterUpdateRequestReflectionFuzzTestRegistrant ConnectionParameterUpdateRequest_reflection_fuzz_test_registrant(REGISTRY);
4477 #endif
4478
4479
Create(uint8_t identifier,ConnectionParameterUpdateResponseResult result)4480 class ConnectionParameterUpdateResponseBuilder : public LeControlBuilder { public: virtual ~ConnectionParameterUpdateResponseBuilder() = default;static std::unique_ptr<ConnectionParameterUpdateResponseBuilder> Create(uint8_t identifier, ConnectionParameterUpdateResponseResult result) {auto builder = std::unique_ptr<ConnectionParameterUpdateResponseBuilder>(new ConnectionParameterUpdateResponseBuilder(identifier, result));return builder;}
4481
4482 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4483 static std::unique_ptr<ConnectionParameterUpdateResponseBuilder> FromView(ConnectionParameterUpdateResponseView view) {if (!view.IsValid()) return nullptr;return ConnectionParameterUpdateResponseBuilder::Create(view.GetIdentifier(), view.GetResult());}
4484 #endif
4485
4486 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(result_), i, 16);}
4487
4488 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4489
4490 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4491
4492 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
4493
4494 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4495
4496 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4497
4498 protected:
4499 explicit ConnectionParameterUpdateResponseBuilder(uint8_t identifier, ConnectionParameterUpdateResponseResult result) :LeControlBuilder(LeCommandCode::CONNECTION_PARAMETER_UPDATE_RESPONSE/* code_ */, identifier) ,result_(result) {}
4500
4501
4502 ConnectionParameterUpdateResponseResult result_{};};
4503 #ifdef PACKET_TESTING
4504 #define DEFINE_AND_INSTANTIATE_ConnectionParameterUpdateResponseReflectionTest(...)class ConnectionParameterUpdateResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {ConnectionParameterUpdateResponseView view = ConnectionParameterUpdateResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = ConnectionParameterUpdateResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(ConnectionParameterUpdateResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(ConnectionParameterUpdateResponse_reflection, ConnectionParameterUpdateResponseReflectionTest, testing::Values(__VA_ARGS__))
4505 #endif
4506 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4507 #define DEFINE_ConnectionParameterUpdateResponseReflectionFuzzTest() void RunConnectionParameterUpdateResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);ConnectionParameterUpdateResponseView view = ConnectionParameterUpdateResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = ConnectionParameterUpdateResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4508 #endif
4509
4510 #ifdef PACKET_FUZZ_TESTING
4511 #define DEFINE_AND_REGISTER_ConnectionParameterUpdateResponseReflectionFuzzTest(REGISTRY) DEFINE_ConnectionParameterUpdateResponseReflectionFuzzTest(); class ConnectionParameterUpdateResponseReflectionFuzzTestRegistrant {public: explicit ConnectionParameterUpdateResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunConnectionParameterUpdateResponseReflectionFuzzTest);}}; ConnectionParameterUpdateResponseReflectionFuzzTestRegistrant ConnectionParameterUpdateResponse_reflection_fuzz_test_registrant(REGISTRY);
4512 #endif
4513
4514
Create(uint8_t identifier,uint16_t le_psm,uint16_t source_cid,uint16_t mtu,uint16_t mps,uint16_t initial_credits)4515 class LeCreditBasedConnectionRequestBuilder : public LeControlBuilder { public: virtual ~LeCreditBasedConnectionRequestBuilder() = default;static std::unique_ptr<LeCreditBasedConnectionRequestBuilder> Create(uint8_t identifier, uint16_t le_psm, uint16_t source_cid, uint16_t mtu, uint16_t mps, uint16_t initial_credits) {auto builder = std::unique_ptr<LeCreditBasedConnectionRequestBuilder>(new LeCreditBasedConnectionRequestBuilder(identifier, le_psm, source_cid, mtu, mps, initial_credits));return builder;}
4516
4517 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4518 static std::unique_ptr<LeCreditBasedConnectionRequestBuilder> FromView(LeCreditBasedConnectionRequestView view) {if (!view.IsValid()) return nullptr;return LeCreditBasedConnectionRequestBuilder::Create(view.GetIdentifier(), view.GetLePsm(), view.GetSourceCid(), view.GetMtu(), view.GetMps(), view.GetInitialCredits());}
4519 #endif
4520
4521 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(le_psm_, i,16);insert(source_cid_, i,16);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);}
4522
4523 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4524
4525 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4526
4527 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4528
4529 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4530
4531 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4532
4533 protected:
4534 explicit LeCreditBasedConnectionRequestBuilder(uint8_t identifier, uint16_t le_psm, uint16_t source_cid, uint16_t mtu, uint16_t mps, uint16_t initial_credits) :LeControlBuilder(LeCommandCode::LE_CREDIT_BASED_CONNECTION_REQUEST/* code_ */, identifier) ,le_psm_(le_psm),source_cid_(source_cid),mtu_(mtu),mps_(mps),initial_credits_(initial_credits) {}
4535
4536
4537 uint16_t le_psm_{};uint16_t source_cid_{};uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};};
4538 #ifdef PACKET_TESTING
4539 #define DEFINE_AND_INSTANTIATE_LeCreditBasedConnectionRequestReflectionTest(...)class LeCreditBasedConnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCreditBasedConnectionRequestView view = LeCreditBasedConnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCreditBasedConnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCreditBasedConnectionRequest_reflection, LeCreditBasedConnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
4540 #endif
4541 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4542 #define DEFINE_LeCreditBasedConnectionRequestReflectionFuzzTest() void RunLeCreditBasedConnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCreditBasedConnectionRequestView view = LeCreditBasedConnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4543 #endif
4544
4545 #ifdef PACKET_FUZZ_TESTING
4546 #define DEFINE_AND_REGISTER_LeCreditBasedConnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_LeCreditBasedConnectionRequestReflectionFuzzTest(); class LeCreditBasedConnectionRequestReflectionFuzzTestRegistrant {public: explicit LeCreditBasedConnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCreditBasedConnectionRequestReflectionFuzzTest);}}; LeCreditBasedConnectionRequestReflectionFuzzTestRegistrant LeCreditBasedConnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
4547 #endif
4548
4549
Create(uint8_t identifier,uint16_t destination_cid,uint16_t mtu,uint16_t mps,uint16_t initial_credits,LeCreditBasedConnectionResponseResult result)4550 class LeCreditBasedConnectionResponseBuilder : public LeControlBuilder { public: virtual ~LeCreditBasedConnectionResponseBuilder() = default;static std::unique_ptr<LeCreditBasedConnectionResponseBuilder> Create(uint8_t identifier, uint16_t destination_cid, uint16_t mtu, uint16_t mps, uint16_t initial_credits, LeCreditBasedConnectionResponseResult result) {auto builder = std::unique_ptr<LeCreditBasedConnectionResponseBuilder>(new LeCreditBasedConnectionResponseBuilder(identifier, destination_cid, mtu, mps, initial_credits, result));return builder;}
4551
4552 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4553 static std::unique_ptr<LeCreditBasedConnectionResponseBuilder> FromView(LeCreditBasedConnectionResponseView view) {if (!view.IsValid()) return nullptr;return LeCreditBasedConnectionResponseBuilder::Create(view.GetIdentifier(), view.GetDestinationCid(), view.GetMtu(), view.GetMps(), view.GetInitialCredits(), view.GetResult());}
4554 #endif
4555
4556 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(destination_cid_, i,16);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);insert(static_cast<uint16_t>(result_), i, 16);}
4557
4558 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4559
4560 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4561
4562 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4563
4564 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4565
4566 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4567
4568 protected:
4569 explicit LeCreditBasedConnectionResponseBuilder(uint8_t identifier, uint16_t destination_cid, uint16_t mtu, uint16_t mps, uint16_t initial_credits, LeCreditBasedConnectionResponseResult result) :LeControlBuilder(LeCommandCode::LE_CREDIT_BASED_CONNECTION_RESPONSE/* code_ */, identifier) ,destination_cid_(destination_cid),mtu_(mtu),mps_(mps),initial_credits_(initial_credits),result_(result) {}
4570
4571
4572 uint16_t destination_cid_{};uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};LeCreditBasedConnectionResponseResult result_{};};
4573 #ifdef PACKET_TESTING
4574 #define DEFINE_AND_INSTANTIATE_LeCreditBasedConnectionResponseReflectionTest(...)class LeCreditBasedConnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeCreditBasedConnectionResponseView view = LeCreditBasedConnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeCreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeCreditBasedConnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeCreditBasedConnectionResponse_reflection, LeCreditBasedConnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
4575 #endif
4576 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4577 #define DEFINE_LeCreditBasedConnectionResponseReflectionFuzzTest() void RunLeCreditBasedConnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeCreditBasedConnectionResponseView view = LeCreditBasedConnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeCreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4578 #endif
4579
4580 #ifdef PACKET_FUZZ_TESTING
4581 #define DEFINE_AND_REGISTER_LeCreditBasedConnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_LeCreditBasedConnectionResponseReflectionFuzzTest(); class LeCreditBasedConnectionResponseReflectionFuzzTestRegistrant {public: explicit LeCreditBasedConnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeCreditBasedConnectionResponseReflectionFuzzTest);}}; LeCreditBasedConnectionResponseReflectionFuzzTestRegistrant LeCreditBasedConnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
4582 #endif
4583
4584
Create(uint8_t identifier,uint16_t cid,uint16_t credits)4585 class LeFlowControlCreditBuilder : public LeControlBuilder { public: virtual ~LeFlowControlCreditBuilder() = default;static std::unique_ptr<LeFlowControlCreditBuilder> Create(uint8_t identifier, uint16_t cid, uint16_t credits) {auto builder = std::unique_ptr<LeFlowControlCreditBuilder>(new LeFlowControlCreditBuilder(identifier, cid, credits));return builder;}
4586
4587 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4588 static std::unique_ptr<LeFlowControlCreditBuilder> FromView(LeFlowControlCreditView view) {if (!view.IsValid()) return nullptr;return LeFlowControlCreditBuilder::Create(view.GetIdentifier(), view.GetCid(), view.GetCredits());}
4589 #endif
4590
4591 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(cid_, i,16);insert(credits_, i,16);}
4592
4593 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4594
4595 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4596
4597 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0;}
4598
4599 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4600
4601 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4602
4603 protected:
4604 explicit LeFlowControlCreditBuilder(uint8_t identifier, uint16_t cid, uint16_t credits) :LeControlBuilder(LeCommandCode::LE_FLOW_CONTROL_CREDIT/* code_ */, identifier) ,cid_(cid),credits_(credits) {}
4605
4606
4607 uint16_t cid_{};uint16_t credits_{};};
4608 #ifdef PACKET_TESTING
4609 #define DEFINE_AND_INSTANTIATE_LeFlowControlCreditReflectionTest(...)class LeFlowControlCreditReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeFlowControlCreditView view = LeFlowControlCreditView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeFlowControlCreditBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeFlowControlCreditReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeFlowControlCredit_reflection, LeFlowControlCreditReflectionTest, testing::Values(__VA_ARGS__))
4610 #endif
4611 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4612 #define DEFINE_LeFlowControlCreditReflectionFuzzTest() void RunLeFlowControlCreditReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeFlowControlCreditView view = LeFlowControlCreditView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeFlowControlCreditBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4613 #endif
4614
4615 #ifdef PACKET_FUZZ_TESTING
4616 #define DEFINE_AND_REGISTER_LeFlowControlCreditReflectionFuzzTest(REGISTRY) DEFINE_LeFlowControlCreditReflectionFuzzTest(); class LeFlowControlCreditReflectionFuzzTestRegistrant {public: explicit LeFlowControlCreditReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeFlowControlCreditReflectionFuzzTest);}}; LeFlowControlCreditReflectionFuzzTestRegistrant LeFlowControlCredit_reflection_fuzz_test_registrant(REGISTRY);
4617 #endif
4618
4619
Create(uint8_t identifier,uint16_t spsm,uint16_t mtu,uint16_t mps,uint16_t initial_credits,const std::vector<uint16_t> & source_cid)4620 class LeEnhancedCreditBasedConnectionRequestBuilder : public LeControlBuilder { public: virtual ~LeEnhancedCreditBasedConnectionRequestBuilder() = default;static std::unique_ptr<LeEnhancedCreditBasedConnectionRequestBuilder> Create(uint8_t identifier, uint16_t spsm, uint16_t mtu, uint16_t mps, uint16_t initial_credits, const std::vector<uint16_t>& source_cid) {auto builder = std::unique_ptr<LeEnhancedCreditBasedConnectionRequestBuilder>(new LeEnhancedCreditBasedConnectionRequestBuilder(identifier, spsm, mtu, mps, initial_credits, source_cid));return builder;}
4621
4622 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4623 static std::unique_ptr<LeEnhancedCreditBasedConnectionRequestBuilder> FromView(LeEnhancedCreditBasedConnectionRequestView view) {if (!view.IsValid()) return nullptr;return LeEnhancedCreditBasedConnectionRequestBuilder::Create(view.GetIdentifier(), view.GetSpsm(), view.GetMtu(), view.GetMps(), view.GetInitialCredits(), view.GetSourceCid());}
4624 #endif
4625
4626 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(spsm_, i,16);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);for (const auto& val_ : source_cid_) {insert(val_, i,16);}
4627 }
4628
4629 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4630
4631 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4632
4633 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(source_cid_.size()) * 16);}
4634
4635 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4636
4637 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4638
4639 protected:
4640 explicit LeEnhancedCreditBasedConnectionRequestBuilder(uint8_t identifier, uint16_t spsm, uint16_t mtu, uint16_t mps, uint16_t initial_credits, const std::vector<uint16_t>& source_cid) :LeControlBuilder(LeCommandCode::CREDIT_BASED_CONNECTION_REQUEST/* code_ */, identifier) ,spsm_(spsm),mtu_(mtu),mps_(mps),initial_credits_(initial_credits),source_cid_(source_cid) {}
4641
4642
4643 uint16_t spsm_{};uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};std::vector<uint16_t> source_cid_{};};
4644 #ifdef PACKET_TESTING
4645 #define DEFINE_AND_INSTANTIATE_LeEnhancedCreditBasedConnectionRequestReflectionTest(...)class LeEnhancedCreditBasedConnectionRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeEnhancedCreditBasedConnectionRequestView view = LeEnhancedCreditBasedConnectionRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeEnhancedCreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeEnhancedCreditBasedConnectionRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeEnhancedCreditBasedConnectionRequest_reflection, LeEnhancedCreditBasedConnectionRequestReflectionTest, testing::Values(__VA_ARGS__))
4646 #endif
4647 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4648 #define DEFINE_LeEnhancedCreditBasedConnectionRequestReflectionFuzzTest() void RunLeEnhancedCreditBasedConnectionRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeEnhancedCreditBasedConnectionRequestView view = LeEnhancedCreditBasedConnectionRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeEnhancedCreditBasedConnectionRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4649 #endif
4650
4651 #ifdef PACKET_FUZZ_TESTING
4652 #define DEFINE_AND_REGISTER_LeEnhancedCreditBasedConnectionRequestReflectionFuzzTest(REGISTRY) DEFINE_LeEnhancedCreditBasedConnectionRequestReflectionFuzzTest(); class LeEnhancedCreditBasedConnectionRequestReflectionFuzzTestRegistrant {public: explicit LeEnhancedCreditBasedConnectionRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeEnhancedCreditBasedConnectionRequestReflectionFuzzTest);}}; LeEnhancedCreditBasedConnectionRequestReflectionFuzzTestRegistrant LeEnhancedCreditBasedConnectionRequest_reflection_fuzz_test_registrant(REGISTRY);
4653 #endif
4654
4655
Create(uint8_t identifier,uint16_t mtu,uint16_t mps,uint16_t initial_credits,CreditBasedConnectionResponseResult result,const std::vector<uint16_t> & destination_cid)4656 class LeEnhancedCreditBasedConnectionResponseBuilder : public LeControlBuilder { public: virtual ~LeEnhancedCreditBasedConnectionResponseBuilder() = default;static std::unique_ptr<LeEnhancedCreditBasedConnectionResponseBuilder> Create(uint8_t identifier, uint16_t mtu, uint16_t mps, uint16_t initial_credits, CreditBasedConnectionResponseResult result, const std::vector<uint16_t>& destination_cid) {auto builder = std::unique_ptr<LeEnhancedCreditBasedConnectionResponseBuilder>(new LeEnhancedCreditBasedConnectionResponseBuilder(identifier, mtu, mps, initial_credits, result, destination_cid));return builder;}
4657
4658 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4659 static std::unique_ptr<LeEnhancedCreditBasedConnectionResponseBuilder> FromView(LeEnhancedCreditBasedConnectionResponseView view) {if (!view.IsValid()) return nullptr;return LeEnhancedCreditBasedConnectionResponseBuilder::Create(view.GetIdentifier(), view.GetMtu(), view.GetMps(), view.GetInitialCredits(), view.GetResult(), view.GetDestinationCid());}
4660 #endif
4661
4662 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(mtu_, i,16);insert(mps_, i,16);insert(initial_credits_, i,16);insert(static_cast<uint16_t>(result_), i, 16);for (const auto& val_ : destination_cid_) {insert(val_, i,16);}
4663 }
4664
4665 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4666
4667 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4668
4669 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(destination_cid_.size()) * 16);}
4670
4671 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4672
4673 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4674
4675 protected:
4676 explicit LeEnhancedCreditBasedConnectionResponseBuilder(uint8_t identifier, uint16_t mtu, uint16_t mps, uint16_t initial_credits, CreditBasedConnectionResponseResult result, const std::vector<uint16_t>& destination_cid) :LeControlBuilder(LeCommandCode::CREDIT_BASED_CONNECTION_RESPONSE/* code_ */, identifier) ,mtu_(mtu),mps_(mps),initial_credits_(initial_credits),result_(result),destination_cid_(destination_cid) {}
4677
4678
4679 uint16_t mtu_{};uint16_t mps_{};uint16_t initial_credits_{};CreditBasedConnectionResponseResult result_{};std::vector<uint16_t> destination_cid_{};};
4680 #ifdef PACKET_TESTING
4681 #define DEFINE_AND_INSTANTIATE_LeEnhancedCreditBasedConnectionResponseReflectionTest(...)class LeEnhancedCreditBasedConnectionResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeEnhancedCreditBasedConnectionResponseView view = LeEnhancedCreditBasedConnectionResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeEnhancedCreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeEnhancedCreditBasedConnectionResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeEnhancedCreditBasedConnectionResponse_reflection, LeEnhancedCreditBasedConnectionResponseReflectionTest, testing::Values(__VA_ARGS__))
4682 #endif
4683 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4684 #define DEFINE_LeEnhancedCreditBasedConnectionResponseReflectionFuzzTest() void RunLeEnhancedCreditBasedConnectionResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeEnhancedCreditBasedConnectionResponseView view = LeEnhancedCreditBasedConnectionResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeEnhancedCreditBasedConnectionResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4685 #endif
4686
4687 #ifdef PACKET_FUZZ_TESTING
4688 #define DEFINE_AND_REGISTER_LeEnhancedCreditBasedConnectionResponseReflectionFuzzTest(REGISTRY) DEFINE_LeEnhancedCreditBasedConnectionResponseReflectionFuzzTest(); class LeEnhancedCreditBasedConnectionResponseReflectionFuzzTestRegistrant {public: explicit LeEnhancedCreditBasedConnectionResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeEnhancedCreditBasedConnectionResponseReflectionFuzzTest);}}; LeEnhancedCreditBasedConnectionResponseReflectionFuzzTestRegistrant LeEnhancedCreditBasedConnectionResponse_reflection_fuzz_test_registrant(REGISTRY);
4689 #endif
4690
4691
Create(uint8_t identifier,uint16_t mtu,uint16_t mps,const std::vector<uint16_t> & destination_cid)4692 class LeEnhancedCreditBasedReconfigureRequestBuilder : public LeControlBuilder { public: virtual ~LeEnhancedCreditBasedReconfigureRequestBuilder() = default;static std::unique_ptr<LeEnhancedCreditBasedReconfigureRequestBuilder> Create(uint8_t identifier, uint16_t mtu, uint16_t mps, const std::vector<uint16_t>& destination_cid) {auto builder = std::unique_ptr<LeEnhancedCreditBasedReconfigureRequestBuilder>(new LeEnhancedCreditBasedReconfigureRequestBuilder(identifier, mtu, mps, destination_cid));return builder;}
4693
4694 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4695 static std::unique_ptr<LeEnhancedCreditBasedReconfigureRequestBuilder> FromView(LeEnhancedCreditBasedReconfigureRequestView view) {if (!view.IsValid()) return nullptr;return LeEnhancedCreditBasedReconfigureRequestBuilder::Create(view.GetIdentifier(), view.GetMtu(), view.GetMps(), view.GetDestinationCid());}
4696 #endif
4697
4698 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(mtu_, i,16);insert(mps_, i,16);for (const auto& val_ : destination_cid_) {insert(val_, i,16);}
4699 }
4700
4701 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4702
4703 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4704
4705 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 16 + /* Dynamic: */ 0 + /* Bits: */ 0 + /* Dynamic: */ (static_cast<size_t>(destination_cid_.size()) * 16);}
4706
4707 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4708
4709 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4710
4711 protected:
4712 explicit LeEnhancedCreditBasedReconfigureRequestBuilder(uint8_t identifier, uint16_t mtu, uint16_t mps, const std::vector<uint16_t>& destination_cid) :LeControlBuilder(LeCommandCode::CREDIT_BASED_RECONFIGURE_REQUEST/* code_ */, identifier) ,mtu_(mtu),mps_(mps),destination_cid_(destination_cid) {}
4713
4714
4715 uint16_t mtu_{};uint16_t mps_{};std::vector<uint16_t> destination_cid_{};};
4716 #ifdef PACKET_TESTING
4717 #define DEFINE_AND_INSTANTIATE_LeEnhancedCreditBasedReconfigureRequestReflectionTest(...)class LeEnhancedCreditBasedReconfigureRequestReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeEnhancedCreditBasedReconfigureRequestView view = LeEnhancedCreditBasedReconfigureRequestView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeEnhancedCreditBasedReconfigureRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeEnhancedCreditBasedReconfigureRequestReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeEnhancedCreditBasedReconfigureRequest_reflection, LeEnhancedCreditBasedReconfigureRequestReflectionTest, testing::Values(__VA_ARGS__))
4718 #endif
4719 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4720 #define DEFINE_LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTest() void RunLeEnhancedCreditBasedReconfigureRequestReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeEnhancedCreditBasedReconfigureRequestView view = LeEnhancedCreditBasedReconfigureRequestView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeEnhancedCreditBasedReconfigureRequestBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4721 #endif
4722
4723 #ifdef PACKET_FUZZ_TESTING
4724 #define DEFINE_AND_REGISTER_LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTest(REGISTRY) DEFINE_LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTest(); class LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTestRegistrant {public: explicit LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeEnhancedCreditBasedReconfigureRequestReflectionFuzzTest);}}; LeEnhancedCreditBasedReconfigureRequestReflectionFuzzTestRegistrant LeEnhancedCreditBasedReconfigureRequest_reflection_fuzz_test_registrant(REGISTRY);
4725 #endif
4726
4727
Create(uint8_t identifier,CreditBasedReconfigureResponseResult result)4728 class LeEnhancedCreditBasedReconfigureResponseBuilder : public LeControlBuilder { public: virtual ~LeEnhancedCreditBasedReconfigureResponseBuilder() = default;static std::unique_ptr<LeEnhancedCreditBasedReconfigureResponseBuilder> Create(uint8_t identifier, CreditBasedReconfigureResponseResult result) {auto builder = std::unique_ptr<LeEnhancedCreditBasedReconfigureResponseBuilder>(new LeEnhancedCreditBasedReconfigureResponseBuilder(identifier, result));return builder;}
4729
4730 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)
4731 static std::unique_ptr<LeEnhancedCreditBasedReconfigureResponseBuilder> FromView(LeEnhancedCreditBasedReconfigureResponseView view) {if (!view.IsValid()) return nullptr;return LeEnhancedCreditBasedReconfigureResponseBuilder::Create(view.GetIdentifier(), view.GetResult());}
4732 #endif
4733
4734 protected:void SerializeHeader(BitInserter& i ) const {LeControlBuilder::SerializeHeader(i);insert(static_cast<uint16_t>(result_), i, 16);}
4735
4736 void SerializeFooter(BitInserter& i ) const {LeControlBuilder::SerializeFooter(i);}
4737
4738 public:virtual void Serialize(BitInserter& i) const override {SerializeHeader(i);SerializeFooter(i);}
4739
4740 protected:size_t BitsOfHeader() const {return 0 + LeControlBuilder::BitsOfHeader() + /* Bits: */ 16 + /* Dynamic: */ 0;}
4741
4742 size_t BitsOfFooter() const {return 0 + LeControlBuilder::BitsOfFooter() ;}
4743
4744 public:virtual size_t size() const override {return (BitsOfHeader() / 8) + (BitsOfFooter() / 8);}
4745
4746 protected:
4747 explicit LeEnhancedCreditBasedReconfigureResponseBuilder(uint8_t identifier, CreditBasedReconfigureResponseResult result) :LeControlBuilder(LeCommandCode::CREDIT_BASED_RECONFIGURE_RESPONSE/* code_ */, identifier) ,result_(result) {}
4748
4749
4750 CreditBasedReconfigureResponseResult result_{};};
4751 #ifdef PACKET_TESTING
4752 #define DEFINE_AND_INSTANTIATE_LeEnhancedCreditBasedReconfigureResponseReflectionTest(...)class LeEnhancedCreditBasedReconfigureResponseReflectionTest : public testing::TestWithParam<std::vector<uint8_t>> { public: void CompareBytes(std::vector<uint8_t> captured_packet) {LeEnhancedCreditBasedReconfigureResponseView view = LeEnhancedCreditBasedReconfigureResponseView::FromBytes(captured_packet);if (!view.IsValid()) { log::info("Invalid Packet Bytes (size = {})", view.size());for (size_t i = 0; i < view.size(); i++) { log::info("{:5}:{:02x}", i, *(view.begin() + i)); }}ASSERT_TRUE(view.IsValid());auto packet = LeEnhancedCreditBasedReconfigureResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);ASSERT_EQ(*packet_bytes, captured_packet);}};TEST_P(LeEnhancedCreditBasedReconfigureResponseReflectionTest, generatedReflectionTest) {CompareBytes(GetParam());}INSTANTIATE_TEST_SUITE_P(LeEnhancedCreditBasedReconfigureResponse_reflection, LeEnhancedCreditBasedReconfigureResponseReflectionTest, testing::Values(__VA_ARGS__))
4753 #endif
4754 #if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING)
4755 #define DEFINE_LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTest() void RunLeEnhancedCreditBasedReconfigureResponseReflectionFuzzTest(const uint8_t* data, size_t size) {auto vec = std::vector<uint8_t>(data, data + size);LeEnhancedCreditBasedReconfigureResponseView view = LeEnhancedCreditBasedReconfigureResponseView::FromBytes(vec);if (!view.IsValid()) { return; }auto packet = LeEnhancedCreditBasedReconfigureResponseBuilder::FromView(view);std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();packet_bytes->reserve(packet->size());BitInserter it(*packet_bytes);packet->Serialize(it);}
4756 #endif
4757
4758 #ifdef PACKET_FUZZ_TESTING
4759 #define DEFINE_AND_REGISTER_LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTest(REGISTRY) DEFINE_LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTest(); class LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTestRegistrant {public: explicit LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTestRegistrant(std::vector<void(*)(const uint8_t*, size_t)>& fuzz_test_registry) {fuzz_test_registry.push_back(RunLeEnhancedCreditBasedReconfigureResponseReflectionFuzzTest);}}; LeEnhancedCreditBasedReconfigureResponseReflectionFuzzTestRegistrant LeEnhancedCreditBasedReconfigureResponse_reflection_fuzz_test_registrant(REGISTRY);
4760 #endif
4761
4762
4763 } //namespace l2cap
4764 } //namespace bluetooth
4765 #if __has_include(<bluetooth/log.h>)
4766 namespace std {
4767 template <>
4768 struct formatter<bluetooth::l2cap::Continuation> : enum_formatter<bluetooth::l2cap::Continuation> {};
4769 template <>
4770 struct formatter<bluetooth::l2cap::FrameType> : enum_formatter<bluetooth::l2cap::FrameType> {};
4771 template <>
4772 struct formatter<bluetooth::l2cap::SupervisoryFunction> : enum_formatter<bluetooth::l2cap::SupervisoryFunction> {};
4773 template <>
4774 struct formatter<bluetooth::l2cap::RetransmissionDisable> : enum_formatter<bluetooth::l2cap::RetransmissionDisable> {};
4775 template <>
4776 struct formatter<bluetooth::l2cap::SegmentationAndReassembly> : enum_formatter<bluetooth::l2cap::SegmentationAndReassembly> {};
4777 template <>
4778 struct formatter<bluetooth::l2cap::Poll> : enum_formatter<bluetooth::l2cap::Poll> {};
4779 template <>
4780 struct formatter<bluetooth::l2cap::Final> : enum_formatter<bluetooth::l2cap::Final> {};
4781 template <>
4782 struct formatter<bluetooth::l2cap::CommandCode> : enum_formatter<bluetooth::l2cap::CommandCode> {};
4783 template <>
4784 struct formatter<bluetooth::l2cap::CommandRejectReason> : enum_formatter<bluetooth::l2cap::CommandRejectReason> {};
4785 template <>
4786 struct formatter<bluetooth::l2cap::ConnectionResponseResult> : enum_formatter<bluetooth::l2cap::ConnectionResponseResult> {};
4787 template <>
4788 struct formatter<bluetooth::l2cap::ConnectionResponseStatus> : enum_formatter<bluetooth::l2cap::ConnectionResponseStatus> {};
4789 template <>
4790 struct formatter<bluetooth::l2cap::ConfigurationOptionType> : enum_formatter<bluetooth::l2cap::ConfigurationOptionType> {};
4791 template <>
4792 struct formatter<bluetooth::l2cap::ConfigurationOptionIsHint> : enum_formatter<bluetooth::l2cap::ConfigurationOptionIsHint> {};
4793 template <>
4794 struct formatter<bluetooth::l2cap::QosServiceType> : enum_formatter<bluetooth::l2cap::QosServiceType> {};
4795 template <>
4796 struct formatter<bluetooth::l2cap::RetransmissionAndFlowControlModeOption> : enum_formatter<bluetooth::l2cap::RetransmissionAndFlowControlModeOption> {};
4797 template <>
4798 struct formatter<bluetooth::l2cap::FcsType> : enum_formatter<bluetooth::l2cap::FcsType> {};
4799 template <>
4800 struct formatter<bluetooth::l2cap::ConfigurationResponseResult> : enum_formatter<bluetooth::l2cap::ConfigurationResponseResult> {};
4801 template <>
4802 struct formatter<bluetooth::l2cap::InformationRequestInfoType> : enum_formatter<bluetooth::l2cap::InformationRequestInfoType> {};
4803 template <>
4804 struct formatter<bluetooth::l2cap::InformationRequestResult> : enum_formatter<bluetooth::l2cap::InformationRequestResult> {};
4805 template <>
4806 struct formatter<bluetooth::l2cap::CreateChannelResponseResult> : enum_formatter<bluetooth::l2cap::CreateChannelResponseResult> {};
4807 template <>
4808 struct formatter<bluetooth::l2cap::CreateChannelResponseStatus> : enum_formatter<bluetooth::l2cap::CreateChannelResponseStatus> {};
4809 template <>
4810 struct formatter<bluetooth::l2cap::MoveChannelResponseResult> : enum_formatter<bluetooth::l2cap::MoveChannelResponseResult> {};
4811 template <>
4812 struct formatter<bluetooth::l2cap::MoveChannelConfirmationResult> : enum_formatter<bluetooth::l2cap::MoveChannelConfirmationResult> {};
4813 template <>
4814 struct formatter<bluetooth::l2cap::CreditBasedConnectionResponseResult> : enum_formatter<bluetooth::l2cap::CreditBasedConnectionResponseResult> {};
4815 template <>
4816 struct formatter<bluetooth::l2cap::CreditBasedReconfigureResponseResult> : enum_formatter<bluetooth::l2cap::CreditBasedReconfigureResponseResult> {};
4817 template <>
4818 struct formatter<bluetooth::l2cap::LeCommandCode> : enum_formatter<bluetooth::l2cap::LeCommandCode> {};
4819 template <>
4820 struct formatter<bluetooth::l2cap::ConnectionParameterUpdateResponseResult> : enum_formatter<bluetooth::l2cap::ConnectionParameterUpdateResponseResult> {};
4821 template <>
4822 struct formatter<bluetooth::l2cap::LeCreditBasedConnectionResponseResult> : enum_formatter<bluetooth::l2cap::LeCreditBasedConnectionResponseResult> {};
4823 } // namespace std
4824 #endif // __has_include(<bluetooth/log.h>)
4825