14 #define PCPP_SIP_FROM_FIELD "From"
16 #define PCPP_SIP_TO_FIELD "To"
18 #define PCPP_SIP_VIA_FIELD "Via"
20 #define PCPP_SIP_CALL_ID_FIELD "Call-ID"
22 #define PCPP_SIP_CONTENT_TYPE_FIELD "Content-Type"
24 #define PCPP_SIP_CONTENT_LENGTH_FIELD "Content-Length"
26 #define PCPP_SIP_CONTENT_DISPOSITION_FIELD "Content-Disposition"
28 #define PCPP_SIP_CONTENT_ENCODING_FIELD "Content-Encoding"
30 #define PCPP_SIP_CONTENT_LANGUAGE_FIELD "Content-Language"
32 #define PCPP_SIP_CSEQ_FIELD "CSeq"
34 #define PCPP_SIP_CONTACT_FIELD "Contact"
36 #define PCPP_SIP_MAX_FORWARDS_FIELD "Max-Forwards"
38 #define PCPP_SIP_USER_AGENT_FIELD "User-Agent"
40 #define PCPP_SIP_ACCEPT_FIELD "Accept"
42 #define PCPP_SIP_ACCEPT_ENCODING_FIELD "Accept-Encoding"
44 #define PCPP_SIP_ACCEPT_LANGUAGE_FIELD "Accept-Language"
46 #define PCPP_SIP_ALLOW_FIELD "Allow"
48 #define PCPP_SIP_AUTHORIZATION_FIELD "Authorization"
50 #define PCPP_SIP_DATE_FIELD "Date"
52 #define PCPP_SIP_MIME_VERSION_FIELD "MIME-Version"
54 #define PCPP_SIP_REASON_FIELD "Reason"
56 #define PCPP_SIP_SUPPORTED_FIELD "Supported"
58 #define PCPP_SIP_SERVER_FIELD "Server"
60 #define PCPP_SIP_WWW_AUTHENTICATE_FIELD "WWW-Authenticate"
62 #define PCPP_SIP_RETRY_AFTER_FIELD "Retry-After"
64 #define PCPP_SIP_RECORD_ROUTE_FIELD "Record-Route"
114 return port == 5060 || port == 5061;
127 uint16_t srcPort, uint16_t dstPort);
145 SipLayer(
const SipLayer& other) : TextBasedProtocolMessage(other)
147 SipLayer& operator=(
const SipLayer& other)
149 TextBasedProtocolMessage::operator=(other);
154 char getHeaderFieldNameValueSeparator()
const override
158 bool spacesAllowedBetweenHeaderFieldNameAndValue()
const override
164 enum class SipParseResult
171 static SipParseResult detectSipMessageType(
const uint8_t* data,
size_t dataLen);
174 class SipRequestFirstLine;
491 const std::string& sipVersion =
"SIP/2.0");
580 static std::pair<bool, SipFirstLineData>
parseFirstLine(
const char* data,
size_t dataLen);
585 return m_FirstLineEndOffset;
606 void setMessage(
const std::string& message)
610 virtual const char* what()
const noexcept
612 return m_Message.c_str();
616 std::string m_Message;
622 const std::string& uri);
628 std::string m_Version;
631 int m_FirstLineEndOffset;
705 static std::pair<bool, FirstLineData>
parseFirstLine(
const char* data,
size_t dataLen);
710 return m_FirstLineEndOffset;
731 void setMessage(
const std::string& message)
735 virtual const char* what()
const noexcept
737 return m_Message.c_str();
741 std::string m_Message;
750 std::string m_Version;
752 int m_FirstLineEndOffset;
Definition: SipLayer.h:70
static SipLayer * parseSipLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet, uint16_t srcPort, uint16_t dstPort)
static SipLayer * parseSipLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
void computeCalculateFields() override
OsiModelLayer getOsiModelLayer() const override
Definition: SipLayer.h:96
HeaderField * setContentLength(int contentLength, const std::string &prevFieldName="")
static bool isSipPort(uint16_t port)
Definition: SipLayer.h:112
int getContentLength() const
void parseNextLayer() override
Definition: SipLayer.h:602
Definition: SipLayer.h:529
static std::pair< bool, SipFirstLineData > parseFirstLine(const char *data, size_t dataLen)
std::string getVersion() const
Definition: SipLayer.h:564
bool setUri(const std::string &newUri)
bool isComplete() const
Definition: SipLayer.h:592
std::string getUri() const
int getSize() const
Definition: SipLayer.h:583
bool setMethod(SipRequestLayer::SipMethod newMethod)
static SipRequestLayer::SipMethod parseMethod(const char *data, size_t dataLen)
SipRequestLayer::SipMethod getMethod() const
Definition: SipLayer.h:543
Definition: SipLayer.h:184
SipRequestLayer(const SipRequestLayer &other)
SipRequestLayer & operator=(const SipRequestLayer &other)
SipRequestFirstLine * getFirstLine() const
Definition: SipLayer.h:250
SipRequestLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
std::string toString() const override
SipRequestLayer(SipMethod method, const std::string &requestUri, const std::string &version="SIP/2.0")
SipMethod
SIP request methods.
Definition: SipLayer.h:190
@ SipMESSAGE
MESSAGE.
Definition: SipLayer.h:216
@ SipSUBSCRIBE
SUBSCRIBE.
Definition: SipLayer.h:206
@ SipINFO
INFO.
Definition: SipLayer.h:212
@ SipUPDATE
UPDATE.
Definition: SipLayer.h:218
@ SipPUBLISH
PUBLISH.
Definition: SipLayer.h:210
@ SipCANCEL
CANCEL.
Definition: SipLayer.h:198
@ SipINVITE
INVITE.
Definition: SipLayer.h:192
@ SipNOTIFY
NOTIFY.
Definition: SipLayer.h:208
@ SipPRACK
PRACK.
Definition: SipLayer.h:202
@ SipOPTIONS
OPTIONS.
Definition: SipLayer.h:204
@ SipREGISTER
REFISTER.
Definition: SipLayer.h:200
@ SipMethodUnknown
Unknown SIP method.
Definition: SipLayer.h:220
@ SipACK
ACK.
Definition: SipLayer.h:194
@ SipREFER
REFER.
Definition: SipLayer.h:214
@ SipBYE
BYE.
Definition: SipLayer.h:196
Definition: SipLayer.h:727
Definition: SipLayer.h:646
static SipResponseLayer::SipResponseStatusCode parseStatusCode(const char *data, size_t dataLen)
static std::string parseVersion(const char *data, size_t dataLen)
bool setStatusCode(SipResponseLayer::SipResponseStatusCode newStatusCode, std::string statusCodeString="")
static std::pair< bool, FirstLineData > parseFirstLine(const char *data, size_t dataLen)
A static method for parsing the complete SIP response first line from raw data.
SipResponseLayer::SipResponseStatusCode getStatusCode() const
Definition: SipLayer.h:660
int getStatusCodeAsInt() const
void setVersion(const std::string &newVersion)
int getSize() const
Definition: SipLayer.h:708
bool isComplete() const
Definition: SipLayer.h:717
std::string getVersion() const
Definition: SipLayer.h:679
std::string getStatusCodeString() const
Definition: SipLayer.h:273
SipResponseStatusCode
Definition: SipLayer.h:280
@ Sip416UnsupportedURIScheme
Request-URI is unknown to the server.
Definition: SipLayer.h:355
@ Sip608Rejected
An intermediary machine or process rejected the call attempt.
Definition: SipLayer.h:470
@ Sip415UnsupportedMediaType
Request body in a format not supported.
Definition: SipLayer.h:353
@ Sip420BadExtension
Bad SIP Protocol Extension used, not understood by the server.
Definition: SipLayer.h:359
@ Sip428UseIdentityHeader
The server policy requires an Identity header, and one has not been provided.
Definition: SipLayer.h:372
@ Sip502BadGateway
Definition: SipLayer.h:438
@ Sip181CallisBeingForwarded
Servers can optionally send this response to indicate a call is being forwarded.
Definition: SipLayer.h:287
@ Sip503ServiceUnavailable
Definition: SipLayer.h:441
@ Sip183SessioninProgress
This response may be used to send extra information for a call which is still being set up.
Definition: SipLayer.h:292
@ Sip301MovedPermanently
Definition: SipLayer.h:307
@ Sip414RequestURITooLong
Definition: SipLayer.h:351
@ Sip555PushNotificationServiceNotSupported
Definition: SipLayer.h:451
@ Sip504ServerTimeout
Definition: SipLayer.h:444
@ Sip380AlternativeService
The call failed, but alternatives are detailed in the message body.
Definition: SipLayer.h:314
@ Sip600BusyEverywhere
Definition: SipLayer.h:456
@ Sip202Accepted
Indicates that the request has been accepted for processing, but the processing has not been complete...
Definition: SipLayer.h:299
@ Sip500ServerInternalError
The server could not fulfill the request due to some unexpected condition.
Definition: SipLayer.h:431
@ Sip493Undecipherable
Request contains an encrypted MIME body, which recipient can not decrypt.
Definition: SipLayer.h:425
@ Sip412ConditionalRequestFailed
The given precondition has not been met.
Definition: SipLayer.h:346
@ Sip402PaymentRequired
Reserved for future use.
Definition: SipLayer.h:320
@ Sip436BadIdentityInfo
The request has an Identity-Info header, and the URI scheme in that header cannot be dereferenced.
Definition: SipLayer.h:382
@ Sip422SessionIntervalTooSmall
The received request contains a Session-Expires header field with a duration below the minimum timer.
Definition: SipLayer.h:363
@ Sip406NotAcceptable
Definition: SipLayer.h:332
@ Sip180Ringing
Destination user agent received INVITE, and is alerting user of call.
Definition: SipLayer.h:285
@ Sip470ConsentNeeded
The source of the request did not have the permission of the recipient to make such a request.
Definition: SipLayer.h:401
@ Sip199EarlyDialogTerminated
Definition: SipLayer.h:295
@ Sip305UseProxy
The Contact field details a proxy that must be used to access the requested destination.
Definition: SipLayer.h:312
@ Sip604DoesNotExistAnywhere
The server has authoritative information that the requested user does not exist anywhere.
Definition: SipLayer.h:462
@ Sip424BadLocationInformation
The request's location content was malformed or otherwise unsatisfactory.
Definition: SipLayer.h:367
@ Sip400BadRequest
The request could not be understood due to malformed syntax.
Definition: SipLayer.h:316
@ Sip486BusyHere
Callee is busy.
Definition: SipLayer.h:415
@ Sip484AddressIncomplete
Request-URI incomplete.
Definition: SipLayer.h:411
@ Sip413RequestEntityTooLarge
Request body too large.
Definition: SipLayer.h:348
@ Sip433AnonymityDisallowed
The request has been rejected because it was anonymous.
Definition: SipLayer.h:380
@ Sip501NotImplemented
Definition: SipLayer.h:435
@ Sip491RequestPending
Server has some pending request from the same dialog.
Definition: SipLayer.h:423
@ Sip429ProvideReferrerIdentity
The server did not receive a valid Referred-By token on the request.
Definition: SipLayer.h:374
@ Sip408RequestTimeout
Definition: SipLayer.h:338
@ Sip603Decline
Definition: SipLayer.h:460
@ Sip440MaxBreadthExceeded
Definition: SipLayer.h:395
@ Sip439FirstHopLacksOutboundSupport
Definition: SipLayer.h:390
@ Sip480TemporarilyUnavailable
Callee currently unavailable.
Definition: SipLayer.h:403
@ Sip481Call_TransactionDoesNotExist
Server received a request that does not match any dialog or transaction.
Definition: SipLayer.h:405
@ Sip409Conflict
User already registered.
Definition: SipLayer.h:340
@ Sip606NotAcceptable
Definition: SipLayer.h:465
@ Sip403Forbidden
The server understood the request, but is refusing to fulfill it.
Definition: SipLayer.h:322
@ Sip421ExtensionRequired
The server needs a specific extension not listed in the Supported header.
Definition: SipLayer.h:361
@ Sip487RequestTerminated
Request has terminated by bye or cancel.
Definition: SipLayer.h:417
@ Sip404NotFound
Definition: SipLayer.h:326
@ Sip100Trying
Definition: SipLayer.h:283
@ Sip411LengthRequired
The server will not accept the request without a valid Content-Length.
Definition: SipLayer.h:344
@ Sip407ProxyAuthenticationRequired
The request requires user authentication. This response is issued by proxies.
Definition: SipLayer.h:334
@ Sip204NoNotification
Indicates the request was successful, but the corresponding response will not be received.
Definition: SipLayer.h:301
@ Sip494SecurityAgreementRequired
Definition: SipLayer.h:429
@ Sip437UnsupportedCertificate
The server was unable to validate a certificate for the domain that signed the request.
Definition: SipLayer.h:384
@ Sip488NotAcceptableHere
Some aspect of the session description or the Request-URI is not acceptable.
Definition: SipLayer.h:419
@ Sip417UnknownResourcePriority
There was a resource-priority option tag, but no Resource-Priority header.
Definition: SipLayer.h:357
@ Sip405MethodNotAllowed
Definition: SipLayer.h:329
@ SipStatusCodeUnknown
Unknown SIP status code.
Definition: SipLayer.h:472
@ Sip430FlowFailed
Definition: SipLayer.h:378
@ Sip469BadInfoPackage
Definition: SipLayer.h:399
@ Sip302MovedTemporarily
Definition: SipLayer.h:310
@ Sip489BadEvent
The server did not understand an event package specified in an Event header field.
Definition: SipLayer.h:421
@ Sip410Gone
The user existed once, but is not available here any more.
Definition: SipLayer.h:342
@ Sip300MultipleChoices
Definition: SipLayer.h:304
@ Sip482LoopDetected
Server has detected a loop.
Definition: SipLayer.h:407
@ Sip483TooManyHops
Max-Forwards header has reached the value '0'.
Definition: SipLayer.h:409
@ Sip513MessageTooLarge
The request message length is longer than the server can process.
Definition: SipLayer.h:448
@ Sip580PreconditionFailure
The server is unable or unwilling to meet some constraints specified in the offer.
Definition: SipLayer.h:453
@ Sip401Unauthorized
The request requires user authentication. This response is issued by UASs and registrars.
Definition: SipLayer.h:318
@ Sip438InvalidIdentityHeader
Definition: SipLayer.h:387
@ Sip485Ambiguous
Request-URI is ambiguous.
Definition: SipLayer.h:413
@ Sip607Unwanted
Definition: SipLayer.h:468
@ Sip425BadAlertMessage
Definition: SipLayer.h:370
@ Sip200OK
Indicates the request was successful.
Definition: SipLayer.h:297
@ Sip182Queued
Definition: SipLayer.h:290
@ Sip423IntervalTooBrief
Expiration time of the resource is too short.
Definition: SipLayer.h:365
@ Sip505VersionNotSupported
The SIP protocol version in the request is not supported by the server.
Definition: SipLayer.h:446
std::string toString() const override
SipResponseLayer(SipResponseLayer::SipResponseStatusCode statusCode, std::string statusCodeString="", const std::string &sipVersion="SIP/2.0")
SipResponseLayer & operator=(const SipResponseLayer &other)
SipResponseFirstLine * getFirstLine() const
Definition: SipLayer.h:506
SipResponseLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
SipResponseLayer(const SipResponseLayer &other)
Definition: TextBasedProtocol.h:105
uint8_t ProtocolType
Definition: ProtocolType.h:35
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:261
@ OsiModelSesionLayer
Session layer (layer 5)
Definition: ProtocolType.h:271
@ Unknown
Unknown ARP message type.
Definition: SipLayer.h:536
std::string uri
The Request-URI destination.
Definition: SipLayer.h:538
std::string method
The SIP method (e.g., INVITE, REGISTER, BYE)
Definition: SipLayer.h:537
std::string version
The SIP protocol version (e.g., SIP/2.0)
Definition: SipLayer.h:539
A structure containing parsed components from a SIP response first line.
Definition: SipLayer.h:652
SipResponseLayer::SipResponseStatusCode statusCode
The response status code number (e.g., 200, 100)
Definition: SipLayer.h:656
std::string version
The SIP protocol version (e.g., SIP/2.0)
Definition: SipLayer.h:654