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 0db45e1
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 @@ -224,6 +224,7 @@ struct sipp_option options_table[] = {
{"dynamicStart", "variable value\nSet the start offset of dynamic_id variable", SIPP_OPTION_INT, &startDynamicId, 1},
{"dynamicMax", "variable value\nSet the maximum of dynamic_id variable ", SIPP_OPTION_INT, &maxDynamicId, 1},
{"dynamicStep", "variable value\nSet the increment of dynamic_id variable", SIPP_OPTION_INT, &stepDynamicId, 1},
{"dontreuseaddr", "Do not reuse TCP ports", SIPP_OPTION_BOOL, &dontreuseaddr, 1},


{"", "Call behavior options:", SIPP_HELP_TEXT_HEADER, NULL, 0},
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 0db45e1

Please sign in to comment.