|
reSIProcate
SIP stack, Dialog Usage Manager and related libraries
|
An aggregation of useful static functions. More...
#include <Helper.hxx>
Classes | |
| struct | ContentsSecAttrs |
Public Types | |
| enum | AuthResult { Failed = 1 , Authenticated , Expired , BadlyFormed } |
| enum | FailureMessageEffect { DialogTermination , TransactionTermination , UsageTermination , RetryAfter , OptionalRetryAfter , ApplicationDependant } |
Static Public Member Functions | |
| template<typename T > | |
| static T | aBitSmallerThan (T secs) |
| Used by Registration, Publication and Subscription refreshes, to calculate the time at which a refresh should be performed (which is some time, that is a bit smaller than the Expiration interval). | |
| static void | integer2hex (char *_d, unsigned int _s, bool _l=true) |
| Converts an interger in a character string containing the hexidecimal representation of the integer. | |
| static unsigned int | hex2integer (const char *_s) |
| Converts a character string containing a hexidecimal value into an unsigned int. | |
| static int | jitterValue (int input, int lowerPercentage, int upperPercentage, int minimum=0) |
| Used to jitter the expires in a SUBSCRIBE or REGISTER expires header. | |
| static SipMessage * | makeRequest (const NameAddr &target, const NameAddr &from, const NameAddr &contact, MethodTypes method) |
| /////////////////////////////////////////////////////////////////////////////////////////// | |
| static SipMessage * | makeRequest (const NameAddr &target, const NameAddr &from, MethodTypes method) |
| Make a new request. | |
| static SipMessage * | makeRegister (const NameAddr &to, const NameAddr &from) |
| Create a Register request with an empty Contact. See makeRequest. | |
| static SipMessage * | makeRegister (const NameAddr &to, const NameAddr &from, const NameAddr &contact) |
| Create a Register request with an overriden Contact. See makeRequest. | |
| static SipMessage * | makeRegister (const NameAddr &to, const Data &transport) |
| Create a Register request with an empty Contact, transport is added to Request URI. See makeRequest. | |
| static SipMessage * | makeRegister (const NameAddr &to, const Data &transport, const NameAddr &contact) |
| Create a Register request with an overriden Contact, transport is added to Request URI. See makeRequest. | |
| static SipMessage * | makeInvite (const NameAddr &target, const NameAddr &from) |
| Make an invite request - Empty Contact and Via is added and will be populated by the stack when sent. | |
| static SipMessage * | makeInvite (const NameAddr &target, const NameAddr &from, const NameAddr &contact) |
| Make an invite request using a overridden contact header - Empty Via is added and will be populated by the stack when sent. | |
| static SipMessage * | makeCancel (const SipMessage &request) |
| Make a new Cancel request for the specified request. | |
| static SipMessage * | makeFailureAck (const SipMessage &request, const SipMessage &response) |
| This interface should be used by the stack (TransactionState) to create an AckMsg to a failure response. | |
| static SipMessage * | makePublish (const NameAddr &target, const NameAddr &from) |
| Create a Publish request with an empty Contact. See makeRequest. | |
| static SipMessage * | makePublish (const NameAddr &target, const NameAddr &from, const NameAddr &contact) |
| Create a Publish request with an overriden Contact. See makeRequest. | |
| static SipMessage * | makeMessage (const NameAddr &target, const NameAddr &from) |
| Create a Message request with an empty Contact. See makeRequest. | |
| static SipMessage * | makeMessage (const NameAddr &target, const NameAddr &from, const NameAddr &contact) |
| Create a Message request with an overriden Contact. See makeRequest. | |
| static SipMessage * | makeSubscribe (const NameAddr &target, const NameAddr &from) |
| Create a Subscribe request with an empty Contact. See makeRequest. | |
| static SipMessage * | makeSubscribe (const NameAddr &target, const NameAddr &from, const NameAddr &contact) |
| Create a Subscribe request with an overriden Contact. See makeRequest. | |
| static void | makeResponse (SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty) |
| Make a response to a provided request. | |
| static void | makeResponse (SipMessage &response, const SipMessage &request, int responseCode, const NameAddr &myContact, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty) |
| Make a response to a provided request with an overridden Contact. | |
| static SipMessage * | makeResponse (const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty) |
| Make a new response to a provided request. | |
| static SipMessage * | makeResponse (const SipMessage &request, int responseCode, const NameAddr &myContact, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty) |
| Make a new response to a provided request with an overridden Contact. | |
| static void | makeRawResponse (Data &rawBuffer, const SipMessage &request, int responseCode, const Data &additionalHeaders=Data::Empty, const Data &body=Data::Empty) |
| static SipMessage * | make405 (const SipMessage &request, const int *allowedMethods=0, int nMethods=-1) |
| Make a 405 response to a provided request. | |
| static void | getResponseCodeReason (int responseCode, Data &reason) |
| Returns the default reason string for a particular response code. | |
| static Data | computeUniqueBranch () |
| Creates and returns a unique branch parameter. | |
| static Data | computeCallId () |
| static Data | computeTag (int numBytes) |
| static void | setNonceHelper (NonceHelper *nonceHelper) |
| /////////////////////////////////////////////////////////////////////////////////////////// | |
| static NonceHelper * | getNonceHelper () |
| static Data | makeNonce (const SipMessage &request, const Data ×tamp) |
| static bool | isDigestAlgorithmSupported (const Auth &auth, DigestType &digestType) |
| static bool | isDigestAlgorithmSupported (const Data &algorithmName, DigestType &digestType) |
| static Data | createResipA1HashString (const Data &username, const Data &realm, const Data &password) |
| static Data | extractA1FromResipA1HashString (const Data &resipA1HashString, DigestType digestType) |
| static bool | isDigestTypeSupportedInResipA1HashString (const Data &resipA1HashString, DigestType digestType) |
| static AuthResult | authenticateRequest (const SipMessage &request, const Data &realm, const Data &password, int expiresDelta=0) |
| static AuthResult | authenticateRequestWithA1 (const SipMessage &request, const Data &realm, const Data &resipPasswordHashA1, int expiresDelta=0) |
| static AuthResult | authenticateRequest (const SipMessage &request, const Data &realm, const Data &passwordOrResipPasswordHashA1, int expiresDelta, bool isPasswordHashResipA1) |
| static std::pair< AuthResult, Data > | advancedAuthenticateRequest (const SipMessage &request, const Data &realm, const Data &resipPasswordHashA1, int expiresDelta=0, bool proxyAuthorization=true) |
| static SipMessage * | makeProxyChallenge (const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >()) |
| static SipMessage * | makeWWWChallenge (const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >()) |
| static SipMessage * | makeChallenge (const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, bool proxy=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >()) |
| static void | addChallenge (SipMessage &response, const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, bool proxy=false, DigestType digestType=MD5) |
| static Data | qopOption (const Auth &challenge) |
| static void | updateNonceCount (unsigned int &nonceCount, Data &nonceCountString) |
| static bool | algorithmAndQopSupported (const Auth &challenge) |
| static bool | algorithmAndQopSupported (const Auth &challenge, DigestType &digestType) |
| static SipMessage & | addAuthorization (SipMessage &request, const SipMessage &challenge, const Data &username, const Data &password, const Data &cnonce, unsigned int &nonceCount) |
| static Auth | makeChallengeResponseAuth (const SipMessage &request, const Data &username, const Data &password, const Auth &challenge, const Data &cnonce, unsigned int &nonceCount, Data &nonceCountString) |
| static void | makeChallengeResponseAuth (const SipMessage &request, const Data &username, const Data &password, const Auth &challenge, const Data &cnonce, const Data &authQop, const Data &nonceCountString, Auth &auth) |
| static Auth | makeChallengeResponseAuthWithA1 (const SipMessage &request, const Data &username, const Data &resipPasswordHashA1, const Auth &challenge, const Data &cnonce, unsigned int &nonceCount, Data &nonceCountString) |
| static void | makeChallengeResponseAuthWithA1 (const SipMessage &request, const Data &username, const Data &resipPasswordHashA1, const Auth &challenge, const Data &cnonce, const Data &authQop, const Data &nonceCountString, Auth &auth) |
| static Data | makeResponseMD5WithA1 (const Data &a1, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0) |
| static Data | makeResponseDigestWithA1 (const Data &a1, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0, DigestType digestType=MD5) |
| static Data | makeResponseMD5 (const Data &username, const Data &password, const Data &realm, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0) |
| static Data | makeResponseDigest (const Data &username, const Data &password, const Data &realm, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0, DigestType digestType=MD5) |
| static Uri | makeUri (const Data &aor, const Data &scheme=Symbols::DefaultSipScheme) |
| /////////////////////////////////////////////////////////////////////////////////////////// | |
| static void | processStrictRoute (SipMessage &request) |
| static int | getPortForReply (SipMessage &request) |
| static void | massageRoute (const SipMessage &request, NameAddr &route) |
| static Uri | fromAor (const Data &aor, const Data &scheme=Symbols::DefaultSipScheme) |
| static bool | validateMessage (const SipMessage &message, resip::Data *reason=0) |
| static Data | gruuUserPart (const Data &instanceId, const Data &aor, const Data &key) |
| static std::pair< Data, Data > | fromGruuUserPart (const Data &gruuUserPart, const Data &key) |
| static ContentsSecAttrs | extractFromPkcs7 (const SipMessage &message, Security &security) |
| static FailureMessageEffect | determineFailureMessageEffect (const SipMessage &response, const std::set< int > *additionalTransactionTerminatingResponses=NULL) |
| static SdpContents * | getSdpRecurse (Contents *tree) |
| static std::unique_ptr< SdpContents > | getSdp (Contents *tree) |
| static bool | isClientBehindNAT (const SipMessage &request, bool privateToPublicOnly=true) |
| Looks at SIP headers and message source for a mismatch to make an assumption that the sender is behind a NAT device. | |
| static Tuple | getClientPublicAddress (const SipMessage &request) |
| Look at Via headers, and find the first public IP address closest to the sending client. | |
Static Public Attributes | |
| static const int | tagSize = 4 |
| bytes in to-tag& from-tag, should prob. live somewhere else | |
An aggregation of useful static functions.
These are mostly involved with
Definition at line 37 of file Helper.hxx.
| Enumerator | |
|---|---|
| Failed | |
| Authenticated | |
| Expired | |
| BadlyFormed | |
Definition at line 425 of file Helper.hxx.
| Enumerator | |
|---|---|
| DialogTermination | |
| TransactionTermination | |
| UsageTermination | |
| RetryAfter | |
| OptionalRetryAfter | |
| ApplicationDependant | |
Definition at line 614 of file Helper.hxx.
|
inlinestatic |
Used by Registration, Publication and Subscription refreshes, to calculate the time at which a refresh should be performed (which is some time, that is a bit smaller than the Expiration interval).
The recommended calculation from the RFC's is the minimnum of the Exipiration interval less 5 seconds and nine tenths of the exipiration interval.
Definition at line 53 of file Helper.hxx.
|
static |
Definition at line 1368 of file Helper.cxx.
|
static |
Definition at line 1250 of file Helper.cxx.
|
static |
Definition at line 1071 of file Helper.cxx.
|
static |
Definition at line 1347 of file Helper.cxx.
|
static |
Definition at line 1354 of file Helper.cxx.
|
static |
Definition at line 875 of file Helper.cxx.
|
static |
Definition at line 894 of file Helper.cxx.
|
static |
Definition at line 884 of file Helper.cxx.
|
static |
Definition at line 690 of file Helper.cxx.
|
static |
Definition at line 713 of file Helper.cxx.
|
static |
Creates and returns a unique branch parameter.
Generated branch will contain the RFC3261 magic cookie + 4 randome hex characters + "C1" + 2 random hex characters.
Definition at line 679 of file Helper.cxx.
|
static |
Definition at line 783 of file Helper.cxx.
|
static |
Definition at line 2151 of file Helper.cxx.
|
static |
Definition at line 822 of file Helper.cxx.
|
static |
Definition at line 2124 of file Helper.cxx.
|
static |
Definition at line 1785 of file Helper.cxx.
|
static |
Definition at line 1955 of file Helper.cxx.
|
static |
Look at Via headers, and find the first public IP address closest to the sending client.
| request | Request message that we use for checking. |
Definition at line 2400 of file Helper.cxx.
|
static |
Definition at line 725 of file Helper.cxx.
|
static |
Definition at line 1741 of file Helper.cxx.
|
static |
Returns the default reason string for a particular response code.
| responseCode | Response code to get reason for |
| reason | Data where the reason string associated with the responseCode will be set. |
Definition at line 610 of file Helper.cxx.
|
static |
Definition at line 2339 of file Helper.cxx.
|
static |
Definition at line 2238 of file Helper.cxx.
Definition at line 1866 of file Helper.cxx.
|
static |
Converts a character string containing a hexidecimal value into an unsigned int.
Note: Parsing stops after the first non-hex character, or after 8 characters have been processed.
| _s | A pointer to the character buffer to convert. |
Definition at line 92 of file Helper.cxx.
|
static |
Converts an interger in a character string containing the hexidecimal representation of the integer.
Note: The string buffer provided should be at least 8 characters long. This function will NOT NULL terminate the string.
| _d | A pointer to the character buffer to write the hex string |
| _s | The integer value to convert. |
| _l | Boolean flag to include leading 0 zeros or not. |
Definition at line 52 of file Helper.cxx.
|
static |
Looks at SIP headers and message source for a mismatch to make an assumption that the sender is behind a NAT device.
| request | Request message that we use for checking. |
@privateToPublicOnly If enabled then we ensure that the via is private address and that the source was a public address. This allows us to ignore cases of private-private NAT'ing or false detections, when a server behind a load balancer is sending us requests and using the load balancer address in the Via, instead of the real of the adapter.
Definition at line 2357 of file Helper.cxx.
|
static |
Definition at line 742 of file Helper.cxx.
|
static |
Definition at line 756 of file Helper.cxx.
|
static |
Definition at line 856 of file Helper.cxx.
|
static |
Used to jitter the expires in a SUBSCRIBE or REGISTER expires header.
| input | Value to jitter |
| lowerPercentage | The lower range of the random percentage by which to jitter the value by. |
| upperPercentage | The upper range of the random percentage by which to jitter the value by. Must be greater than or equal to lowerPercentage |
| minimum | Only jitter the input if greater than minimum |
Definition at line 123 of file Helper.cxx.
|
static |
Make a 405 response to a provided request.
Allows header is added with specified methods, or with all methods the stack knows about. Caller owns the returned pointer and is responsible for deleting it.
| request | SipMessage request from which to generate the response |
| allowedMethods | Array of integers representing a list of Method Types to add to the generated Allows header. See MethodTypes.hxx. |
| nMethods | Number of methods specified in the allowedMethods integer array. Specify -1 to have this method fill in the Allows header automatically with each method supported by the stack. |
Definition at line 573 of file Helper.cxx.
|
static |
Make a new Cancel request for the specified request.
Caller owns the returned pointer and is responsible for deleting it.
| request | Request for which the Cancel will apply. ie. Invite request. |
Definition at line 261 of file Helper.cxx.
|
static |
Definition at line 1224 of file Helper.cxx.
|
static |
Definition at line 1434 of file Helper.cxx.
|
static |
Definition at line 1415 of file Helper.cxx.
|
static |
Definition at line 1525 of file Helper.cxx.
|
static |
Definition at line 1506 of file Helper.cxx.
|
static |
This interface should be used by the stack (TransactionState) to create an AckMsg to a failure response.
See RFC3261 section 17.1.1.3. Caller owns the returned pointer and is responsible for deleting it.
| request | Request that this ACK applies to. |
| response | Response that we are ACKing - required so that we can get the To tag into the generated ACK. |
Definition at line 296 of file Helper.cxx.
|
static |
Make an invite request - Empty Contact and Via is added and will be populated by the stack when sent.
| target | Ends up in the RequestURI and To header |
| from | Ends up in the From header |
Definition at line 249 of file Helper.cxx.
|
static |
Make an invite request using a overridden contact header - Empty Via is added and will be populated by the stack when sent.
| target | Ends up in the RequestURI and To header |
| from | Ends up in the From header |
| contact | Ends up in the Contact header. Stack will not change this when sent. |
Definition at line 255 of file Helper.cxx.
|
static |
Create a Message request with an empty Contact. See makeRequest.
Definition at line 352 of file Helper.cxx.
|
static |
Create a Message request with an overriden Contact. See makeRequest.
Definition at line 359 of file Helper.cxx.
|
static |
Definition at line 736 of file Helper.cxx.
|
static |
Definition at line 1212 of file Helper.cxx.
|
static |
Create a Publish request with an empty Contact. See makeRequest.
Definition at line 322 of file Helper.cxx.
|
static |
Create a Publish request with an overriden Contact. See makeRequest.
Definition at line 329 of file Helper.cxx.
|
static |
Definition at line 549 of file Helper.cxx.
|
static |
Create a Register request with an empty Contact, transport is added to Request URI. See makeRequest.
Definition at line 210 of file Helper.cxx.
|
static |
Create a Register request with an overriden Contact, transport is added to Request URI. See makeRequest.
Definition at line 218 of file Helper.cxx.
|
static |
Create a Register request with an empty Contact. See makeRequest.
Definition at line 172 of file Helper.cxx.
|
static |
Create a Register request with an overriden Contact. See makeRequest.
Definition at line 179 of file Helper.cxx.
|
static |
///////////////////////////////////////////////////////////////////////////////////////////
SIP Message Helpers
/////////////////////////////////////////////////////////////////////////////////////////// Make a new request with a overridden Contact. To, maxforward=70, requestline created, cseq method set, cseq sequence is 1, from and from tag set, contact set, CallId created. Caller owns the returned pointer and is responsible for deleting it.
| target | Ends up in the RequestURI and To header |
| from | Ends up in the From header |
| contact | Ends up in the Contact header. Stack will not change this when sent. |
| method | Type of request to create. Methos is used in the Request Line and the CSeq. |
Definition at line 142 of file Helper.cxx.
|
static |
Make a new request.
To, maxforward=70, requestline created, cseq method set, cseq sequence is 1, from and from tag set, CallId created. Caller owns the returned pointer and is responsible for deleting it.
| target | Ends up in the RequestURI and To header |
| from | Ends up in the From header |
| method | Type of request to create. Methos is used in the Request Line and the CSeq. |
Definition at line 165 of file Helper.cxx.
|
static |
Make a new response to a provided request.
Adds a To tag, Contact and Record-Route headers appropriately. Caller owns the returned pointer and is responsible for deleting it.
| request | SipMessage request from which to generate the response |
| responseCode | Response code to use on status line. |
| reason | Optional reason string to use on status line. If not provided then a default reason string will be added for well defined response codes. |
| hostname | Optional hostname to use in Warning header. Only used if warning is also provided. |
| warning | Optional warning text. If present a Warning header is added and hostname is used in warning header |
Definition at line 512 of file Helper.cxx.
|
static |
Make a new response to a provided request with an overridden Contact.
Adds a To tag, Contact and Record-Route headers appropriately. Caller owns the returned pointer and is responsible for deleting it.
| request | SipMessage request from which to generate the response |
| responseCode | Response code to use on status line. |
| myContact | Contact header to add to response. |
| reason | Optional reason string to use on status line. If not provided then a default reason string will be added for well defined response codes. |
| hostname | Optional hostname to use in Warning header. Only used if warning is also provided. |
| warning | Optional warning text. If present a Warning header is added and hostname is used in warning header. |
Definition at line 527 of file Helper.cxx.
|
static |
Make a response to a provided request.
Adds a To tag, Contact and Record-Route headers appropriately.
| response | SipMessage populated with the appropriate response |
| request | SipMessage request from which to generate the response |
| responseCode | Response code to use on status line. |
| reason | Optional reason string to use on status line. If not provided then a default reason string will be added for well defined response codes. |
| hostname | Optional hostname to use in Warning header. Only used if warning is also provided. |
| warning | Optional warning text. If present a Warning header is added and hostname is used in warning header. |
Definition at line 412 of file Helper.cxx.
|
static |
Make a response to a provided request with an overridden Contact.
Adds a To tag, Contact and Record-Route headers appropriately.
| response | SipMessage populated with the appropriate response |
| request | SipMessage request from which to generate the response |
| responseCode | Response code to use on status line. |
| myContact | Contact header to add to response. |
| reason | Optional reason string to use on status line. If not provided then a default reason string will be added for well defined response codes. |
| hostname | Optional hostname to use in Warning header. Only used if warning is also provided. |
| warning | Optional warning text. If present a Warning header is added and hostname is used in warning header. |
Definition at line 495 of file Helper.cxx.
|
static |
Definition at line 1670 of file Helper.cxx.
|
static |
Definition at line 1593 of file Helper.cxx.
|
inlinestatic |
Definition at line 547 of file Helper.hxx.
|
inlinestatic |
Definition at line 532 of file Helper.hxx.
|
static |
Create a Subscribe request with an empty Contact. See makeRequest.
Definition at line 382 of file Helper.cxx.
|
static |
Create a Subscribe request with an overriden Contact. See makeRequest.
Definition at line 389 of file Helper.cxx.
|
static |
///////////////////////////////////////////////////////////////////////////////////////////
Miscellaneous Helpers
///////////////////////////////////////////////////////////////////////////////////////////
Definition at line 1687 of file Helper.cxx.
|
static |
Definition at line 1218 of file Helper.cxx.
|
static |
Definition at line 1719 of file Helper.cxx.
|
static |
Definition at line 1701 of file Helper.cxx.
Definition at line 1284 of file Helper.cxx.
|
static |
///////////////////////////////////////////////////////////////////////////////////////////
Digest Authentication Helpers
/////////////////////////////////////////////////////////////////////////////////////////// Note: Helper assumes control of NonceHelper object and will delete when global scope is cleaned up
Definition at line 719 of file Helper.cxx.
|
static |
Definition at line 1325 of file Helper.cxx.
|
static |
Definition at line 1791 of file Helper.cxx.
|
static |
bytes in to-tag& from-tag, should prob. live somewhere else
Definition at line 42 of file Helper.hxx.