Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
IfTcp.hxx
Go to the documentation of this file.
1
35#ifndef _OPENLCB_IFTCP_HXX_
36#define _OPENLCB_IFTCP_HXX_
37
38#include "openlcb/If.hxx"
39#include "utils/Hub.hxx"
40
41namespace openlcb
42{
43
46{
51 string data;
52};
53
55class TcpSendFlow;
56class TcpRecvFlow;
57
66class IfTcp : public If
67{
68public:
77 IfTcp(NodeID gateway_node_id, HubFlow *device, int local_nodes_count);
78
80 ~IfTcp();
81
88 void add_owned_flow(Executable *e) override;
94 {
95 ownedFlows_.emplace_back(e);
96 }
106 void delete_local_node(Node *node) override;
109 bool matching_node(NodeHandle expected, NodeHandle actual) override;
110
114 void add_network_fd(int fd, Notifiable *on_error = nullptr);
115
117 NodeID get_default_node_id() override;
118
119private:
123 std::vector<std::unique_ptr<Destructable>> ownedFlows_;
131};
132
133} // namespace openlcb
134
135#endif // _OPENLCB_IFTCP_HXX_
Base class of everything with a virtual destructor.
An object that can be scheduled on an executor to run.
An object that can schedule itself on an executor to run.
Implementation of sequence number generator that uses the real clock.
Network interface class for a character stream link that speaks the (point-to-point) TcpTransfer prot...
Definition IfTcp.hxx:67
TcpSendFlow * sendFlow_
Flow used for converting GenMessage into the binary representation.
Definition IfTcp.hxx:128
~IfTcp()
Destructor.
Definition IfTcp.cxx:205
bool matching_node(NodeHandle expected, NodeHandle actual) override
Definition IfTcp.cxx:71
void delete_owned_flow(Destructable *d)
Finds a given pointer in the owned flows list, deletes it and removes it from the list.
Definition IfTcp.cxx:58
void delete_local_node(Node *node) override
Removes a local node from this interface.
Definition IfTcp.cxx:48
void add_owned_flow(Executable *e) override
Transfers ownership of a module to the interface.
Definition IfTcp.cxx:53
void add_network_fd(int fd, Notifiable *on_error=nullptr)
Adds a network client connection to the device.
Definition IfTcp.cxx:83
HubFlow * device_
Where to send traffic to.
Definition IfTcp.hxx:121
ClockBaseSequenceNumberGenerator * seq_
Sequence number generator for outgoing TCP packets.
Definition IfTcp.hxx:125
void add_owned_flow(Destructable *e)
Transfers ownership of a module to the interface.
Definition IfTcp.hxx:93
std::vector< std::unique_ptr< Destructable > > ownedFlows_
Various implementation control flows that this interface owns.
Definition IfTcp.hxx:123
NodeID get_default_node_id() override
Definition IfTcp.cxx:214
TcpRecvFlow * recvFlow_
Flow for parsing incoming messages. Owned by ownedFlows_.
Definition IfTcp.hxx:130
Abstract class representing an OpenLCB Interface.
Definition If.hxx:185
Base class for NMRAnet nodes conforming to the asynchronous interface.
Definition Node.hxx:52
Simple stateless translator for incoming TCP messages from binary format into the structured format.
This flow renders outgoing OpenLCB messages to their TCP stream representation.
uint64_t NodeID
48-bit NMRAnet Node ID type
Container of both a NodeID and NodeAlias.
This is not used at the moment, as TCP packet routing is not supported yet.
Definition IfTcp.hxx:46
NodeHandle dst
Destination node, or {0,0} for broadcast. Helper function for routing.
Definition IfTcp.hxx:48
string data
Rendered string for the message payload.
Definition IfTcp.hxx:51