Module: kamailio
Branch: master
Commit: 9ea922d82f1ab4acc3efe2f79ce9aa6a6bdab759
URL:
https://github.com/kamailio/kamailio/commit/9ea922d82f1ab4acc3efe2f79ce9aa6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-16T12:44:00+01:00
dmq: build node uri with transport
---
Modified: src/modules/dmq/dmq_funcs.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9ea922d82f1ab4acc3efe2f79ce9aa6…
Patch:
https://github.com/kamailio/kamailio/commit/9ea922d82f1ab4acc3efe2f79ce9aa6…
---
diff --git a/src/modules/dmq/dmq_funcs.c b/src/modules/dmq/dmq_funcs.c
index f9fb5c78ea..af3db27d6e 100644
--- a/src/modules/dmq/dmq_funcs.c
+++ b/src/modules/dmq/dmq_funcs.c
@@ -74,8 +74,9 @@ void dmq_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
int build_uri_str(str *username, struct sip_uri *uri, str *from)
{
- /* sip:user@host:port */
+ /* sip:user@host:port;transport=abcd */
int from_len;
+ str sproto = STR_NULL;
if(!uri->host.s || !uri->host.len) {
LM_ERR("no host in uri\n");
@@ -86,7 +87,8 @@ int build_uri_str(str *username, struct sip_uri *uri, str *from)
return -1;
}
- from_len = username->len + uri->host.len + uri->port.len + 10;
+ from_len = username->len + uri->host.len + uri->port.len + 12
+ + TRANSPORT_PARAM_LEN;
from->s = pkg_malloc(from_len);
if(from->s == NULL) {
LM_ERR("no more pkg\n");
@@ -112,6 +114,21 @@ int build_uri_str(str *username, struct sip_uri *uri, str *from)
memcpy(from->s + from->len, uri->port.s, uri->port.len);
from->len += uri->port.len;
}
+
+ if(uri->proto!=PROTO_NONE && uri->proto!=PROTO_UDP
+ && uri->proto!=PROTO_OTHER) {
+ if(get_valid_proto_string(uri->proto, 1, 0, &sproto)<0) {
+ LM_WARN("unknown transport protocol - fall back to udp\n");
+ sproto.s = "udp";
+ sproto.len = 3;
+ }
+ memcpy(from->s + from->len, TRANSPORT_PARAM, TRANSPORT_PARAM_LEN);
+ from->len += TRANSPORT_PARAM_LEN;
+ memcpy(from->s + from->len, sproto.s, sproto.len);
+ from->len += sproto.len;
+ }
+ from->s[from->len] = '\0';
+
return 0;
}