Module: kamailio
Branch: master
Commit: eb6b9c6bbd3674dc9e2b6da80b010986dd300e3f
URL:
https://github.com/kamailio/kamailio/commit/eb6b9c6bbd3674dc9e2b6da80b01098…
Author: AndreasHuber-CH <andreas.huber(a)nagra.com>
Committer: AndreasHuber-CH <andreas.huber(a)nagra.com>
Date: 2016-07-26T10:33:01+02:00
registrar: Add module parameter "contact_max_size" to make max contact size
configurable
The new module parameter "contact_max_size" allows changing the max size of
contact URIs
that are accepted in REGISTER requests.
The default value of this parameter is 255 which was the value of the compile time
constant
that is replaced by this module parameter.
If configured one must make sure that the DB actually supports the configured size in the
column "contact".
---
Modified: modules/registrar/doc/registrar_admin.xml
Modified: modules/registrar/registrar.c
Modified: modules/registrar/registrar.h
Modified: modules/registrar/sip_msg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/eb6b9c6bbd3674dc9e2b6da80b01098…
Patch:
https://github.com/kamailio/kamailio/commit/eb6b9c6bbd3674dc9e2b6da80b01098…
---
diff --git a/modules/registrar/doc/registrar_admin.xml
b/modules/registrar/doc/registrar_admin.xml
index 15550d8..eb47652 100644
--- a/modules/registrar/doc/registrar_admin.xml
+++ b/modules/registrar/doc/registrar_admin.xml
@@ -929,6 +929,36 @@ modparam("registrar", "flow_timer", 25)
</example>
</section>
+ <section id="registrar.p.contact_max_size">
+ <title><varname>contact_max_size</varname> (integer)</title>
+ <para>
+ Max size of URIs in <quote>Contact:</quote> header.
+ </para>
+ <para>
+ The size of URIs in <quote>Contact:</quote> headers are checked to be
+ lower or equal to this value.
+ A warning is logged and a 400 Bad Request is sent in response to REGISTER
+ requests with contact URIs that are longer than this value.
+ </para>
+ <para>
+ If a database is used then you must make sure that your database model supports
+ strings of the configured size in the column <quote>contact</quote> of the
table
+ specified in <quote>save()</quote> function.
+ </para>
+ <para>
+ <emphasis>
+ Default value is 255.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>contact_max_size</varname>
parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("registrar", "contact_max_size", 500)
+...
+ </programlisting>
+ </example>
+ </section>
</section>
diff --git a/modules/registrar/registrar.c b/modules/registrar/registrar.c
index b04dbb3..4277ed9 100644
--- a/modules/registrar/registrar.c
+++ b/modules/registrar/registrar.c
@@ -106,6 +106,8 @@ int reg_outbound_mode = 0;
int reg_regid_mode = 0;
int reg_flow_timer = 0;
+int contact_max_size = 255; /* max size of contact URIs */
+
str match_callid_name = str_init("match_callid");
str match_received_name = str_init("match_received");
str match_contact_name = str_init("match_contact");
@@ -225,6 +227,7 @@ static param_export_t params[] = {
{"outbound_mode", INT_PARAM, ®_outbound_mode },
{"regid_mode", INT_PARAM, ®_regid_mode },
{"flow_timer", INT_PARAM, ®_flow_timer },
+ {"contact_max_size", INT_PARAM, &contact_max_size },
{0, 0, 0}
};
diff --git a/modules/registrar/registrar.h b/modules/registrar/registrar.h
index 5dda71e..6c4b2be 100644
--- a/modules/registrar/registrar.h
+++ b/modules/registrar/registrar.h
@@ -39,7 +39,7 @@
/* if DB support is used, this values must not exceed the
* storage capacity of the DB columns! See db/schema/entities.xml */
-#define CONTACT_MAX_SIZE 255
+extern int contact_max_size; /* configurable using module parameter
"contact_max_size" instead of compile time constant */
#define RECEIVED_MAX_SIZE 255
#define USERNAME_MAX_SIZE 64
#define DOMAIN_MAX_SIZE 128
diff --git a/modules/registrar/sip_msg.c b/modules/registrar/sip_msg.c
index dd4ccce..8bc56cc 100644
--- a/modules/registrar/sip_msg.c
+++ b/modules/registrar/sip_msg.c
@@ -190,7 +190,7 @@ int check_contacts(struct sip_msg* _m, int* _s)
}
/* check also the length of all contacts */
for(c=((contact_body_t*)p->parsed)->contacts ; c ; c=c->next) {
- if (c->uri.len > CONTACT_MAX_SIZE) {
+ if (c->uri.len > contact_max_size) {
LM_WARN("contact uri is too long: [%.*s]\n", c->uri.len,
c->uri.s);
rerrno = R_CONTACT_LEN;
return 1;