[asterisk-commits] rizzo: branch rizzo/astobj2 r47921 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 22 03:44:57 MST 2006
Author: rizzo
Date: Wed Nov 22 04:44:57 2006
New Revision: 47921
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47921
Log:
merge two common blocks in handle_response_register.
Reset r->timeout early in the timeout handler, as it needs to
be done anyways.
This is in preparation of having only a single timeout
pending for the sip_registry objects, because we only have
one pending event.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47921&r1=47920&r2=47921
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 04:44:57 2006
@@ -7385,7 +7385,7 @@
* Registered as a timeout handler during transmit_register(), but not always
* (e.g. not on the auth case).
* This is called by the scheduler so the event is not pending anymore when
- * we are called, and
+ * we are called.
*/
static int sip_reg_timeout(void *data)
{
@@ -7400,6 +7400,7 @@
return 0;
}
+ r->timeout = -1; /* reset event reference */
ast_log(LOG_NOTICE, " -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts);
/* if the initial tranmission failed, we may not have an existing dialog,
* so it is possible that r->register_pvt == NULL.
@@ -7417,8 +7418,9 @@
__sip_pretend_ack(p); /* XXX we need p locked, not sure we have */
r->register_pvt = pvt_unref(r->register_pvt); /* reference goes away */
}
+
/* If we have a limit, stop registration and give up */
- if (global_regattempts_max && (r->regattempts > global_regattempts_max)) {
+ if (global_regattempts_max && r->regattempts > global_regattempts_max) {
/* Ok, enough is enough. Don't try any more */
/* We could add an external notification here...
steal it from app_voicemail :-) */
@@ -7426,7 +7428,6 @@
r->regstate = REG_STATE_FAILED;
} else {
r->regstate = REG_STATE_UNREGISTERED;
- r->timeout = -1;
res=transmit_register(r, NULL, NULL);
}
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
@@ -12344,6 +12345,7 @@
switch (resp) {
case 401: /* Unauthorized */
case 407: /* Proxy auth */
+ /* retransmit with proper auth credentials */
if (p->authtries == MAX_AUTHTRIES || do_register_auth(p, req, resp)) {
ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s@%s' (Tries %d)\n", r->username, r->hostname, p->authtries);
set_destroy(p);
@@ -12351,21 +12353,18 @@
break;
case 403: /* Forbidden */
- ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", r->username, r->hostname);
+ case 404: /* Not found */
+ if (resp == 403)
+ ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", r->username, r->hostname);
+ else
+ ast_log(LOG_WARNING, "Got 404 Not found on SIP register to service %s@%s, giving up\n", r->username, r->hostname);
+ /* XXX how is this useful given we have no pending event anymore ??? */
if (global_regattempts_max)
r->regattempts = global_regattempts_max+1;
ast_sched_del(sched, r->timeout);
r->timeout = -1;
set_destroy(p);
- break;
- case 404: /* Not found */
- ast_log(LOG_WARNING, "Got 404 Not found on SIP register to service %s@%s, giving up\n", r->username, r->hostname);
- if (global_regattempts_max)
- r->regattempts = global_regattempts_max+1;
- set_destroy(p);
r->register_pvt = pvt_unref(r->register_pvt);
- ast_sched_del(sched, r->timeout);
- r->timeout = -1;
break;
case 423: /* Interval too brief */
@@ -12373,8 +12372,8 @@
ast_log(LOG_WARNING, "Got 423 Interval too brief for service %s@%s, minimum is %d seconds\n", r->username, r->hostname, r->expiry);
ast_sched_del(sched, r->timeout);
r->timeout = -1;
+ set_destroy(p);
r->register_pvt = pvt_unref(r->register_pvt);
- set_destroy(p);
if (r->expiry > max_expiry) {
ast_log(LOG_WARNING, "Required expiration time from %s@%s is too high, giving up\n", r->username, r->hostname);
r->expiry = default_expiry;
@@ -12385,8 +12384,10 @@
}
manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
break;
+
case 479: /* SER: Not able to process the URI - address is wrong in register*/
ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", r->username, r->hostname);
+ /* XXX how is this useful given we have no pending event anymore ??? */
if (global_regattempts_max)
r->regattempts = global_regattempts_max+1;
set_destroy(p);
More information about the asterisk-commits
mailing list