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

Enumerator
Sip100Trying 

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

Sip180Ringing 

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

Sip181CallisBeingForwarded 

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

Sip182Queued 

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

Sip183SessioninProgress 

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

Sip199EarlyDialogTerminated 

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

Sip200OK 

Indicates the request was successful

Sip202Accepted 

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

Sip204NoNotification 

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

Sip300MultipleChoices 

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

Sip301MovedPermanently 

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

Sip302MovedTemporarily 

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

Sip305UseProxy 

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

Sip380AlternativeService 

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

Sip400BadRequest 

The request could not be understood due to malformed syntax

Sip401Unauthorized 

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

Sip402PaymentRequired 

Reserved for future use

Sip403Forbidden 

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

Sip404NotFound 

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

Sip405MethodNotAllowed 

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

Sip406NotAcceptable 

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

Sip407ProxyAuthenticationRequired 

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

Sip408RequestTimeout 

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

Sip409Conflict 

User already registered

Sip410Gone 

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

Sip411LengthRequired 

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

Sip412ConditionalRequestFailed 

The given precondition has not been met

Sip413RequestEntityTooLarge 

Request body too large

Sip414RequestURITooLong 

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

Sip415UnsupportedMediaType 

Request body in a format not supported

Sip416UnsupportedURIScheme 

Request-URI is unknown to the server

Sip417UnknownResourcePriority 

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

Sip420BadExtension 

Bad SIP Protocol Extension used, not understood by the server

Sip421ExtensionRequired 

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

Sip422SessionIntervalTooSmall 

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

Sip423IntervalTooBrief 

Expiration time of the resource is too short

Sip424BadLocationInformation 

The request's location content was malformed or otherwise unsatisfactory

Sip428UseIdentityHeader 

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

Sip429ProvideReferrerIdentity 

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

Sip430FlowFailed 

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)

Sip433AnonymityDisallowed 

The request has been rejected because it was anonymous

Sip436BadIdentityInfo 

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

Sip437UnsupportedCertificate 

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

Sip438InvalidIdentityHeader 

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

Sip439FirstHopLacksOutboundSupport 

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

Sip440MaxBreadthExceeded 

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

Sip469BadInfoPackage 

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

Sip470ConsentNeeded 

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

Sip480TemporarilyUnavailable 

Callee currently unavailable

Sip481Call_TransactionDoesNotExist 

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

Sip482LoopDetected 

Server has detected a loop

Sip483TooManyHops 

Max-Forwards header has reached the value '0'

Sip484AddressIncomplete 

Request-URI incomplete

Sip485Ambiguous 

Request-URI is ambiguous

Sip486BusyHere 

Callee is busy

Sip487RequestTerminated 

Request has terminated by bye or cancel

Sip488NotAcceptableHere 

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

Sip489BadEvent 

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

Sip491RequestPending 

Server has some pending request from the same dialog

Sip493Undecipherable 

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

Sip494SecurityAgreementRequired 

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

Sip500ServerInternalError 

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

Sip501NotImplemented 

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.)

Sip502BadGateway 

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

Sip503ServiceUnavailable 

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

Sip504ServerTimeout 

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

Sip505VersionNotSupported 

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

Sip513MessageTooLarge 

The request message length is longer than the server can process

Sip580PreconditionFailure 

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

Sip600BusyEverywhere 

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

Sip603Decline 

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

Sip604DoesNotExistAnywhere 

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

Sip606NotAcceptable 

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

Sip607Unwanted 

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

SipStatusCodeUnknown 

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

Parameters
[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

Parameters
[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

Parameters
[in]otherThe instance to copy from

Member Function Documentation

◆ getFirstLine()

SipResponseFirstLine* pcpp::SipResponseLayer::getFirstLine ( ) const
inline
Returns
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

Parameters
[in]otherThe instance to copy from

◆ toString()

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

Implements pcpp::Layer.