PcapPlusPlus  19.12
pcpp::SipLayer Class Reference

#include <SipLayer.h>

Inheritance diagram for pcpp::SipLayer:
pcpp::TextBasedProtocolMessage pcpp::Layer pcpp::IDataContainer pcpp::SipRequestLayer pcpp::SipResponseLayer

Public Member Functions

int getContentLength () const
 
HeaderFieldsetContentLength (int contentLength, const std::string prevFieldName="")
 
OsiModelLayer getOsiModelLayer () const
 
void parseNextLayer ()
 
void computeCalculateFields ()
 
- Public Member Functions inherited from pcpp::TextBasedProtocolMessage
HeaderFieldgetFieldByName (std::string fieldName, int index=0) const
 
HeaderFieldgetFirstField () const
 
HeaderFieldgetNextField (HeaderField *prevField) const
 
int getFieldCount () const
 
virtual HeaderFieldaddField (const std::string &fieldName, const std::string &fieldValue)
 
virtual HeaderFieldaddField (const HeaderField &newField)
 
HeaderFieldaddEndOfHeader ()
 
virtual HeaderFieldinsertField (HeaderField *prevField, const std::string &fieldName, const std::string &fieldValue)
 
virtual HeaderFieldinsertField (std::string prevFieldName, const std::string &fieldName, const std::string &fieldValue)
 
virtual HeaderFieldinsertField (HeaderField *prevField, const HeaderField &newField)
 
bool removeField (HeaderField *fieldToRemove)
 
bool removeField (std::string fieldName, int index=0)
 
bool isHeaderComplete () const
 
size_t getHeaderLen () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 
virtual std::string toString () const =0
 

Detailed Description

Represents a general SIP message. It's an abstract class and cannot be instantiated. It's inherited by SipRequestLayer and SipResponseLayer

Member Function Documentation

◆ computeCalculateFields()

void pcpp::SipLayer::computeCalculateFields ( )
virtual

Set the content-length only if a content-length field already exists and if its current value is different than the total length of the next layer(s)

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ getContentLength()

int pcpp::SipLayer::getContentLength ( ) const

The length of the body of many SIP response messages is determined by a SIP header field called "Content-Length". This method parses this field, extracts its value and return it. If this field doesn't exist 0 is returned

Returns
SIP response body length determined by "Content-Length" field

◆ getOsiModelLayer()

OsiModelLayer pcpp::SipLayer::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ parseNextLayer()

void pcpp::SipLayer::parseNextLayer ( )
virtual

Currently identifies only SDP if content-length field exists and set to a value greater than zero. If content-length field doesn't exist or set to zero and still there is data after this layer, a PayloadLayer will be created

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ setContentLength()

HeaderField* pcpp::SipLayer::setContentLength ( int  contentLength,
const std::string  prevFieldName = "" 
)

The length of the body of many SIP messages is determined by a header field called "Content-Length". This method sets The content-length field value. The method supports several cases:

  • If the "Content-Length" field exists - the method will only replace the existing value with the new value
  • If the "Content-Length" field doesn't exist - the method will create this field and put the value in it. Here are also 2 cases:
    • If prevFieldName is specified - the new "Content-Length" field will be created after it
    • If prevFieldName isn't specified or doesn't exist - the new "Content-Length" field will be created as the last field before end-of-header field
Parameters
[in]contentLengthThe content length value to set
[in]prevFieldNameOptional parameter, if specified and "Content-Length" field doesn't exist, it will be created after this field
Returns
A pointer to the "Content-Length" field, or NULL if creation failed