35#ifndef _OPENLCB_DATAGRAMHANDLERDEFAULT_HXX_
36#define _OPENLCB_DATAGRAMHANDLERDEFAULT_HXX_
71 dg_service()->iface()->addressed_message_write_flow(),
72 STATE(send_ok_response));
94 responseErrorCode_ = flags;
100 b->
data()->reset(responseMti_,
message()->data()->dst->node_id(),
102 Payload(1, (
char)(responseErrorCode_ & 0xff)));
106 Action send_ok_response()
109 dg_service()->iface()->addressed_message_write_flow());
124 responseErrorCode_ = error_code;
126 dg_service()->iface()->addressed_message_write_flow(),
127 STATE(send_reject_response));
131 Action send_reject_response()
134 dg_service()->iface()->addressed_message_write_flow());
135 b->data()->reset(responseMti_,
message()->data()->dst->node_id(),
153 return message()->data()->payload.size();
160 return reinterpret_cast<const uint8_t *
>(
161 message()->data()->payload.data());
165 uint16_t responseErrorCode_;
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
Base class for all QMember types that hold data in an expandable format.
T * data()
get a pointer to the start of the data.
virtual void send(MessageType *message, unsigned priority=UINT_MAX)=0
Entry point to the flow.
MessageType * alloc()
Synchronously allocates a message buffer from the pool of this flow.
Return type for a state flow callback.
Service * service()
Return a pointer to the service I am bound to.
Action allocate_and_call(FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
Allocates a buffer from a pool and proceed to the next state when allocation is successful.
Buffer< T > * get_allocation_result(FlowInterface< Buffer< T > > *target_flow)
Takes the result of the asynchronous allocation.
Action release_and_exit()
Terminates the processing of the current message.
State flow with a given typed input queue.
Action call_immediately(Callback c)
Imediately call the next state upon return.
Transport-agnostic dispatcher of datagrams.
Base class with utility functionality that implements some common functionality.
Action respond_reject(uint16_t error_code)
Sends a DATAGRAM_REJECT response to the datagram originator node.
void respond_ok_helper(Buffer< GenMessage > *b)
Helper function for respond_ok.
Action respond_ok(uint8_t flags)
Sends a DATAGRAM_OK response to the datagram originator node.
void prepare_respond_ok(uint8_t flags)
Helper function for respond_ok.
virtual Action ok_response_sent()
This state is where the handling will end up after a respond_ok call.
const uint8_t * payload()
void inline_respond_ok(uint8_t flags)
Sends a DATAGRAM_OK response to the datagram originator node.
MessageHandler * addressed_message_write_flow()
string Payload
Container that carries the data bytes in an NMRAnet message.
StateFlow< Buffer< IncomingDatagram >, QList< 1 > > DatagramHandlerFlow
Derive datagram handlers that are stateflows from this base class.
string error_to_buffer(uint16_t error_code, uint16_t mti)
Formats a payload for response of error response messages such as OPtioanl Interaction Rejected or Te...
MTI
Known Message type indicators.
@ MTI_DATAGRAM_REJECTED
datagram rejected by receiver
@ MTI_DATAGRAM_OK
datagram received okay