From 26b58b7e4af27b632a3765249ba8f8a9b024fa08 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 10 Oct 2018 13:12:50 +0200 Subject: telnetd: Add server port to configuration Close #3543. --- cpukit/telnetd/telnetd.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cpukit/telnetd') diff --git a/cpukit/telnetd/telnetd.c b/cpukit/telnetd/telnetd.c index 147e18f070..b8adec297a 100644 --- a/cpukit/telnetd/telnetd.c +++ b/cpukit/telnetd/telnetd.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include -#include #include #include #include @@ -295,7 +295,7 @@ static rtems_status_code telnetd_create_server_socket(telnetd_context *ctx) memset(&srv, 0, sizeof(srv)); srv.sin.sin_family = AF_INET; - srv.sin.sin_port = htons(23); + srv.sin.sin_port = htons(ctx->config.port); address_len = sizeof(srv.sin); if (bind(ctx->server_socket, &srv.sa, address_len) != 0) { @@ -415,6 +415,10 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config) ctx->config.stack_size = (size_t)32 * 1024; } + if (ctx->config.port == 0) { + ctx->config.port = 23; + } + sc = telnetd_create_server_socket(ctx); if (sc != RTEMS_SUCCESSFUL) { telnetd_destroy_context(ctx); @@ -447,6 +451,9 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config) (rtems_task_argument) ctx ); - syslog(LOG_DAEMON | LOG_INFO, "telnetd: started successfully"); + syslog( + LOG_DAEMON | LOG_INFO, + "telnetd: started successfully on port %" PRIu16, ctx->config.port + ); return RTEMS_SUCCESSFUL; } -- cgit v1.2.3