Module: kamailio
Branch: master
Commit: 91bf474a77ad594edccc5e5f8aca9f0abd905aca
URL:
https://github.com/kamailio/kamailio/commit/91bf474a77ad594edccc5e5f8aca9f0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-03-27T10:16:23+01:00
usrloc: options to do keepalive for natted or udp contacts only
- variants to make it emulate the current nathelper keepalive, which is
done for UDP only
- usrloc keepalive can be sent for all types of contacts
---
Modified: src/modules/usrloc/ul_keepalive.c
Modified: src/modules/usrloc/ul_keepalive.h
Modified: src/modules/usrloc/usrloc_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/91bf474a77ad594edccc5e5f8aca9f0…
Patch:
https://github.com/kamailio/kamailio/commit/91bf474a77ad594edccc5e5f8aca9f0…
---
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index b40a93040a..3557848e34 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -97,7 +97,7 @@ int ul_ka_urecord(urecord_t *ur)
int i;
struct timeval tv;
- if (ul_ka_mode == 0) {
+ if (ul_ka_mode == ULKA_NONE) {
return 0;
}
LM_DBG("keepalive for aor: %.*s\n", ur->aor.len, ur->aor.s);
@@ -113,7 +113,7 @@ int ul_ka_urecord(urecord_t *ur)
if (uc->c.len <= 0) {
continue;
}
- if(ul_ka_mode == 2) {
+ if(ul_ka_mode & ULKA_NAT) {
/* keepalive for natted contacts only */
if (nat_bflag == 0) {
continue;
@@ -145,9 +145,15 @@ int ul_ka_urecord(urecord_t *ur)
dproto = duri.proto;
he = sip_resolvehost(&duri.host, &duri.port_no, &dproto);
if(he == NULL) {
- LM_ERR("can't resolve_host\n");
+ LM_ERR("cannot resolve destination\n");
continue;
}
+ if(ul_ka_mode & ULKA_UDP) {
+ if(dproto != PROTO_UDP) {
+ LM_DBG("skipping non-udp contact - proto %d\n", (int)dproto);
+ continue;
+ }
+ }
init_dest_info(&idst);
hostent2su(&idst.to, he, 0, duri.port_no);
ssock = uc->sock;
diff --git a/src/modules/usrloc/ul_keepalive.h b/src/modules/usrloc/ul_keepalive.h
index b5c673efce..71a59db81a 100644
--- a/src/modules/usrloc/ul_keepalive.h
+++ b/src/modules/usrloc/ul_keepalive.h
@@ -28,6 +28,11 @@
#include "urecord.h"
+#define ULKA_NONE 0
+#define ULKA_ALL 1
+#define ULKA_NAT (1<<1)
+#define ULKA_UDP (1<<2)
+
int ul_ka_urecord(urecord_t *ur);
int ul_ka_reply_received(sip_msg_t *msg);
diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c
index b633e4c1ed..42964e1315 100644
--- a/src/modules/usrloc/usrloc_mod.c
+++ b/src/modules/usrloc/usrloc_mod.c
@@ -251,8 +251,8 @@ static param_export_t params[] = {
{"version_table", PARAM_INT, &ul_version_table},
{"ka_mode", PARAM_INT, &ul_ka_mode},
{"ka_from", PARAM_STR, &ul_ka_from},
- {"ka_domain", PARAM_STR, &ul_ka_domain},
- {"ka_method", PARAM_STR, &ul_ka_method},
+ {"ka_domain", PARAM_STR, &ul_ka_domain},
+ {"ka_method", PARAM_STR, &ul_ka_method},
{0, 0, 0}
};