PcapPlusPlus  21.05
pcpp::SipResponseLayer Class Reference

#include <SipLayer.h>

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

Public Types

enum  SipResponseStatusCode {
  Sip100Trying, Sip180Ringing, Sip181CallisBeingForwarded, Sip182Queued,
  Sip183SessioninProgress, Sip199EarlyDialogTerminated, Sip200OK, Sip202Accepted,
  Sip204NoNotification, Sip300MultipleChoices, Sip301MovedPermanently, Sip302MovedTemporarily,
  Sip305UseProxy, Sip380AlternativeService, Sip400BadRequest, Sip401Unauthorized,
  Sip402PaymentRequired, Sip403Forbidden, Sip404NotFound, Sip405MethodNotAllowed,
  Sip406NotAcceptable, Sip407ProxyAuthenticationRequired, Sip408RequestTimeout, Sip409Conflict,
  Sip410Gone, Sip411LengthRequired, Sip412ConditionalRequestFailed, Sip413RequestEntityTooLarge,
  Sip414RequestURITooLong, Sip415UnsupportedMediaType, Sip416UnsupportedURIScheme, Sip417UnknownResourcePriority,
  Sip420BadExtension, Sip421ExtensionRequired, Sip422SessionIntervalTooSmall, Sip423IntervalTooBrief,
  Sip424BadLocationInformation, Sip428UseIdentityHeader, Sip429ProvideReferrerIdentity, Sip430FlowFailed,
  Sip433AnonymityDisallowed, Sip436BadIdentityInfo, Sip437UnsupportedCertificate, Sip438InvalidIdentityHeader,
  Sip439FirstHopLacksOutboundSupport, Sip440MaxBreadthExceeded, Sip469BadInfoPackage, Sip470ConsentNeeded,
  Sip480TemporarilyUnavailable, Sip481Call_TransactionDoesNotExist, Sip482LoopDetected, Sip483TooManyHops,
  Sip484AddressIncomplete, Sip485Ambiguous, Sip486BusyHere, Sip487RequestTerminated,
  Sip488NotAcceptableHere, Sip489BadEvent, Sip491RequestPending, Sip493Undecipherable,
  Sip494SecurityAgreementRequired, Sip500ServerInternalError, Sip501NotImplemented, Sip502BadGateway,
  Sip503ServiceUnavailable, Sip504ServerTimeout, Sip505VersionNotSupported, Sip513MessageTooLarge,
  Sip580PreconditionFailure, Sip600BusyEverywhere, Sip603Decline, Sip604DoesNotExistAnywhere,
  Sip606NotAcceptable, Sip607Unwanted, SipStatusCodeUnknown

Public Member Functions

 SipResponseLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 SipResponseLayer (SipResponseLayer::SipResponseStatusCode statusCode, std::string statusCodeString="", std::string sipVersion="SIP/2.0")
 SipResponseLayer (const SipResponseLayer &other)
SipResponseLayeroperator= (const SipResponseLayer &other)
SipResponseFirstLinegetFirstLine () const
std::string toString () const
- Public Member Functions inherited from pcpp::SipLayer
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

Additional Inherited Members

- Static Public Member Functions inherited from pcpp::SipLayer
static bool isSipPort (uint16_t port)

Detailed Description

Represents an SIP response message and inherits all basic functionality of SipLayer and TextBasedProtocolMessage. The functionality that is added for this class is the SIP first line concept. A SIP response has the following first line: 200 OK SIP/2.0 Since it's not an "ordinary" header field, it requires a special treatment and gets a class of it's own: SipResponseFirstLine. In most cases a SIP response will be contained in a single packet but for cases it is not, only the first packet will be identified as SIP response layer. You can find out whether the header is complete by using SipLayer::isHeaderComplete()

Member Enumeration Documentation

◆ SipResponseStatusCode

Enum for SIP response status codes. List is taken from Wikipedia: https://en.wikipedia.org/wiki/List_of_SIP_response_codes


Extended search being performed may take a significant time so a forking proxy must send a 100 Trying response


Destination user agent received INVITE, and is alerting user of call


Servers can optionally send this response to indicate a call is being forwarded


Indicates that the destination was temporarily unavailable, so the server has queued the call until the destination is available. A server may send multiple 182 responses to update progress of the queue


This response may be used to send extra information for a call which is still being set up


Can be used by User Agent Server to indicate to upstream SIP entities (including the User Agent Client (UAC)) that an early dialog has been terminated


Indicates the request was successful


Indicates that the request has been accepted for processing, but the processing has not been completed


Indicates the request was successful, but the corresponding response will not be received


The address resolved to one of several options for the user or client to choose between, which are listed in the message body or the message's Contact fields


The original Request-URI is no longer valid, the new address is given in the Contact header field, and the client should update any records of the original Request-URI with the new value


The client should try at the address in the Contact field. If an Expires field is present, the client may cache the result for that period of time


The Contact field details a proxy that must be used to access the requested destination


The call failed, but alternatives are detailed in the message body


The request could not be understood due to malformed syntax


The request requires user authentication. This response is issued by UASs and registrars


Reserved for future use


The server understood the request, but is refusing to fulfill it


The server has definitive information that the user does not exist at the domain specified in the Request-URI. This status is also returned if the domain in the Request-URI does not match any of the domains handled by the recipient of the request


The method specified in the Request-Line is understood, but not allowed for the address identified by the Request-URI


The resource identified by the request is only capable of generating response entities that have content characteristics but not acceptable according to the Accept header field sent in the request


The request requires user authentication. This response is issued by proxys


Couldn't find the user in time. The server could not produce a response within a suitable amount of time, for example, if it could not determine the location of the user in time. The client MAY repeat the request without modifications at any later time


User already registered


The user existed once, but is not available here any more


The server will not accept the request without a valid Content-Length


The given precondition has not been met


Request body too large


The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret


Request body in a format not supported


Request-URI is unknown to the server


There was a resource-priority option tag, but no Resource-Priority header


Bad SIP Protocol Extension used, not understood by the server


The server needs a specific extension not listed in the Supported header


The received request contains a Session-Expires header field with a duration below the minimum timer


Expiration time of the resource is too short


The request's location content was malformed or otherwise unsatisfactory


The server policy requires an Identity header, and one has not been provided


The server did not receive a valid Referred-By token on the request


A specific flow to a user agent has failed, although other flows may succeed. This response is intended for use between proxy devices, and should not be seen by an endpoint (and if it is seen by one, should be treated as a 400 Bad Request response)


The request has been rejected because it was anonymous


The request has an Identity-Info header, and the URI scheme in that header cannot be dereferenced


The server was unable to validate a certificate for the domain that signed the request


The server obtained a valid certificate that the request claimed was used to sign the request, but was unable to verify that signature


The first outbound proxy the user is attempting to register through does not support the "outbound" feature of RFC 5626, although the registrar does


If a SIP proxy determines a response context has insufficient Incoming Max-Breadth to carry out a desired parallel fork, and the proxy is unwilling/unable to compensate by forking serially or sending a redirect, that proxy MUST return a 440 response. A client receiving a 440 response can infer that its request did not reach all possible destinations


If a SIP UA receives an INFO request associated with an Info Package that the UA has not indicated willingness to receive, the UA MUST send a 469 response, which contains a Recv-Info header field with Info Packages for which the UA is willing to receive INFO requests


The source of the request did not have the permission of the recipient to make such a request


Callee currently unavailable


Server received a request that does not match any dialog or transaction


Server has detected a loop


Max-Forwards header has reached the value '0'


Request-URI incomplete


Request-URI is ambiguous


Callee is busy


Request has terminated by bye or cancel


Some aspect of the session description or the Request-URI is not acceptable


The server did not understand an event package specified in an Event header field


Server has some pending request from the same dialog


Request contains an encrypted MIME body, which recipient can not decrypt


The server has received a request that requires a negotiated security mechanism, and the response contains a list of suitable security mechanisms for the requester to choose between, or a digest authentication challenge


The server could not fulfill the request due to some unexpected condition


The server does not have the ability to fulfill the request, such as because it does not recognize the request method. (Compare with 405 Method Not Allowed, where the server recognizes the method but does not allow or support it.)


The server is acting as a gateway or proxy, and received an invalid response from a downstream server while attempting to fulfill the request


The server is undergoing maintenance or is temporarily overloaded and so cannot process the request. A "Retry-After" header field may specify when the client may reattempt its request


The server attempted to access another server in attempting to process the request, and did not receive a prompt response


The SIP protocol version in the request is not supported by the server


The request message length is longer than the server can process


The server is unable or unwilling to meet some constraints specified in the offer


All possible destinations are busy. Unlike the 486 response, this response indicates the destination knows there are no alternative destinations (such as a voicemail server) able to accept the call


The destination does not wish to participate in the call, or cannot do so, and additionally the destination knows there are no alternative destinations (such as a voicemail server) willing to accept the call


The server has authoritative information that the requested user does not exist anywhere


The user's agent was contacted successfully but some aspects of the session description such as the requested media, bandwidth, or addressing style were not acceptable


The called party did not want this call from the calling party. Future attempts from the calling party are likely to be similarly rejected


Unknown SIP status code

Constructor & Destructor Documentation

◆ SipResponseLayer() [1/3]

pcpp::SipResponseLayer::SipResponseLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 

A constructor that creates the layer from an existing packet raw data

[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ SipResponseLayer() [2/3]

pcpp::SipResponseLayer::SipResponseLayer ( SipResponseLayer::SipResponseStatusCode  statusCode,
std::string  statusCodeString = "",
std::string  sipVersion = "SIP/2.0" 

A constructor that allocates a new SIP response with only the first line filled. The request will be created without further fields. The user can then add fields using addField() or insertField() methods

[in]statusCodeSIP status code to set
[in]statusCodeStringMost status codes have their default string, e.g 200 is usually "OK" etc. But the user can set a non-default status code string and it will be written in the header first line. Empty string ("") means using the default status code string. Also, the default is using the default status code string
[in]sipVersionSIP version to set, default is SIP/2.0

◆ SipResponseLayer() [3/3]

pcpp::SipResponseLayer::SipResponseLayer ( const SipResponseLayer other)

A copy constructor for this layer. This copy constructor inherits base copy constructor SipLayer and adds the functionality of copying the first line as well

[in]otherThe instance to copy from

Member Function Documentation

◆ getFirstLine()

SipResponseFirstLine* pcpp::SipResponseLayer::getFirstLine ( ) const
A pointer to the first line instance for this message

◆ operator=()

SipResponseLayer& pcpp::SipResponseLayer::operator= ( const SipResponseLayer other)

An assignment operator overload for this layer. This method inherits base assignment operator SipLayer::operator=() and adds the functionality of copying the first line as well

[in]otherThe instance to copy from

◆ toString()

std::string pcpp::SipResponseLayer::toString ( ) const
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.