PcapPlusPlus
pcpp::SipResponseFirstLine Class Reference

#include <SipLayer.h>

Classes

class  SipResponseFirstLineException
 

Public Member Functions

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

Static Public Member Functions

static SipResponseLayer::SipResponseStatusCode parseStatusCode (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

int pcpp::SipResponseFirstLine::getSize ( )
inline
Returns
The size in bytes of the SIP response first line
SipResponseLayer::SipResponseStatusCode pcpp::SipResponseFirstLine::getStatusCode ( )
inline
Returns
The status code as SipResponseLayer::SipResponseStatusCode enum
int pcpp::SipResponseFirstLine::getStatusCodeAsInt ( )
Returns
The status code number as integer (e.g 200, 100, etc.)
std::string pcpp::SipResponseFirstLine::getStatusCodeString ( )
Returns
The status code message (e.g "OK", "Trying", etc.)
std::string pcpp::SipResponseFirstLine::getVersion ( )
inline
Returns
The SIP version
bool pcpp::SipResponseFirstLine::isComplete ( )
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
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
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
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