[Asterisk-Dev] Registrations SHOULD use same Call-ID. Packet8 seems to care

Stephen Davies steve at daviesfam.org
Sun Apr 20 14:03:12 MST 2003


Hi Mark,

I was investigating a problem where Packet8 didn't always send me my
incoming calls.  Making incoming calls, occasionally
I'd hear ringback but Packet8 wouldn't send Asterisk an INVITE.

Two things were needed to fix.  Firstly - Packet8 expires
registrations after 30 seconds (!), but actually seems to want to see
REGISTER even more often than that.  The DTA310 sends a REGISTER every
15 seconds.

So I added a define in sip_chan to tweak the amount of "guard time" *
allows.  I've set it to 15 seconds in the patch.

I also wrote to the Packet8 guys to find out if the expiry really
needs to be so brutally short!

Secondly: Asterisk uses a different Call-ID for each registration.

RFC3261, section 10.2 (Constructing the REGISTER Request) says:

     Call-ID: All registrations from a UAC SHOULD use the same Call-ID
           header field value for registrations sent to a particular
           registrar.

           If the same client were to use different Call-ID values, a
           registrar could not detect whether a delayed REGISTER request
           might have arrived out of order.

OK - so its a SHOULD not a MUST.  And I can't say I understand the
reasoning.  But I adjusted chan_sip to keep the same Call-ID for all
REGISTERs to a particular registry and that fixed my remaining
problems with incoming calls nicely.

In any case, it improves our compliance with the RFC, and its a very
tiny patch (half the code seemed to be there already, anyway).

Attached is the patch - hope its OK to apply.

Regards,
Steve
-------------- next part --------------
Index: channels/chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.85
diff -u -r1.85 chan_sip.c
--- channels/chan_sip.c	18 Apr 2003 15:47:33 -0000	1.85
+++ channels/chan_sip.c	20 Apr 2003 21:02:56 -0000
@@ -52,6 +52,7 @@
 #define SIPDUMPER
 #define DEFAULT_DEFAULT_EXPIRY  120
 #define DEFAULT_MAX_EXPIRY      3600
+#define EXPIRY_GUARD_SECS	15
 
 #define SIP_DTMF_RFC2833	(1 << 0)
 #define SIP_DTMF_INBAND		(1 << 1)
@@ -2540,7 +2541,10 @@
 		} else
 			p = r->call;
 	} else {
-		build_callid(r->callid, sizeof(r->callid), __ourip);
+		if (!r->callid_valid) {
+			build_callid(r->callid, sizeof(r->callid), __ourip);
+			r->callid_valid = 1;
+		}
 		p=sip_alloc( r->callid, &r->addr, 0);
 		if (!p) {
 			ast_log(LOG_WARNING, "Unable to allocate registration call\n");
@@ -3919,7 +3923,9 @@
 						ast_sched_del(sched, r->expire);
 					expires=atoi(get_header(req, "expires"));
 					if (!expires) expires=default_expiry;
-						r->expire=ast_sched_add(sched, (expires-2)*1000, sip_reregister, r); 
+					if (expires > EXPIRY_GUARD_SECS)
+						expires -= EXPIRY_GUARD_SECS;
+					r->expire=ast_sched_add(sched, expires*1000, sip_reregister, r); 
 				} else
 					ast_log(LOG_WARNING, "Got 200 OK on REGISTER that isn't a register\n");
 


More information about the asterisk-dev mailing list