Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.194 diff -u -r1.194 chan_sip.c --- channels/chan_sip.c 12 Oct 2003 11:43:18 -0000 1.194 +++ channels/chan_sip.c 6 Nov 2003 14:52:08 -0000 @@ -90,6 +90,7 @@ #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER" static char context[AST_MAX_EXTENSION] = "default"; +static char fwd_context[AST_MAX_EXTENSION] = "default"; static char language[MAX_LANGUAGE] = ""; @@ -215,6 +216,7 @@ char remote_party_id[256]; char from[256]; char context[AST_MAX_EXTENSION]; + char fwd_context[AST_MAX_EXTENSION]; char fromdomain[AST_MAX_EXTENSION]; /* Domain to show in the from field */ char fromuser[AST_MAX_EXTENSION]; /* Domain to show in the user field */ char tohost[AST_MAX_EXTENSION]; /* Host we should put in the "to" field */ @@ -273,6 +275,7 @@ char name[80]; char secret[80]; char context[80]; + char fwd_context[80]; char callerid[80]; char methods[80]; char accountcode[20]; @@ -297,6 +300,7 @@ char name[80]; char secret[80]; char context[80]; /* JK02: peers need context too to allow parking etc */ + char fwd_context[80]; /* JK02: peers need context too to allow parking etc */ char methods[80]; char username[80]; char tohost[80]; @@ -688,6 +692,7 @@ r->noncodeccapability &= ~AST_RTP_DTMF; } strncpy(r->context, p->context,sizeof(r->context)-1); + strncpy(r->fwd_context, p->fwd_context,sizeof(r->fwd_context)-1); if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) && (!p->maxms || ((p->lastms > 0) && (p->lastms <= p->maxms)))) { if (p->addr.sin_addr.s_addr) { @@ -1530,6 +1535,7 @@ if (p->dtmfmode & SIP_DTMF_RFC2833) p->noncodeccapability |= AST_RTP_DTMF; strncpy(p->context, context, sizeof(p->context) - 1); + strncpy(p->fwd_context, fwd_context, sizeof(p->fwd_context) - 1); strncpy(p->fromdomain, fromdomain, sizeof(p->fromdomain) - 1); /* Add to list */ ast_mutex_lock(&iflock); @@ -3865,6 +3871,8 @@ sip_cancel_destroy(p); if (strlen(user->context)) strncpy(p->context, user->context, sizeof(p->context) - 1); + if (strlen(user->fwd_context)) + strncpy(p->fwd_context, user->fwd_context, sizeof(p->fwd_context) - 1); if (strlen(user->callerid) && strlen(p->callerid)) strncpy(p->callerid, user->callerid, sizeof(p->callerid) - 1); strncpy(p->username, user->name, sizeof(p->username) - 1); @@ -4441,7 +4449,12 @@ s += 4; ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s); if (p->owner) + { strncpy(p->owner->call_forward, s, sizeof(p->owner->call_forward) - 1); + ast_verbose(VERBOSE_PREFIX_3 "Found 302 Redirect to extension '%s'\n", s); + ast_verbose(VERBOSE_PREFIX_3 "Changing Context from '%s' to '%s'\n", p->owner->context,p->fwd_context); + strncpy(p->owner->context, p->fwd_context, strlen(p->fwd_context)+1); + } } static int hangup_sip2cause(int cause) @@ -5582,6 +5595,7 @@ { struct sip_user *user; int format; + int isFwdSet=0; user = (struct sip_user *)malloc(sizeof(struct sip_user)); if (user) { memset(user, 0, sizeof(struct sip_user)); @@ -5594,9 +5608,16 @@ user->canreinvite = REINVITE_INVITE; /* JK02: set default context */ strcpy(user->context, context); + strcpy(user->fwd_context, context); while(v) { if (!strcasecmp(v->name, "context")) { strncpy(user->context, v->value, sizeof(user->context)); + if(!isFwdSet) + strncpy(user->fwd_context, v->value, sizeof(user->fwd_context)); + + } else if (!strcasecmp(v->name, "fwdcontext")) { + strncpy(user->fwd_context, v->value, sizeof(user->fwd_context)); + isFwdSet=1; } else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) { user->ha = ast_append_ha(v->name, v->value, user->ha); @@ -5669,6 +5690,7 @@ int maskfound=0; int format; int found=0; + int isFwdSet=0; prev = NULL; ast_mutex_lock(&peerl.lock); peer = peerl.peers; @@ -5720,7 +5742,16 @@ } else if (!strcasecmp(v->name, "nat")) peer->nat = ast_true(v->value); else if (!strcasecmp(v->name, "context")) + { strncpy(peer->context, v->value, sizeof(peer->context)-1); + if(!isFwdSet) + strncpy(peer->fwd_context, v->value, sizeof(peer->fwd_context)-1); + } + else if (!strcasecmp(v->name, "fwdcontext")) + { + strncpy(peer->fwd_context, v->value, sizeof(peer->fwd_context)-1); + isFwdSet=1; + } else if (!strcasecmp(v->name, "fromdomain")) strncpy(peer->fromdomain, v->value, sizeof(peer->fromdomain)-1); else if (!strcasecmp(v->name, "fromuser")) @@ -5834,6 +5865,7 @@ char *utype; struct hostent *hp; int format; + int isFwdSet=0; int oldport = ntohs(bindaddr.sin_port); globaldtmfmode = SIP_DTMF_RFC2833; @@ -5857,6 +5889,7 @@ memset(&bindaddr, 0, sizeof(bindaddr)); /* Initialize some reasonable defaults */ strncpy(context, "default", sizeof(context) - 1); + strncpy(fwd_context, "default", sizeof(fwd_context) - 1); strcpy(language, ""); strcpy(fromdomain, ""); globalcanreinvite = REINVITE_INVITE; @@ -5867,6 +5900,11 @@ /* Create the interface list */ if (!strcasecmp(v->name, "context")) { strncpy(context, v->value, sizeof(context)-1); + if(!isFwdSet) + strncpy(fwd_context, v->value, sizeof(fwd_context)-1); + } else if (!strcasecmp(v->name, "fwdcontext")) { + strncpy(fwd_context, v->value, sizeof(fwd_context)-1); + isFwdSet=1; } else if (!strcasecmp(v->name, "dtmfmode")) { if (!strcasecmp(v->value, "inband")) globaldtmfmode=SIP_DTMF_INBAND;