|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
Default implementation of IConnectionContext. More...
#include <DoIPDefaultConnection.h>


Public Member Functions | |
| DoIPDefaultConnection (UniqueServerModelPtr model) | |
| Constructs a DoIPDefaultConnection. More... | |
| ssize_t | sendProtocolMessage (const DoIPMessage &msg) override |
| Sends a DoIP protocol message to the client. More... | |
| void | closeConnection (DoIPCloseReason reason) override |
| Closes the connection. More... | |
| bool | isOpen () const override |
| Checks if the connection is open. More... | |
| DoIPCloseReason | getCloseReason () const override |
| Gets the reason for connection closure. More... | |
| bool | isRoutingActivated () const |
| Checks if routing is currently activated. More... | |
| uint8_t | getAliveCheckRetryCount () const |
| Gets the alive check retry count. More... | |
| std::chrono::milliseconds | getInitialInactivityTimeout () const |
| Gets the initial inactivity timeout duration. More... | |
| std::chrono::milliseconds | getGeneralInactivityTimeout () const |
| Gets the general inactivity timeout duration. More... | |
| std::chrono::milliseconds | getAliveCheckTimeout () const |
| Gets the alive check timeout duration. More... | |
| std::chrono::milliseconds | getDownstreamResponseTimeout () const |
| Gets the downstream response timeout duration. More... | |
| void | setAliveCheckRetryCount (uint8_t count) |
| Sets the alive check retry count. More... | |
| void | setInitialInactivityTimeout (std::chrono::milliseconds timeout) |
| Sets the initial inactivity timeout duration. More... | |
| void | setGeneralInactivityTimeout (std::chrono::milliseconds timeout) |
| Sets the general inactivity timeout duration. More... | |
| void | setAliveCheckTimeout (std::chrono::milliseconds timeout) |
| Sets the alive check timeout duration. More... | |
| void | setDownstreamResponseTimeout (std::chrono::milliseconds timeout) |
| Sets the downstream response timeout duration. More... | |
| DoIPAddress | getServerAddress () const override |
| Gets the server's logical address. More... | |
| DoIPAddress | getClientAddress () const override |
| Gets the client's address. More... | |
| DoIPDiagnosticAck | notifyDiagnosticMessage (const DoIPMessage &msg) override |
| Handles an incoming diagnostic message. More... | |
| void | notifyConnectionClosed (DoIPCloseReason reason) override |
| Notifies application that connection is closing. More... | |
| void | notifyDiagnosticAckSent (DoIPDiagnosticAck ack) override |
| Notifies application that diagnostic ACK/NACK was sent. More... | |
| bool | hasDownstreamHandler () const override |
| Checks if a downstream handler is present. More... | |
| DoIPDownstreamResult | notifyDownstreamRequest (const DoIPMessage &msg) override |
| Notifies application of a downstream request. More... | |
| void | receiveDownstreamResponse (const ByteArray &response, DoIPDownstreamResult result) override |
| Receives a downstream response. More... | |
| DoIPServerState | getState () const |
| Gets the current state of the connection. More... | |
| UniqueServerModelPtr & | getServerModel () |
| Gets the server model. More... | |
| void | handleMessage2 (const DoIPMessage &message) |
| Handles a message (internal helper) More... | |
Public Member Functions inherited from doip::IConnectionContext | |
| virtual | ~IConnectionContext ()=default |
Protected Attributes | |
| UniqueServerModelPtr | m_serverModel |
| std::array< StateDescriptor, 7 > | STATE_DESCRIPTORS |
| DoIPAddress | m_routedClientAddress |
| bool | m_isOpen |
| DoIPCloseReason | m_closeReason = DoIPCloseReason::None |
| const StateDescriptor * | m_state = nullptr |
| TimerManager< ConnectionTimers > | m_timerManager |
| uint8_t | m_aliveCheckRetry {0} |
| uint8_t | m_aliveCheckRetryCount {DOIP_ALIVE_CHECK_RETRIES} |
| std::chrono::milliseconds | m_initialInactivityTimeout {times::server::InitialInactivityTimeout} |
| std::chrono::milliseconds | m_generalInactivityTimeout {times::server::GeneralInactivityTimeout} |
| std::chrono::milliseconds | m_aliveCheckTimeout {times::server::AliveCheckResponseTimeout} |
| std::chrono::milliseconds | m_downstreamResponseTimeout {10s} |
Default implementation of IConnectionContext.
This class provides a default implementation of the IConnectionContext interface, including the state machine and server model. It excludes TCP socket support, making it suitable for non-TCP-based connections.
Definition at line 54 of file DoIPDefaultConnection.h.
|
explicit |
Constructs a DoIPDefaultConnection.
| model | The server model to use |
Definition at line 9 of file DoIPDefaultConnection.cpp.
References handleSocketInitialized(), doip::SocketInitialized, and doip::WaitRoutingActivation.
|
overridevirtual |
Closes the connection.
| reason | The reason for closure |
Implements doip::IConnectionContext.
Definition at line 62 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_ERROR, LOG_DOIP_INFO, and fmt::streamed().
Referenced by doip::DoIPConnection::closeConnection().
|
inline |
Gets the alive check retry count.
Definition at line 148 of file DoIPDefaultConnection.h.
|
inline |
Gets the alive check timeout duration.
Definition at line 166 of file DoIPDefaultConnection.h.
|
overridevirtual |
Gets the client's address.
Implements doip::IConnectionContext.
Definition at line 90 of file DoIPDefaultConnection.cpp.
|
inlineoverridevirtual |
Gets the reason for connection closure.
Implements doip::IConnectionContext.
Definition at line 134 of file DoIPDefaultConnection.h.
|
inline |
Gets the downstream response timeout duration.
Definition at line 172 of file DoIPDefaultConnection.h.
|
inline |
Gets the general inactivity timeout duration.
Definition at line 160 of file DoIPDefaultConnection.h.
|
inline |
Gets the initial inactivity timeout duration.
Definition at line 154 of file DoIPDefaultConnection.h.
|
overridevirtual |
Gets the server's logical address.
Implements doip::IConnectionContext.
Definition at line 86 of file DoIPDefaultConnection.cpp.
|
inline |
Gets the server model.
Definition at line 267 of file DoIPDefaultConnection.h.
|
inline |
Gets the current state of the connection.
Definition at line 259 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 126 of file DoIPDefaultConnection.cpp.
|
protected |
Definition at line 317 of file DoIPDefaultConnection.cpp.
| void doip::DoIPDefaultConnection::handleMessage2 | ( | const DoIPMessage & | message | ) |
Handles a message (internal helper)
| message | The message to handle |
Definition at line 98 of file DoIPDefaultConnection.cpp.
Referenced by doip::DoIPConnection::receiveTcpMessage().
|
protected |
Definition at line 219 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_DEBUG, LOG_DOIP_WARN, fmt::streamed(), and doip::ZERO_ADDRESS.
|
protected |
Definition at line 184 of file DoIPDefaultConnection.cpp.
Referenced by DoIPDefaultConnection().
|
protected |
Default timeout handler.
| timer_id | the timer ID that expired |
Definition at line 325 of file DoIPDefaultConnection.cpp.
References doip::times::server::InitialInactivityTimeout(), LOG_DOIP_ERROR, LOG_DOIP_WARN, and fmt::streamed().
|
protected |
Definition at line 282 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_WARN, fmt::streamed(), and doip::ZERO_ADDRESS.
|
protected |
Definition at line 308 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_CRITICAL.
|
protected |
Definition at line 191 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_WARN.
|
overridevirtual |
Checks if a downstream handler is present.
Implements doip::IConnectionContext.
Definition at line 427 of file DoIPDefaultConnection.cpp.
|
inlineoverridevirtual |
Checks if the connection is open.
Implements doip::IConnectionContext.
Definition at line 126 of file DoIPDefaultConnection.h.
|
inline |
Checks if routing is currently activated.
Definition at line 142 of file DoIPDefaultConnection.h.
References doip::RoutingActivated.
|
overridevirtual |
Notifies application that connection is closing.
| reason | The close reason |
Implements doip::IConnectionContext.
Definition at line 415 of file DoIPDefaultConnection.cpp.
|
overridevirtual |
Notifies application that diagnostic ACK/NACK was sent.
| ack | The acknowledgment sent |
Implements doip::IConnectionContext.
Definition at line 421 of file DoIPDefaultConnection.cpp.
|
overridevirtual |
Handles an incoming diagnostic message.
| msg | The diagnostic message |
Implements doip::IConnectionContext.
Definition at line 408 of file DoIPDefaultConnection.cpp.
|
overridevirtual |
Notifies application of a downstream request.
| msg | The downstream request message |
Implements doip::IConnectionContext.
Definition at line 433 of file DoIPDefaultConnection.cpp.
|
overridevirtual |
Receives a downstream response.
| response | The downstream response message |
| result | the downstream result |
Implements doip::IConnectionContext.
Definition at line 443 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_INFO, doip::message::makeDiagnosticMessage(), doip::message::makeDiagnosticNegativeResponse(), and fmt::streamed().
|
protected |
Definition at line 177 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_ERROR, and fmt::streamed().
|
protected |
Definition at line 372 of file DoIPDefaultConnection.cpp.
References doip::message::makeAliveCheckRequest().
|
protected |
Definition at line 377 of file DoIPDefaultConnection.cpp.
References doip::message::makeDiagnosticNegativeResponse(), and doip::message::makeDiagnosticPositiveResponse().
|
protected |
Definition at line 401 of file DoIPDefaultConnection.cpp.
References doip::message::makeDiagnosticMessage().
|
overridevirtual |
Sends a DoIP protocol message to the client.
| msg | The message to send |
Implements doip::IConnectionContext.
Definition at line 57 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_INFO, doip::DoIPMessage::size(), and fmt::streamed().
|
protected |
Definition at line 356 of file DoIPDefaultConnection.cpp.
References doip::ByteArray::writeU16BE().
|
inline |
Sets the alive check retry count.
| count | The number of retries for alive checks |
Definition at line 178 of file DoIPDefaultConnection.h.
|
inline |
Sets the alive check timeout duration.
| timeout | The timeout duration in milliseconds |
Definition at line 196 of file DoIPDefaultConnection.h.
|
inline |
Sets the downstream response timeout duration.
| timeout | The timeout duration in milliseconds |
Definition at line 202 of file DoIPDefaultConnection.h.
|
inline |
Sets the general inactivity timeout duration.
| timeout | The timeout duration in milliseconds |
Definition at line 190 of file DoIPDefaultConnection.h.
|
inline |
Sets the initial inactivity timeout duration.
| timeout | The timeout duration in milliseconds |
Definition at line 184 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 144 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_DEBUG, LOG_DOIP_ERROR, and fmt::streamed().
|
protected |
Definition at line 102 of file DoIPDefaultConnection.cpp.
References LOG_DOIP_ERROR, LOG_DOIP_INFO, and fmt::streamed().
|
protected |
Definition at line 288 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 289 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 294 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 283 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 295 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 293 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 292 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 282 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 280 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 278 of file DoIPDefaultConnection.h.
Referenced by doip::DoIPConnection::getServerAddress(), doip::DoIPConnection::hasDownstreamHandler(), doip::DoIPConnection::notifyConnectionClosed(), doip::DoIPConnection::notifyDiagnosticAckSent(), and doip::DoIPConnection::notifyDiagnosticMessage().
|
protected |
Definition at line 284 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 285 of file DoIPDefaultConnection.h.
|
protected |
Definition at line 279 of file DoIPDefaultConnection.h.