[asterisk-commits] branch oej/sipdiversion r17411 - in
/team/oej/sipdiversion: ./ channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Apr 4 12:24:43 MST 2006
Author: oej
Date: Tue Apr 4 14:24:40 2006
New Revision: 17411
URL: http://svn.digium.com/view/asterisk?rev=17411&view=rev
Log:
Updates
Modified:
team/oej/sipdiversion/ (props changed)
team/oej/sipdiversion/channels/chan_sip.c
Propchange: team/oej/sipdiversion/
------------------------------------------------------------------------------
automerge = http://edvina.net/training/
Modified: team/oej/sipdiversion/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipdiversion/channels/chan_sip.c?rev=17411&r1=17410&r2=17411&view=diff
==============================================================================
--- team/oej/sipdiversion/channels/chan_sip.c (original)
+++ team/oej/sipdiversion/channels/chan_sip.c Tue Apr 4 14:24:40 2006
@@ -2998,8 +2998,6 @@
tmp->cid.cid_name = ast_strdup(i->cid_name);
if (!ast_strlen_zero(i->rdnis))
tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
- if (!ast_strlen_zero(i->redircause))
- pbx_builtin_setvar_helper(tmp, "__PRIREDIRECTREASON", i->redircause);
if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
tmp->cid.cid_dnid = ast_strdup(i->exten);
tmp->priority = 1;
@@ -6737,7 +6735,7 @@
static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq)
{
char tmp[256], *c, *a;
- char *params, *reason, *stop;
+ char *params, *reason = NULL, *stop;
struct sip_request *req;
req = oreq;
@@ -6747,51 +6745,58 @@
if (ast_strlen_zero(tmp))
return 0;
- /* Get diversion-reason param if present */
- params = strchr(tmp, ';');
- if (params && *params == ';' && *(params+1) != '\0') {
- while (*params == ';' || *params == ' ') params++;
- if (strlen(params) >= strlen("reason=")) {
- if (strncasecmp(params, "reason", strlen("reason")) == 0) {
- reason = strchr(params, '=');
- if (reason && *reason == '=') {
- reason++;
- /* Remove enclosing double-quotes */
- if (*reason == '"') {
- reason++;
- stop = reason;
- while (*stop != '"') {
- if (*stop == '\0') {
- /* Missing end-quote */
- *reason = '\0';
- break;
- }
- stop++;
- }
- *stop = '\0';
- } else {
- stop = reason;
- while (*stop && *stop != ';' && *stop != '"') stop++;
- *stop = '\0';
- }
- if (*reason)
- sip_set_redirstr(p, reason);
- }
- }
- }
- }
-
c = get_in_brackets(tmp);
if (strncmp(c, "sip:", 4)) {
ast_log(LOG_WARNING, "Huh? Not an RDNIS SIP header (%s)?\n", c);
return -1;
}
c += 4;
- if ((a = strchr(c, '@')) || (a = strchr(c, ';'))) {
+
+ /* Get diversion-reason param if present */
+ if (params = strchr(tmp, ';')) {
+ *params = '\0'; /* Cut off parameters */
+ params++;
+ while (*params == ';' || *params == ' ')
+ params++;
+ /* Check if we have a reason parameter */
+ if (strncasecmp(params, "reason", strlen("reason")) == 0) {
+ reason = strchr(params, '=');
+ if (reason) {
+ reason++;
+ /* Remove enclosing double-quotes */
+ if (*reason == '"') {
+ reason++;
+ stop = reason;
+ while (*stop != '"') {
+ if (*stop == '\0') {
+ /* Missing end-quote */
+ *reason = '\0';
+ break;
+ }
+ stop++;
+ }
+ *stop = '\0';
+ } else {
+ stop = reason;
+ while (*stop && *stop != ';' && *stop != '"')
+ stop++;
+ *stop = '\0';
+ }
+ if (*reason) {
+ sip_set_redirstr(p, reason);
+ pbx_builtin_setvar_helper(tmp, "__PRIREDIRECTREASON", p->redircause);
+ pbx_builtin_setvar_helper(tmp, "__SIPREDIRECTREASON", reason);
+ }
+ }
+ }
+ }
+
+ if ((a = strchr(c, '@')) || (a = strchr(c, ';')))
*a = '\0';
- }
+
if (sip_debug_test_pvt(p))
- ast_verbose("RDNIS is %s\n", c);
+ ast_verbose(" -- RDNIS for tis call is is %s (reason %s)\n", c, reason ? reason : "");
+
ast_string_field_set(p, rdnis, c);
return 0;
@@ -13327,7 +13332,9 @@
{
char *cdest;
char *extension, *host, *port;
- char tmp[80];
+ char *tmp;
+ char tmp2[256];
+ char *reason;
if (!(cdest = ast_strdupa(dest)))
return 0;
@@ -13343,13 +13350,15 @@
/* we'll issue the redirect message here */
if (!host) {
char *localtmp;
- ast_copy_string(tmp, get_header(&p->initreq, "To"), sizeof(tmp));
- if (!strlen(tmp)) {
+
+ tmp = get_header(&p->initreq, "To"));
+ if (ast_strlen_zero(tmp)) {
ast_log(LOG_ERROR, "Cannot retrieve the 'To' header from the original SIP request!\n");
return 0;
}
if ((localtmp = strstr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) {
char lhost[80], lport[80];
+
memset(lhost, 0, sizeof(lhost));
memset(lport, 0, sizeof(lport));
localtmp++;
More information about the asterisk-commits
mailing list