Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::StreamDefs Struct Reference

Static constants and helper functions for the OpenLCB streaming protocol. More...

#include <StreamDefs.hxx>

Public Types

enum  Flags {
  FLAG_CARRIES_ID = 0x01 , FLAG_REJECT_OUT_OF_ORDER = 0x02 , FLAG_PERMANENT_ERROR = 0x10 , FLAG_TEMPORARY_ERROR = 0x20 ,
  FLAG_ACCEPT = 0x80
}
 
enum  AdditionalFlags {
  REJECT_INFO_LOGGED = 0x01 , REJECT_PERMANENT_INVALID_REQUEST = 0x20 , REJECT_PERMANENT_SRC_NOT_PERMITTED = 0x40 , REJECT_PERMANENT_STREAMS_NOT_ACCEPTED = 0x80 ,
  REJECT_TEMPORARY_BUFFER_FULL = 0x20 , REJECT_TEMPORARY_OUT_OF_ORDER = 0x40
}
 

Static Public Member Functions

static Payload create_initiate_request (uint16_t max_buffer_size, bool has_ident, uint8_t src_stream_id, uint8_t dst_stream_id=INVALID_STREAM_ID)
 Creates a Stream Initiate Request message payload.
 
static Payload create_initiate_response (uint16_t max_buffer_size, uint8_t src_stream_id, uint8_t dst_stream_id, uint16_t error_code=STREAM_ACCEPT)
 Creates a Stream Initiate Reply message payload.
 
static Payload create_data_proceed (uint8_t src_stream_id, uint8_t dst_stream_id)
 Creates a Stream Data Proceed message payload.
 
static Payload create_close_request (uint8_t src_stream_id, uint8_t dst_stream_id, uint32_t total_bytes=INVALID_TOTAL_BYTE_COUNT)
 Creates the payload for a stream close message.
 

Static Public Attributes

static constexpr uint16_t MAX_PAYLOAD = 0xffff
 Maximum window size for stream send.
 
static constexpr uint8_t INVALID_STREAM_ID = 0xff
 This value is invalid as a source or destination stream ID.
 
static constexpr uint32_t INVALID_TOTAL_BYTE_COUNT = 0xffffffff
 Supply this value to the total byte count in stream close to mark it as invalid.
 
static constexpr uint16_t STREAM_ACCEPT = ((uint16_t)FLAG_ACCEPT) << 8
 This code is sent back in the error code field in the stream initiate reply if the stream is accepted.
 
static constexpr uint16_t STREAM_ERROR_INVALID_ARGS
 This code is sent back in the error code field in the stream initiate reply if the stream is rejected with invalid arguments.
 

Detailed Description

Static constants and helper functions for the OpenLCB streaming protocol.

Definition at line 43 of file StreamDefs.hxx.

Member Enumeration Documentation

◆ AdditionalFlags

enum openlcb::StreamDefs::AdditionalFlags

Definition at line 64 of file StreamDefs.hxx.

◆ Flags

Enumerator
FLAG_PERMANENT_ERROR 
Todo:
synchronize the draft text in the standards repository with these definitions. These definitions match other OpenLCB protocols.

Definition at line 53 of file StreamDefs.hxx.

Member Function Documentation

◆ create_close_request()

static Payload openlcb::StreamDefs::create_close_request ( uint8_t  src_stream_id,
uint8_t  dst_stream_id,
uint32_t  total_bytes = INVALID_TOTAL_BYTE_COUNT 
)
inlinestatic

Creates the payload for a stream close message.

Parameters
src_stream_id1-byte SID stream identifier at the source side
dst_stream_id1-byte SID stream identifier at the dst side
total_bytesif nonzero, specifies how many bytes were transferred in the stream in total.
Returns
a Payload object for GenMessage.

Definition at line 156 of file StreamDefs.hxx.

◆ create_data_proceed()

static Payload openlcb::StreamDefs::create_data_proceed ( uint8_t  src_stream_id,
uint8_t  dst_stream_id 
)
inlinestatic

Creates a Stream Data Proceed message payload.

Parameters
src_stream_idstream ID on the source side
dst_stream_idstream ID on the destination side
Returns
Payload object for GenMessage

Definition at line 138 of file StreamDefs.hxx.

◆ create_initiate_request()

static Payload openlcb::StreamDefs::create_initiate_request ( uint16_t  max_buffer_size,
bool  has_ident,
uint8_t  src_stream_id,
uint8_t  dst_stream_id = INVALID_STREAM_ID 
)
inlinestatic

Creates a Stream Initiate Request message payload.

Parameters
max_buffer_sizevalue to propose as stream window size.
has_identif true, sets the flag for carrying a source stream ID.
src_stream_idsource stream ID value.
Returns
a Payload object for a GenMessage.

Definition at line 93 of file StreamDefs.hxx.

◆ create_initiate_response()

static Payload openlcb::StreamDefs::create_initiate_response ( uint16_t  max_buffer_size,
uint8_t  src_stream_id,
uint8_t  dst_stream_id,
uint16_t  error_code = STREAM_ACCEPT 
)
inlinestatic

Creates a Stream Initiate Reply message payload.

Parameters
max_buffer_sizethe definite window size of the stream
src_stream_idstream ID on the source side.
dst_stream_idstream ID on the dst side.
error_codeerror code if the stream is rejected, otherwise STREAM_ACCEPT if it is accepted.
Returns
a Payload object for a GenMessage.

Definition at line 117 of file StreamDefs.hxx.

Member Data Documentation

◆ INVALID_STREAM_ID

constexpr uint8_t openlcb::StreamDefs::INVALID_STREAM_ID = 0xff
staticconstexpr

This value is invalid as a source or destination stream ID.

Definition at line 48 of file StreamDefs.hxx.

◆ INVALID_TOTAL_BYTE_COUNT

constexpr uint32_t openlcb::StreamDefs::INVALID_TOTAL_BYTE_COUNT = 0xffffffff
staticconstexpr

Supply this value to the total byte count in stream close to mark it as invalid.

Definition at line 51 of file StreamDefs.hxx.

◆ MAX_PAYLOAD

constexpr uint16_t openlcb::StreamDefs::MAX_PAYLOAD = 0xffff
staticconstexpr

Maximum window size for stream send.

Definition at line 46 of file StreamDefs.hxx.

◆ STREAM_ACCEPT

constexpr uint16_t openlcb::StreamDefs::STREAM_ACCEPT = ((uint16_t)FLAG_ACCEPT) << 8
staticconstexpr

This code is sent back in the error code field in the stream initiate reply if the stream is accepted.

Definition at line 76 of file StreamDefs.hxx.

◆ STREAM_ERROR_INVALID_ARGS

constexpr uint16_t openlcb::StreamDefs::STREAM_ERROR_INVALID_ARGS
staticconstexpr
Initial value:
=
(((uint16_t)FLAG_PERMANENT_ERROR) << 8) |
REJECT_PERMANENT_INVALID_REQUEST

This code is sent back in the error code field in the stream initiate reply if the stream is rejected with invalid arguments.

Definition at line 80 of file StreamDefs.hxx.


The documentation for this struct was generated from the following file: