diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-16 10:58:22 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-16 10:58:22 +0000 |
commit | 731139cf64e44e56c1cc83bbad5d926696217539 (patch) | |
tree | 64a2ff24e0a11230478e601559882b18f4c5a411 | |
parent | bd9269b92badebee875524260d55c27bfff7393b (diff) |
Below patches with some re-structuring for trunk
---
Merged revisions 64602 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r64602 | oej | 2007-05-16 12:38:18 +0200 (Wed, 16 May 2007) | 2 lines
Issue #9681 - Handle www-auth on BYE
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@64604 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 380f711eb..7e5499d44 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -13162,14 +13162,26 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ handle_response_refer(p, resp, rest, req, seqno); break; case 401: /* Not www-authorized on SIP method */ + case 407: /* Proxy auth required */ if (sipmethod == SIP_INVITE) handle_response_invite(p, resp, rest, req, seqno); else if (sipmethod == SIP_REFER) handle_response_refer(p, resp, rest, req, seqno); else if (p->registry && sipmethod == SIP_REGISTER) res = handle_response_register(p, resp, rest, req, seqno); - else { - ast_log(LOG_WARNING, "Got authentication request (401) on unknown %s to '%s'\n", sip_methods[sipmethod].text, get_header(req, "To")); + else if (sipmethod == SIP_BYE) { + if (p->options) + p->options->auth_type = resp; + if (ast_strlen_zero(p->authname)) { + ast_log(LOG_WARNING, "Asked to authenticate %s, to %s:%d but we have no matching peer!\n", + msg, ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port)); + ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); + } else if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, resp, sipmethod, 0)) { + ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From")); + ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); + } + } else { + ast_log(LOG_WARNING, "Got authentication request (%d) on %s to '%s'\n", resp, sip_methods[sipmethod].text, get_header(req, "To")); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); } break; @@ -13191,26 +13203,6 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ else if (owner) ast_queue_control(p->owner, AST_CONTROL_CONGESTION); break; - case 407: /* Proxy auth required */ - if (sipmethod == SIP_INVITE) - handle_response_invite(p, resp, rest, req, seqno); - else if (sipmethod == SIP_REFER) - handle_response_refer(p, resp, rest, req, seqno); - else if (p->registry && sipmethod == SIP_REGISTER) - res = handle_response_register(p, resp, rest, req, seqno); - else if (sipmethod == SIP_BYE) { - if (ast_strlen_zero(p->authname)) - ast_log(LOG_WARNING, "Asked to authenticate %s, to %s:%d but we have no matching peer!\n", - msg, ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port)); - ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); - if (p->authtries == MAX_AUTHTRIES || do_proxy_auth(p, req, 407, sipmethod, 0)) { - ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From")); - ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); - } - } else /* We can't handle this, giving up in a bad way */ - ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); - - break; case 423: /* Interval too brief */ if (sipmethod == SIP_REGISTER) res = handle_response_register(p, resp, rest, req, seqno); |