LCOV - code coverage report
Current view: top level - zephyr/shell - shell_telnet.h Coverage Total Hit
Test: new.info Lines: 63.6 % 22 14
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2019 Nordic Semiconductor ASA
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : #ifndef ZEPHYR_INCLUDE_SHELL_TELNET_H_
       8              : #define ZEPHYR_INCLUDE_SHELL_TELNET_H_
       9              : 
      10              : #include <zephyr/net/socket.h>
      11              : #include <zephyr/shell/shell.h>
      12              : 
      13              : #ifdef __cplusplus
      14              : extern "C" {
      15              : #endif
      16              : 
      17            0 : extern const struct shell_transport_api shell_telnet_transport_api;
      18              : 
      19            0 : #define SHELL_TELNET_POLLFD_COUNT 3
      20            0 : #define SHELL_TELNET_MAX_CMD_SIZE 3
      21              : 
      22              : /** Line buffer structure. */
      23            1 : struct shell_telnet_line_buf {
      24              :         /** Line buffer. */
      25            1 :         char buf[CONFIG_SHELL_TELNET_LINE_BUF_SIZE];
      26              : 
      27              :         /** Current line length. */
      28            1 :         uint16_t len;
      29              : };
      30              : 
      31              : /** TELNET-based shell transport. */
      32            1 : struct shell_telnet {
      33              :         /** Handler function registered by shell. */
      34            1 :         shell_transport_handler_t shell_handler;
      35              : 
      36              :         /** Context registered by shell. */
      37            1 :         void *shell_context;
      38              : 
      39              :         /** Buffer for outgoing line. */
      40            1 :         struct shell_telnet_line_buf line_out;
      41              : 
      42              :         /** Array for sockets used by the telnet service. */
      43            1 :         struct zsock_pollfd fds[SHELL_TELNET_POLLFD_COUNT];
      44              : 
      45              :         /** Input buffer. */
      46            1 :         uint8_t rx_buf[CONFIG_SHELL_CMD_BUFF_SIZE];
      47              : 
      48              :         /** Number of data bytes within the input buffer. */
      49            1 :         size_t rx_len;
      50              : 
      51              :         /** Mutex protecting the input buffer access. */
      52            1 :         struct k_mutex rx_lock;
      53            0 :         uint8_t cmd_buf[SHELL_TELNET_MAX_CMD_SIZE];
      54            0 :         uint8_t cmd_len;
      55              : 
      56              :         /** The delayed work is used to send non-lf terminated output that has
      57              :          *  been around for "too long". This will prove to be useful
      58              :          *  to send the shell prompt for instance.
      59              :          */
      60            1 :         struct k_work_delayable send_work;
      61            0 :         struct k_work_sync work_sync;
      62              : 
      63              :         /** If set, no output is sent to the TELNET client. */
      64            1 :         bool output_lock;
      65              : };
      66              : 
      67            0 : #define SHELL_TELNET_DEFINE(_name)                                      \
      68              :         static struct shell_telnet _name##_shell_telnet;                \
      69              :         struct shell_transport _name = {                                \
      70              :                 .api = &shell_telnet_transport_api,                 \
      71              :                 .ctx = (struct shell_telnet *)&_name##_shell_telnet \
      72              :         }
      73              : 
      74              : /**
      75              :  * @brief This function provides pointer to shell telnet backend instance.
      76              :  *
      77              :  * Function returns pointer to the shell telnet instance. This instance can be
      78              :  * next used with shell_execute_cmd function in order to test commands behavior.
      79              :  *
      80              :  * @returns Pointer to the shell instance.
      81              :  */
      82            1 : const struct shell *shell_backend_telnet_get_ptr(void);
      83              : 
      84              : #ifdef __cplusplus
      85              : }
      86              : #endif
      87              : 
      88              : #endif /* ZEPHYR_INCLUDE_SHELL_TELNET_H_ */
        

Generated by: LCOV version 2.0-1