1 #ifndef DOIPCONNECTION_H
2 #define DOIPCONNECTION_H
5 #include "DoIPConfig.h"
11 #include <arpa/inet.h>
15 #include <netinet/in.h>
17 #include <sys/ioctl.h>
18 #include <sys/socket.h>
106 std::array<uint8_t, DOIP_MAXIMUM_MTU> m_receiveBuf{};
107 bool m_isClosing{
false};
108 std::optional<DoIPMessage> m_pendingDownstreamRequest;
112 int reactOnReceivedTcpMessage(
const DoIPMessage &message);
114 void handleMessage(
const DoIPMessage &message);
115 ssize_t sendMessage(
const uint8_t *message,
size_t messageLength);
bool hasDownstreamHandler() const override
Check if downstream forwarding is available.
DoIPAddress getClientAddress() const override
Get the currently client (active source) address.
void sendDiagnosticAck(const DoIPAddress &sourceAddress)
void sendDiagnosticNegativeAck(const DoIPAddress &sourceAddress, DoIPNegativeDiagnosticAck ackCode)
DoIPDiagnosticAck notifyDiagnosticMessage(const DoIPMessage &msg) override
Handle an incoming diagnostic message (application callback)
void notifyDiagnosticAckSent(DoIPDiagnosticAck ack) override
Notify application that diagnostic ACK/NACK was sent.
ssize_t sendProtocolMessage(const DoIPMessage &msg) override
Send a DoIP protocol message to the client.
void setClientAddress(const DoIPAddress &address) override
Set the client (active source) address after routing activation.
void closeConnection(DoIPCloseReason reason) override
Close the TCP connection.
size_t receiveFixedNumberOfBytesFromTCP(uint8_t *receivedData, size_t payloadLength)
Receive exactly payloadLength bytes from the TCP stream and put them into receivedData.
void triggerDisconnection()
DoIPConnection(int tcpSocket, UniqueServerModelPtr model)
void notifyConnectionClosed(DoIPCloseReason reason) override
Notify application that connection is closing.
void sendDiagnosticPayload(const DoIPAddress &sourceAddress, const ByteArray &payload)
DoIPAddress getServerAddress() const override
Get the server's logical address.
Default implementation of IConnectionContext.
Represents a complete DoIP message with internal ByteArray representation.
uint16_t DoIPAddress
Represents a 16-bit DoIP address consisting of high and low significant bytes.
std::optional< DoIPNegativeDiagnosticAck > DoIPDiagnosticAck
Alias for diagnostic acknowledgment type.
DoIPNegativeDiagnosticAck
DoIPCloseReason
Reason for connection closure.
std::unique_ptr< DoIPServerModel > UniqueServerModelPtr
A dynamic array of bytes with utility methods for network protocol handling.