30#include <unordered_set>
59 using buffer_ptr = std::unique_ptr<unsigned char, Gcs_packet_buffer_deleter>;
142 std::vector<Gcs_dynamic_header> &&dynamic_headers,
143 std::vector<std::unique_ptr<Gcs_stage_metadata>> &&stage_metadata,
144 unsigned long long const &payload_size);
163 unsigned long long const &new_payload_size);
177 synode_no
const &delivery_synode,
178 synode_no
const &origin_synode,
289 unsigned long long const &payload_size);
298 unsigned long long const &new_payload_size);
307 explicit
Gcs_packet(synode_no const &delivery_synode,
308 synode_no const &origin_synode);
This is the pipeline that an outgoing or incoming message has to go through when being sent to or rec...
Definition: gcs_message_stages.h:364
This class is an abstraction for the packet concept.
Definition: gcs_internal_message.h:57
static std::pair< bool, Gcs_packet > make_from_existing_packet(Gcs_packet const &original_packet, unsigned long long const &new_payload_size)
This factory method is to be used when modifying a packet.
Definition: gcs_internal_message.cc:98
void set_payload_length(unsigned long long const &new_length)
Definition: gcs_internal_message.cc:247
Gcs_internal_message_header m_fixed_header
Fixed header which is common regardless whether the packet has been changed by a stage or not.
Definition: gcs_internal_message.h:66
buffer_ptr m_serialized_packet
The buffer containing all serialized data for this packet.
Definition: gcs_internal_message.h:94
std::vector< Gcs_dynamic_header > m_dynamic_headers
List of dynamic headers created by the stages by which the packet has passed through and changed it.
Definition: gcs_internal_message.h:72
Gcs_protocol_version get_used_version() const
Return the value of the version in use.
Definition: gcs_internal_message.cc:257
std::size_t m_serialized_payload_offset
The offset in m_serialized_packet where the application payload starts.
Definition: gcs_internal_message.h:104
std::vector< Gcs_dynamic_header > const & get_dynamic_headers() const
Retrieve this packet's dynamic headers.
Definition: gcs_internal_message.cc:217
void prepare_for_next_outgoing_stage()
Definition: gcs_internal_message.cc:231
static std::pair< bool, Gcs_packet > make_outgoing_packet(Cargo_type const &cargo, Gcs_protocol_version const ¤t_version, std::vector< Gcs_dynamic_header > &&dynamic_headers, std::vector< std::unique_ptr< Gcs_stage_metadata > > &&stage_metadata, unsigned long long const &payload_size)
This factory method is to be used when sending a packet.
Definition: gcs_internal_message.cc:42
void dump(std::ostringstream &output) const
Create a string representation of the packet to be logged.
Definition: gcs_internal_message.cc:374
std::size_t m_next_stage_index
Index of the next stage to apply/revert in both m_dynamic_headers and m_stage_metadata.
Definition: gcs_internal_message.h:89
Gcs_xcom_synode m_delivery_synode
The XCom synode in which this packet was delivered.
Definition: gcs_internal_message.h:119
unsigned long long const & get_payload_length() const
Return the payload length.
Definition: gcs_internal_message.cc:269
Gcs_xcom_synode const & get_origin_synode() const
Definition: gcs_internal_message.cc:390
Gcs_xcom_synode const & get_delivery_synode() const
Definition: gcs_internal_message.cc:386
Gcs_packet() noexcept
Definition: gcs_internal_message.cc:29
static Gcs_packet make_incoming_packet(buffer_ptr &&buffer, unsigned long long buffer_size, synode_no const &delivery_synode, synode_no const &origin_synode, Gcs_message_pipeline const &pipeline)
This factory method is to be used when receiving a packet from the network.
Definition: gcs_internal_message.cc:142
Gcs_xcom_synode m_origin_synode
The XCom synode in which this packet was delivered.
Definition: gcs_internal_message.h:124
Gcs_stage_metadata & get_current_stage_header()
Definition: gcs_internal_message.cc:239
std::vector< std::unique_ptr< Gcs_stage_metadata > > const & get_stage_metadata() const
Retrieve this packet's stage metadata.
Definition: gcs_internal_message.cc:223
void deserialize(buffer_ptr &&buffer, unsigned long long buffer_size, Gcs_message_pipeline const &pipeline)
Decode the packet content from the given buffer containing a serialized packet.
Definition: gcs_internal_message.cc:323
unsigned long long m_serialized_payload_size
The size of the serialized application payload in m_serialized_packet.
Definition: gcs_internal_message.h:109
std::vector< std::unique_ptr< Gcs_stage_metadata > > m_stage_metadata
List of stage metadata created by the stages by which the packet has passed through.
Definition: gcs_internal_message.h:83
unsigned long long m_serialized_stage_metadata_size
The size of the serialized m_stage_metadata in m_serialized_packet.
Definition: gcs_internal_message.h:114
std::unique_ptr< unsigned char, Gcs_packet_buffer_deleter > buffer_ptr
Definition: gcs_internal_message.h:59
void prepare_for_next_incoming_stage()
Definition: gcs_internal_message.cc:233
Gcs_internal_message_header const & get_fixed_header() const
Retrieve this packet's header.
Definition: gcs_internal_message.cc:213
unsigned long long get_total_length() const
Return the total length.
Definition: gcs_internal_message.cc:265
Cargo_type get_cargo_type() const
Return the cargo type.
Definition: gcs_internal_message.cc:261
unsigned long long m_serialized_packet_size
The capacity of the serialization buffer.
Definition: gcs_internal_message.h:99
bool allocate_serialization_buffer()
Allocates the underlying buffer where the packet will be serialized to using serialize.
Definition: gcs_internal_message.cc:273
unsigned char * get_payload_pointer()
Definition: gcs_internal_message.cc:243
Gcs_protocol_version get_maximum_version() const
Return the value of the maximum supported version.
Definition: gcs_internal_message.cc:253
std::pair< buffer_ptr, unsigned long long > serialize()
Encode the packet content into its serialization buffer, and release ownership of the serialization b...
Definition: gcs_internal_message.cc:292
Gcs_dynamic_header & get_current_dynamic_header()
Definition: gcs_internal_message.cc:235
std::size_t const & get_next_stage_index() const
Definition: gcs_internal_message.cc:227
Defines a message identifier so that joining members can fetch the associated packet from a remote no...
Definition: gcs_xcom_synode.h:38
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:127
#define free(A)
Definition: lexyy.cc:915
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:314
Definition: varlen_sort.h:183
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2869
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2873
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2437
Deleter for objects managed by a std::unique_ptr that were allocated using the malloc family of funct...
Definition: gcs_internal_message.h:43
void operator()(unsigned char *buffer) const
Definition: gcs_internal_message.h:44