Skip to content

Commit

Permalink
Add dontreuseaddr parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
smititelu committed Mar 18, 2022
1 parent f44d0cf commit db5b3d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
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

0 comments on commit db5b3d9

Please sign in to comment.