31#include <unordered_set>
60 using buffer_ptr = std::unique_ptr<unsigned char, Gcs_packet_buffer_deleter>;
143 std::vector<Gcs_dynamic_header> &&dynamic_headers,
144 std::vector<std::unique_ptr<Gcs_stage_metadata>> &&stage_metadata,
145 unsigned long long const &payload_size);
164 unsigned long long const &new_payload_size);
178 synode_no
const &delivery_synode,
179 synode_no
const &origin_synode,
290 unsigned long long const &payload_size);
299 unsigned long long const &new_payload_size);
308 explicit
Gcs_packet(synode_no const &delivery_synode,
309 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:365
This class is an abstraction for the packet concept.
Definition: gcs_internal_message.h:58
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:99
void set_payload_length(unsigned long long const &new_length)
Definition: gcs_internal_message.cc:248
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:67
buffer_ptr m_serialized_packet
The buffer containing all serialized data for this packet.
Definition: gcs_internal_message.h:95
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:73
Gcs_protocol_version get_used_version() const
Return the value of the version in use.
Definition: gcs_internal_message.cc:258
std::size_t m_serialized_payload_offset
The offset in m_serialized_packet where the application payload starts.
Definition: gcs_internal_message.h:105
std::vector< Gcs_dynamic_header > const & get_dynamic_headers() const
Retrieve this packet's dynamic headers.
Definition: gcs_internal_message.cc:218
void prepare_for_next_outgoing_stage()
Definition: gcs_internal_message.cc:232
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:43
void dump(std::ostringstream &output) const
Create a string representation of the packet to be logged.
Definition: gcs_internal_message.cc:375
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:90
Gcs_xcom_synode m_delivery_synode
The XCom synode in which this packet was delivered.
Definition: gcs_internal_message.h:120
unsigned long long const & get_payload_length() const
Return the payload length.
Definition: gcs_internal_message.cc:270
Gcs_xcom_synode const & get_origin_synode() const
Definition: gcs_internal_message.cc:391
Gcs_xcom_synode const & get_delivery_synode() const
Definition: gcs_internal_message.cc:387
Gcs_packet() noexcept
Definition: gcs_internal_message.cc:30
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:143
Gcs_xcom_synode m_origin_synode
The XCom synode in which this packet was delivered.
Definition: gcs_internal_message.h:125
Gcs_stage_metadata & get_current_stage_header()
Definition: gcs_internal_message.cc:240
std::vector< std::unique_ptr< Gcs_stage_metadata > > const & get_stage_metadata() const
Retrieve this packet's stage metadata.
Definition: gcs_internal_message.cc:224
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:324
unsigned long long m_serialized_payload_size
The size of the serialized application payload in m_serialized_packet.
Definition: gcs_internal_message.h:110
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:84
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:115
std::unique_ptr< unsigned char, Gcs_packet_buffer_deleter > buffer_ptr
Definition: gcs_internal_message.h:60
void prepare_for_next_incoming_stage()
Definition: gcs_internal_message.cc:234
Gcs_internal_message_header const & get_fixed_header() const
Retrieve this packet's header.
Definition: gcs_internal_message.cc:214
unsigned long long get_total_length() const
Return the total length.
Definition: gcs_internal_message.cc:266
Cargo_type get_cargo_type() const
Return the cargo type.
Definition: gcs_internal_message.cc:262
unsigned long long m_serialized_packet_size
The capacity of the serialization buffer.
Definition: gcs_internal_message.h:100
bool allocate_serialization_buffer()
Allocates the underlying buffer where the packet will be serialized to using serialize.
Definition: gcs_internal_message.cc:274
unsigned char * get_payload_pointer()
Definition: gcs_internal_message.cc:244
Gcs_protocol_version get_maximum_version() const
Return the value of the maximum supported version.
Definition: gcs_internal_message.cc:254
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:293
Gcs_dynamic_header & get_current_dynamic_header()
Definition: gcs_internal_message.cc:236
std::size_t const & get_next_stage_index() const
Definition: gcs_internal_message.cc:228
Defines a message identifier so that joining members can fetch the associated packet from a remote no...
Definition: gcs_xcom_synode.h:39
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:128
#define free(A)
Definition: lexyy.cc:915
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:313
Definition: gcs_xcom_synode.h:64
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2872
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
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:2440
Deleter for objects managed by a std::unique_ptr that were allocated using the malloc family of funct...
Definition: gcs_internal_message.h:44
void operator()(unsigned char *buffer) const
Definition: gcs_internal_message.h:45