summaryrefslogtreecommitdiff
path: root/pjsip/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2013-04-26 06:01:43 +0000
committerBenny Prijono <bennylp@teluu.com>2013-04-26 06:01:43 +0000
commit794a79431f46ba8a6c5316c082c064b1b768586a (patch)
tree6f176e0204a84a4ea29578c15c833903eb745818 /pjsip/include
parent688fdf10f000a6190b31eee6fc183decda5005aa (diff)
Fixed #1661: Option to use SO_REUSEADDR for TCP and TLS listeners and use it by default on non-Windows platforms
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4506 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r--pjsip/include/pjsip/sip_config.h33
-rw-r--r--pjsip/include/pjsip/sip_transport_tcp.h6
-rw-r--r--pjsip/include/pjsip/sip_transport_tls.h7
3 files changed, 46 insertions, 0 deletions
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h
index bc895c59..430dde22 100644
--- a/pjsip/include/pjsip/sip_config.h
+++ b/pjsip/include/pjsip/sip_config.h
@@ -569,6 +569,24 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
/**
+ * Specify whether TCP listener should use SO_REUSEADDR option. This constant
+ * will be used as the default value for the "reuse_addr" field in the
+ * pjsip_tcp_transport_cfg structure.
+ *
+ * Default is FALSE on Windows and TRUE on non-Windows.
+ *
+ * @see PJSIP_TLS_TRANSPORT_REUSEADDR
+ */
+#ifndef PJSIP_TCP_TRANSPORT_REUSEADDR
+# if defined(PJ_WIN32) && PJ_WIN32
+# define PJSIP_TCP_TRANSPORT_REUSEADDR 0
+# else
+# define PJSIP_TCP_TRANSPORT_REUSEADDR 1
+# endif
+#endif
+
+
+/**
* Set the interval to send keep-alive packet for TCP transports.
* If the value is zero, keep-alive will be disabled for TCP.
*
@@ -676,6 +694,21 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
#endif
+/**
+ * Specify whether TLS listener should use SO_REUSEADDR option.
+ *
+ * Default is FALSE on Windows and TRUE on non-Windows.
+ *
+ * @see PJSIP_TCP_TRANSPORT_REUSEADDR
+ */
+#ifndef PJSIP_TLS_TRANSPORT_REUSEADDR
+# if defined(PJ_WIN32) && PJ_WIN32
+# define PJSIP_TLS_TRANSPORT_REUSEADDR 0
+# else
+# define PJSIP_TLS_TRANSPORT_REUSEADDR 1
+# endif
+#endif
+
/* Endpoint. */
#define PJSIP_MAX_TIMER_COUNT (2*pjsip_cfg()->tsx.max_count + \
diff --git a/pjsip/include/pjsip/sip_transport_tcp.h b/pjsip/include/pjsip/sip_transport_tcp.h
index fc4940e3..7e7bc139 100644
--- a/pjsip/include/pjsip/sip_transport_tcp.h
+++ b/pjsip/include/pjsip/sip_transport_tcp.h
@@ -64,6 +64,12 @@ typedef struct pjsip_tcp_transport_cfg
pj_sockaddr bind_addr;
/**
+ * Should SO_REUSEADDR be used for the listener socket.
+ * Default value is PJSIP_TCP_TRANSPORT_REUSEADDR.
+ */
+ pj_bool_t reuse_addr;
+
+ /**
* Optional published address, which is the address to be
* advertised as the address of this SIP transport.
* By default the bound address will be used as the published address.
diff --git a/pjsip/include/pjsip/sip_transport_tls.h b/pjsip/include/pjsip/sip_transport_tls.h
index 1f8ee431..00d8fe76 100644
--- a/pjsip/include/pjsip/sip_transport_tls.h
+++ b/pjsip/include/pjsip/sip_transport_tls.h
@@ -174,6 +174,12 @@ typedef struct pjsip_tls_setting
pj_time_val timeout;
/**
+ * Should SO_REUSEADDR be used for the listener socket.
+ * Default value is PJSIP_TLS_TRANSPORT_REUSEADDR.
+ */
+ pj_bool_t reuse_addr;
+
+ /**
* QoS traffic type to be set on this transport. When application wants
* to apply QoS tagging to the transport, it's preferable to set this
* field rather than \a qos_param fields since this is more portable.
@@ -225,6 +231,7 @@ typedef struct pjsip_tls_state_info
PJ_INLINE(void) pjsip_tls_setting_default(pjsip_tls_setting *tls_opt)
{
pj_memset(tls_opt, 0, sizeof(*tls_opt));
+ tls_opt->reuse_addr = PJSIP_TLS_TRANSPORT_REUSEADDR;
tls_opt->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
tls_opt->qos_ignore_error = PJ_TRUE;
}