[sr-dev] git:master:aaec127f: rr: use default port for protocol if it is omitted in route header

Timmo Verlaan tverlaan at gmail.com
Fri Oct 28 15:44:38 CEST 2016


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

Author: Timmo Verlaan <tverlaan at gmail.com>
Committer: Timmo Verlaan <tverlaan at gmail.com>
Date: 2016-10-28T14:56:54+02:00

rr: use default port for protocol if it is omitted in route header

When using double route headers the selection of the outgoing
socket is only done on IP address if the port is omitted in that
route header. This fix defaults the port to 5060/5061 depending on
protocol so the correct listen socket is chosen. When no socket is
found it will fallback to the current behaviour keeping backwards
interoperability.

---

Modified: modules/rr/loose.c
Modified: socket_info.h

---

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

---

diff --git a/modules/rr/loose.c b/modules/rr/loose.c
index 71d7d43..a0054ba 100644
--- a/modules/rr/loose.c
+++ b/modules/rr/loose.c
@@ -827,8 +827,9 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
 			}
 
 			if (!use_ob) {
-				si = grep_sock_info( &puri.host, puri.port_no, puri.proto);
-				if (si) {
+				if ((si = grep_sock_info( &puri.host, puri.port_no?puri.port_no:proto_default_port(puri.proto), puri.proto)) != 0) {
+					set_force_socket(_m, si);
+				} else if ((si = grep_sock_info( &puri.host, puri.port_no, puri.proto)) != 0) {
 					set_force_socket(_m, si);
 				} else {
 					if (enable_socket_mismatch_warning)
diff --git a/socket_info.h b/socket_info.h
index eec9dd4..03225ac 100644
--- a/socket_info.h
+++ b/socket_info.h
@@ -44,6 +44,8 @@
 int socket2str(char* s, int* len, struct socket_info* si);
 int socketinfo2str(char* s, int* len, struct socket_info* si, int mode);
 
+/* Helper macro that results in the default port based on the protocol */
+#define proto_default_port(proto) ((proto==PROTO_TLS)?SIPS_PORT:SIP_PORT)
 
 /* struct socket_info is defined in ip_addr.h */
 




More information about the sr-dev mailing list