|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
DoIP Server class to handle incoming DoIP connections and UDP messages. More...
#include <DoIPServer.h>
Public Member Functions | |
| DoIPServer (const ServerConfig &config=DefaultServerConfig) | |
| Construct a DoIP server with the given configuration. More... | |
| ~DoIPServer () | |
| Destructor. More... | |
| DoIPServer (const DoIPServer &)=delete | |
| DoIPServer & | operator= (const DoIPServer &)=delete |
| DoIPServer (DoIPServer &&)=delete | |
| DoIPServer & | operator= (DoIPServer &&)=delete |
| bool | setupTcpSocket () |
| Initialize and bind the TCP socket for DoIP. More... | |
| template<typename Model = DefaultDoIPServerModel> | |
| std::unique_ptr< DoIPConnection > | waitForTcpConnection () |
| Block until a TCP client connects and create a DoIP connection. More... | |
| bool | setupUdpSocket () |
| Initialize and bind the UDP socket for announcements and UDP messages. More... | |
| bool | isRunning () const |
| Check if the server is currently running. More... | |
| void | setAnnounceNum (int Num) |
| Set the number of vehicle announcements to send. More... | |
| void | setAnnounceInterval (unsigned int Interval) |
| Set the interval between announcements in milliseconds. More... | |
| void | setLoopbackMode (bool useLoopback) |
| Enable/disable loopback mode for announcements (no broadcast). More... | |
| void | closeTcpSocket () |
| Close the TCP socket if open. More... | |
| void | closeUdpSocket () |
| Close the UDP socket if open. More... | |
| void | setLogicalGatewayAddress (DoIPAddress logicalAddress) |
| Set the logical DoIP gateway address. More... | |
| bool | setDefaultEid () |
| Sets the EID to a default value based on the MAC address. More... | |
| void | setVin (const std::string &VINString) |
| Set VIN from a 17-character string. More... | |
| void | setVin (const DoIpVin &vin) |
Set VIN from a DoIpVin instance. More... | |
| const DoIpVin & | getVin () const |
| Get current VIN. More... | |
| void | setEid (uint64_t nputEID) |
| Set EID value. More... | |
| const DoIpEid & | getEid () const |
| Get current EID. More... | |
| void | setGid (uint64_t inputGID) |
| Set GID value. More... | |
| const DoIpGid & | getGid () const |
| Get current GID. More... | |
| DoIPFurtherAction | getFurtherActionRequired () const |
| Get current further action requirement status. More... | |
| void | setFurtherActionRequired (DoIPFurtherAction furtherActionRequired) |
| Set further action requirement status. More... | |
| std::string | getClientIp () const |
| Get last accepted client IP (string form). More... | |
| int | getClientPort () const |
| Get last accepted client TCP port. More... | |
DoIP Server class to handle incoming DoIP connections and UDP messages.
This class manages the low-level TCP/UDP socket handling.
Definition at line 70 of file DoIPServer.h.
|
explicit |
Construct a DoIP server with the given configuration.
| config | Server configuration (EID/GID/VIN, announce params, etc.). |
Definition at line 24 of file DoIPServer.cpp.
References doip::ServerConfig::daemonize, doip::ServerConfig::loopback, and setLoopbackMode().
| DoIPServer::~DoIPServer | ( | ) |
Destructor.
Ensures sockets/threads are closed/stopped.
Definition at line 18 of file DoIPServer.cpp.
|
delete |
|
delete |
| void DoIPServer::closeTcpSocket | ( | ) |
Close the TCP socket if open.
Definition at line 164 of file DoIPServer.cpp.
| void DoIPServer::closeUdpSocket | ( | ) |
Close the UDP socket if open.
Definition at line 220 of file DoIPServer.cpp.
|
inline |
Get last accepted client IP (string form).
Definition at line 209 of file DoIPServer.h.
|
inline |
Get last accepted client TCP port.
Definition at line 214 of file DoIPServer.h.
|
inline |
Get current EID.
Definition at line 181 of file DoIPServer.h.
References doip::ServerConfig::eid.
|
inline |
Get current further action requirement status.
DoIPFurtherAction value. Definition at line 198 of file DoIPServer.h.
|
inline |
Get current GID.
Definition at line 192 of file DoIPServer.h.
References doip::ServerConfig::gid.
|
inline |
Get current VIN.
Definition at line 170 of file DoIPServer.h.
References doip::ServerConfig::vin.
|
inline |
Check if the server is currently running.
Definition at line 115 of file DoIPServer.h.
|
delete |
|
delete |
| void DoIPServer::setAnnounceInterval | ( | unsigned int | Interval | ) |
Set the interval between announcements in milliseconds.
| Interval | Interval in ms. |
Definition at line 271 of file DoIPServer.cpp.
References doip::ServerConfig::announceInterval.
| void DoIPServer::setAnnounceNum | ( | int | Num | ) |
Set the number of vehicle announcements to send.
| Num | Count of announcements. |
Definition at line 267 of file DoIPServer.cpp.
References doip::ServerConfig::announceCount.
| bool DoIPServer::setDefaultEid | ( | ) |
Sets the EID to a default value based on the MAC address.
Definition at line 230 of file DoIPServer.cpp.
References doip::ServerConfig::eid, doip::getFirstMacAddress(), doip::GenericFixedId< IdLength, zeroPadding, padChar >::ID_LENGTH, LOG_DOIP_ERROR, and doip::GenericFixedId< 6, false >::Zero.
| void DoIPServer::setEid | ( | uint64_t | nputEID | ) |
Set EID value.
| nputEID | EID as 64-bit value (lower 48 bits used). |
Definition at line 255 of file DoIPServer.cpp.
References doip::ServerConfig::eid.
| void DoIPServer::setFurtherActionRequired | ( | DoIPFurtherAction | furtherActionRequired | ) |
Set further action requirement status.
| furtherActionRequired | Value to set. |
Definition at line 263 of file DoIPServer.cpp.
| void DoIPServer::setGid | ( | uint64_t | inputGID | ) |
Set GID value.
| inputGID | GID as 64-bit value (lower 48 bits used). |
Definition at line 259 of file DoIPServer.cpp.
References doip::ServerConfig::gid.
| void DoIPServer::setLogicalGatewayAddress | ( | DoIPAddress | logicalAddress | ) |
Set the logical DoIP gateway address.
| logicalAddress | Logical address value. |
Definition at line 251 of file DoIPServer.cpp.
References doip::ServerConfig::logicalAddress.
| void DoIPServer::setLoopbackMode | ( | bool | useLoopback | ) |
Enable/disable loopback mode for announcements (no broadcast).
| useLoopback | True to use loopback, false for broadcast. |
Definition at line 275 of file DoIPServer.cpp.
References LOG_DOIP_INFO, and doip::ServerConfig::loopback.
Referenced by DoIPServer().
| bool DoIPServer::setupTcpSocket | ( | ) |
Initialize and bind the TCP socket for DoIP.
Definition at line 132 of file DoIPServer.cpp.
References doip::DOIP_SERVER_TCP_PORT, LOG_DOIP_DEBUG, LOG_TCP_ERROR, LOG_TCP_INFO, and LOG_TCP_WARN.
| bool DoIPServer::setupUdpSocket | ( | ) |
Initialize and bind the UDP socket for announcements and UDP messages.
Definition at line 168 of file DoIPServer.cpp.
References LOG_UDP_DEBUG, LOG_UDP_INFO, and doip::ServerConfig::loopback.
| void DoIPServer::setVin | ( | const DoIpVin & | vin | ) |
Set VIN from a DoIpVin instance.
| vin | VIN value. |
Definition at line 247 of file DoIPServer.cpp.
References doip::ServerConfig::vin.
| void DoIPServer::setVin | ( | const std::string & | VINString | ) |
Set VIN from a 17-character string.
| VINString | VIN string (17 bytes expected). |
Definition at line 242 of file DoIPServer.cpp.
References doip::ServerConfig::vin.
| std::unique_ptr< DoIPConnection > doip::DoIPServer::waitForTcpConnection |
Block until a TCP client connects and create a DoIP connection.
| Model | Server model type used by the connection (default DefaultDoIPServerModel). |
DoIPConnection, or nullptr on failure. Definition at line 255 of file DoIPServer.h.