|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
Interface between DoIPServerStateMachine and DoIPConnection. More...
#include <IConnectionContext.h>
Public Member Functions | |
| virtual | ~IConnectionContext ()=default |
| virtual ssize_t | sendProtocolMessage (const DoIPMessage &msg)=0 |
| Send a DoIP protocol message to the client. More... | |
| virtual void | closeConnection (DoIPCloseReason reason)=0 |
| Close the TCP connection. More... | |
| virtual bool | isOpen () const =0 |
| Check if the connection is currently open. More... | |
| virtual DoIPCloseReason | getCloseReason () const =0 |
| Get the reason why the connection was closed. More... | |
| virtual DoIPAddress | getServerAddress () const =0 |
| Get the server's logical address. More... | |
| virtual DoIPAddress | getClientAddress () const =0 |
| Get the currently active source address (routed client) More... | |
| virtual void | setClientAddress (const DoIPAddress &address)=0 |
| Set the active source address after routing activation. More... | |
| virtual DoIPDiagnosticAck | notifyDiagnosticMessage (const DoIPMessage &msg)=0 |
| Handle an incoming diagnostic message (application callback) More... | |
| virtual void | notifyConnectionClosed (DoIPCloseReason reason)=0 |
| Notify application that connection is closing. More... | |
| virtual void | notifyDiagnosticAckSent (DoIPDiagnosticAck ack)=0 |
| Notify application that diagnostic ACK/NACK was sent. More... | |
| virtual bool | hasDownstreamHandler () const =0 |
| Check if downstream forwarding is available. More... | |
| virtual DoIPDownstreamResult | notifyDownstreamRequest (const DoIPMessage &msg)=0 |
| Forward a diagnostic message to downstream (subnet device) More... | |
| virtual void | receiveDownstreamResponse (const ByteArray &response, DoIPDownstreamResult result)=0 |
| Receive a response from downstream device. More... | |
Interface between DoIPServerStateMachine and DoIPConnection.
This interface inverts the dependency between the state machine and connection. Instead of the state machine holding callbacks to the connection, the connection implements this interface and passes itself to the state machine.
Responsibilities:
Definition at line 27 of file IConnectionContext.h.
|
virtualdefault |
|
pure virtual |
Close the TCP connection.
This is called by the state machine when the connection should be closed (timeout, invalid message, etc.)
| reason | Why the connection is being closed |
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Get the currently active source address (routed client)
After routing activation, this returns the client's source address
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Get the reason why the connection was closed.
Implemented in doip::DoIPDefaultConnection.
|
pure virtual |
Get the server's logical address.
Used by state machine for constructing response messages
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Check if downstream forwarding is available.
This checks if the DoIPServerModel has a downstream handler configured. The state machine uses this to decide whether to forward messages downstream or handle them locally.
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Check if the connection is currently open.
Implemented in doip::DoIPDefaultConnection.
|
pure virtual |
Notify application that connection is closing.
This allows the application to perform cleanup when the connection is closed (by timeout, error, or graceful shutdown)
| reason | Why the connection is closing |
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Notify application that diagnostic ACK/NACK was sent.
Optional notification after sending diagnostic message acknowledgement
| ack | The ACK/NACK that was sent (nullopt = positive ACK) |
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Handle an incoming diagnostic message (application callback)
This forwards the diagnostic message to the application layer for processing. The application returns either:
| msg | The diagnostic message received |
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Forward a diagnostic message to downstream (subnet device)
Called by the state machine when a diagnostic message should be routed to a downstream device (e.g., ECU on CAN bus). The implementation delegates to DoIPServerModel::onDownstreamRequest.
The downstream handler is responsible for:
The state machine handles:
| msg | The diagnostic message to forward |
Implemented in doip::DoIPDefaultConnection.
|
pure virtual |
Receive a response from downstream device.
Called by the application layer when a response is received from a downstream device. This injects the response back into the state machine for processing.
Thread-safety: This method may be called from a different thread than the one running the state machine. Implementations should ensure thread-safe access to the state machine.
Typical call sequence:
| response | The diagnostic response from downstream |
Implemented in doip::DoIPDefaultConnection.
|
pure virtual |
Send a DoIP protocol message to the client.
This is called by the state machine when it needs to send a protocol message (ACK, NACK, alive check, routing activation response, etc.)
| msg | The DoIP message to send |
Implemented in doip::DoIPDefaultConnection, and doip::DoIPConnection.
|
pure virtual |
Set the active source address after routing activation.
Called by state machine when routing activation is successful
| address | The client's source address |
Implemented in doip::DoIPConnection.