|
Yate
|
A container and parser for SIP messages. More...
#include <yatesip.h>
Public Types | |
| enum | Flags { Defaults = 0 , NotReqRport = 0x0001 , NotAddAllow = 0x0002 , NotAddAgent = 0x0004 , RportAfterBranch = 0x0008 , NotSetRport = 0x0010 , NotSetReceived = 0x0020 , NoConnReuse = 0x0040 , NoTagFailure = 0x0080 } |
Public Member Functions | |
| 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) |
| SIPParty * | getParty () const |
| void | setParty (SIPParty *ep=0) |
| bool | isValid () const |
| bool | isAnswer () const |
| bool | isOutgoing () const |
| bool | isACK () const |
| bool | isReliable () const |
| int32_t | getCSeq () const |
| void | setCSeq (int32_t cseq) |
| int | getFlags () const |
| bool | dontSend () const |
| void | dontSend (bool val) |
| 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 |
| void | addHeader (const char *name, const char *value=0) |
| void | addHeader (MimeHeaderLine *line) |
| void | clearHeaders (const char *name) |
| 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 |
| void | setAutoAuth (const char *username=0, const char *password=0) |
| const String & | getAuthUsername () const |
| const String & | getAuthPassword () const |
| ObjList * | getRoutes () const |
| void | addRoutes (const ObjList *routes) |
| SIPSequence * | getSequence () const |
| void | setSequence (SIPSequence *seq) |
| const DataBlock & | getBuffer () const |
| const String & | getHeaders () const |
| void | setBody (MimeBody *newbody=0) |
| const String & | traceId () const |
Public Member Functions inherited from RefObject | |
| RefObject () | |
| virtual | ~RefObject () |
| virtual void * | getObject (const String &name) const |
| virtual bool | alive () const |
| bool | ref () |
| bool | deref () |
| int | refcount () const |
| virtual void | destruct () |
Public Member Functions inherited from GenObject | |
| GenObject () | |
| virtual | ~GenObject () |
| virtual const String & | toString () const |
| NamedCounter * | getObjCounter () const |
| NamedCounter * | setObjCounter (NamedCounter *counter) |
Static Public Member Functions | |
| static SIPMessage * | fromParsing (SIPParty *ep, const char *buf, int len=-1, unsigned int *bodyLen=0) |
Static Public Member Functions inherited from RefObject | |
| static bool | alive (const RefObject *obj) |
| static bool | efficientIncDec () |
Static Public Member Functions inherited from GenObject | |
| static void * | getObject (const String &name, const GenObject *obj) |
| static bool | getObjCounting () |
| static void | setObjCounting (bool enable) |
| static NamedCounter * | getObjCounter (const String &name, bool create=true) |
| static ObjList & | getObjCounters () |
Public Attributes | |
| String | version |
| String | method |
| String | uri |
| int | code |
| String | reason |
| ObjList | header |
| MimeBody * | body |
| String | msgTraceId |
| bool | msgPrint |
Protected Member Functions | |
| bool | parse (const char *buf, int len, unsigned int *bodyLen) |
| bool | parseFirst (String &line) |
Protected Member Functions inherited from RefObject | |
| virtual void | zeroRefs () |
| bool | resurrect () |
| virtual void | destroyed () |
Protected Attributes | |
| SIPParty * | m_ep |
| RefPointer< SIPSequence > | m_seq |
| bool | m_valid |
| bool | m_answer |
| bool | m_outgoing |
| bool | m_ack |
| int32_t | m_cseq |
| int | m_flags |
| String | m_string |
| DataBlock | m_data |
| String | m_authUser |
| String | m_authPass |
| bool | m_dontSend |
A container and parser for SIP messages.
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 |
Various message flags
| SIPMessage | ( | const SIPMessage & | original | ) |
Copy constructor
References SIPMessage().
Referenced by buildAuth(), copyAllHeaders(), copyHeader(), fromParsing(), SIPMessage(), SIPMessage(), and SIPMessage().
| SIPMessage | ( | const char * | _method, |
| const char * | _uri, | ||
| const char * | _version = "SIP/2.0" ) |
Creates a new, empty, outgoing SIPMessage.
| SIPMessage | ( | SIPParty * | ep, |
| const char * | buf, | ||
| int | len = -1, | ||
| unsigned int * | bodyLen = 0 ) |
Creates a new SIPMessage from parsing a text buffer.
| 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 ) |
Creates a new SIPMessage as answer to another message.
References SIPMessage().
| SIPMessage | ( | const SIPMessage * | original, |
| const SIPMessage * | answer ) |
Creates an ACK message from an original message and a response.
References SIPMessage().
|
virtual |
Destroy the message and all
|
inline |
Append a new header line constructed from name and content
| name | Name of the header to add |
| value | Content of the new header line |
References header.
Referenced by setHeader().
|
inline |
| void addRoutes | ( | const ObjList * | routes | ) |
Add Route: headers to an outgoing message
| routes | List of MimeHeaderLine representing SIP routes |
| MimeAuthLine * buildAuth | ( | const SIPMessage & | original, |
| SIPEngine * | engine = 0 ) const |
Construct a new authorization line based on this answer and original message
| original | Origianl outgoing message |
| engine | Optional engine processing this message |
References SIPMessage().
| MimeAuthLine * buildAuth | ( | const String & | username, |
| const String & | password, | ||
| const String & | meth, | ||
| const String & | uri, | ||
| bool | proxy = false, | ||
| SIPEngine * | engine = 0 ) const |
Construct a new authorization line based on credentials and challenge
| 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 |
References uri.
| void buildBody | ( | const char * | buf, |
| int | len = -1 ) |
Build message's body. Reset it before. This method should be called after parsing a partial message (headers only)
| buf | Buffer to parse |
| len | Optional buffer length |
| void clearHeaders | ( | const char * | name | ) |
Clear all header lines that match a name
| name | Name of the header to clear |
Referenced by setHeader().
| void complete | ( | SIPEngine * | engine, |
| const char * | user = 0, | ||
| const char * | domain = 0, | ||
| const char * | dlgTag = 0, | ||
| int | flags = -1 ) |
Complete missing fields with defaults taken from a SIP engine
| 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 |
| int copyAllHeaders | ( | const SIPMessage * | message, |
| const char * | name, | ||
| const char * | newName = 0 ) |
Copy multiple header lines (including all parameters) from another message
| 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 |
References SIPMessage().
| bool copyHeader | ( | const SIPMessage * | message, |
| const char * | name, | ||
| const char * | newName = 0 ) |
Copy an entire header line (including all parameters) from another message
| 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 |
References SIPMessage().
| int countHeaders | ( | const char * | name | ) | const |
Count the header lines matching a specific name
| name | Name of the header to locate |
|
inline |
Get value of flag that specifies the message is not to be sent on wire
|
inline |
Set flag that specifies the message is not to be sent on wire
| val | Value of the flag to send |
|
static |
Construct a new SIP message by parsing a text buffer
| 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 |
References SIPMessage().
|
inline |
Retrieve the password to be used for auto authentication
|
inline |
Retrieve the username to be used for auto authentication
| const DataBlock & getBuffer | ( | ) | const |
Creates a binary buffer from a SIPMessage.
|
inline |
Get the Command Sequence number from this message
Referenced by SIPDialog::adjustCSeq().
|
inline |
Get the last flags used by this message
| const MimeHeaderLine * getHeader | ( | const char * | name | ) | const |
Find a header line by name
| name | Name of the header to locate |
| const String & getHeaders | ( | ) | const |
Creates a text buffer from the headers.
| const String & getHeaderValue | ( | const char * | name, |
| bool | last = false ) const |
Get a string value (without parameters) from a header line
| name | Name of the header to locate |
| last | Find the last header with that name instead of first |
| const MimeHeaderLine * getLastHeader | ( | const char * | name | ) | const |
Find the last header line that matches a given name name
| name | Name of the header to locate |
| const NamedString * getParam | ( | const char * | name, |
| const char * | param, | ||
| bool | last = false ) const |
Find a header parameter by name
| 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 |
| const String & getParamValue | ( | const char * | name, |
| const char * | param, | ||
| bool | last = false ) const |
Get a string value from a parameter in a header line
| 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 |
|
inline |
Get the endpoint this message uses
| ObjList * getRoutes | ( | ) | const |
Extract routes from Record-Route: headers
|
inline |
Get the Command Sequence Number generator
|
inline |
Check if this message is an ACK message
|
inline |
Check if this message is an answer or a request
|
inline |
Check if this message is an outgoing message
|
inline |
Check if this message is handled by a reliable protocol
|
inline |
Check if this message is valid as result of the parsing
|
inline |
Prepare the message for automatic client transaction authentication.
| username | Username for auto authentication |
| password | Password for auto authentication |
| void setBody | ( | MimeBody * | newbody = 0 | ) |
Set a new body for this message
|
inline |
Set the Command Sequence number for this message
| cseq | Sequence number for this message |
|
inline |
Set a header line constructed from name and content
References addHeader(), and clearHeaders().
| void setParty | ( | SIPParty * | ep = 0 | ) |
Set the endpoint this message uses
| ep | Pointer to the endpoint of this message |
|
inline |
Set the Command Sequence Number generator
| seq | Pointer to the new CSeq generator of this message |
|
inlinevirtual |
Get trace ID of the message
Reimplemented from GenObject.
References msgTraceId.
| MimeBody* body |
All the body related things should be here, including the entire body and the parsed body.
| int code |
Status code
| ObjList header |
All the headers should be in this list.
Referenced by addHeader(), and addHeader().
| String method |
This holds the method name of the message.
| bool msgPrint |
Message print in debug
| String reason |
Reason Phrase
| String uri |
URI of the request
Referenced by buildAuth().
| String version |
Sip Version