Changeset 65c65bb in rtems-libbsd


Ignore:
Timestamp:
Jul 1, 2016, 5:49:52 AM (3 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
afaeccc05a556f6aa25ba044a7e49d6aa634a59e, freebsd-9.3, master
Children:
4dec435
Parents:
fc26479
Message:

Add telnetd as service to rc.conf.

Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • libbsd.py

    rfc26479 r65c65bb  
    149149            'telnetd/pty.c',
    150150            'telnetd/telnetd.c',
     151            'telnetd/telnetd-init.c',
     152            'telnetd/telnetd-service.c',
    151153            'sys/dev/tsec/if_tsec_nexus.c',
    152154        ],
  • libbsd_waf.py

    rfc26479 r65c65bb  
    11161116              'rtemsbsd/telnetd/des.c',
    11171117              'rtemsbsd/telnetd/pty.c',
     1118              'rtemsbsd/telnetd/telnetd-init.c',
     1119              'rtemsbsd/telnetd/telnetd-service.c',
    11181120              'rtemsbsd/telnetd/telnetd.c']
    11191121    if bld.get_env()["RTEMS_ARCH"] == "arm":
  • rtemsbsd/include/machine/rtems-bsd-config.h

    rfc26479 r65c65bb  
    3333 *  RTEMS_BSD_CONFIG_NET_IF_LAGG            : Link Aggregetion and Failover.
    3434 *  RTEMS_BSD_CONFIG_NET_IF_VLAN            : Virtual LAN.
     35 *  RTEMS_BSD_CONFIG_SERVICE_TELNETD        : Telnet Protocol (TELNET).
     36 *   RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE    : Telnet shell task stack size.
    3537 *  RTEMS_BSD_CONFIG_SERVICE_FTPD           : File Transfer Protocol (FTP).
    3638 *  RTEMS_BSD_CONFIG_BSP_CONFIG             : Configure default BSP devices.
     
    119121
    120122/*
     123 * Telnetd
     124 */
     125#if defined(RTEMS_BSD_CONFIG_SERVICE_TELNETD)
     126  #if defined(RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE)
     127    #define RTEMS_BSD_CFGDECL_TELNETD_STACK_SIZE \
     128      int rtems_telnetd_stack_size = RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE
     129  #endif /* RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE */
     130  #define RTEMS_BSD_CFGDECL_TELNETD RTEMS_BSD_RC_CONF_SYSINT(rc_conf_telnetd)
     131#endif /* RTEMS_BSD_CONFIG_SERVICE_TELNETD */
     132
     133/*
    121134 * Configure the system.
    122135 */
     
    146159   * Create the services.
    147160   */
     161  RTEMS_BSD_CFGDECL_TELNETD;
     162  RTEMS_BSD_CFGDECL_TELNETD_STACK_SIZE;
    148163  RTEMS_BSD_CFGDECL_FTPD;
    149164#endif /* RTEMS_BSD_CONFIG_INIT */
  • rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h

    rfc26479 r65c65bb  
    155155 * Decls for the handlers.
    156156 */
    157 void rc_conf_net_init(void* arg);    /* Installed by default. */
    158 void rc_conf_ftpd_init(void* arg);   /* ftpd_enabled="YES" */
     157void rc_conf_net_init(void* arg);           /* Installed by default. */
     158void rc_conf_telnetd_init(void* arg);       /* telnetd_enabled="YES" */
     159void rc_conf_ftpd_init(void* arg);          /* ftpd_enabled="YES" */
    159160
    160161/*
  • rtemsbsd/include/rtems/telnetd.h

    rfc26479 r65c65bb  
    8989
    9090/**
     91 * @brief Start the Telnet subsystem with the provided configuration.
     92 */
     93rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config);
     94
     95/**
    9196 * @brief Telnet configuration.
    9297 *
  • rtemsbsd/telnetd/telnetd.c

    rfc26479 r65c65bb  
    8888
    8989/***********************************************************/
    90 static rtems_id telnetd_task_id = RTEMS_ID_NONE;
    91 
    92 rtems_id (*telnetd_spawn_task)(
     90static rtems_telnetd_config_table* telnetd_config;
     91static rtems_id                    telnetd_task_id;
     92
     93/*
     94 * chrisj: this variable was global and with no declared interface in a header
     95 *         file and with no means to set it so I have stopped it being global;
     96 *         if this breaks any user they will have be to provide a formal
     97 *         interface to get this change reverted.
     98 */
     99static const rtems_id (*telnetd_spawn_task)(
    93100  const char *,
    94101  unsigned,
     
    208215
    209216  /* we don't redirect stdio as this probably
    210    * was started from the console anyways..
     217   * was started from the console anyway ..
    211218   */
    212219  do {
    213     if (rtems_telnetd_config.keep_stdio) {
     220    if (telnetd_config->keep_stdio) {
    214221      bool start = true;
    215222      char device_name [32];
    216223
    217224      ttyname_r( 1, device_name, sizeof( device_name));
    218       if (rtems_telnetd_config.login_check != NULL) {
     225      if (telnetd_config->login_check != NULL) {
    219226        start = rtems_shell_login_prompt(
    220227          stdin,
    221228          stderr,
    222229          device_name,
    223           rtems_telnetd_config.login_check
     230          telnetd_config->login_check
    224231        );
    225232      }
    226233      if (start) {
    227         rtems_telnetd_config.command( device_name, arg->arg);
     234        telnetd_config->command( device_name, arg->arg);
    228235      } else {
    229236        syslog(
     
    245252
    246253      arg->devname = devname;
    247       arg->arg = rtems_telnetd_config.arg;
     254      arg->arg = telnetd_config->arg;
    248255      strncpy(arg->peername, peername, sizeof(arg->peername));
    249256
    250257      telnetd_task_id = telnetd_spawn_task(
    251258        devname,
    252         rtems_telnetd_config.priority,
    253         rtems_telnetd_config.stack_size,
     259        telnetd_config->priority,
     260        telnetd_config->stack_size,
    254261        spawned_shell,
    255262        arg
     
    288295}
    289296
    290 rtems_status_code rtems_telnetd_initialize( void)
    291 {
    292   if (telnetd_task_id != RTEMS_ID_NONE) {
     297rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
     298{
     299  if (telnetd_config != NULL) {
    293300    fprintf(stderr, "telnetd already started\n");
    294301    return RTEMS_RESOURCE_IN_USE;
    295302  }
    296303
    297   if (rtems_telnetd_config.command == NULL) {
     304  if (config->command == NULL) {
    298305    fprintf(stderr, "telnetd setup with invalid command\n");
    299306    return RTEMS_IO_ERROR;
    300307  }
    301308
     309  telnetd_config = calloc(1, sizeof(*telnetd_config));
     310  if (telnetd_config == NULL) {
     311    fprintf(stderr, "telnetd cannot alloc telnetd config table\n");
     312    return RTEMS_NO_MEMORY;
     313  }
     314
     315
    302316  if ( !telnet_pty_initialize() ) {
    303317    fprintf(stderr, "telnetd cannot initialize PTY driver\n");
     318    free(telnetd_config);
     319    telnetd_config = NULL;
    304320    return RTEMS_IO_ERROR;
    305321  }
    306322
     323  *telnetd_config = *config;
     324
    307325  /* Check priority */
    308   if (rtems_telnetd_config.priority < 2) {
    309     rtems_telnetd_config.priority = 100;
     326  if (telnetd_config->priority < 2) {
     327    telnetd_config->priority = 100;
    310328  }
    311329
    312330  /* Check stack size */
    313   if (rtems_telnetd_config.stack_size <= 0) {
    314     rtems_telnetd_config.stack_size = (size_t)32 * 1024;
     331  if (telnetd_config->stack_size <= 0) {
     332    telnetd_config->stack_size = (size_t)32 * 1024;
    315333  }
    316334
     
    318336  telnetd_task_id = telnetd_spawn_task(
    319337    "TNTD",
    320     rtems_telnetd_config.priority,
    321     rtems_telnetd_config.stack_size,
     338    telnetd_config->priority,
     339    telnetd_config->stack_size,
    322340    rtems_task_telnetd,
    323341    0
    324342  );
    325343  if (telnetd_task_id == RTEMS_ID_NONE) {
     344    free(telnetd_config);
     345    telnetd_config = NULL;
    326346    return RTEMS_IO_ERROR;
    327347  }
    328348
    329349  /* Print status */
    330   if (!rtems_telnetd_config.keep_stdio) {
     350  if (!telnetd_config->keep_stdio) {
    331351    fprintf(
    332352      stderr,
    333353      "telnetd started with stacksize = %u and priority = %d\n",
    334       (unsigned) rtems_telnetd_config.stack_size,
    335       (unsigned) rtems_telnetd_config.priority
     354      (unsigned) telnetd_config->stack_size,
     355      (unsigned) telnetd_config->priority
    336356    );
    337357  }
     
    387407
    388408  /* call their routine */
    389   if (rtems_telnetd_config.login_check != NULL) {
     409  if (telnetd_config->login_check != NULL) {
    390410    start = rtems_shell_login_prompt(
    391411      stdin,
    392412      stderr,
    393413      arg->devname,
    394       rtems_telnetd_config.login_check
     414      telnetd_config->login_check
    395415    );
    396416    login_failed = !start;
    397417  }
    398418  if (start) {
    399     rtems_telnetd_config.command( arg->devname, arg->arg);
     419    telnetd_config->command( arg->devname, arg->arg);
    400420  }
    401421
  • testsuite/rcconf02/test_main.c

    rfc26479 r65c65bb  
    7070#include <rtems/shell.h>
    7171
    72 #if DEFINE_FOR_TESTING
    73 #define RCCONF02_HAS_SHELL
    74 #endif
    75 
    7672#define TEST_NAME "LIBBSD RC.CONF 2"
    7773
     
    121117  "\n"                                                     \
    122118  "dhcpcd_options=\"-h foobar\"\n"                         \
     119  "\n"                                                     \
     120  "telnetd_enable=\"YES\"\n"                               \
     121  "telnetd_options=\"-v -C 10 -P 50 -L\"\n"                \
    123122  "\n"                                                     \
    124123  "ftpd_enable=\"YES\"\n"                                  \
     
    154153  test_rc_conf_script();
    155154
    156 #if defined(RCCONF02_HAS_SHELL)
    157155  rtems_shell_init(
    158156    "SHLL",
     
    164162    NULL
    165163    );
    166 #else
    167   printf("RCCONF02 sleeping for 10s\n");
    168   sleep(10);
    169 #endif /* RCCONF02_HAS_SHELL */
    170164
    171165  exit(0);
    172166}
    173 
    174 /*
    175  * Optional shell for testing this test.
    176  */
    177 #if defined(RCCONF02_HAS_SHELL)
    178167
    179168#define CONFIGURE_SHELL_COMMANDS_INIT
     
    215204
    216205#include <rtems/shellconfig.h>
    217 #endif /* RCCONF02_HAS_SHELL */
    218206
    219207#define RTEMS_BSD_CONFIG_BSP_CONFIG
     208#define RTEMS_BSD_CONFIG_SERVICE_TELNETD
     209#define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024)
    220210#define RTEMS_BSD_CONFIG_SERVICE_FTPD
    221211
     212#define CONFIGURE_MAXIMUM_DRIVERS 32
     213
    222214#include <rtems/bsd/test/default-init.h>
Note: See TracChangeset for help on using the changeset viewer.