Skip to content

Commit

Permalink
. make safe search in enumsToString, add parseNextLayer for UDS layer…
Browse files Browse the repository at this point in the history
… as generic PayloadLayeruse byte shifting instead of reinterprete_cast for field crafting
  • Loading branch information
raissi-oussema committed Jan 18, 2025
1 parent 14bc5a5 commit 0545afe
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 86 deletions.
5 changes: 5 additions & 0 deletions Packet++/header/DoIpEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,11 @@ namespace pcpp
NODE = 0x01U
};

/**
* @brief Enum representing DoIP sync status (ISO 13400).
*
* These codes are used to indicate whether GID and VIN are synchronized or not.
*/
enum class DoIpSyncStatus : uint8_t
{
/**
Expand Down
4 changes: 2 additions & 2 deletions Packet++/header/DoIpLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vector>
#include <unordered_map>
#include "Layer.h"
#include "PayloadLayer.h"
#include "IpAddress.h"
#include "MacAddress.h"
#include "Logger.h"
Expand Down Expand Up @@ -215,8 +216,7 @@ namespace pcpp
/**
* TODO, parse UDS layer
*/
void parseNextLayer() override
{}
void parseNextLayer() override;

/**
* @return The size of @ref doiphdr + attached fields length
Expand Down
12 changes: 12 additions & 0 deletions Packet++/src/DoIpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,16 @@ namespace pcpp
}
}
}

void DoIpLayer::parseNextLayer()
{
DiagnosticMessageData diagnosticMessage;

if (diagnosticMessage.buildFromLayer(this))
{
// handle UDS layer as generic PayloadLayer for now.
m_NextLayer = new PayloadLayer(diagnosticMessage.diagnosticData.data(),
diagnosticMessage.diagnosticData.size(), this, m_Packet);
}
}
} // namespace pcpp
Loading

0 comments on commit 0545afe

Please sign in to comment.