|
libe3 0.6.1
C++ library for E3AP RAN vendor integration
|
POSIX socket-based E3 connector: one endpoint per dApp. More...
#include <posix_connector.hpp>
Classes | |
| struct | Peer |
| One accepted connection of a RAN. Closes its socket when the last reference goes. More... | |
| struct | Queued |
| A PDU read from a peer and waiting for the thread that takes it. More... | |
Public Member Functions | |
| PosixE3Connector (E3TransportLayer transport_layer, const std::string &endpoint, uint16_t port, const PosixOptions &options) | |
| Create a POSIX connector. | |
| ~PosixE3Connector () override | |
| Close every socket. | |
| ErrorCode | setup_initial_connection () override |
| Set up the initial connection (setup channel). | |
| int | recv_setup_request (std::vector< uint8_t > &buffer) override |
| Receive a setup request. | |
| ErrorCode | send_response (const std::vector< uint8_t > &data) override |
| Send a setup response. | |
| ErrorCode | setup_inbound_connection () override |
| Set up the inbound connection (SUB channel). | |
| int | receive (std::vector< uint8_t > &buffer) override |
| Receive data from the inbound channel. | |
| ErrorCode | setup_outbound_connection () override |
| Set up the outbound connection (PUB channel). | |
| ErrorCode | send (const std::vector< uint8_t > &data) override |
| Send data on the outbound channel. | |
| ErrorCode | send_to (uint64_t peer_token, const std::vector< uint8_t > &data, PduClass kind) override |
| Send data to one peer, or to all of them (RAN role). | |
| ErrorCode | setup_initial_connection_client () override |
| Connect the setup channel (dApp role: REQ connect). | |
| ErrorCode | send_setup_request_client (const std::vector< uint8_t > &data) override |
| Send a SetupRequest on the setup channel (dApp role). | |
| int | recv_setup_response_client (std::vector< uint8_t > &buffer) override |
| Receive a SetupResponse on the setup channel (dApp role). | |
| ErrorCode | setup_inbound_connection_client () override |
| Connect the inbound channel (dApp role: SUB connect to the RAN's publisher endpoint). | |
| ErrorCode | setup_outbound_connection_client () override |
| Connect the outbound channel (dApp role: PUB connect to the RAN's subscriber endpoint). | |
| void | dispose () override |
| Clean up and release all resources. | |
| void | shutdown () override |
| Interrupt blocking operations for shutdown. | |
| uint64_t | last_peer_token () const override |
| Which peer supplied the bytes the last receive() returned (RAN role). | |
| uint64_t | last_setup_peer_token () const override |
| Which peer sent the setup request the last recv_setup_request() returned (RAN role). | |
| std::vector< uint64_t > | take_closed_peers () override |
| Peers whose connection has closed since the last call (RAN role). | |
| E3LinkLayer | link_layer () const noexcept override |
| Get the link layer type. | |
| E3TransportLayer | transport_layer () const noexcept override |
| Get the transport layer type. | |
| bool | is_connected () const noexcept override |
| Check if connector is connected. | |
| Public Member Functions inherited from libe3::E3Connector | |
| virtual | ~E3Connector ()=default |
| E3Connector (const E3Connector &)=delete | |
| E3Connector & | operator= (const E3Connector &)=delete |
| E3Connector (E3Connector &&)=default | |
| Move constructor. | |
| E3Connector & | operator= (E3Connector &&)=default |
| Move assignment. | |
| void | set_role (E3Role role) noexcept |
| Set role (RAN or DAPP). Affects bind vs connect direction and cleanup behaviour. Must be set before any setup_* call. Default RAN. | |
| E3Role | role () const noexcept |
| Get current role. | |
| const std::string & | setup_endpoint () const noexcept |
| Get setup endpoint. | |
| const std::string & | inbound_endpoint () const noexcept |
| Get inbound endpoint. | |
| const std::string & | outbound_endpoint () const noexcept |
| Get outbound endpoint. | |
Additional Inherited Members | |
| Protected Member Functions inherited from libe3::E3Connector | |
| E3Connector ()=default | |
| Protected Attributes inherited from libe3::E3Connector | |
| std::string | setup_endpoint_ |
| Endpoint of the setup channel. | |
| std::string | inbound_endpoint_ |
| Endpoint of the inbound channel. | |
| std::string | outbound_endpoint_ |
| Endpoint of the outbound channel. | |
| E3Role | role_ {E3Role::RAN} |
| Role of this peer. | |
POSIX socket-based E3 connector: one endpoint per dApp.
Supports TCP, SCTP and IPC. A dApp opens one connection to the RAN's single endpoint and the setup, inbound and outbound traffic all use it; the three channels of E3Connector are logical. The first PDU on a connection is the dApp's setup request and goes to recv_setup_request(); every later PDU goes to receive(). The inbound thread is the only reader of the sockets, so the receive path costs the same as with one channel per socket.
Each PDU is one message. SCTP and IPC (a sequenced-packet socket) keep message boundaries and carry no prefix. TCP is a byte stream and prefixes each PDU with its length as four bytes in network order, in both directions. SCTP stamps payload protocol id 0x00E3A001 and sends indications on stream 1, everything else on stream 0.
The RAN names each accepted connection with a token that is never reused (see E3Connector::last_peer_token) and can send to one peer or to all.
Definition at line 42 of file posix_connector.hpp.
| libe3::PosixE3Connector::PosixE3Connector | ( | E3TransportLayer | transport_layer, |
| const std::string & | endpoint, | ||
| uint16_t | port, | ||
| const PosixOptions & | options ) |
Create a POSIX connector.
| transport_layer | SCTP, TCP or IPC |
| endpoint | Endpoint of the link. IPC: a path, "ipc://" prefix optional, and the library's shared default is replaced by /tmp/dapps/e3. TCP and SCTP: "tcp://host:port" or "sctp://host:port" (a host in brackets for IPv6); anything else means the default host and port |
| port | Port of the link (SCTP and TCP) when the endpoint names none |
| options | Socket and admission options |
Definition at line 380 of file posix_connector.cpp.
|
override |
Close every socket.
Definition at line 400 of file posix_connector.cpp.
|
overridevirtual |
Clean up and release all resources.
Implements libe3::E3Connector.
Definition at line 1139 of file posix_connector.cpp.
|
inlineoverridevirtualnoexcept |
Check if connector is connected.
Implements libe3::E3Connector.
Definition at line 95 of file posix_connector.hpp.
|
overridevirtual |
Which peer supplied the bytes the last receive() returned (RAN role).
Call it on the thread that calls receive(), right after a receive() that returned bytes. A token names one accepted connection and is never reused by the same connector, so a closed peer's token cannot name a later one.
Reimplemented from libe3::E3Connector.
Definition at line 963 of file posix_connector.cpp.
|
overridevirtual |
Which peer sent the setup request the last recv_setup_request() returned (RAN role).
Call it on the thread that calls recv_setup_request(), right after a call that returned bytes. The token is the one last_peer_token() gives for the same peer's later bytes, so a RAN can tie a dApp to its connection at setup.
Reimplemented from libe3::E3Connector.
Definition at line 967 of file posix_connector.cpp.
|
inlineoverridevirtualnoexcept |
Get the link layer type.
Implements libe3::E3Connector.
Definition at line 87 of file posix_connector.hpp.
|
overridevirtual |
Receive data from the inbound channel.
| buffer | Buffer to store received data |
Implements libe3::E3Connector.
Definition at line 840 of file posix_connector.cpp.
|
overridevirtual |
Receive a setup request.
Blocks until a setup request is received on the setup channel.
| buffer | Buffer to store received data |
Implements libe3::E3Connector.
Definition at line 867 of file posix_connector.cpp.
|
overridevirtual |
Receive a SetupResponse on the setup channel (dApp role).
Reimplemented from libe3::E3Connector.
Definition at line 1034 of file posix_connector.cpp.
|
overridevirtual |
Send data on the outbound channel.
| data | Data to send |
Implements libe3::E3Connector.
Definition at line 914 of file posix_connector.cpp.
|
overridevirtual |
Send a setup response.
| data | Response data to send |
Implements libe3::E3Connector.
Definition at line 905 of file posix_connector.cpp.
|
overridevirtual |
Send a SetupRequest on the setup channel (dApp role).
Reimplemented from libe3::E3Connector.
Definition at line 1017 of file posix_connector.cpp.
|
overridevirtual |
Send data to one peer, or to all of them (RAN role).
The default broadcasts with send(), which is what a connector that cannot tell its peers apart does.
| peer_token | The peer named by last_peer_token() or last_setup_peer_token(); 0 sends to every peer |
| data | Data to send |
| kind | What the PDU is for |
Reimplemented from libe3::E3Connector.
Definition at line 918 of file posix_connector.cpp.
|
overridevirtual |
Set up the inbound connection (SUB channel).
This establishes the channel for receiving control actions from dApps.
Implements libe3::E3Connector.
Definition at line 680 of file posix_connector.cpp.
|
overridevirtual |
Connect the inbound channel (dApp role: SUB connect to the RAN's publisher endpoint).
Reimplemented from libe3::E3Connector.
Definition at line 1068 of file posix_connector.cpp.
|
overridevirtual |
Set up the initial connection (setup channel).
This establishes the REQ/REP channel used for E3 Setup procedures.
Implements libe3::E3Connector.
Definition at line 670 of file posix_connector.cpp.
|
overridevirtual |
Connect the setup channel (dApp role: REQ connect).
Reimplemented from libe3::E3Connector.
Definition at line 982 of file posix_connector.cpp.
|
overridevirtual |
Set up the outbound connection (PUB channel).
This establishes the channel for sending indications to dApps.
Implements libe3::E3Connector.
Definition at line 685 of file posix_connector.cpp.
|
overridevirtual |
Connect the outbound channel (dApp role: PUB connect to the RAN's subscriber endpoint).
Reimplemented from libe3::E3Connector.
Definition at line 1072 of file posix_connector.cpp.
|
overridevirtual |
Interrupt blocking operations for shutdown.
Called before joining threads to unblock any blocking socket operations. Default implementation does nothing (for connectors that use timeouts).
Reimplemented from libe3::E3Connector.
Definition at line 1120 of file posix_connector.cpp.
|
overridevirtual |
Peers whose connection has closed since the last call (RAN role).
Call it on the thread that calls receive(). Each token is returned once, and only after the bytes that peer sent before closing were delivered. The default returns nothing: a connector that cannot tell its peers apart cannot tell that one left.
Reimplemented from libe3::E3Connector.
Definition at line 971 of file posix_connector.cpp.
|
inlineoverridevirtualnoexcept |
Get the transport layer type.
Implements libe3::E3Connector.
Definition at line 91 of file posix_connector.hpp.