Module: kamailio
Branch: master
Commit: 9f3b6ab377160e0fd96d5a6616c845edc83a14e9
URL: 
https://github.com/kamailio/kamailio/commit/9f3b6ab377160e0fd96d5a6616c845edc83a14e9

Author: Xenofon Karamanos <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-06T12:50:54+01:00

dispatcher: Fix default transport protocol when not defined in list

---

Modified: src/modules/dispatcher/dispatch.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/9f3b6ab377160e0fd96d5a6616c845edc83a14e9.diff
Patch: 
https://github.com/kamailio/kamailio/commit/9f3b6ab377160e0fd96d5a6616c845edc83a14e9.patch

---

diff --git a/src/modules/dispatcher/dispatch.c 
b/src/modules/dispatcher/dispatch.c
index ccb67a4337d..d53bea6ad37 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -35,7 +35,6 @@
 #include <stdint.h>
 #include <time.h>
 #include <math.h>
-
 #include "../../core/ut.h"
 #include "../../core/trim.h"
 #include "../../core/dprint.h"
@@ -699,8 +698,28 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, 
str *attrs, int dload)
 
        /* Copy the port out of the URI */
        dp->port = puri.port_no;
-       /* Copy the proto out of the URI */
-       dp->proto = puri.proto;
+       /* Modify proto to default if PROTO_NONE was found according to RFC 3263
+               If no transport param is present in the URI, the default is UDP 
for numerical
+               addresses:
+               If non-numerical address and port it specified, the default is 
UDP as well.
+               If non-numerical address and no port is specified, the proto 
should be discovered
+               using DNS NAPTR/SRV lookups.  In this case we set PROTO_NONE 
and later the
+               forwarding function (e.g. t_relay) will set the correct proto 
based on the DNS records found.
+       */
+       if(puri.proto == PROTO_NONE) {
+               if(str2ipx(&puri.host) != NULL) {
+                       dp->proto = PROTO_UDP;
+               } else {
+                       if(puri.port_no != 0) {
+                               dp->proto = (puri.type == SIP_URI_T) ? 
PROTO_UDP : PROTO_TCP;
+                       } else {
+                               dp->proto = PROTO_NONE;
+                       }
+               }
+       } else {
+               /* Copy the proto out of the URI */
+               dp->proto = puri.proto;
+       }
 
        /* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
        if(dp->flags & DS_NODNSARES_DST) {

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to