Module: kamailio
Branch: master
Commit: 68928e95f50581170097373dafe7a441e7f88304
URL:
https://github.com/kamailio/kamailio/commit/68928e95f50581170097373dafe7a44…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-03-26T21:57:08+01:00
usrloc: store keepalive roundtrip in contact structure
---
Modified: src/modules/usrloc/dlist.c
Modified: src/modules/usrloc/ul_keepalive.c
Modified: src/modules/usrloc/usrloc.h
---
Diff:
https://github.com/kamailio/kamailio/commit/68928e95f50581170097373dafe7a44…
Patch:
https://github.com/kamailio/kamailio/commit/68928e95f50581170097373dafe7a44…
---
diff --git a/src/modules/usrloc/dlist.c b/src/modules/usrloc/dlist.c
index a4c838e1f6..11366cc0f7 100644
--- a/src/modules/usrloc/dlist.c
+++ b/src/modules/usrloc/dlist.c
@@ -489,11 +489,11 @@ int get_all_ucontacts(void *buf, int len, unsigned int flags,
}
-
/**
*
*/
-int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
+int ul_update_keepalive(unsigned int _aorhash, str *_ruid, time_t tval,
+ unsigned int rtrip)
{
dlist_t *p;
urecord_t *r;
@@ -523,7 +523,7 @@ int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
&& !memcmp(c->ruid.s, _ruid->s, _ruid->len))
{
/* found */
- c->last_keepalive = time(NULL);
+ c->last_keepalive = tval;
LM_DBG("updated keepalive for [%.*s:%u] to %u\n",
_ruid->len, _ruid->s, _aorhash,
(unsigned int)c->last_keepalive);
@@ -539,6 +539,14 @@ int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
return 0;
}
+/**
+ *
+ */
+int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
+{
+ return ul_update_keepalive(_aorhash, _ruid, time(NULL), 0);
+}
+
/*!
* \brief Create a new domain structure
* \return 0 if everything went OK, otherwise value < 0 is returned
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index 83bce13c77..b40a93040a 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -410,7 +410,7 @@ int ul_ka_reply_received(sip_msg_t *msg)
LM_DBG("reply for keepalive of [%.*s:%u] roundtrip: %u.%06usec\n",
ruid.len, ruid.s, aorhash, tvdiff/1000000, tvdiff%1000000);
- ul_refresh_keepalive(aorhash, &ruid);
+ ul_update_keepalive(aorhash, &ruid, tvn.tv_sec, tvdiff);
return 0;
}
diff --git a/src/modules/usrloc/usrloc.h b/src/modules/usrloc/usrloc.h
index a1e26da211..5d071c1734 100644
--- a/src/modules/usrloc/usrloc.h
+++ b/src/modules/usrloc/usrloc.h
@@ -88,7 +88,8 @@ typedef struct ucontact {
str uniq; /*!< Uniq header field */
struct socket_info *sock; /*!< received socket */
time_t last_modified; /*!< When the record was last modified */
- time_t last_keepalive; /*!< last keepalive timestamp */
+ time_t last_keepalive; /*!< Last keepalive timestamp */
+ unsigned int ka_roundtrip; /*!< Keepalive roundtrip in microseconds */
unsigned int methods; /*!< Supported methods */
str instance; /*!< SIP instance value - gruu */
unsigned int reg_id; /*!< reg-id parameters */
@@ -192,6 +193,8 @@ int ul_set_keepalive_timeout(int _to);
typedef int (*ul_refresh_keepalive_t)(unsigned int _aorhash, str *_ruid);
int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid);
+int ul_update_keepalive(unsigned int _aorhash, str *_ruid, time_t tval,
+ unsigned int rtrip);
typedef void (*ul_set_max_partition_t)(unsigned int m);