|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
#include <DoIPConnection.h>


Public Member Functions | |
| DoIPConnection (int tcpSocket, UniqueServerModelPtr model) | |
| int | receiveTcpMessage () |
| size_t | receiveFixedNumberOfBytesFromTCP (uint8_t *receivedData, size_t payloadLength) |
| Receive exactly payloadLength bytes from the TCP stream and put them into receivedData. More... | |
| void | sendDiagnosticPayload (const DoIPAddress &sourceAddress, const ByteArray &payload) |
| bool | isSocketActive () |
| void | triggerDisconnection () |
| void | sendDiagnosticAck (const DoIPAddress &sourceAddress) |
| void | sendDiagnosticNegativeAck (const DoIPAddress &sourceAddress, DoIPNegativeDiagnosticAck ackCode) |
| ssize_t | sendProtocolMessage (const DoIPMessage &msg) override |
| Send a DoIP protocol message to the client. More... | |
| void | closeConnection (DoIPCloseReason reason) override |
| Close the TCP connection. More... | |
| DoIPAddress | getServerAddress () const override |
| Get the server's logical address. More... | |
| DoIPAddress | getClientAddress () const override |
| Get the currently client (active source) address. More... | |
| void | setClientAddress (const DoIPAddress &address) override |
| Set the client (active source) address after routing activation. More... | |
| DoIPDiagnosticAck | notifyDiagnosticMessage (const DoIPMessage &msg) override |
| Handle an incoming diagnostic message (application callback) More... | |
| void | notifyConnectionClosed (DoIPCloseReason reason) override |
| Notify application that connection is closing. More... | |
| void | notifyDiagnosticAckSent (DoIPDiagnosticAck ack) override |
| Notify application that diagnostic ACK/NACK was sent. More... | |
| bool | hasDownstreamHandler () const override |
| Check if downstream forwarding is available. More... | |
Public Member Functions inherited from doip::DoIPDefaultConnection | |
| 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 |
Definition at line 25 of file DoIPConnection.h.
| doip::DoIPConnection::DoIPConnection | ( | int | tcpSocket, |
| UniqueServerModelPtr | model | ||
| ) |
Definition at line 11 of file DoIPConnection.cpp.
|
overridevirtual |
Close the TCP connection.
| reason | Why the connection is being closed |
Implements doip::IConnectionContext.
Definition at line 130 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::closeConnection(), LOG_DOIP_DEBUG, LOG_DOIP_INFO, and fmt::streamed().
|
overridevirtual |
Get the currently client (active source) address.
Implements doip::IConnectionContext.
Definition at line 151 of file DoIPConnection.cpp.
|
overridevirtual |
Get the server's logical address.
Implements doip::IConnectionContext.
Definition at line 147 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::m_serverModel.
|
overridevirtual |
Check if downstream forwarding is available.
Implements doip::IConnectionContext.
Definition at line 181 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::m_serverModel.
|
inline |
Definition at line 34 of file DoIPConnection.h.
|
overridevirtual |
Notify application that connection is closing.
| reason | Why the connection is closing |
Implements doip::IConnectionContext.
Definition at line 168 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::m_serverModel.
|
overridevirtual |
Notify application that diagnostic ACK/NACK was sent.
| ack | The ACK/NACK that was sent |
Implements doip::IConnectionContext.
Definition at line 175 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::m_serverModel.
|
overridevirtual |
Handle an incoming diagnostic message (application callback)
| msg | The diagnostic message received |
Implements doip::IConnectionContext.
Definition at line 159 of file DoIPConnection.cpp.
References doip::DoIPDefaultConnection::m_serverModel.
| size_t doip::DoIPConnection::receiveFixedNumberOfBytesFromTCP | ( | uint8_t * | receivedData, |
| size_t | payloadLength | ||
| ) |
Receive exactly payloadLength bytes from the TCP stream and put them into receivedData.
The method blocks until receivedData bytes are received or the socket is closed.
The parameter receivedData needs to point to a readily allocated array with at least payloadLength items.
Definition at line 85 of file DoIPConnection.cpp.
Referenced by receiveTcpMessage().
| int doip::DoIPConnection::receiveTcpMessage | ( | ) |
Definition at line 29 of file DoIPConnection.cpp.
References doip::DOIP_HEADER_SIZE, doip::DoIPDefaultConnection::handleMessage2(), LOG_DOIP_DEBUG, LOG_DOIP_ERROR, LOG_DOIP_INFO, receiveFixedNumberOfBytesFromTCP(), fmt::streamed(), and doip::DoIPMessage::tryParseHeader().
| void doip::DoIPConnection::sendDiagnosticAck | ( | const DoIPAddress & | sourceAddress | ) |
| void doip::DoIPConnection::sendDiagnosticNegativeAck | ( | const DoIPAddress & | sourceAddress, |
| DoIPNegativeDiagnosticAck | ackCode | ||
| ) |
| void doip::DoIPConnection::sendDiagnosticPayload | ( | const DoIPAddress & | sourceAddress, |
| const ByteArray & | payload | ||
| ) |
|
overridevirtual |
Send a DoIP protocol message to the client.
| msg | The DoIP message to send |
Implements doip::IConnectionContext.
Definition at line 120 of file DoIPConnection.cpp.
References doip::DoIPMessage::data(), LOG_DOIP_ERROR, LOG_DOIP_INFO, doip::DoIPMessage::size(), and fmt::streamed().
|
overridevirtual |
Set the client (active source) address after routing activation.
| address | The client's source address |
Implements doip::IConnectionContext.
Definition at line 155 of file DoIPConnection.cpp.
| void doip::DoIPConnection::triggerDisconnection | ( | ) |
Definition at line 102 of file DoIPConnection.cpp.
References LOG_DOIP_INFO.