PcapPlusPlus  20.08
pcpp::SipResponseFirstLine Class Reference

#include <SipLayer.h>

Classes

class  SipResponseFirstLineException
 

Public Member Functions

SipResponseLayer::SipResponseStatusCode getStatusCode () const
 
int getStatusCodeAsInt () const
 
std::string getStatusCodeString () const
 
bool setStatusCode (SipResponseLayer::SipResponseStatusCode newStatusCode, std::string statusCodeString="")
 
std::string getVersion () const
 
void setVersion (std::string newVersion)
 
int getSize () const
 
bool isComplete () const
 

Static Public Member Functions

static SipResponseLayer::SipResponseStatusCode parseStatusCode (char *data, size_t dataLen)
 
static std::string parseVersion (char *data, size_t dataLen)
 

Detailed Description

Represents an SIP response message first line. The first line includes 2 parameters: status code (e.g 100 Trying ,200 OK, etc.), and SIP version (usually SIP/2.0). These 2 parameters are included in this class, and the user can retrieve or set them. This class cannot be instantiated by users, it's created inside SipResponseLayer and user can get a pointer to an instance of it. The "getter" methods of this class will retrieve the actual data of the SIP response and the "setter" methods will change the packet data. Since SIP is a textual protocol, most fields aren't of fixed size and this also applies to the first line parameters. So most "setter" methods of this class may need to shorten or extend the data in SipResponseLayer. These methods will return a false value if this action failed

Member Function Documentation

◆ getSize()

int pcpp::SipResponseFirstLine::getSize ( ) const
inline
Returns
The size in bytes of the SIP response first line

◆ getStatusCode()

SipResponseLayer::SipResponseStatusCode pcpp::SipResponseFirstLine::getStatusCode ( ) const
inline
Returns
The status code as SipResponseLayer::SipResponseStatusCode enum

◆ getStatusCodeAsInt()

int pcpp::SipResponseFirstLine::getStatusCodeAsInt ( ) const
Returns
The status code number as integer (e.g 200, 100, etc.)

◆ getStatusCodeString()

std::string pcpp::SipResponseFirstLine::getStatusCodeString ( ) const
Returns
The status code message (e.g "OK", "Trying", etc.)

◆ getVersion()

std::string pcpp::SipResponseFirstLine::getVersion ( ) const
inline
Returns
The SIP version

◆ isComplete()

bool pcpp::SipResponseFirstLine::isComplete ( ) const
inline

As explained in SipResponseLayer, A SIP message can sometimes spread over more than 1 packet, so when looking at a single packet the header can be partial. Same goes for the first line - it can spread over more than 1 packet. This method returns an indication whether the first line is partial

Returns
False if the first line is partial, true if it's complete

◆ parseStatusCode()

static SipResponseLayer::SipResponseStatusCode pcpp::SipResponseFirstLine::parseStatusCode ( char *  data,
size_t  dataLen 
)
static

A static method for parsing the SIP status code out of raw data

Parameters
[in]dataThe raw data
[in]dataLenThe raw data length
Returns
The parsed SIP status code as enum

◆ parseVersion()

static std::string pcpp::SipResponseFirstLine::parseVersion ( char *  data,
size_t  dataLen 
)
static

A static method for parsing the SIP version out of raw data

Parameters
[in]dataThe raw data
[in]dataLenThe raw data length
Returns
The parsed SIP version string or an empty string if version cannot be extracted

◆ setStatusCode()

bool pcpp::SipResponseFirstLine::setStatusCode ( SipResponseLayer::SipResponseStatusCode  newStatusCode,
std::string  statusCodeString = "" 
)

Set the status code

Parameters
[in]newStatusCodeThe new status code to set
[in]statusCodeStringAn optional parameter: set a non-default status code message (e.g "Bla Bla" instead of "Not Found"). If this parameter isn't supplied or supplied as empty string (""), the default message for the status code will be set

◆ setVersion()

void pcpp::SipResponseFirstLine::setVersion ( std::string  newVersion)

Set the SIP version. The version to set is expected to be in the format of SIP/x.y otherwise an error will be written to log

Parameters
[in]newVersionThe SIP version to set