Module: sip-router
Branch: 4.1
Commit: 20a01c50c8a144c7edc838bea003b665469f4120
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=20a01c5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jul 4 13:46:35 2014 +0200
usrloc: generate callid at startup and increase cseq for records added via mi
- should fix FS#448, reported by Savolainen Dmitri
(cherry picked from commit 66c497fdf4ac1c3b889a7c3b50c3e5fed770cf0b)
---
modules/usrloc/ul_mi.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/modules/usrloc/ul_mi.c b/modules/usrloc/ul_mi.c
index 3e12bf1..695fd38 100644
--- a/modules/usrloc/ul_mi.c
+++ b/modules/usrloc/ul_mi.c
@@ -48,9 +48,9 @@
#include "usrloc.h"
/*! CSEQ nr used */
-#define MI_UL_CSEQ 1
+static int MI_UL_CSEQ = 0;
/*! call-id used for ul_add and ul_rm_contact */
-static str mi_ul_cid = str_init("dfjrewr12386fd6-343(a)kamailio.mi").mi");
+static str mi_ul_cid = {0,0}; /*
str_init("dfjrewr12386fd6-343(a)kamailio.mi");*/
/*! user agent used for ul_add */
static str mi_ul_ua = str_init("SIP Router MI Server");
/*! path used for ul_add and ul_rm_contact */
@@ -58,8 +58,27 @@ static str mi_ul_path = str_init("dummypath");
extern sruid_t _ul_sruid;
+static char mi_ul_cid_buf[32];
+
/************************ helper functions ****************************/
+static void set_mi_ul_cid(void)
+{
+ int i;
+ char charset[] = "0123456789"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ if(mi_ul_cid.s!=NULL) return;
+
+ for(i=0; i<19; i++) {
+ mi_ul_cid_buf[i] = charset[rand()%(sizeof(charset) - 1)];
+ }
+ memcpy(mi_ul_cid_buf+i, "(a)kamailio.mi"o.mi", sizeof("(a)kamailio.mi"))mi"));
+ mi_ul_cid.s = mi_ul_cid_buf;
+ mi_ul_cid.len = strlen(mi_ul_cid.s);
+}
+
/*!
* \brief Search a domain in the global domain list
* \param table domain (table) name
@@ -360,6 +379,7 @@ struct mi_root* mi_usrloc_rm_contact(struct mi_root *cmd, void
*param)
}
contact = &node->next->next->value;
+ set_mi_ul_cid();
ret = get_ucontact( rec, contact, &mi_ul_cid, &mi_ul_path, MI_UL_CSEQ+1,
&con);
if (ret < 0) {
unlock_udomain( dom, aor);
@@ -566,6 +586,7 @@ struct mi_root* mi_usrloc_add(struct mi_root *cmd, void *param)
lock_udomain( dom, aor);
+ set_mi_ul_cid();
n = get_urecord( dom, aor, &r);
if ( n==1) {
if (insert_urecord( dom, aor, &r) < 0)
@@ -580,7 +601,7 @@ struct mi_root* mi_usrloc_add(struct mi_root *cmd, void *param)
ci.callid = &mi_ul_cid;
ci.user_agent = &mi_ul_ua;
- ci.cseq = MI_UL_CSEQ;
+ ci.cseq = ++MI_UL_CSEQ;
/* 0 expires means permanent contact */
if (ci.expires!=0)
ci.expires += act_time;