Skip to content

Commit

Permalink
rr: use default port for protocol if it is omitted in route header
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tverlaan committed Oct 28, 2016
1 parent 1a8a18d commit aaec127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/rr/loose.c
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions socket_info.h
Expand Up @@ -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 */

Expand Down

0 comments on commit aaec127

Please sign in to comment.