[asterisk-commits] branch oej/strictrouting r8994 -
/team/oej/strictrouting/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 31 09:50:34 MST 2006
Author: oej
Date: Tue Jan 31 10:50:32 2006
New Revision: 8994
URL: http://svn.digium.com/view/asterisk?rev=8994&view=rev
Log:
Checking for strict routing at first invite and keeping state during session
Modified:
team/oej/strictrouting/channels/chan_sip.c
Modified: team/oej/strictrouting/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/strictrouting/channels/chan_sip.c?rev=8994&r1=8993&r2=8994&view=diff
==============================================================================
--- team/oej/strictrouting/channels/chan_sip.c (original)
+++ team/oej/strictrouting/channels/chan_sip.c Tue Jan 31 10:50:32 2006
@@ -544,7 +544,7 @@
#define SIP_REALTIME (1 << 11) /*!< Flag for realtime users */
#define SIP_USECLIENTCODE (1 << 12) /*!< Trust X-ClientCode info message */
#define SIP_OUTGOING (1 << 13) /*!< Is this an outgoing call? */
-#define SIP_FREEBIT (1 << 14) /*!< Free for session-related use */
+#define SIP_STRICTROUTING (1 << 14) /*!< Does this session use Strict SIP routing? */
#define SIP_FREEBIT3 (1 << 15) /*!< Free for session-related use */
#define SIP_DTMF (3 << 16) /*!< DTMF Support: four settings, uses two bits */
#define SIP_DTMF_RFC2833 (0 << 16) /*!< DTMF Support: RTP DTMF - "rfc2833" */
@@ -4160,7 +4160,7 @@
return 0;
}
-/*! \brief Initialize a SIP request response packet */
+/*! \brief Initialize a SIP request packet within an existing dialog */
static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch)
{
struct sip_request *orig = &p->initreq;
@@ -4170,7 +4170,7 @@
const char *c;
char *n;
char *ot, *of;
- int is_strict = FALSE; /*!< Strict routing flag */
+ int is_strict = FALSE;
memset(req, 0, sizeof(struct sip_request));
@@ -4187,15 +4187,15 @@
}
/* Check for strict or loose router */
- if (p->route && !ast_strlen_zero(p->route->hop) && strstr(p->route->hop,";lr") == NULL) {
+ if (ast_test_flag(p, SIP_STRICTROUTING)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Strict routing enforced for session %s\n", p->callid);
is_strict = TRUE;
- if (sipdebug)
- ast_log(LOG_DEBUG, "Strict routing enforced for session %s\n", p->callid);
- }
-
- if (sipmethod == SIP_CANCEL) {
+ }
+
+ if (sipmethod == SIP_CANCEL) { /* Cancel goes to the INVITEs URI */
c = p->initreq.rlPart2; /* Use original URI */
- } else if (sipmethod == SIP_ACK) {
+ } else if (sipmethod == SIP_ACK) { /* SIP_ACK has two routing scenarios */
/* Use URI from Contact: in 200 OK (if INVITE)
(we only have the contacturi on INVITEs) */
if (!ast_strlen_zero(p->okcontacturi))
@@ -4222,10 +4222,10 @@
add_header(req, "Via", p->via);
if (p->route) {
set_destination(p, p->route->hop);
- if (is_strict)
- add_route(req, p->route->next);
+ if (ast_test_flag(p, SIP_STRICTROUTING))
+ add_route(req, p->route->next); /* Start with second hop */
else
- add_route(req, p->route);
+ add_route(req, p->route); /* Start with first hop */
}
ot = get_header(orig, "To");
@@ -6164,22 +6164,18 @@
/* Only append the contact if we are dealing with a strict router */
if (!head || (!ast_strlen_zero(head->hop) && strstr(head->hop,";lr") == NULL) ) {
+ ast_set_flag(p, SIP_STRICTROUTING);
/* 2nd append the Contact: if there is one */
/* Can be multiple Contact headers, comma separated values - we just take the first */
contact = get_header(req, "Contact");
if (!ast_strlen_zero(contact)) {
- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact);
+
/* Look for <: delimited address */
- c = strchr(contact, '<');
- if (c) {
- /* Take to > */
- ++c;
- len = strcspn(c, ">") + 1;
- } else {
- /* No <> - just take the lot */
- c = contact;
- len = strlen(contact) + 1;
- }
+ c = get_in_brackets(contact);
+
+ len = strlen(contact) + 1;
if ((thishop = ast_malloc(sizeof(*thishop) + len))) {
/* ast_calloc is not needed because all fields are initialized in this block */
ast_copy_string(thishop->hop, c, len);
More information about the asterisk-commits
mailing list