[asterisk-commits] dvossel: trunk r268205 - /trunk/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 4 16:55:18 CDT 2010
Author: dvossel
Date: Fri Jun 4 16:55:14 2010
New Revision: 268205
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=268205
Log:
RFC3261 compliant sip unreliable retransmit timing + 'registerattempts' option tweak
Changes.
1. RFC 3261 states in section 17.1.2.2 and 17.1.1.2 that retransmission
timers should initially be set to timer T1. T1 by default is 500ms.
Asterisk was starting the retransmission timers at T1*2 which shouldn't
cause any problems, but is not RFC compliant.
2. RFC 3261 states in section 17.1.2.2 that for a non-INVITE client transaction,
if the retransmit timer fires while in the proceeding state that
the request must be retransmitted. Asterisk currently ack's
requests for both INVITE and non-INVITE transactions when a
1XX response is received, this patch changes this for non-INVITE requests.
3. The 'registerattempts' option in sip.conf is supposed to set
how many registry attempts will be made before giving up. When
this option is set to 1, I would expect only one registry attempt
to be made before stopping because of a failure, but instead two are
made. In my opinion this is not expected behavior. This option does
not indicate that these are re-attempts. The logic behind this option
has been changed to only attempt registers the exact number of times
this option is set to. If this option is 0, it still continues to
re-attempt the registration forever.
Review: https://reviewboard.asterisk.org/r/687/
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=268205&r1=268204&r2=268205
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jun 4 16:55:14 2010
@@ -3469,7 +3469,7 @@
pkt->timer_t1 = p->timer_t1; /* Set SIP timer T1 */
pkt->retransid = -1;
if (pkt->timer_t1)
- siptimer_a = pkt->timer_t1 * 2;
+ siptimer_a = pkt->timer_t1;
/* Schedule retransmission */
AST_SCHED_REPLACE_VARIABLE(pkt->retransid, sched, siptimer_a, retrans_pkt, pkt, 1);
@@ -11528,7 +11528,6 @@
ast_dnsmgr_refresh(r->dnsmgr);
}
- 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->call == NULL.
* Otherwise destroy it, as we have a timeout so we don't want it.
@@ -11551,15 +11550,16 @@
}
/* If we have a limit, stop registration and give up */
r->timeout = -1;
- 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 :-) */
- ast_log(LOG_NOTICE, " -- Giving up forever trying to register '%s@%s'\n", r->username, r->hostname);
+ ast_log(LOG_NOTICE, " -- Last Registration Attempt #%d failed, Giving up forever trying to register '%s@%s'\n", r->regattempts, r->username, r->hostname);
r->regstate = REG_STATE_FAILED;
} else {
r->regstate = REG_STATE_UNREGISTERED;
- res=transmit_register(r, SIP_REGISTER, NULL, NULL);
+ res = transmit_register(r, SIP_REGISTER, NULL, NULL);
+ ast_log(LOG_NOTICE, " -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts);
}
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
registry_unref(r, "unreffing registry_unref r");
@@ -18768,7 +18768,10 @@
/* Acknowledge whatever it is destined for */
if ((resp >= 100) && (resp <= 199)) {
- ack_res = __sip_semi_ack(p, seqno, 0, sipmethod);
+ /* NON-INVITE messages do not ack a 1XX response. RFC 3261 section 17.1.2.2 */
+ if (sipmethod == SIP_INVITE) {
+ ack_res = __sip_semi_ack(p, seqno, 0, sipmethod);
+ }
} else {
ack_res = __sip_ack(p, seqno, 0, sipmethod);
}
More information about the asterisk-commits
mailing list