Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:14

0001 /**
0002  * @file
0003  * 
0004  * @brief Telnet Daemon Interface
0005  */
0006 
0007 /*
0008  * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com>
0009  * Reworked by Till Straumann and .h overhauled by Joel Sherrill.
0010  * Copyright (c) 2009 embedded brains GmbH & Co. KG
0011  *
0012  * The license and distribution terms for this file may be
0013  * found in the file LICENSE in this distribution or at
0014  * http://www.rtems.org/license/LICENSE.
0015  */
0016 
0017 #ifndef _RTEMS_TELNETD_H
0018 #define _RTEMS_TELNETD_H
0019 
0020 #include <rtems.h>
0021 #include <rtems/shell.h>
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 bool rtems_telnetd_login_check(
0028   const char *user,
0029   const char *passphrase
0030 );
0031 
0032 /**
0033  * @brief Telnet command type.
0034  */
0035 typedef void (*rtems_telnetd_command)(
0036   char * /* device name */,
0037   void * /* arg */
0038 );
0039 
0040 /**
0041  * @brief Telnet configuration structure.
0042  */
0043 typedef struct {
0044   /**
0045    * @brief Function invoked for each Telnet connection.
0046    *
0047    * The first parameter contains the device name.  The second parameter
0048    * contains the argument pointer of this configuration table.
0049    */
0050   rtems_telnetd_command command;
0051 
0052   /**
0053    * @brief Argument for command function.
0054    */
0055   void *arg;
0056 
0057   /**
0058    * @brief Task priority.
0059    *
0060    * Use 0 for the default value.
0061    */
0062   rtems_task_priority priority;
0063 
0064   /**
0065    * @brief Task stack size.
0066    *
0067    * Use 0 for the default value.
0068    */
0069   size_t stack_size;
0070 
0071   /**
0072    * @brief Login check function.
0073    *
0074    * Method used for login checks.  Use @c NULL to disable a login check.
0075    */
0076   rtems_shell_login_check_t login_check;
0077 
0078   /**
0079    * @brief This is an obsolete configuration option.
0080    *
0081    * It must be set to false, otherwise rtems_telnetd_start() will do nothing
0082    * and returns with a status of RTEMS_NOT_IMPLEMENTED.
0083    */
0084   bool keep_stdio;
0085 
0086   /**
0087    * @brief Maximum number of clients which can connect to the system at a
0088    * time.
0089    *
0090    * Use 0 for the default value.
0091    */
0092   uint16_t client_maximum;
0093 
0094   /**
0095    * @brief Server port number in host byte order.
0096    *
0097    * Use 0 for the default value.
0098    */
0099   uint16_t port;
0100 } rtems_telnetd_config_table;
0101 
0102 /**
0103  * @brief Starts the Telnet server using the provided configuration.
0104  *
0105  * @retval RTEMS_SUCCESSFUL Successful operation.
0106  * @retval RTEMS_INVALID_ADDRESS The command function in the configuration is
0107  *   @c NULL.
0108  * @retval RTEMS_RESOURCE_IN_USE The server port is already in use.
0109  * @retval RTEMS_NOT_IMPLEMENTED The keep stdio configuration option is true.
0110  * @retval RTEMS_UNSATISFIED Not enough resources to start the Telnet server or
0111  *   task priority in configuration is invalid.
0112  */
0113 rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table *config);
0114 
0115 /**
0116  * @brief Telnet configuration.
0117  *
0118  * The application must provide this configuration table.  It is used by
0119  * rtems_telnetd_initialize() to configure the Telnet subsystem.  Do not modify
0120  * the entries after the intialization since it is used internally.
0121  */
0122 extern rtems_telnetd_config_table rtems_telnetd_config;
0123 
0124 /**
0125  * @brief Initializes the Telnet subsystem.
0126  *
0127  * Uses the application provided @ref rtems_telnetd_config configuration table.
0128  */
0129 rtems_status_code rtems_telnetd_initialize(void);
0130 
0131 #ifdef __cplusplus
0132 }
0133 #endif
0134 
0135 #endif