mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
@@ -92,6 +92,13 @@ typedef struct {
|
|||||||
* Use 0 for the default value.
|
* Use 0 for the default value.
|
||||||
*/
|
*/
|
||||||
uint16_t client_maximum;
|
uint16_t client_maximum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Server port number in host byte order.
|
||||||
|
*
|
||||||
|
* Use 0 for the default value.
|
||||||
|
*/
|
||||||
|
uint16_t port;
|
||||||
} rtems_telnetd_config_table;
|
} rtems_telnetd_config_table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +107,7 @@ typedef struct {
|
|||||||
* @retval RTEMS_SUCCESSFUL Successful operation.
|
* @retval RTEMS_SUCCESSFUL Successful operation.
|
||||||
* @retval RTEMS_INVALID_ADDRESS The command function in the configuration is
|
* @retval RTEMS_INVALID_ADDRESS The command function in the configuration is
|
||||||
* @c NULL.
|
* @c NULL.
|
||||||
* @retval RTEMS_RESOURCE_IN_USE The Telnet server was already started.
|
* @retval RTEMS_RESOURCE_IN_USE The server port is already in use.
|
||||||
* @retval RTEMS_NOT_IMPLEMENTED The keep stdio configuration option is true.
|
* @retval RTEMS_NOT_IMPLEMENTED The keep stdio configuration option is true.
|
||||||
* @retval RTEMS_UNSATISFIED Not enough resources to start the Telnet server or
|
* @retval RTEMS_UNSATISFIED Not enough resources to start the Telnet server or
|
||||||
* task priority in configuration is invalid.
|
* task priority in configuration is invalid.
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -51,7 +52,6 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/error.h>
|
|
||||||
#include <rtems/pty.h>
|
#include <rtems/pty.h>
|
||||||
#include <rtems/shell.h>
|
#include <rtems/shell.h>
|
||||||
#include <rtems/telnetd.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));
|
memset(&srv, 0, sizeof(srv));
|
||||||
srv.sin.sin_family = AF_INET;
|
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);
|
address_len = sizeof(srv.sin);
|
||||||
|
|
||||||
if (bind(ctx->server_socket, &srv.sa, address_len) != 0) {
|
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;
|
ctx->config.stack_size = (size_t)32 * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->config.port == 0) {
|
||||||
|
ctx->config.port = 23;
|
||||||
|
}
|
||||||
|
|
||||||
sc = telnetd_create_server_socket(ctx);
|
sc = telnetd_create_server_socket(ctx);
|
||||||
if (sc != RTEMS_SUCCESSFUL) {
|
if (sc != RTEMS_SUCCESSFUL) {
|
||||||
telnetd_destroy_context(ctx);
|
telnetd_destroy_context(ctx);
|
||||||
@@ -447,6 +451,9 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
|
|||||||
(rtems_task_argument) ctx
|
(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;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 9670d7541e0621915e521fe76e7bb33de8cee661, Newlib d13c84eb07e35984bf7a974cd786a6cdac29e6b9)
|
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 9670d7541e0621915e521fe76e7bb33de8cee661, Newlib d13c84eb07e35984bf7a974cd786a6cdac29e6b9)
|
||||||
syslog: telnetd: configuration with invalid command
|
syslog: telnetd: configuration with invalid command
|
||||||
syslog: telnetd: cannot create session task
|
syslog: telnetd: cannot create session task
|
||||||
syslog: telnetd: started successfully
|
syslog: telnetd: started successfully on port 23
|
||||||
syslog: telnetd: cannot bind server socket
|
syslog: telnetd: cannot bind server socket
|
||||||
|
|
||||||
*** END OF TEST TELNETD 1 ***
|
*** END OF TEST TELNETD 1 ***
|
||||||
|
|||||||
Reference in New Issue
Block a user