|
Open Model Railroad Network (OpenMRN)
|
Network interface class for a character stream link that speaks the (point-to-point) TcpTransfer protocol. More...
#include <IfTcp.hxx>
Public Member Functions | |
| IfTcp (NodeID gateway_node_id, HubFlow *device, int local_nodes_count) | |
| Creates a TCP interface. | |
| ~IfTcp () | |
| Destructor. | |
| void | add_owned_flow (Executable *e) override |
| Transfers ownership of a module to the interface. | |
| void | add_owned_flow (Destructable *e) |
| Transfers ownership of a module to the interface. | |
| void | delete_owned_flow (Destructable *d) |
| Finds a given pointer in the owned flows list, deletes it and removes it from the list. | |
| void | delete_local_node (Node *node) override |
| Removes a local node from this interface. | |
| bool | matching_node (NodeHandle expected, NodeHandle actual) override |
| void | add_network_fd (int fd, Notifiable *on_error=nullptr) |
| Adds a network client connection to the device. | |
| NodeID | get_default_node_id () override |
Public Member Functions inherited from openlcb::If | |
| If (ExecutorBase *executor, int local_nodes_count) | |
| Constructs an NMRAnet interface. | |
| virtual | ~If () |
| Destructor. | |
| MessageHandler * | global_message_write_flow () |
| MessageHandler * | addressed_message_write_flow () |
| MessageDispatchFlow * | dispatcher () |
| void | add_local_node (Node *node) |
| Registers a new local node on this interface. | |
| Node * | lookup_local_node (NodeID id) |
| Looks up a node ID in the local nodes' registry. | |
| virtual Node * | lookup_local_node_handle (NodeHandle handle) |
| Looks up a node ID in the local nodes' registry. | |
| Node * | first_local_node () |
| Node * | next_local_node (NodeID previous) |
| Iterator helper on the local nodes map. | |
| virtual void | canonicalize_handle (NodeHandle *h) |
| Canonicalizes the node handle: fills in id and/or alias from the maps the interface holds internally. | |
| void | set_tx_hook (std::function< void()> hook) |
| Sets a transmit hook. | |
| StreamTransport * | stream_transport () |
| void | set_stream_transport (StreamTransport *s) |
| Adds the necessary object for this interface to support stream transport. | |
Public Member Functions inherited from Service | |
| Service (ExecutorBase *e) | |
| Constructor. | |
| ~Service () | |
| Destructor. | |
| ExecutorBase * | executor () |
Private Attributes | |
| HubFlow * | device_ |
| Where to send traffic to. | |
| std::vector< std::unique_ptr< Destructable > > | ownedFlows_ |
| Various implementation control flows that this interface owns. | |
| ClockBaseSequenceNumberGenerator * | seq_ |
| Sequence number generator for outgoing TCP packets. | |
| TcpSendFlow * | sendFlow_ |
| Flow used for converting GenMessage into the binary representation. | |
| TcpRecvFlow * | recvFlow_ |
| Flow for parsing incoming messages. Owned by ownedFlows_. | |
Additional Inherited Members | |
Public Types inherited from openlcb::If | |
| typedef DispatchFlow< Buffer< GenMessage >, 4 > | MessageDispatchFlow |
| Type of the dispatcher of incoming NMRAnet messages. | |
Protected Member Functions inherited from openlcb::If | |
| void | remove_local_node_from_map (Node *node) |
Protected Attributes inherited from openlcb::If | |
| MessageHandler * | globalWriteFlow_ |
| Allocator containing the global write flows. | |
| MessageHandler * | addressedWriteFlow_ |
| Allocator containing the addressed write flows. | |
Network interface class for a character stream link that speaks the (point-to-point) TcpTransfer protocol.
This is the class that needs to be given to the virtual node (Node*) on the constructor. The If class provides the API and owns all of the implementation for sending and receiving messages to/from this network link.
Today the IfTcp class supports a dumb hub on the device end. This allows creating servers although without any advanced routing logic.
Creates a TCP interface.
| gateway_node_id | will be stamped on outgoing messages as the gateway's node ID. |
| device | is a Hub to send the TCP packets to / receive input from. The interface will register itself into this hub. The executor of this device will be used for processing the packets in this interface. |
| local_nodes_count | is the maximum number of virtual nodes that this interface will support. |
| void openlcb::IfTcp::add_network_fd | ( | int | fd, |
| Notifiable * | on_error = nullptr |
||
| ) |
|
inline |
|
overridevirtual |
Transfers ownership of a module to the interface.
It will be brought down in the destructor. The destruction order is guaranteed such that all supporting structures are still available when the flow is destryed, but incoming messages can not come in anymore.
Implements openlcb::If.
|
overridevirtual |
Removes a local node from this interface.
This function must be called from the interface's executor.
| node | is the node to delete. The node will not be freed, just removed from the data structures. |
Implements openlcb::If.
| void openlcb::IfTcp::delete_owned_flow | ( | Destructable * | d | ) |
|
overridevirtual |
|
overridevirtual |
Implements openlcb::If.
|
private |
|
private |
|
private |
|
private |
Flow used for converting GenMessage into the binary representation.
Owned by ownedFlows_.
|
private |