48 const char *src =
reinterpret_cast<const char *
>(&id);
49 return string(src + 2, 6);
55 const char *src =
reinterpret_cast<const char *
>(&id);
56 memcpy(buf, src + 2, 6);
62 memcpy(
reinterpret_cast<uint8_t *
>(&d) + 2, buf, 6);
74 eventid = htobe64(eventid);
75 return string(
reinterpret_cast<char*
>(&eventid), 8);
79 uint8_t* p = (uint8_t*) data;
80 p[0] = error_code >> 8;
81 p[1] = error_code & 0xff;
86 const uint8_t *p = (
const uint8_t *)data;
87 return (((uint16_t)p[0]) << 8) | p[1];
107 p->push_back(error_code >> 8);
108 p->push_back(error_code & 0xff);
113 uint16_t *mti,
string *error_message)
118 *error_code = Defs::ERROR_PERMANENT;
120 error_message->clear();
121 if (payload.size() >= 2 && error_code)
123 *error_code = (((uint16_t)payload[0]) << 8) | (uint8_t)payload[1];
125 if (payload.size() >= 4 && mti)
127 *mti = (((uint16_t)payload[2]) << 8) | (uint8_t)payload[3];
129 if (payload.size() > 4 && error_message)
131 error_message->assign(&payload[4], payload.size() - 4);
146 b->data()->reset(Defs::MTI_EVENT_REPORT, src_node->node_id(),
176 , globalWriteFlow_(nullptr)
177 , addressedWriteFlow_(nullptr)
179 , localNodes_(local_nodes_count)
const unsigned LARGEST_BUFFERPOOL_BUCKET
Ensures that the largest bucket in the main buffer pool is exactly the size of a GenMessage.
Base class for all QMember types that hold data in an expandable format.
This class implements an execution of tasks pulled off an input queue.
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.
Collection of related state machines that pend on incoming messages.
MessageHandler * global_message_write_flow()
If(ExecutorBase *executor, int local_nodes_count)
Constructs an NMRAnet interface.
Base class for NMRAnet nodes conforming to the asynchronous interface.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
string EMPTY_PAYLOAD
A global class / variable for empty or not-yet-initialized payloads.
void node_id_to_data(NodeID id, void *data)
Convenience function to render a 48-bit NMRAnet node ID into an existing buffer.
string node_id_to_buffer(NodeID id)
Convenience function to render a 48-bit NMRAnet node ID into a new buffer.
NodeID data_to_node_id(const void *d)
Converts 6 bytes of big-endian data to a node ID.
uint64_t NodeID
48-bit NMRAnet Node ID type
void send_event(Node *src_node, uint64_t event_id)
Helper function to send an event report to the bus.
uint16_t data_to_error(const void *data)
Parses an error code from a payload object at a given pointer.
void error_to_data(uint16_t error_code, void *data)
Writes an error code into a payload object at a given pointer.
NodeID buffer_to_node_id(const string &buf)
Converts a 6-byte-long buffer to a node ID.
void append_error_to_buffer(uint16_t error_code, Payload *p)
Appends an error to the end of an existing buffer.
string Payload
Container that carries the data bytes in an NMRAnet message.
Payload eventid_to_buffer(uint64_t eventid)
Converts an Event ID to a Payload suitable to be sent as an event report.
void buffer_to_error(const Payload &payload, uint16_t *error_code, uint16_t *mti, string *error_message)
Parses the payload of an Optional Interaction Rejected or Terminate Due To Error message.
Payload error_payload(uint16_t error_code, Defs::MTI incoming_mti)
Generates the payload for an OIR or TDE message.
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.