aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-06 03:58:02 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-06 03:58:02 +0000
commit1e892b1e4897985928de40bc526445422589cd63 (patch)
tree2c45735f1307adeb190e30248aa4cda7d25068c3 /channels
parent146aafabc00e24dade83e23bcae716be29ad0a18 (diff)
Try to ACK on 487 response, handle case of incoming HANGUP before 200 OK
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@753 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 4d1a7d1e2..c8c25f0e6 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -859,6 +859,8 @@ static struct in_addr *myaddrfor(struct in_addr *them)
return temp;
}
+static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req);
+
static int sip_hangup(struct ast_channel *ast)
{
@@ -891,7 +893,14 @@ static int sip_hangup(struct ast_channel *ast)
/* Start the process if it's not already started */
if (!p->alreadygone && strlen(p->initreq.data)) {
if (needcancel) {
- transmit_request(p, "CANCEL", 0, 1);
+ if (p->outgoing) {
+ transmit_request(p, "CANCEL", 0, 1);
+ /* Actually don't destroy us yet, wait for the 487 on our original
+ INVITE, but do set an autodestruct just in case. */
+ p->needdestroy = 0;
+ sip_scheddestroy(p, 15000);
+ } else
+ transmit_response_reliable(p, "480 Temporarily Unavailable", &p->initreq);
} else {
/* Send a hangup */
transmit_request(p, "BYE", 1, 1);
@@ -1741,6 +1750,7 @@ static void set_destination(struct sip_pvt *p, char *uri)
++h;
hn = strcspn(h, ":;>");
strncpy(hostname, h, (hn>255)?255:hn);
+ hostname[(hn > 255) ? 255 : hn] = '\0';
h+=hn;
/* Is "port" present? if not default to 5060 */
if (*h == ':') {
@@ -1757,6 +1767,7 @@ static void set_destination(struct sip_pvt *p, char *uri)
maddr += 7;
hn = strspn(maddr, "0123456789.");
strncpy(hostname, maddr, (hn>255)?255:hn);
+ hostname[(hn > 255) ? 255 : hn] = '\0';
}
hp = gethostbyname(hostname);
@@ -3657,6 +3668,8 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
}
transmit_request(p, "ACK", 0, 0);
p->alreadygone = 1;
+ if (!p->owner)
+ p->needdestroy = 1;
} else
ast_log(LOG_NOTICE, "Dunno anything about a %d %s response from %s\n", resp, rest, p->owner ? p->owner->name : inet_ntoa(p->sa.sin_addr));
}