When detecting a hairpin, redirect to the appropriate local extension (bug #1974)
authorMark Spencer <markster@digium.com>
Fri, 27 Aug 2004 03:16:16 +0000 (03:16 +0000)
committerMark Spencer <markster@digium.com>
Fri, 27 Aug 2004 03:16:16 +0000 (03:16 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3662 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_dial.c
channels/chan_sip.c

index b32ab20..0bc754c 100755 (executable)
@@ -250,10 +250,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
                                                        if (!o->chan->callerid)
                                                                ast_log(LOG_WARNING, "Out of memory\n");
                                                } else {
-                                                       if (in->callerid)
+                                                       if (in->callerid) {
                                                                o->chan->callerid = strdup(in->callerid);
-                                                       if (!o->chan->callerid)
-                                                               ast_log(LOG_WARNING, "Out of memory\n");
+                                                               if (!o->chan->callerid)
+                                                                       ast_log(LOG_WARNING, "Out of memory\n");        
+                                                       }
                                                        strncpy(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode) - 1);
                                                        o->chan->cdrflags = in->cdrflags;
                                                }
index 4f80781..7c235d5 100755 (executable)
@@ -6719,6 +6719,14 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
                                                update_user_counter(p, DEC_IN_USE);
                                        }
                                        break;
+                               case 482: /* SIP is incapable of performing a hairpin call, which
+                                            is yet another failure of not having a layer 2 (again, YAY
+                                                        IETF for thinking ahead).  So we treat this as a call
+                                                        forward and hope we end up at the right place... */
+                                       ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+                                       if (p->owner)
+                                               snprintf(p->owner->call_forward, sizeof(p->owner->call_forward), "Local/%s@%s", p->username, p->context);
+                                       /* Fall through */
                                case 486: /* Busy here */
                                case 600: /* Busy everywhere */
                                case 603: /* Decline */