libdoip  0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
DoIPRoutingActivationResult.h
Go to the documentation of this file.
1 #ifndef DOIPROUTINGACTIVATIONRESULT_H
2 #define DOIPROUTINGACTIVATIONRESULT_H
3 
4 namespace doip {
5 
6 // Table 56 - Routing activation response codes
7 enum class DoIPRoutingActivationResult : uint8_t{
8  UnknownSourceAddress = 0x00, // close socket
9  NoMoreRoutingSlotsAvailable = 0x01, // no more routing slots available, close socket
10  InvalidAddressOrRoutingType = 0x02, // Source address or routing type differ from already registered one
11  SourceAddressAlreadyRegistered = 0x03, // source address already registered, close socket
12  Unauthorized = 0x04, // unauthorized source address, do not activate routing but keep socket open
13  MissingConfirmation = 0x05, // missing confirmation, close socket
14  InvalidRoutingType = 0x06, // invalid routing type, close socket
15  SecuredConnectionRequired = 0x07, // secured connection (TLS) required, close socket
16  VehicleNotReadyForRouting = 0x08, // vehicle not ready for routing (e. g. pending update), do not activate routing but keep socket open
17  // 0x09: reserved
18  RouteActivated = 0x10, // routing activated successfully
19  RouteActivatedConfirmationRequired = 0x11 // routing activated successfully but requires confirmation (optional)
20 };
21 
22 /**
23  * @brief Check if the socket should be closed based on the routing activation result.
24  *
25  * @param result the routing activation result code
26  * @return true if the socket should be closed, false otherwise
27  */
29  switch (result) {
36  return true;
42  return false;
43  default:
44  return true; // unknown code, be safe and close socket
45  }
46 }
47 
48 inline std::ostream& operator<<(std::ostream& os, DoIPRoutingActivationResult result) {
49  switch (result) {
51  return os << "UnknownSourceAddress";
53  return os << "NoMoreRoutingSlotsAvailable";
55  return os << "InvalidAddressOrRoutingType";
57  return os << "SourceAddressAlreadyRegistered";
59  return os << "Unauthorized";
61  return os << "MissingConfirmation";
63  return os << "InvalidRoutingType";
65  return os << "SecuredConnectionRequired";
67  return os << "VehicleNotReadyForRouting";
69  return os << "RouteActivated";
71  return os << "RouteActivatedConfirmationRequired";
72  default:
73  return os << "Unknown(" << static_cast<int>(result) << ")";
74  }
75 }
76 
77 } // namespace doip
78 
79 #endif /* DOIPROUTINGACTIVATIONRESULT_H */
Definition: AnsiColors.h:3
std::ostream & operator<<(std::ostream &os, const ByteArray &arr)
Stream operator for ByteArray.
Definition: ByteArray.h:303
bool closeSocketOnRoutingActivationResult(DoIPRoutingActivationResult result)
Check if the socket should be closed based on the routing activation result.