summaryrefslogtreecommitdiffstats
path: root/cpukit/telnetd
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-10 13:12:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-11 09:08:10 +0200
commit26b58b7e4af27b632a3765249ba8f8a9b024fa08 (patch)
tree51eab844c2a4fd20338f9f95d9d8fdde40f6eb6f /cpukit/telnetd
parenttelnetd: Create sessions at start (diff)
downloadrtems-26b58b7e4af27b632a3765249ba8f8a9b024fa08.tar.bz2
telnetd: Add server port to configuration
Close #3543.
Diffstat (limited to 'cpukit/telnetd')
-rw-r--r--cpukit/telnetd/telnetd.c13
1 files changed, 10 insertions, 3 deletions
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 <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -51,7 +52,6 @@
#include <syslog.h>
#include <rtems.h>
-#include <rtems/error.h>
#include <rtems/pty.h>
#include <rtems/shell.h>
#include <rtems/telnetd.h>
@@ -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;
}