Skip to content

Commit 9d14556

Browse files
committed
registrars: Allow accepting Re-REGISTERs with equal CSeq
New module setting for both registrar and mid-registrar which controls the policy on handling same Call-ID REGISTERs, with the same CSeq. modparam: allow_dup_cseq default: false (100% backwards-compatible) Ultimately, this boils down to a trade-off between interoperability and RFC strictness. More info in the modparam documentation. (cherry picked from commit dda9010) (cherry picked from commit f47c2f4)
1 parent bbc7b74 commit 9d14556

5 files changed

Lines changed: 35 additions & 3 deletions

File tree

lib/reg/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ int max_username_len = USERNAME_MAX_SIZE;
2828
int max_domain_len = DOMAIN_MAX_SIZE;
2929
int max_aor_len = MAX_AOR_LEN;
3030
int max_contact_len = CONTACT_MAX_SIZE;
31+
int allow_dup_cseq = 0;
3132

3233
int reg_init_globals(void)
3334
{
@@ -38,6 +39,7 @@ int reg_init_globals(void)
3839

3940
realm_prefix.len = strlen(realm_prefix.s);
4041
rcv_param.len = strlen(rcv_param.s);
42+
allow_dup_cseq = !!allow_dup_cseq;
4143

4244
if (expires_max_deviation < 0) {
4345
expires_max_deviation = -expires_max_deviation;

lib/reg/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern int max_contacts;
5252
extern int max_username_len;
5353
extern int max_domain_len;
5454
extern int max_aor_len;
55+
extern int allow_dup_cseq;
5556
extern int max_contact_len;
5657

5758
#define reg_modparams \
@@ -60,6 +61,7 @@ extern int max_contact_len;
6061
{"max_domain_len", INT_PARAM, &max_domain_len}, \
6162
{"max_aor_len", INT_PARAM, &max_aor_len}, \
6263
{"max_contact_len", INT_PARAM, &max_contact_len}, \
64+
{"allow_dup_cseq", INT_PARAM, &allow_dup_cseq}, \
6365
{"expires_max_deviation", INT_PARAM, &expires_max_deviation}
6466

6567
/* common registrar init code */
@@ -91,4 +93,6 @@ static inline time_t randomize_expires(unsigned int expires_ts)
9193
return ret;
9294
}
9395

96+
#define REG_CSEQ_ADJUST(_cs) ((_cs) + allow_dup_cseq)
97+
9498
#endif /* __LIB_REG_COMMON_H__ */

lib/reg/doc/reg_modparams.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
<!-- Common registrar modparams-->
22

3+
<section id="param_allow_dup_cseq" xreflabel="allow_dup_cseq">
4+
<title><varname>allow_dup_cseq</varname> (boolean)</title>
5+
<para>
6+
Some SIP stacks will re-REGISTER using the same Call-ID and CSeq values.
7+
While rejecting such requests is consistent with RFC 3261 § 10.3.7, enabling
8+
this parameter instructs the &reg_module; to accept them instead,
9+
improving interoperability.
10+
</para>
11+
<para>
12+
<emphasis>
13+
Default value is <emphasis>false</emphasis> (duplicate CSeq is rejected).
14+
</emphasis>
15+
</para>
16+
<example>
17+
<title>Setting the <varname>allow_dup_cseq</varname> parameter</title>
18+
<programlisting format="linespecific">
19+
...
20+
# loose RFC 3261 compliance: allow REGISTER requests with duplicate CSeq
21+
modparam("&reg_module;", "allow_dup_cseq", true)
22+
...
23+
</programlisting>
24+
</example>
25+
</section>
26+
27+
328
<section id="param_expires_max_deviation" xreflabel="expires_max_deviation">
429
<title><varname>expires_max_deviation</varname> (integer)</title>
530
<para>

modules/mid_registrar/save.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ static int process_contacts_by_ct(struct sip_msg *msg, urecord_t *urec,
22142214
return 1;
22152215
}
22162216

2217-
ret = ul.get_ucontact(urec, &ct->uri, ci->callid, ci->cseq,
2217+
ret = ul.get_ucontact(urec, &ct->uri, ci->callid, REG_CSEQ_ADJUST(ci->cseq),
22182218
&_sctx->cmatch, &c);
22192219
if (ret == -1) {
22202220
LM_ERR("invalid cseq for aor <%.*s>\n",urec->aor.len,urec->aor.s);
@@ -2400,7 +2400,8 @@ static int process_contacts_by_aor(struct sip_msg *req, urecord_t *urec,
24002400
e = e_out;
24012401
}
24022402

2403-
ret = ul.get_ucontact(urec, &ct->uri, ci->callid, ci->cseq,
2403+
2404+
ret = ul.get_ucontact(urec, &ct->uri, ci->callid, REG_CSEQ_ADJUST(ci->cseq),
24042405
&_sctx->cmatch, &c);
24052406
if (ret == -1) {
24062407
LM_ERR("invalid cseq for aor <%.*s>\n",urec->aor.len,urec->aor.s);

modules/registrar/save.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
399399
calc_contact_expires(_m, _c->expires, &e, _sctx);
400400

401401
/* search for the contact*/
402-
ret = ul.get_ucontact( _r, &_c->uri, ci->callid, ci->cseq,
402+
ret = ul.get_ucontact( _r, &_c->uri, ci->callid, REG_CSEQ_ADJUST(ci->cseq),
403403
&_sctx->cmatch, &c);
404404
if (ret==-1) {
405405
LM_ERR("invalid cseq for aor <%.*s>\n",_r->aor.len,_r->aor.s);

0 commit comments

Comments
 (0)