# class SIPMessage | A container and parser for SIP messages. More...
Full name | `TelEngine::SIPMessage`
Definition | `#include <libs/ysip/yatesip.h>`
Inherits | TelEngine::RefObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Flags { Defaults = 0, NotReqRport = 0x0001, NotAddAllow = 0x0002, NotAddAgent = 0x0004, RportAfterBranch = 0x0008, NotSetRport = 0x0010, NotSetReceived = 0x0020, NoConnReuse = 0x0040, }

#### Public Methods

- SIPMessage (const SIPMessage& original)
- SIPMessage (const char* _method, const char* _uri, const char* _version = "SIP/2.0")
- SIPMessage (SIPParty* ep, const char* buf, int len = -1, unsigned int* bodyLen = 0)
- SIPMessage (const SIPMessage* message, int _code, const char* _reason = 0)
- SIPMessage (const SIPMessage* original, const SIPMessage* answer)
- virtual ~SIPMessage ()
- void buildBody (const char* buf, int len = -1)
- void complete (SIPEngine* engine, const char* user = 0, const char* domain = 0, const char* dlgTag = 0, int flags = -1)
- bool copyHeader (const SIPMessage* message, const char* name, const char* newName = 0)
- int copyAllHeaders (const SIPMessage* message, const char* name, const char* newName = 0)
- inline SIPParty* getParty () const
- void setParty (SIPParty* ep = 0)
- inline bool isValid () const
- inline bool isAnswer () const
- inline bool isOutgoing () const
- inline bool isACK () const
- inline bool isReliable () const
- inline int getCSeq () const
- inline int getFlags () const
- const MimeHeaderLine* getHeader (const char* name) const
- const MimeHeaderLine* getLastHeader (const char* name) const
- int countHeaders (const char* name) const
- const NamedString* getParam (const char* name, const char* param, bool last = false) const
- const String& getHeaderValue (const char* name, bool last = false) const
- const String& getParamValue (const char* name, const char* param, bool last = false) const
- inline void addHeader (const char* name, const char* value = 0)
- inline void addHeader (MimeHeaderLine* line)
- void clearHeaders (const char* name)
- inline void setHeader (const char* name, const char* value = 0)
- MimeAuthLine* buildAuth (const String& username, const String& password, const String& meth, const String& uri, bool proxy = false, SIPEngine* engine = 0) const
- MimeAuthLine* buildAuth (const SIPMessage& original, SIPEngine* engine = 0) const
- inline void setAutoAuth (const char* username = 0, const char* password = 0)
- inline const String& getAuthUsername () const
- inline const String& getAuthPassword () const
- ObjList* getRoutes () const
- void addRoutes (const ObjList* routes)
- const DataBlock& getBuffer () const
- const String& getHeaders () const
- void setBody (MimeBody* newbody = 0)

#### Public Static Methods

- static SIPMessage* fromParsing (SIPParty* ep, const char* buf, int len = -1, unsigned int* bodyLen = 0)

#### Public Members

- String version
- String method
- String uri
- int code
- String reason
- ObjList header
- MimeBody* body

#### Protected Methods

- bool parse (const char* buf, int len, unsigned int* bodyLen)
- bool parseFirst (String& line)

#### Protected Members

- SIPParty* m_ep
- bool m_valid
- bool m_answer
- bool m_outgoing
- bool m_ack
- int m_cseq
- int m_flags
- mutable String m_string
- mutable DataBlock m_data
- String m_authUser
- String m_authPass

## Detailed Description

An object that holds the sip message parsed into this library model. This class can be used to parse a sip message from a text buffer, or it can be used to create a text buffer from a sip message.

enum Flags { Defaults = 0, NotReqRport = 0x0001, NotAddAllow = 0x0002, NotAddAgent = 0x0004, RportAfterBranch = 0x0008, NotSetRport = 0x0010, NotSetReceived = 0x0020, NoConnReuse = 0x0040, } | ### Flags

Various message flags

SIPMessage (const SIPMessage& original) | ### SIPMessage

Copy constructor

SIPMessage (const char* _method, const char* _uri, const char* _version = "SIP/2.0") | ### SIPMessage

Creates a new, empty, outgoing SIPMessage.

SIPMessage (SIPParty* ep, const char* buf, int len = -1, unsigned int* bodyLen = 0) | ### SIPMessage

Creates a new SIPMessage from parsing a text buffer.

Parameters:

ep | Party to set in message
buf | Buffer to parse
len | Optional buffer length
bodyLen | Pointer to body length to be set if the message was received on a stream transport. If not 0 the buffer must contain the message without its body

SIPMessage (const SIPMessage* message, int _code, const char* _reason = 0) | ### SIPMessage

Creates a new SIPMessage as answer to another message.

SIPMessage (const SIPMessage* original, const SIPMessage* answer) | ### SIPMessage

Creates an ACK message from an original message and a response.

~SIPMessage () | ### ~SIPMessage

[virtual]

Destroy the message and all

SIPMessage* fromParsing (SIPParty* ep, const char* buf, int len = -1, unsigned int* bodyLen = 0) | ### fromParsing

[static]

Construct a new SIP message by parsing a text buffer

Parameters:

ep | Party to set in message
buf | Buffer to parse
len | Optional buffer length
bodyLen | Pointer to body length to be set if the message was received on a stream transport. If not 0 the buffer must contain the message without its body

Returns: A pointer to a valid new message or NULL

void buildBody (const char* buf, int len = -1) | ### buildBody

Build message's body. Reset it before. This method should be called after parsing a partial message (headers only)

Parameters:

buf | Buffer to parse
len | Optional buffer length

void complete (SIPEngine* engine, const char* user = 0, const char* domain = 0, const char* dlgTag = 0, int flags = -1) | ### complete

Complete missing fields with defaults taken from a SIP engine

Parameters:

engine | Pointer to the SIP engine to use for extra parameters
user | Username to set in the From header instead of that in rURI
domain | Domain to use in From instead of the local IP address
dlgTag | Value of dialog tag parameter to set in To header
flags | Miscellaneous completion flags, -1 to take them from engine

bool copyHeader (const SIPMessage* message, const char* name, const char* newName = 0) | ### copyHeader

Copy an entire header line (including all parameters) from another message

Parameters:

message | Pointer to the message to copy the header from
name | Name of the header to copy
newName | New name to force in headers, NULL to just copy

Returns: True if the header was found and copied

int copyAllHeaders (const SIPMessage* message, const char* name, const char* newName = 0) | ### copyAllHeaders

Copy multiple header lines (including all parameters) from another message

Parameters:

message | Pointer to the message to copy the header from
name | Name of the headers to copy
newName | New name to force in headers, NULL to just copy

Returns: Number of headers found and copied

inline SIPParty* getParty () | ### getParty

[const]

Get the endpoint this message uses

Returns: Pointer to the endpoint of this message

void setParty (SIPParty* ep = 0) | ### setParty

Set the endpoint this message uses

Parameters:

ep | Pointer to the endpoint of this message

inline bool isValid () | ### isValid

[const]

Check if this message is valid as result of the parsing

inline bool isAnswer () | ### isAnswer

[const]

Check if this message is an answer or a request

inline bool isOutgoing () | ### isOutgoing

[const]

Check if this message is an outgoing message

Returns: True if this message should be sent to remote

inline bool isACK () | ### isACK

[const]

Check if this message is an ACK message

Returns: True if this message has an ACK method

inline bool isReliable () | ### isReliable

[const]

Check if this message is handled by a reliable protocol

Returns: True if a reliable protocol (TCP, SCTP) is used

inline int getCSeq () | ### getCSeq

[const]

Get the Command Sequence number from this message

Returns: Number part of CSEQ in this message

inline int getFlags () | ### getFlags

[const]

Get the last flags used by this message

Returns: Flags last used, ORed together

const MimeHeaderLine* getHeader (const char* name) | ### getHeader

[const]

Find a header line by name

Parameters:

name | Name of the header to locate

Returns: A pointer to the first matching header line or 0 if not found

const MimeHeaderLine* getLastHeader (const char* name) | ### getLastHeader

[const]

Find the last header line that matches a given name name

Parameters:

name | Name of the header to locate

Returns: A pointer to the last matching header line or 0 if not found

int countHeaders (const char* name) | ### countHeaders

[const]

Count the header lines matching a specific name

Parameters:

name | Name of the header to locate

Returns: Number of matching header lines

const NamedString* getParam (const char* name, const char* param, bool last = false) | ### getParam

[const]

Find a header parameter by name

Parameters:

name | Name of the header to locate
param | Name of the parameter to locate in the tag
last | Find the last header with that name instead of first

Returns: A pointer to the first matching header line or 0 if not found

const String& getHeaderValue (const char* name, bool last = false) | ### getHeaderValue

[const]

Get a string value (without parameters) from a header line

Parameters:

name | Name of the header to locate
last | Find the last header with that name instead of first

Returns: The value hold in the header or an empty String

const String& getParamValue (const char* name, const char* param, bool last = false) | ### getParamValue

[const]

Get a string value from a parameter in a header line

Parameters:

name | Name of the header to locate
param | Name of the parameter to locate in the tag
last | Find the last header with that name instead of first

Returns: The value hold in the parameter or an empty String

inline void addHeader (const char* name, const char* value = 0) | ### addHeader

Append a new header line constructed from name and content

Parameters:

name | Name of the header to add
value | Content of the new header line

inline void addHeader (MimeHeaderLine* line) | ### addHeader

Append an already constructed header line

Parameters:

line | Header line to add

void clearHeaders (const char* name) | ### clearHeaders

Clear all header lines that match a name

Parameters:

name | Name of the header to clear

inline void setHeader (const char* name, const char* value = 0) | ### setHeader

Set a header line constructed from name and content

MimeAuthLine* buildAuth (const String& username, const String& password, const String& meth, const String& uri, bool proxy = false, SIPEngine* engine = 0) | ### buildAuth

[const]

Construct a new authorization line based on credentials and challenge

Parameters:

username | User account name
password | Clear text password for the account
meth | Method to include in the authorization digest
uri | URI to include in the authorization digest
proxy | Set to true to authenticate to a proxy, false to a server
engine | Optional engine processing this message

Returns: A new authorization line to be used in a new transaction

MimeAuthLine* buildAuth (const SIPMessage& original, SIPEngine* engine = 0) | ### buildAuth

[const]

Construct a new authorization line based on this answer and original message

Parameters:

original | Origianl outgoing message
engine | Optional engine processing this message

Returns: A new authorization line to be used in a new transaction

inline void setAutoAuth (const char* username = 0, const char* password = 0) | ### setAutoAuth

Prepare the message for automatic client transaction authentication.

Parameters:

username | Username for auto authentication
password | Password for auto authentication

inline const String& getAuthUsername () | ### getAuthUsername

[const]

Retrieve the username to be used for auto authentication

Returns: Username for auto authentication

inline const String& getAuthPassword () | ### getAuthPassword

[const]

Retrieve the password to be used for auto authentication

Returns: Password for auto authentication

ObjList* getRoutes () | ### getRoutes

[const]

Extract routes from Record-Route: headers

Returns: A list of MimeHeaderLine representing SIP routes

void addRoutes (const ObjList* routes) | ### addRoutes

Add Route: headers to an outgoing message

Parameters:

routes | List of MimeHeaderLine representing SIP routes

const DataBlock& getBuffer () | ### getBuffer

[const]

Creates a binary buffer from a SIPMessage.

const String& getHeaders () | ### getHeaders

[const]

Creates a text buffer from the headers.

void setBody (MimeBody* newbody = 0) | ### setBody

Set a new body for this message

String version | ### version

String method | ### method

String uri | ### uri

int code | ### code

String reason | ### reason

ObjList header | ### header

MimeBody* body | ### body

bool parse (const char* buf, int len, unsigned int* bodyLen) | ### parse

[protected]

All the body related things should be here, including the entire body and the parsed body.

bool parseFirst (String& line) | ### parseFirst

[protected]

SIPParty* m_ep | ### m_ep

[protected]

bool m_valid | ### m_valid

[protected]

bool m_answer | ### m_answer

[protected]

bool m_outgoing | ### m_outgoing

[protected]

bool m_ack | ### m_ack

[protected]

int m_cseq | ### m_cseq

[protected]

int m_flags | ### m_flags

[protected]

mutable String m_string | ### m_string

[protected]

mutable DataBlock m_data | ### m_data

[protected]

String m_authUser | ### m_authUser

[protected]

String m_authPass | ### m_authPass

[protected]

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.