Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dontreuseaddr parameter #573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sipp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ MAYBE_EXTERN int reset_number DEFVAL(0);
MAYBE_EXTERN bool reset_close DEFVAL(true);
MAYBE_EXTERN int reset_sleep DEFVAL(1000);
MAYBE_EXTERN bool sendbuffer_warn DEFVAL(false);
MAYBE_EXTERN bool dontreuseaddr DEFVAL(false);
/* A list of sockets pending reset. */
MAYBE_EXTERN set<SIPpSocket*> sockets_pending_reset;

Expand Down
1 change: 1 addition & 0 deletions src/sipp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ struct sipp_option options_table[] = {
"- cn: un + compression (only if compression plugin loaded). This plugin is not provided with SIPp.\n"
, SIPP_OPTION_TRANSPORT, NULL, 1
},
{"dontreuseaddr", "Do not reuse TCP ports. Might be important in multi-socket mode (see -t parameter) in order to allow higher amount of calls.", SIPP_OPTION_SETFLAG, &dontreuseaddr, 1},
{"i", "Set the local IP address for 'Contact:','Via:', and 'From:' headers. Default is primary host IP address.\n", SIPP_OPTION_IP, local_ip, 1},
{"p", "Set the local port number. Default is a random free port chosen by the system.", SIPP_OPTION_INT, &user_port, 1},
{"bind_local", "Bind socket to local IP address, i.e. the local IP address is used as the source IP address. If SIPp runs in server mode it will only listen on the local IP address instead of all IP addresses.", SIPP_OPTION_SETFLAG, &bind_local, 1},
Expand Down
8 changes: 5 additions & 3 deletions src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,9 +1733,11 @@ void sipp_customize_socket(SIPpSocket *socket)
socket->ss_transport == T_SCTP) {
int sock_opt = 1;

if (setsockopt(socket->ss_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&sock_opt,
sizeof (sock_opt)) == -1) {
ERROR_NO("setsockopt(SO_REUSEADDR) failed");
if (dontreuseaddr == false) {
if (setsockopt(socket->ss_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&sock_opt,
sizeof (sock_opt)) == -1) {
ERROR_NO("setsockopt(SO_REUSEADDR) failed");
}
}

#ifdef USE_SCTP
Expand Down