Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::CanDatagramParser Class Reference

Frame handler that assembles incoming datagram fragments into a single datagram message. More...

Inheritance diagram for openlcb::CanDatagramParser:
openlcb::CanFrameStateFlow StateFlow< Buffer< CanMessageData >, QList< 1 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Public Types

enum  { CAN_FILTER , CAN_MASK }
 
- Public Types inherited from TypedStateFlow< MessageType, Base >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 

Public Member Functions

 CanDatagramParser (IfCan *iface)
 
Action entry () override
 Handler callback for incoming frames.
 
Action send_rejection ()
 Sends a datagram rejection.
 
Action datagram_complete ()
 Requests the datagram in buf_, dstNode_ etc... to be sent to the AsyncIf for processing.
 
- Public Member Functions inherited from openlcb::CanFrameStateFlow
 CanFrameStateFlow (IfCan *service)
 
IfCanif_can ()
 
- Public Member Functions inherited from StateFlow< Buffer< CanMessageData >, QList< 1 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Private Attributes

DatagramPayload localBuffer_
 A local buffer that owns the datagram payload bytes after we took the entry from the pending buffers map.
 
NodedstNode_
 
NodeHandle dst_
 
unsigned short srcAlias_: 12
 
uint16_t errorCode_
 If non-zero, contains a Rejection error code and the datagram should not be forwarded to the upper layer in this case.
 
StlMap< uint64_t, DatagramPayloadpendingBuffers_
 Open datagram buffers.
 

Additional Inherited Members

- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, Base >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 

Detailed Description

Frame handler that assembles incoming datagram fragments into a single datagram message.

(That is, datagrams addressed to local nodes.)

Definition at line 131 of file DatagramCan.cxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 134 of file DatagramCan.cxx.

Constructor & Destructor Documentation

◆ CanDatagramParser()

openlcb::CanDatagramParser::CanDatagramParser ( IfCan iface)

Definition at line 369 of file DatagramCan.cxx.

◆ ~CanDatagramParser()

openlcb::CanDatagramParser::~CanDatagramParser ( )

Definition at line 386 of file DatagramCan.cxx.

Member Function Documentation

◆ datagram_complete()

Action openlcb::CanDatagramParser::datagram_complete ( )
inline

Requests the datagram in buf_, dstNode_ etc... to be sent to the AsyncIf for processing.

The lock_ is held and must be released. entry is the dispatcher.

Definition at line 301 of file DatagramCan.cxx.

◆ entry()

Action openlcb::CanDatagramParser::entry ( )
inlineoverridevirtual

Handler callback for incoming frames.

Frames came out of order or more than one datagram is being sent to the same dst.

Implements TypedStateFlow< MessageType, Base >.

Definition at line 148 of file DatagramCan.cxx.

◆ send_rejection()

Action openlcb::CanDatagramParser::send_rejection ( )
inline

Sends a datagram rejection.

The lock_ is held and must be released. entry is an If::addressed write flow. errorCode_ != 0.

Definition at line 286 of file DatagramCan.cxx.

Member Data Documentation

◆ dst_

NodeHandle openlcb::CanDatagramParser::dst_
private

Definition at line 331 of file DatagramCan.cxx.

◆ dstNode_

Node* openlcb::CanDatagramParser::dstNode_
private

Definition at line 330 of file DatagramCan.cxx.

◆ errorCode_

uint16_t openlcb::CanDatagramParser::errorCode_
private

If non-zero, contains a Rejection error code and the datagram should not be forwarded to the upper layer in this case.

Definition at line 335 of file DatagramCan.cxx.

◆ localBuffer_

DatagramPayload openlcb::CanDatagramParser::localBuffer_
private

A local buffer that owns the datagram payload bytes after we took the entry from the pending buffers map.

Definition at line 328 of file DatagramCan.cxx.

◆ pendingBuffers_

StlMap<uint64_t, DatagramPayload> openlcb::CanDatagramParser::pendingBuffers_
private

Open datagram buffers.

Keyed by (dstid | srcid), value is a datagram payload. When a payload is finished, it should be moved into the final datagram message using swap() to avoid memory copies. @TODO(balazs.racz) we need some kind of timeout-based release mechanism in here.

Definition at line 342 of file DatagramCan.cxx.

◆ srcAlias_

unsigned short openlcb::CanDatagramParser::srcAlias_
private

Definition at line 332 of file DatagramCan.cxx.


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