Skip to content

Commit 50c8430

Browse files
authored
Optimized SIP response code parsing. (#2041)
* Optimized SIP response code parsing. * Lint * Fix. * Updaete raw arrays to std::array. Update static variables to have internal linkage.
1 parent 5c11564 commit 50c8430

File tree

2 files changed

+374
-204
lines changed

2 files changed

+374
-204
lines changed

Packet++/header/SipLayer.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,15 @@ namespace pcpp
647647
friend class SipResponseLayer;
648648

649649
public:
650+
/// @brief A structure containing parsed components from a SIP response first line.
651+
struct FirstLineData
652+
{
653+
/// @brief The SIP protocol version (e.g., SIP/2.0)
654+
std::string version;
655+
/// @brief The response status code number (e.g., 200, 100)
656+
SipResponseLayer::SipResponseStatusCode statusCode;
657+
};
658+
650659
/// @return The status code as SipResponseLayer#SipResponseStatusCode enum
651660
SipResponseLayer::SipResponseStatusCode getStatusCode() const
652661
{
@@ -689,6 +698,12 @@ namespace pcpp
689698
/// @return The parsed SIP version string or an empty string if version cannot be extracted
690699
static std::string parseVersion(const char* data, size_t dataLen);
691700

701+
/// @brief A static method for parsing the complete SIP response first line from raw data
702+
/// @param data The raw data containing the SIP response line
703+
/// @param dataLen The raw data length
704+
/// @return A pair where first indicates success/failure, and second contains the parsed data.
705+
static std::pair<bool, FirstLineData> parseFirstLine(const char* data, size_t dataLen);
706+
692707
/// @return The size in bytes of the SIP response first line
693708
int getSize() const
694709
{

0 commit comments

Comments
 (0)