Commit 610cb86e authored by Simon Morlat's avatar Simon Morlat

Merge branch 'bc' of git.linphone.org:sofia-sip into bc

parents 9b5af9c3 55611217
......@@ -89,7 +89,7 @@ SOFIA_PLAT_CFLAGS=
# This is a dirty hack, but shuts up all the warnings
case "$host" in
*-openbsd*) SOFIA_PLAT_CFLAGS="-DNULL='((void *)0L)'";;
*-darwin15*)
*-darwin15*)
LDFLAGS="$LDFLAGS -framework CoreFoundation -framework SystemConfiguration"
SOFIA_CFLAGS="$SOFIA_CFLAGS -I/usr/local/include";;
*) ;;
......
......@@ -1037,7 +1037,11 @@ tport_t *tport_base_connect(tport_primary_t *pri,
__func__, (void *)self, su_strerror(su_errno())));
}
else {
susa.su_port = 0;
if (susa.su_sa.sa_family == AF_INET) {
susa.su_sin.sin_port = 0;
} else {
susa.su_sin6.sin6_port = 0;
}
if (bind(s, &susa.su_sa, susalen) < 0) {
SU_DEBUG_3(("%s(%p): bind(local-ip): %s\n",
__func__, (void *)self, su_strerror(su_errno())));
......@@ -3010,7 +3014,7 @@ void tport_recv_event(tport_t *self)
if (!tport_is_secondary(self))
return;
self->tp_dos_stats.recv_msg_count_since_last_check++;
gettimeofday(&now, NULL);
double now_in_millis = now.tv_sec * 1000 + (now.tv_usec / 1000);
......@@ -4677,9 +4681,15 @@ tport_t *tport_by_name(tport_t const *tp, tp_name_t const *tpn)
nocomp = self;
continue;
}
if (!default_primary)
if (!default_primary) {
default_primary=tp;
} else if (strcmp(tpn->tpn_host, "127.0.0.1") == 0 || strcmp(tpn->tpn_host, "::1") == 0) {
if (family == AF_INET && strcmp(inet_ntoa(tp->tp_addr->su_sin.sin_addr), tpn->tpn_host) == 0) {
SU_DEBUG_7(("tport: default primary changed to loopback\n"));
default_primary = tp;
}
}
secondary=tport_by_name_from_primary(tp,tpn);
if (secondary) {
SU_DEBUG_7(("tport(%p): found from primary " TPN_FORMAT "\n",
......@@ -4919,7 +4929,7 @@ int tport_name_by_url(su_home_t *home,
su_free(home, b);
return -1;
}
/*ipv6 addresses are enclosed by [ ] in urls, remove them.
/*ipv6 addresses are enclosed by [ ] in urls, remove them.
Note that it seems that in sofia-sip the tport_name_t::tpn_host can carry both enclosed and non-enclosed ipv6 addresses*/
if (url->url_host && url->url_host[0] == '['){
char *end = strchr(url->url_host,']');
......
......@@ -143,7 +143,7 @@ int tport_stream_init_primary(tport_primary_t *pri,
/* Set IP TOS if set */
tport_set_tos(socket, ai, pri->pri_params->tpp_tos);
#if defined(__linux__)
#if defined(__linux__) || defined(__APPLE__)
/* Linux does not allow reusing TCP port while this one is open,
so we can safely call su_setreuseaddr() before bind(). */
su_setreuseaddr(socket, 1);
......@@ -155,7 +155,7 @@ int tport_stream_init_primary(tport_primary_t *pri,
if (listen(socket, pri->pri_params->tpp_qsize) == SOCKET_ERROR)
return *return_culprit = "listen", -1;
#if !defined(__linux__)
#if !defined(__linux__) && !defined(__APPLE__)
/* Allow reusing TCP sockets
*
* On Solaris & BSD, call setreuseaddr() after bind in order to avoid
......@@ -188,6 +188,12 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted,
self->tp_has_connection = 1;
#if defined(__linux__) || defined(__APPLE__)
/* Linux does not allow reusing TCP port while this one is open,
so we can safely call su_setreuseaddr() before bind(). */
su_setreuseaddr(socket, 1);
#endif
if (setsockopt(socket, SOL_TCP, TCP_NODELAY, (void *)&one, sizeof one) == -1)
return *return_reason = "TCP_NODELAY", -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment