PcapPlusPlus  Next
DoIpLayer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <cstring>
5 #include "Layer.h"
6 #include "Logger.h"
7 
9 
12 namespace pcpp
13 {
16 #pragma pack(push, 1)
17  struct doiphdr
18  {
20  uint8_t protocolVersion;
24  uint16_t payloadType;
26  uint32_t payloadLength;
27  };
28 #pragma pack(pop)
29  static_assert(sizeof(doiphdr) == 8, "DoIP header must be exactly 8 bytes.");
30 
31  namespace DoIpConstants
32  {
34  static constexpr size_t DOIP_HEADER_LEN = sizeof(doiphdr);
35 
37  static constexpr size_t DOIP_EID_LEN = 6;
38 
40  static constexpr size_t DOIP_GID_LEN = 6;
41 
43  static constexpr size_t DOIP_VIN_LEN = 17;
44 
46  static constexpr size_t DOIP_RESERVED_ISO_LEN = 4;
47 
49  static constexpr size_t DOIP_RESERVED_OEM_LEN = 4;
50 
52  static constexpr size_t DOIP_SOURCE_ADDRESS_LEN = 2;
53 
55  static constexpr size_t DOIP_TARGET_ADDRESS_LEN = 2;
56  } // namespace DoIpConstants
57 
60  enum class DoIpActivationTypes : uint8_t
61  {
64  DEFAULT = 0x00U,
65 
68  WWH_OBD = 0x01U,
69 
72  CENTRAL_SECURITY = 0xE0U,
73 
76  UNKNOWN
77  };
78 
81  enum class DoIpGenericHeaderNackCodes : uint8_t
82  {
85  INCORRECT_PATTERN = 0x00U,
86 
89  UNKNOWN_PAYLOAD_TYPE = 0x01U,
90 
93  MESSAGE_TOO_LARGE = 0x02U,
94 
97  OUT_OF_MEMORY = 0x03U,
98 
101  INVALID_PAYLOAD_LENGTH = 0x04U,
102 
105  UNKNOWN
106  };
107 
111  enum class DoIpActionCodes : uint8_t
112  {
116 
119  RESERVED_ISO_0x01 = 0x01U,
120 
123  RESERVED_ISO_0x02 = 0x02U,
124 
127  RESERVED_ISO_0x03 = 0x03U,
128 
131  RESERVED_ISO_0x04 = 0x04U,
132 
135  RESERVED_ISO_0x05 = 0x05U,
136 
139  RESERVED_ISO_0x06 = 0x06U,
140 
143  RESERVED_ISO_0x07 = 0x07U,
144 
147  RESERVED_ISO_0x08 = 0x08U,
148 
151  RESERVED_ISO_0x09 = 0x09U,
152 
155  RESERVED_ISO_0x0A = 0x0AU,
156 
159  RESERVED_ISO_0x0B = 0x0BU,
160 
163  RESERVED_ISO_0x0C = 0x0CU,
164 
167  RESERVED_ISO_0x0D = 0x0DU,
168 
171  RESERVED_ISO_0x0E = 0x0EU,
172 
175  RESERVED_ISO_0x0F = 0x0FU,
176 
180 
183  UNKNOWN
184  };
185 
189  enum class DoIpRoutingResponseCodes : uint8_t
190  {
193  UNKNOWN_SOURCE_ADDRESS = 0x00U,
194 
197  NO_FREE_SOCKET = 0x01U,
198 
201  WRONG_SOURCE_ADDRESS = 0x02U,
202 
206 
209  MISSING_AUTHENTICATION = 0x04U,
210 
213  REJECTED_CONFIRMATION = 0x05U,
214 
217 
219 
222  ENCRYPTED_CONNECTION_TLS = 0x07U,
223 
226  RESERVED_ISO_0x08 = 0x08U,
227 
230  RESERVED_ISO_0x09 = 0x09U,
231 
234  RESERVED_ISO_0x0A = 0x0AU,
235 
238  RESERVED_ISO_0x0B = 0x0BU,
239 
242  RESERVED_ISO_0x0C = 0x0CU,
243 
246  RESERVED_ISO_0x0D = 0x0DU,
247 
250  RESERVED_ISO_0x0E = 0x0EU,
251 
254  RESERVED_ISO_0x0F = 0x0FU,
255 
259 
262  CONFIRMATION_REQUIRED = 0x11U,
263 
266  UNKNOWN
267  };
268 
272  enum class DoIpDiagnosticMessageNackCodes : uint8_t
273  {
276  RESERVED_ISO_0x00 = 0x00U,
277 
280  RESERVED_ISO_0x01 = 0x01U,
281 
284  INVALID_SOURCE_ADDRESS = 0x02U,
285 
288  INVALID_TARGET_ADDRESS = 0x03U,
289 
292  MESSAGE_TOO_LARGE = 0x04U,
293 
296  OUT_OF_MEMORY = 0x05U,
297 
300  TARGET_UNREACHABLE = 0x06U,
301 
304  UNKNOWN_NETWORK = 0x07U,
305 
308  TRANSPORT_PROTOCOL_ERROR = 0x08U,
309 
312  UNKNOWN
313  };
314 
318  enum class DoIpDiagnosticPowerModeCodes : uint8_t
319  {
322  NOT_READY = 0x00U,
323 
326  READY = 0x01U,
327 
330  NOT_SUPPORTED = 0x02U,
331 
334  UNKNOWN
335  };
336 
340  enum class DoIpDiagnosticAckCodes : uint8_t
341  {
344  ACK = 0x00U,
345 
348  UNKNOWN
349  };
350 
353  enum class DoIpEntityStatusResponseCode : uint8_t
354  {
358  GATEWAY = 0x00U,
359 
362  NODE = 0x01U,
363 
366  UNKNOWN
367  };
368 
371  enum class DoIpSyncStatus : uint8_t
372  {
375 
378  RESERVED_ISO_0x01 = 0x01U,
379 
382  RESERVED_ISO_0x02 = 0x02U,
383 
386  RESERVED_ISO_0x03 = 0x03U,
387 
390  RESERVED_ISO_0x04 = 0x04U,
391 
394  RESERVED_ISO_0x05 = 0x05U,
395 
398  RESERVED_ISO_0x06 = 0x06U,
399 
402  RESERVED_ISO_0x07 = 0x07U,
403 
406  RESERVED_ISO_0x08 = 0x08U,
407 
410  RESERVED_ISO_0x09 = 0x09U,
411 
414  RESERVED_ISO_0x0A = 0x0AU,
415 
418  RESERVED_ISO_0x0B = 0x0BU,
419 
422  RESERVED_ISO_0x0C = 0x0CU,
423 
426  RESERVED_ISO_0x0D = 0x0DU,
427 
430  RESERVED_ISO_0x0E = 0x0EU,
431 
434  RESERVED_ISO_0x0F = 0x0FU,
435 
438 
441  UNKNOWN
442  };
443 
445  enum class DoIpProtocolVersion : uint8_t
446  {
449  RESERVED_VER = 0x00U,
450 
452  ISO13400_2010 = 0x01U,
453 
455  ISO13400_2012 = 0x02U,
456 
458  ISO13400_2019 = 0x03U,
459 
461  ISO13400_2019_AMD1 = 0x04U,
462 
465  DEFAULT_VALUE = 0xFFU,
466 
469  UNKNOWN = 0xEF
470  };
471 
475  enum class DoIpPayloadTypes : uint16_t
476  {
479  GENERIC_HEADER_NACK = 0x0000U,
480 
484 
488 
492 
496 
499  ROUTING_ACTIVATION_REQUEST = 0x0005U,
500 
503  ROUTING_ACTIVATION_RESPONSE = 0x0006U,
504 
507  ALIVE_CHECK_REQUEST = 0x0007U,
508 
511  ALIVE_CHECK_RESPONSE = 0x0008U,
512 
515  ENTITY_STATUS_REQUEST = 0x4001U,
516 
519  ENTITY_STATUS_RESPONSE = 0x4002U,
520 
524 
528 
531  DIAGNOSTIC_MESSAGE = 0x8001U,
532 
535  DIAGNOSTIC_MESSAGE_ACK = 0x8002U,
536 
539  DIAGNOSTIC_MESSAGE_NACK = 0x8003U
540  };
541 
544  enum class DoIpPorts : uint16_t
545  {
548  TCP_UDP_PORT = 13400U,
549 
552  TLS_PORT = 3496U
553  };
554 
555  using namespace DoIpConstants;
556 
559  class DoIpLayer : public Layer
560  {
561  public:
564  virtual DoIpPayloadTypes getPayloadType() const = 0;
565 
568  std::string getPayloadTypeAsStr() const;
569 
573 
576  std::string getProtocolVersionAsStr() const;
577 
581 
584  void setProtocolVersion(uint8_t rawVersion);
585 
588  uint8_t getInvertProtocolVersion() const;
589 
592  void setInvertProtocolVersion(uint8_t iVersion);
593 
596  uint32_t getPayloadLength() const;
597 
600  void setPayloadLength(uint32_t length);
601 
608  static DoIpLayer* parseDoIpLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
609 
613  static inline bool isDoIpPort(uint16_t port);
614 
619  static bool isDataValid(uint8_t* data, size_t dataLen);
620 
621  // implement abstract methods
622 
624  void parseNextLayer() override;
625 
627  size_t getHeaderLen() const override
628  {
629  return m_DataLen;
630  }
631 
632  std::string toString() const override;
633 
634  void computeCalculateFields() override
635  {}
636 
638  {
640  }
641 
642  private:
643  void setPayloadType(DoIpPayloadTypes payloadType);
644 
645  static inline bool isPayloadTypeValid(uint16_t type);
646 
647  static inline bool isProtocolVersionValid(uint8_t version, uint8_t inVersion, DoIpPayloadTypes type);
648 
649  static inline bool isPayloadLengthValid(uint32_t payloadLength, size_t dataLen);
650 
651  protected:
652  // protected c'tors, this class cannot be instantiated by users
653  DoIpLayer(size_t length);
654 
655  DoIpLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
656 
657  doiphdr* getDoIpHeader() const
658  {
659  return reinterpret_cast<doiphdr*>(m_Data);
660  }
661 
662  void setHeaderFields(DoIpProtocolVersion version, DoIpPayloadTypes type, uint32_t length);
663  };
664 
665  // inline methods definition
666  inline bool DoIpLayer::isDoIpPort(uint16_t port)
667  {
668  auto portAsEnum = static_cast<DoIpPorts>(port);
669  return (portAsEnum == DoIpPorts::TCP_UDP_PORT || portAsEnum == DoIpPorts::TLS_PORT);
670  }
671 
672  inline bool DoIpLayer::isProtocolVersionValid(uint8_t version, uint8_t inVersion, DoIpPayloadTypes type)
673  {
674  const DoIpProtocolVersion parsedVersion = static_cast<DoIpProtocolVersion>(version);
675 
676  switch (parsedVersion)
677  {
679  {
680  PCPP_LOG_DEBUG("[Malformed doip packet]: Reserved ISO DoIP protocol version detected: 0x"
681  << std::hex << static_cast<int>(version));
682  return false;
683  }
688  {
689  PCPP_LOG_DEBUG("[Malformed doip packet]: Invalid/unsupported DoIP version!");
690  return false;
691  }
696  {
697  if (version != static_cast<uint8_t>(~inVersion))
698  {
699  PCPP_LOG_DEBUG("[Malformed doip packet]: Protocol version and inverse version mismatch! Version: 0x"
700  << std::hex << static_cast<int>(version) << ", Inverted: 0x"
701  << static_cast<int>(inVersion));
702  return false;
703  }
704  return true;
705  }
706  default:
707  PCPP_LOG_DEBUG("[Malformed doip packet]: Unknown DoIP protocol version: 0x" << std::hex
708  << static_cast<int>(version));
709  return false;
710  }
711  }
712 
713  inline bool DoIpLayer::isPayloadTypeValid(uint16_t type)
714  {
715  const DoIpPayloadTypes payloadType = static_cast<DoIpPayloadTypes>(type);
716 
717  switch (payloadType)
718  {
735  return true;
736 
737  default:
738  PCPP_LOG_DEBUG("[Malformed doip packet]: Invalid DoIP payload type: 0x" << std::hex << type);
739  return false;
740  }
741  }
742 
743  inline bool DoIpLayer::isPayloadLengthValid(uint32_t payloadLength, size_t dataLen)
744  {
745  const size_t actualPayloadLen = dataLen - DOIP_HEADER_LEN;
746 
747  if (payloadLength != actualPayloadLen)
748  {
749  PCPP_LOG_DEBUG("[Malformed doip packet]: Payload length mismatch: expected "
750  << payloadLength << " bytes, but got " << actualPayloadLen << " bytes.");
751  return false;
752  }
753 
754  return true;
755  }
756 
757  //~~~~~~~~~~~~~~~~~~~~~~|
758  // DoIpGenericHeaderNack|
759  //~~~~~~~~~~~~~~~~~~~~~~|
760 
766  {
767  public:
773  DoIpGenericHeaderNack(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
774 
778 
782 
786 
788  std::string getSummary() const;
789 
792  {
794  }
795 
799  static inline bool isDataLenValid(size_t dataLen)
800  {
801  return (dataLen == FIXED_LEN);
802  }
803 
804  private:
805 #pragma pack(push, 1)
806  struct generic_header_nack : doiphdr
807  {
808  uint8_t nackCode;
809  };
810 #pragma pack(pop)
811  generic_header_nack* getGenericHeaderNack() const
812  {
813  return reinterpret_cast<generic_header_nack*>(m_Data);
814  }
815  static constexpr size_t FIXED_LEN = sizeof(generic_header_nack);
816  };
817 
818  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
819  // DoIpVehicleIdentificationRequest|
820  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
821 
828  {
829  public:
835  DoIpVehicleIdentificationRequest(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
836  : DoIpLayer(data, dataLen, prevLayer, packet)
837  {}
838 
841 
844  {
846  }
847 
851  static inline bool isDataLenValid(size_t dataLen)
852  {
853  return (dataLen == DOIP_HEADER_LEN); // No payload
854  }
855  };
856 
857  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
858  // DoIpVehicleIdentificationRequestWithEID|
859  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
860 
866  {
867  public:
873  DoIpVehicleIdentificationRequestWithEID(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
874 
877  explicit DoIpVehicleIdentificationRequestWithEID(const std::array<uint8_t, DOIP_EID_LEN>& eid = {});
878 
881  std::array<uint8_t, DOIP_EID_LEN> getEID() const;
882 
885  void setEID(const std::array<uint8_t, DOIP_EID_LEN>& eid);
886 
888  std::string getSummary() const;
889 
892  {
894  }
895 
899  static inline bool isDataLenValid(size_t dataLen)
900  {
901  return (dataLen == FIXED_LEN);
902  }
903 
904  private:
905 #pragma pack(push, 1)
906  struct vehicle_identification_request_with_eid : doiphdr
907  {
908  std::array<uint8_t, DOIP_EID_LEN> eid;
909  };
910 #pragma pack(pop)
911  vehicle_identification_request_with_eid* getVehicleIdentificationRequestWEID() const
912  {
913  return reinterpret_cast<vehicle_identification_request_with_eid*>(m_Data);
914  }
915  static constexpr size_t FIXED_LEN = sizeof(vehicle_identification_request_with_eid);
916  };
917 
918  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
919  // DoIpVehicleIdentificationRequestWithVIN|
920  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
921 
927  {
928  public:
934  DoIpVehicleIdentificationRequestWithVIN(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
935 
938  explicit DoIpVehicleIdentificationRequestWithVIN(const std::array<uint8_t, DOIP_VIN_LEN>& vin = {});
939 
942  std::array<uint8_t, DOIP_VIN_LEN> getVIN() const;
943 
946  void setVIN(const std::array<uint8_t, DOIP_VIN_LEN>& vin);
947 
949  std::string getSummary() const;
950 
953  {
955  }
956 
960  static inline bool isDataLenValid(size_t dataLen)
961  {
962  return (dataLen == FIXED_LEN);
963  }
964 
965  private:
966 #pragma pack(push, 1)
967  struct vehicle_identification_request_with_vin : doiphdr
968  {
969  std::array<uint8_t, DOIP_VIN_LEN> vin;
970  };
971 #pragma pack(pop)
972  vehicle_identification_request_with_vin* getVehicleIdentificationRequestWVIN() const
973  {
974  return reinterpret_cast<vehicle_identification_request_with_vin*>(m_Data);
975  }
976  static constexpr size_t FIXED_LEN = sizeof(vehicle_identification_request_with_vin);
977  };
978 
979  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
980  // DoIpVehicleAnnouncementMessage|
981  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
982 
989  {
990  public:
996  DoIpVehicleAnnouncementMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
997 
1004  DoIpVehicleAnnouncementMessage(const std::array<uint8_t, DOIP_VIN_LEN>& vin, uint16_t logicalAddress,
1005  const std::array<uint8_t, DOIP_EID_LEN>& eid,
1006  const std::array<uint8_t, DOIP_GID_LEN>& gid, DoIpActionCodes actionCode);
1007 
1010  std::array<uint8_t, DOIP_VIN_LEN> getVIN() const;
1011 
1014  void setVIN(const std::array<uint8_t, DOIP_VIN_LEN>& vin);
1015 
1018  uint16_t getLogicalAddress() const;
1019 
1022  void setLogicalAddress(uint16_t address);
1023 
1026  std::array<uint8_t, DOIP_EID_LEN> getEID() const;
1027 
1030  void setEID(const std::array<uint8_t, DOIP_EID_LEN>& eid);
1031 
1034  std::array<uint8_t, DOIP_GID_LEN> getGID() const;
1035 
1038  void setGID(const std::array<uint8_t, DOIP_GID_LEN>& gid);
1039 
1043 
1047 
1053 
1057 
1060  bool hasSyncStatus() const;
1061 
1064 
1066  std::string getSummary() const;
1067 
1070  {
1072  }
1073 
1077  static inline bool isDataLenValid(size_t dataLen)
1078  {
1079  return (dataLen == FIXED_LEN || dataLen == OPT_LEN);
1080  }
1081 
1082  private:
1083 #pragma pack(push, 1)
1084  struct vehicle_announcement_message : doiphdr
1085  {
1086  std::array<uint8_t, DOIP_VIN_LEN> vin;
1087 
1088  uint16_t logicalAddress;
1089 
1090  std::array<uint8_t, DOIP_EID_LEN> eid;
1091 
1092  std::array<uint8_t, DOIP_GID_LEN> gid;
1093 
1094  uint8_t actionCode;
1095  };
1096 #pragma pack(pop)
1097 
1098  vehicle_announcement_message* getVehicleAnnouncementMessage() const
1099  {
1100  return reinterpret_cast<vehicle_announcement_message*>(m_Data);
1101  }
1102  static constexpr size_t FIXED_LEN = sizeof(vehicle_announcement_message);
1103  static constexpr size_t SYNC_STATUS_OFFSET = FIXED_LEN;
1104  static constexpr size_t SYNC_STATUS_LEN = sizeof(uint8_t);
1105  static constexpr size_t OPT_LEN = FIXED_LEN + SYNC_STATUS_LEN;
1106  };
1107 
1108  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1109  // DoIpRoutingActivationRequest|
1110  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1111 
1118  {
1119  public:
1125  DoIpRoutingActivationRequest(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1126 
1130  DoIpRoutingActivationRequest(uint16_t sourceAddress, DoIpActivationTypes activationType);
1131 
1134  uint16_t getSourceAddress() const;
1135 
1138  void setSourceAddress(uint16_t value);
1139 
1143 
1147 
1150  std::array<uint8_t, DOIP_RESERVED_ISO_LEN> getReservedIso() const;
1151 
1154  void setReservedIso(const std::array<uint8_t, DOIP_RESERVED_ISO_LEN>& reservedIso);
1155 
1160  std::array<uint8_t, DOIP_RESERVED_OEM_LEN> getReservedOem() const;
1161 
1164  void setReservedOem(const std::array<uint8_t, DOIP_RESERVED_OEM_LEN>& reservedOem);
1165 
1168  bool hasReservedOem() const;
1169 
1172 
1174  std::string getSummary() const;
1175 
1178  {
1180  }
1181 
1185  static inline bool isDataLenValid(size_t dataLen)
1186  {
1187  return (dataLen == FIXED_LEN || dataLen == OPT_LEN);
1188  }
1189 
1190  private:
1191 #pragma pack(push, 1)
1192  struct routing_activation_request : doiphdr
1193  {
1194  uint16_t sourceAddress;
1195 
1196  uint8_t activationType;
1197 
1198  std::array<uint8_t, DOIP_RESERVED_ISO_LEN> reservedIso;
1199  };
1200 #pragma pack(pop)
1201 
1202  routing_activation_request* getRoutingActivationRequest() const
1203  {
1204  return reinterpret_cast<routing_activation_request*>(m_Data);
1205  }
1206  static constexpr size_t FIXED_LEN = sizeof(routing_activation_request);
1207  static constexpr size_t RESERVED_OEM_OFFSET = FIXED_LEN;
1208  static constexpr size_t OPT_LEN = FIXED_LEN + DOIP_RESERVED_OEM_LEN;
1209  };
1210 
1211  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1212  // DoIpRoutingActivationResponse|
1213  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1214 
1221  {
1222  public:
1228  DoIpRoutingActivationResponse(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1229 
1234  DoIpRoutingActivationResponse(uint16_t logicalAddressExternalTester, uint16_t sourceAddress,
1235  DoIpRoutingResponseCodes responseCode);
1236 
1240 
1243  void setLogicalAddressExternalTester(uint16_t addr);
1244 
1247  uint16_t getSourceAddress() const;
1248 
1251  void setSourceAddress(uint16_t sourceAddress);
1252 
1256 
1260 
1263  std::array<uint8_t, DOIP_RESERVED_ISO_LEN> getReservedIso() const;
1264 
1267  void setReservedIso(const std::array<uint8_t, DOIP_RESERVED_ISO_LEN>& reservedIso);
1268 
1273  std::array<uint8_t, DOIP_RESERVED_OEM_LEN> getReservedOem() const;
1274 
1277  void setReservedOem(const std::array<uint8_t, DOIP_RESERVED_OEM_LEN>& reservedOem);
1278 
1281  bool hasReservedOem() const;
1282 
1285 
1287  std::string getSummary() const;
1288 
1291  {
1293  }
1294 
1298  static inline bool isDataLenValid(size_t dataLen)
1299  {
1300  return (dataLen == FIXED_LEN || dataLen == OPT_LEN);
1301  }
1302 
1303  private:
1304 #pragma pack(push, 1)
1305  struct routing_activation_response : doiphdr
1306  {
1307  uint16_t logicalAddressExternalTester;
1308 
1309  uint16_t sourceAddress;
1310 
1311  uint8_t responseCode;
1312 
1313  std::array<uint8_t, DOIP_RESERVED_ISO_LEN> reservedIso;
1314  };
1315 #pragma pack(pop)
1316  routing_activation_response* getRoutingActivationResponse() const
1317  {
1318  return reinterpret_cast<routing_activation_response*>(m_Data);
1319  }
1320  static constexpr size_t FIXED_LEN = sizeof(routing_activation_response);
1321  static constexpr size_t RESERVED_OEM_OFFSET = FIXED_LEN;
1322  static constexpr size_t OPT_LEN = FIXED_LEN + DOIP_RESERVED_OEM_LEN;
1323  };
1324 
1325  //~~~~~~~~~~~~~~~~~~~~~~|
1326  // DoIpAliveCheckRequest|
1327  //~~~~~~~~~~~~~~~~~~~~~~|
1328 
1335  {
1336  public:
1342  DoIpAliveCheckRequest(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
1343  : DoIpLayer(data, dataLen, prevLayer, packet)
1344  {}
1345 
1348 
1351  {
1353  }
1354 
1358  static inline bool isDataLenValid(size_t dataLen)
1359  {
1360  return (dataLen == DOIP_HEADER_LEN); // No payload
1361  }
1362  };
1363 
1364  //~~~~~~~~~~~~~~~~~~~~~~~|
1365  // DoIpAliveCheckResponse|
1366  //~~~~~~~~~~~~~~~~~~~~~~~|
1367 
1374  {
1375  public:
1381  DoIpAliveCheckResponse(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1382 
1385  explicit DoIpAliveCheckResponse(uint16_t sourceAddress);
1386 
1389  uint16_t getSourceAddress() const;
1390 
1393  void setSourceAddress(uint16_t address);
1394 
1396  std::string getSummary() const;
1397 
1401  {
1403  }
1407  static inline bool isDataLenValid(size_t dataLen)
1408  {
1409  return (dataLen == FIXED_LEN);
1410  }
1411 
1412  private:
1413 #pragma pack(push, 1)
1414  struct alive_check_response : doiphdr
1415  {
1416  uint16_t sourceAddress;
1417  };
1418 #pragma pack(pop)
1419  alive_check_response* getAliveCheckResponse() const
1420  {
1421  return reinterpret_cast<alive_check_response*>(m_Data);
1422  }
1423  static constexpr size_t FIXED_LEN = sizeof(alive_check_response);
1424  };
1425 
1426  //~~~~~~~~~~~~~~~~~~~~~~~~|
1427  // DoIpEntityStatusRequest|
1428  //~~~~~~~~~~~~~~~~~~~~~~~~|
1429 
1437  {
1438  public:
1444  DoIpEntityStatusRequest(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
1445  : DoIpLayer(data, dataLen, prevLayer, packet)
1446  {}
1447 
1450 
1453  {
1455  }
1456 
1460  static inline bool isDataLenValid(size_t dataLen)
1461  {
1462  return (dataLen == DOIP_HEADER_LEN); // No payload
1463  }
1464  };
1465 
1466  //~~~~~~~~~~~~~~~~~~~~~~~~~|
1467  // DoIpEntityStatusResponse|
1468  //~~~~~~~~~~~~~~~~~~~~~~~~~|
1469 
1476  {
1477  public:
1483  DoIpEntityStatusResponse(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1484 
1489  DoIpEntityStatusResponse(DoIpEntityStatusResponseCode nodeType, uint8_t maxConcurrentSockets,
1490  uint8_t currentlyOpenSockets);
1491 
1495  {
1497  }
1498 
1502 
1505  uint8_t getMaxConcurrentSockets() const;
1506 
1509  uint8_t getCurrentlyOpenSockets() const;
1510 
1515  uint32_t getMaxDataSize() const;
1516 
1520 
1523  void setMaxConcurrentSockets(uint8_t sockets);
1524 
1527  void setCurrentlyOpenSockets(uint8_t sockets);
1528 
1531  void setMaxDataSize(uint32_t data);
1532 
1535  bool hasMaxDataSize() const;
1536 
1539 
1542  std::string getSummary() const;
1543 
1547  static inline bool isDataLenValid(size_t dataLen)
1548  {
1549  return (dataLen == FIXED_LEN || dataLen == OPT_LEN);
1550  }
1551 
1552  private:
1553 #pragma pack(push, 1)
1554  struct entity_status_response : doiphdr
1555  {
1556  uint8_t nodeType;
1557 
1558  uint8_t maxConcurrentSockets;
1559 
1560  uint8_t currentlyOpenSockets;
1561  };
1562 #pragma pack(pop)
1563 
1564  entity_status_response* getEntityStatusResponse() const
1565  {
1566  return reinterpret_cast<entity_status_response*>(m_Data);
1567  }
1568  static constexpr size_t FIXED_LEN = sizeof(entity_status_response);
1569  static constexpr size_t MAX_DATA_SIZE_OFFSET = FIXED_LEN;
1570  static constexpr size_t MAX_DATA_SIZE_LEN = sizeof(uint32_t);
1571  static constexpr size_t OPT_LEN = FIXED_LEN + MAX_DATA_SIZE_LEN;
1572  };
1573 
1574  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1575  // DoIpDiagnosticPowerModeRequest|
1576  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1577 
1584  {
1585  public:
1591  DoIpDiagnosticPowerModeRequest(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
1592  : DoIpLayer(data, dataLen, prevLayer, packet)
1593  {}
1594 
1597 
1600  {
1602  }
1603 
1607  static inline bool isDataLenValid(size_t dataLen)
1608  {
1609  return (dataLen == DOIP_HEADER_LEN); // No payload
1610  }
1611  };
1612 
1613  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1614  // DoIpDiagnosticPowerModeResponse|
1615  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1616 
1623  {
1624  public:
1630  DoIpDiagnosticPowerModeResponse(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1631 
1635 
1639 
1643 
1645  std::string getSummary() const;
1646 
1650  {
1652  }
1653 
1657  static inline bool isDataLenValid(size_t dataLen)
1658  {
1659  return (dataLen == FIXED_LEN);
1660  }
1661 
1662  private:
1663 #pragma pack(push, 1)
1664  struct diagnostic_power_mode_response : doiphdr
1665  {
1666  uint8_t powerModeCode;
1667  };
1668 #pragma pack(pop)
1669  diagnostic_power_mode_response* getDiagnosticPowerModeResponse() const
1670  {
1671  return reinterpret_cast<diagnostic_power_mode_response*>(m_Data);
1672  }
1673  static constexpr size_t FIXED_LEN = sizeof(diagnostic_power_mode_response);
1674  };
1675 
1676  //~~~~~~~~~~~~~~~~~~~|
1677  // DoIpDiagnosticBase|
1678  //~~~~~~~~~~~~~~~~~~~|
1679 
1684  {
1685  public:
1688  uint16_t getSourceAddress() const;
1689 
1692  void setSourceAddress(uint16_t sourceAddress);
1693 
1696  uint16_t getTargetAddress() const;
1697 
1700  void setTargetAddress(uint16_t targetAddress);
1701 
1704  virtual std::string getSummary() const = 0;
1705 
1706  protected:
1707  DoIpDiagnosticBase(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1708 
1709  DoIpDiagnosticBase(size_t length) : DoIpLayer(length) {};
1710 
1711 #pragma pack(push, 1)
1714  {
1715  uint16_t sourceAddress;
1716 
1717  uint16_t targetAddress;
1718  };
1719 #pragma pack(pop)
1720  common_diagnostic_header* getCommonDiagnosticHeader() const
1721  {
1722  return reinterpret_cast<common_diagnostic_header*>(m_Data);
1723  }
1724  };
1725 
1726  //~~~~~~~~~~~~~~~~~~~~~~|
1727  // DoIpDiagnosticMessage|
1728  //~~~~~~~~~~~~~~~~~~~~~~|
1729 
1735  {
1736  public:
1742  DoIpDiagnosticMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1743 
1748  DoIpDiagnosticMessage(uint16_t sourceAddress, uint16_t targetAddress,
1749  const std::vector<uint8_t>& diagnosticData);
1750 
1753  void setDiagnosticData(const std::vector<uint8_t>& data);
1754 
1757  std::vector<uint8_t> getDiagnosticData() const;
1758 
1761  std::string getSummary() const override;
1762 
1766  {
1768  }
1769 
1770  // override getHeaderLen()
1771  size_t getHeaderLen() const override
1772  {
1773  return sizeof(doiphdr) + 2 * sizeof(uint16_t);
1774  }
1775 
1778  static inline bool isDataLenValid(size_t dataLen)
1779  {
1780  return (dataLen >= MIN_LEN);
1781  }
1782 
1783  private:
1784  static constexpr size_t DIAGNOSTIC_DATA_OFFSET = sizeof(common_diagnostic_header);
1785  static constexpr size_t MIN_LEN = DIAGNOSTIC_DATA_OFFSET + 1; /*Min diagnostic request Len*/
1786  };
1787 
1788  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1789  // DoIpDiagnosticResponseMessageBase|
1790  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1794  {
1795  public:
1798  uint8_t getResponseCode() const;
1799 
1802  void setResponseCode(uint8_t code);
1803 
1806  std::vector<uint8_t> getPreviousMessage() const;
1807 
1810  bool hasPreviousMessage() const;
1811 
1814  void setPreviousMessage(const std::vector<uint8_t>& msg);
1815 
1818 
1822  static inline bool isDataLenValid(size_t dataLen)
1823  {
1824  return (dataLen >= FIXED_LEN);
1825  }
1826 
1827  protected:
1828  DoIpDiagnosticResponseMessageBase(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1829  DoIpDiagnosticResponseMessageBase(uint16_t sourceAddress, uint16_t targetAddress, DoIpPayloadTypes type);
1830 
1831  private:
1832 #pragma pack(push, 1)
1833  struct diagnostic_response_message_base : common_diagnostic_header
1834  {
1835  uint8_t diagnosticCode;
1836  };
1837 #pragma pack(pop)
1838  diagnostic_response_message_base* getDiagnosticResponseMessageBase() const
1839  {
1840  return reinterpret_cast<diagnostic_response_message_base*>(m_Data);
1841  }
1842  static constexpr size_t FIXED_LEN = sizeof(diagnostic_response_message_base);
1843  static constexpr size_t PREVIOUS_MSG_OFFSET = FIXED_LEN;
1844  };
1845 
1846  //~~~~~~~~~~~~~~~~~~~~~~~~~|
1847  // DoIpDiagnosticMessageAck|
1848  //~~~~~~~~~~~~~~~~~~~~~~~~~|
1849 
1856  {
1857  public:
1863  DoIpDiagnosticMessageAck(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1864 
1869  DoIpDiagnosticMessageAck(uint16_t sourceAddress, uint16_t targetAddress, DoIpDiagnosticAckCodes ackCode);
1870 
1874 
1878 
1880  std::string getSummary() const override;
1881 
1884  {
1886  }
1887  };
1888 
1889  //~~~~~~~~~~~~~~~~~~~~~~~~~~|
1890  // DoIpDiagnosticMessageNack|
1891  //~~~~~~~~~~~~~~~~~~~~~~~~~~|
1892 
1899  {
1900  public:
1906  DoIpDiagnosticMessageNack(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1907 
1912  DoIpDiagnosticMessageNack(uint16_t sourceAddress, uint16_t targetAddress,
1914 
1918 
1922 
1924  std::string getSummary() const override;
1925 
1928  {
1930  }
1931  };
1932 
1933 } // namespace pcpp
Represents an Alive Check Request message in the DoIP protocol.
Definition: DoIpLayer.h:1335
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:1350
DoIpAliveCheckRequest(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs an AliveCheckRequest from raw packet data.
Definition: DoIpLayer.h:1342
DoIpAliveCheckRequest()
Default constructor to create an empty AliveCheckRequest message.
static bool isDataLenValid(size_t dataLen)
Checks if the Alive Check Request data length is valid.
Definition: DoIpLayer.h:1358
Represents a DoIP Alive Check Response message.
Definition: DoIpLayer.h:1374
DoIpAliveCheckResponse(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1400
DoIpAliveCheckResponse(uint16_t sourceAddress)
Constructs the message using the specified source address.
std::string getSummary() const
Returns a human-readable summary of the message.
uint16_t getSourceAddress() const
Gets the source address.
void setSourceAddress(uint16_t address)
Sets the source address.
static bool isDataLenValid(size_t dataLen)
Checks if the Alive Check Response data length is valid.
Definition: DoIpLayer.h:1407
Represents a DoIP Diagnostic Message sent between tester and ECU. This class includes source and targ...
Definition: DoIpLayer.h:1684
uint16_t getTargetAddress() const
Gets the target logical address of the message.
uint16_t getSourceAddress() const
Gets the source logical address of the message.
void setSourceAddress(uint16_t sourceAddress)
Sets the source logical address.
virtual std::string getSummary() const =0
Returns a human-readable summary of the message content.
void setTargetAddress(uint16_t targetAddress)
Sets the target logical address.
Represents a positive acknowledgment message in response to a DiagnosticMessage.
Definition: DoIpLayer.h:1856
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1883
DoIpDiagnosticAckCodes getAckCode() const
Gets the diagnostic acknowledgment code.
DoIpDiagnosticMessageAck(uint16_t sourceAddress, uint16_t targetAddress, DoIpDiagnosticAckCodes ackCode)
Constructs a DiagnosticAckMessage from specified field values.
void setAckCode(DoIpDiagnosticAckCodes code)
Sets the acknowledgment code.
DoIpDiagnosticMessageAck(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs a DiagnosticAckMessage from raw packet data.
std::string getSummary() const override
Returns a human-readable summary of the message.
Represents a DoIP Diagnostic message sent between tester and ECU.
Definition: DoIpLayer.h:1735
DoIpDiagnosticMessage(uint16_t sourceAddress, uint16_t targetAddress, const std::vector< uint8_t > &diagnosticData)
Constructs a DiagnosticMessage from specified field values.
DoIpDiagnosticMessage(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the DiagnosticMessage from raw packet data.
size_t getHeaderLen() const override
Definition: DoIpLayer.h:1771
std::vector< uint8_t > getDiagnosticData() const
Get the diagnostic data payload.
static bool isDataLenValid(size_t dataLen)
Checks if the diagnostic data length is valid.
Definition: DoIpLayer.h:1778
void setDiagnosticData(const std::vector< uint8_t > &data)
Set the diagnostic data payload.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1765
std::string getSummary() const override
Returns a human-readable summary of the message content.
Represents a negative acknowledgment message in response to a DiagnosticMessage.
Definition: DoIpLayer.h:1899
std::string getSummary() const override
Returns a human-readable summary of the message.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1927
DoIpDiagnosticMessageNackCodes getNackCode() const
Gets the negative acknowledgment code.
DoIpDiagnosticMessageNack(uint16_t sourceAddress, uint16_t targetAddress, DoIpDiagnosticMessageNackCodes nackCode)
Constructs a DiagnosticNackMessage from specified field values.
void setNackCode(DoIpDiagnosticMessageNackCodes code)
Sets the negative acknowledgment code.
DoIpDiagnosticMessageNack(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs a DiagnosticNackMessage from raw packet data.
Represents a Diagnostic Power Mode Request message in the DoIP protocol.
Definition: DoIpLayer.h:1584
DoIpDiagnosticPowerModeRequest(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs a DiagnosticPowerModeRequest from raw packet data.
Definition: DoIpLayer.h:1591
static bool isDataLenValid(size_t dataLen)
Checks if the Entity Status Request data length is valid.
Definition: DoIpLayer.h:1607
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1599
DoIpDiagnosticPowerModeRequest()
Default constructor to create an empty DiagnosticPowerModeRequest.
Represents a DoIP Diagnostic Power Mode Response message.
Definition: DoIpLayer.h:1623
DoIpDiagnosticPowerModeCodes getPowerModeCode() const
Gets the current power mode code.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1649
static bool isDataLenValid(size_t dataLen)
Checks if the Diagnostic Power Mode Response data length is valid.
Definition: DoIpLayer.h:1657
std::string getSummary() const
Returns a human-readable summary of the message.
void setPowerModeCode(DoIpDiagnosticPowerModeCodes code)
Sets the power mode code.
DoIpDiagnosticPowerModeResponse(DoIpDiagnosticPowerModeCodes modeCode)
Constructs the message using the specified power mode code.
DoIpDiagnosticPowerModeResponse(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
Represents a Basic class for Diagnostic message (ACK/NACK) sent back to tester.
Definition: DoIpLayer.h:1794
uint8_t getResponseCode() const
Gets the acknowledgment/nack code (1-byte).
bool hasPreviousMessage() const
Checks if a previous message is attached.
static bool isDataLenValid(size_t dataLen)
Checks if data length is valid.
Definition: DoIpLayer.h:1822
std::vector< uint8_t > getPreviousMessage() const
Gets the optional previously echoed diagnostic message.
void setResponseCode(uint8_t code)
Sets the acknowledgment/nack code (1-byte).
void clearPreviousMessage()
Clears the previously stored diagnostic message.
void setPreviousMessage(const std::vector< uint8_t > &msg)
Sets the previous echoed diagnostic message.
Represents an Entity Status Request message in the DoIP protocol.
Definition: DoIpLayer.h:1437
static bool isDataLenValid(size_t dataLen)
Checks if the Entity Status Request data length is valid.
Definition: DoIpLayer.h:1460
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:1452
DoIpEntityStatusRequest()
Default constructor to create an empty EntityStatusRequest message.
DoIpEntityStatusRequest(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs an EntityStatusRequest from raw packet data.
Definition: DoIpLayer.h:1444
Represents a DoIP Entity Status Response message.
Definition: DoIpLayer.h:1476
void setCurrentlyOpenSockets(uint8_t sockets)
Sets the number of currently open sockets.
void clearMaxDataSize()
Clears the optional max data size field.
uint8_t getMaxConcurrentSockets() const
Gets the maximum number of concurrent sockets supported.
DoIpEntityStatusResponse(DoIpEntityStatusResponseCode nodeType, uint8_t maxConcurrentSockets, uint8_t currentlyOpenSockets)
Constructs the message using provided field values.
void setNodeType(DoIpEntityStatusResponseCode status)
Sets the DoIP node type.
uint32_t getMaxDataSize() const
Gets the optional maximum data size field.
void setMaxDataSize(uint32_t data)
Sets the maximum data size field.
bool hasMaxDataSize() const
Checks if the optional max data size is present.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1494
static bool isDataLenValid(size_t dataLen)
Checks if the Entity Status Response data length is valid.
Definition: DoIpLayer.h:1547
DoIpEntityStatusResponse(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
void setMaxConcurrentSockets(uint8_t sockets)
Sets the maximum number of concurrent sockets.
DoIpEntityStatusResponseCode getNodeType() const
Gets the type of the DoIP node.
uint8_t getCurrentlyOpenSockets() const
Gets the number of currently open sockets.
std::string getSummary() const
Returns a human-readable summary of the message.
Represents a DoIP Generic Header Negative Acknowledgement message.
Definition: DoIpLayer.h:766
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:791
DoIpGenericHeaderNackCodes getNackCode() const
Gets the NACK code.
void setNackCode(DoIpGenericHeaderNackCodes code)
Sets the NACK code.
DoIpGenericHeaderNack(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
std::string getSummary() const
Returns a human-readable summary of the message.
DoIpGenericHeaderNack(DoIpGenericHeaderNackCodes nackCode)
Constructs the message with a specific NACK code.
static bool isDataLenValid(size_t dataLen)
Checks if the NACK data length is valid.
Definition: DoIpLayer.h:799
Definition: DoIpLayer.h:560
size_t getHeaderLen() const override
Definition: DoIpLayer.h:627
static DoIpLayer * parseDoIpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
OsiModelLayer getOsiModelLayer() const override
Definition: DoIpLayer.h:637
void setProtocolVersion(uint8_t rawVersion)
static bool isDoIpPort(uint16_t port)
Definition: DoIpLayer.h:666
uint8_t getInvertProtocolVersion() const
uint32_t getPayloadLength() const
void setProtocolVersion(DoIpProtocolVersion version)
void computeCalculateFields() override
Each layer can compute field values automatically using this method. This is an abstract method.
Definition: DoIpLayer.h:634
virtual DoIpPayloadTypes getPayloadType() const =0
std::string getPayloadTypeAsStr() const
void setPayloadLength(uint32_t length)
std::string toString() const override
void parseNextLayer() override
parse UDS layer
static bool isDataValid(uint8_t *data, size_t dataLen)
std::string getProtocolVersionAsStr() const
void setInvertProtocolVersion(uint8_t iVersion)
DoIpProtocolVersion getProtocolVersion() const
Represents a DoIP Routing Activation Request message.
Definition: DoIpLayer.h:1118
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:1177
uint16_t getSourceAddress() const
Returns the source address.
DoIpRoutingActivationRequest(uint16_t sourceAddress, DoIpActivationTypes activationType)
Constructs the message from field values.
DoIpActivationTypes getActivationType() const
Returns the activation type.
std::array< uint8_t, DOIP_RESERVED_OEM_LEN > getReservedOem() const
Gets the to reserved OEM bytes if present.
bool hasReservedOem() const
Checks if OEM reserved bytes are present.
void setReservedOem(const std::array< uint8_t, DOIP_RESERVED_OEM_LEN > &reservedOem)
Sets the reserved OEM bytes.
static bool isDataLenValid(size_t dataLen)
Checks if the routing activation request data length is valid.
Definition: DoIpLayer.h:1185
void setActivationType(DoIpActivationTypes activationType)
Sets the activation type.
DoIpRoutingActivationRequest(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
std::string getSummary() const
Returns a human-readable summary of the message.
std::array< uint8_t, DOIP_RESERVED_ISO_LEN > getReservedIso() const
Gets the reserved ISO bytes.
void setReservedIso(const std::array< uint8_t, DOIP_RESERVED_ISO_LEN > &reservedIso)
Sets the reserved ISO bytes.
void setSourceAddress(uint16_t value)
Sets the source address.
void clearReservedOem()
Clears the OEM reserved bytes.
Represents a DoIP Routing Activation Response message.
Definition: DoIpLayer.h:1221
DoIpRoutingResponseCodes getResponseCode() const
Gets the routing response code.
void clearReservedOem()
Clears the OEM reserved bytes.
static bool isDataLenValid(size_t dataLen)
Checks if the routing activation response data length is valid.
Definition: DoIpLayer.h:1298
std::string getSummary() const
Returns a human-readable summary of the message.
uint16_t getSourceAddress() const
Gets the source address.
std::array< uint8_t, DOIP_RESERVED_OEM_LEN > getReservedOem() const
Gets pointer to reserved OEM bytes if present.
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:1290
std::array< uint8_t, DOIP_RESERVED_ISO_LEN > getReservedIso() const
Gets the reserved ISO bytes.
void setResponseCode(DoIpRoutingResponseCodes code)
Sets the routing response code.
DoIpRoutingActivationResponse(uint16_t logicalAddressExternalTester, uint16_t sourceAddress, DoIpRoutingResponseCodes responseCode)
Constructs the message from field values.
bool hasReservedOem() const
Checks if OEM reserved bytes are present.
void setReservedOem(const std::array< uint8_t, DOIP_RESERVED_OEM_LEN > &reservedOem)
Sets the reserved OEM bytes.
uint16_t getLogicalAddressExternalTester() const
Gets the logical address of the external tester.
void setSourceAddress(uint16_t sourceAddress)
Sets the source address.
DoIpRoutingActivationResponse(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
void setReservedIso(const std::array< uint8_t, DOIP_RESERVED_ISO_LEN > &reservedIso)
Sets the reserved ISO bytes.
void setLogicalAddressExternalTester(uint16_t addr)
Sets the logical address of the external tester.
Represents a DoIP Vehicle Announcement message.
Definition: DoIpLayer.h:989
uint16_t getLogicalAddress() const
Gets the logical address of the vehicle.
std::array< uint8_t, DOIP_EID_LEN > getEID() const
Gets the Entity Identifier (EID).
std::array< uint8_t, DOIP_GID_LEN > getGID() const
Gets the Group Identifier (GID).
std::string getSummary() const
Returns a human-readable summary of the message.
static bool isDataLenValid(size_t dataLen)
checks if the vehicle announcement data length is valid.
Definition: DoIpLayer.h:1077
DoIpVehicleAnnouncementMessage(const std::array< uint8_t, DOIP_VIN_LEN > &vin, uint16_t logicalAddress, const std::array< uint8_t, DOIP_EID_LEN > &eid, const std::array< uint8_t, DOIP_GID_LEN > &gid, DoIpActionCodes actionCode)
Constructs the message using specified field values.
void setGID(const std::array< uint8_t, DOIP_GID_LEN > &gid)
Sets the Group Identifier (GID).
bool hasSyncStatus() const
Checks whether the sync status is present.
void setEID(const std::array< uint8_t, DOIP_EID_LEN > &eid)
Sets the Entity Identifier (EID).
void setVIN(const std::array< uint8_t, DOIP_VIN_LEN > &vin)
Sets the Vehicle Identification Number (VIN).
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:1069
DoIpSyncStatus getSyncStatus() const
Gets the optional synchronization status if available.
std::array< uint8_t, DOIP_VIN_LEN > getVIN() const
Gets the Vehicle Identification Number (VIN).
DoIpActionCodes getFurtherActionRequired() const
Gets the further action required code.
void setFurtherActionRequired(DoIpActionCodes action)
Sets the further action required code.
void clearSyncStatus()
Clears the optional sync status field.
void setLogicalAddress(uint16_t address)
Sets the logical address.
void setSyncStatus(DoIpSyncStatus sync)
Sets the synchronization status.
DoIpVehicleAnnouncementMessage(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
Represents a Vehicle Identification Request message in the DoIP protocol.
Definition: DoIpLayer.h:828
DoIpVehicleIdentificationRequest()
Default constructor to create an empty VehicleIdentificationRequest.
static bool isDataLenValid(size_t dataLen)
Checks if the Vehicle Identification Request data length is valid.
Definition: DoIpLayer.h:851
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type.
Definition: DoIpLayer.h:843
DoIpVehicleIdentificationRequest(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs a VehicleIdentificationRequest from raw packet data.
Definition: DoIpLayer.h:835
Represents a DoIP Vehicle Identification Request with EID.
Definition: DoIpLayer.h:866
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:891
std::array< uint8_t, DOIP_EID_LEN > getEID() const
Gets the Entity ID (EID).
DoIpVehicleIdentificationRequestWithEID(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
std::string getSummary() const
Returns a human-readable summary of the message.
static bool isDataLenValid(size_t dataLen)
Checks if the EID data length is valid.
Definition: DoIpLayer.h:899
DoIpVehicleIdentificationRequestWithEID(const std::array< uint8_t, DOIP_EID_LEN > &eid={})
Constructs the message using the specified EID.
void setEID(const std::array< uint8_t, DOIP_EID_LEN > &eid)
Sets the Entity ID (EID).
Represents a DoIP Vehicle Identification Request with VIN.
Definition: DoIpLayer.h:927
DoIpPayloadTypes getPayloadType() const override
Returns the DoIP payload type for this message.
Definition: DoIpLayer.h:952
DoIpVehicleIdentificationRequestWithVIN(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Constructs the layer from raw DoIP packet data.
static bool isDataLenValid(size_t dataLen)
Checks if the VIN data length is valid.
Definition: DoIpLayer.h:960
DoIpVehicleIdentificationRequestWithVIN(const std::array< uint8_t, DOIP_VIN_LEN > &vin={})
Constructs the message using the specified VIN.
std::array< uint8_t, DOIP_VIN_LEN > getVIN() const
Gets the Vehicle Identification Number (VIN).
void setVIN(const std::array< uint8_t, DOIP_VIN_LEN > &vin)
Sets the Vehicle Identification Number (VIN).
std::string getSummary() const
Returns a human-readable summary of the message.
Definition: Layer.h:62
Definition: Packet.h:22
The main namespace for the PcapPlusPlus lib.
DoIpProtocolVersion
Represents the DoIP (Diagnostics over IP) protocol versions.
Definition: DoIpLayer.h:446
@ DEFAULT_VALUE
Default protocol version. Used for broadcast Vehicle Identification Request Messages.
@ ISO13400_2019
Protocol version 3, based on ISO 2019 specification.
@ ISO13400_2012
Protocol version 2, based on ISO 2012 specification.
@ RESERVED_VER
Reserved protocol version. This value is used when the version is not specified.
@ ISO13400_2010
Protocol version 1, based on ISO 2010 specification.
@ ISO13400_2019_AMD1
Protocol version 4, based on ISO 2019 AMD1 (Amendment 1) specification.
DoIpDiagnosticAckCodes
Enum representing DoIP diagnostic acknowledgment codes (ISO 13400). These codes are used to acknowled...
Definition: DoIpLayer.h:341
DoIpPorts
Enum representing DoIP diagnostic ports (ISO 13400). These ports are used for communication in the Do...
Definition: DoIpLayer.h:545
DoIpSyncStatus
Enum representing DoIP sync status (ISO 13400). These codes are used to indicate whether GID and VIN ...
Definition: DoIpLayer.h:372
@ VIN_AND_OR_GID_ARE_SINCHRONIZED
VIN and or GID are synchronized.
@ VIN_AND_OR_GID_ARE_NOT_SINCHRONIZED
VIN and or GID are not synchronized.
DoIpActivationTypes
Enum representing DoIP routing activation types. These values specify the type of routing activation ...
Definition: DoIpLayer.h:61
DoIpRoutingResponseCodes
Enum representing DoIP routing activation response codes (ISO 13400). These codes are used in respons...
Definition: DoIpLayer.h:190
DoIpGenericHeaderNackCodes
Enum representing DoIP Generic Header NACK codes (ISO 13400). These codes are used to indicate specif...
Definition: DoIpLayer.h:82
DoIpEntityStatusResponseCode
Enum representing DoIP entity status response codes (ISO 13400). These codes are used to indicate the...
Definition: DoIpLayer.h:354
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:258
@ OsiModelApplicationLayer
Application layer (layer 7)
Definition: ProtocolType.h:272
DoIpPayloadTypes
Enum representing DoIP payload types. These payload types are defined as part of theDoIP(Diagnostic o...
Definition: DoIpLayer.h:476
DoIpDiagnosticPowerModeCodes
Enum representing DoIP diagnostic power mode codes (ISO 13400). These codes indicate the diagnostic p...
Definition: DoIpLayer.h:319
DoIpActionCodes
Enum representing DoIP action codes for DoIP announcement messages (ISO 13400). These action codes sp...
Definition: DoIpLayer.h:112
DoIpDiagnosticMessageNackCodes
Enum representing DoIP diagnostic message NACK codes (ISO 13400). These codes indicate reasons for re...
Definition: DoIpLayer.h:273
An internal structure representing the common diagnostic header.
Definition: DoIpLayer.h:1714
Definition: DoIpLayer.h:18
uint8_t protocolVersion
DoIP version (DOIPV)
Definition: DoIpLayer.h:20
uint16_t payloadType
DoIP payload type (DOIPT)
Definition: DoIpLayer.h:24
uint32_t payloadLength
DoIP content payload length (DOIPL)
Definition: DoIpLayer.h:26
uint8_t invertProtocolVersion
DoIP invert version (DOIPIV). Inverse of protocol version.
Definition: DoIpLayer.h:22