diff --git a/src/control_socket.cpp b/src/control_socket.cpp index cd914791a..1e00ff64d 100644 --- a/src/control_socket.cpp +++ b/src/control_socket.cpp @@ -153,24 +153,6 @@ static void new_message(struct module *m) { } } -static int get_bound_port(fd_t fd, int ip_version){ - assert(ip_version == 4 || ip_version == 6); - sockaddr_storage ss; - socklen_t s_len = sizeof(ss); - - int rc = getsockname(fd, reinterpret_cast(&ss), &s_len); - if(rc != 0) - return -1; - - if(ip_version == 4){ - auto *s_in = reinterpret_cast(&ss); - return ntohs(s_in->sin_port); - } - - auto *s_in6 = reinterpret_cast(&ss); - return ntohs(s_in6->sin6_port); -} - int control_init(int port, int connection_type, struct control_state **state, struct module *root_module, int force_ip_version) { control_state *s = new control_state(); @@ -251,7 +233,7 @@ int control_init(int port, int connection_type, struct control_state **state, st goto error; } log_msg(LOG_LEVEL_NOTICE, "Control socket listening on port %d\n", - get_bound_port(s->socket_fd, ip_version)); + socket_get_recv_port(s->socket_fd)); } } else { if (force_ip_version == 6) {