Module: kamailio
Branch: master
Commit: 5e3a016eb3d424b39b1f811f72ba34c69f5dea28
URL:
https://github.com/kamailio/kamailio/commit/5e3a016eb3d424b39b1f811f72ba34c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-16T11:51:48+01:00
dmq: use core function to get protocol string from parsed uri
---
Modified: src/modules/dmq/dmq.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5e3a016eb3d424b39b1f811f72ba34c…
Patch:
https://github.com/kamailio/kamailio/commit/5e3a016eb3d424b39b1f811f72ba34c…
---
diff --git a/src/modules/dmq/dmq.c b/src/modules/dmq/dmq.c
index 337d75c1b9..51ea35588e 100644
--- a/src/modules/dmq/dmq.c
+++ b/src/modules/dmq/dmq.c
@@ -136,19 +136,29 @@ struct module_exports exports = {
static int make_socket_str_from_uri(struct sip_uri *uri, str *socket)
{
+ str sproto = STR_NULL;
+
if(!uri->host.s || !uri->host.len) {
LM_ERR("no host in uri\n");
return -1;
}
- socket->len = uri->host.len + uri->port.len + 6;
+ socket->len = uri->host.len + uri->port.len + 7 /*sctp + : + : \0*/;
socket->s = pkg_malloc(socket->len);
if(socket->s == NULL) {
LM_ERR("no more pkg\n");
return -1;
}
- memcpy(socket->s, "udp:", 4);
- socket->len = 4;
+
+ if(get_valid_proto_string(uri->proto, 0, 0, &sproto)<0) {
+ LM_WARN("unknown transport protocol - fall back to udp\n");
+ sproto.s = "udp";
+ sproto.len = 3;
+ }
+
+ memcpy(socket->s, sproto.s, sproto.len);
+ socket->s[sproto.len] = ':';
+ socket->len = sproto.len + 1;
memcpy(socket->s + socket->len, uri->host.s, uri->host.len);
socket->len += uri->host.len;