OpenOCD
telnet_server.c File Reference
Include dependency graph for telnet_server.c:

Go to the source code of this file.

Macros

#define CTRL(c)   (c - '@')
 
#define TELNET_HISTORY   ".openocd_history"
 

Functions

 COMMAND_HANDLER (handle_exit_command)
 
 COMMAND_HANDLER (handle_telnet_port_command)
 
static void telnet_auto_complete (struct connection *connection)
 
static int telnet_bell (struct connection *connection)
 
static bool telnet_can_insert (struct connection *connection, size_t len)
 
static void telnet_clear_line (struct connection *connection, struct telnet_connection *t_con)
 
static int telnet_connection_closed (struct connection *connection)
 
static void telnet_cut_line_to_end (struct connection *connection)
 
static void telnet_delete_character (struct connection *connection)
 
static int telnet_exec_line (struct connection *connection)
 
static void telnet_history_add (struct connection *connection)
 
static void telnet_history_down (struct connection *connection)
 
static void telnet_history_go (struct connection *connection, int idx)
 
static int telnet_history_print (struct connection *connection)
 
static void telnet_history_up (struct connection *connection)
 
int telnet_init (char *banner)
 
static int telnet_input (struct connection *connection)
 
static bool telnet_insert (struct connection *connection, const void *data, size_t len)
 
static void telnet_interrupt (struct connection *connection)
 
static void telnet_load_history (struct telnet_connection *t_con)
 
static void telnet_log_callback (void *priv, const char *file, unsigned line, const char *function, const char *string)
 
static void telnet_move_cursor (struct connection *connection, size_t pos)
 
static int telnet_new_connection (struct connection *connection)
 
static int telnet_output (struct command_context *cmd_ctx, const char *line)
 
static int telnet_outputline (struct connection *connection, const char *line)
 
static int telnet_prompt (struct connection *connection)
 
int telnet_register_commands (struct command_context *cmd_ctx)
 
static void telnet_remove_character (struct connection *connection)
 
static void telnet_save_history (struct telnet_connection *t_con)
 
void telnet_service_free (void)
 
static int telnet_write (struct connection *connection, const void *data, int len)
 

Variables

static char * negotiate
 
static const struct command_registration telnet_command_handlers []
 
static char * telnet_port
 
static const struct service_driver telnet_service_driver
 

Macro Definition Documentation

◆ CTRL

#define CTRL (   c)    (c - '@')

Definition at line 31 of file telnet_server.c.

◆ TELNET_HISTORY

#define TELNET_HISTORY   ".openocd_history"

Definition at line 32 of file telnet_server.c.

Function Documentation

◆ COMMAND_HANDLER() [1/2]

COMMAND_HANDLER ( handle_exit_command  )

Definition at line 976 of file telnet_server.c.

References ERROR_COMMAND_CLOSE_CONNECTION.

◆ COMMAND_HANDLER() [2/2]

COMMAND_HANDLER ( handle_telnet_port_command  )

Definition at line 971 of file telnet_server.c.

References CALL_COMMAND_HANDLER, and telnet_port.

◆ telnet_auto_complete()

◆ telnet_bell()

static int telnet_bell ( struct connection connection)
static

Definition at line 52 of file telnet_server.c.

References telnet_write().

Referenced by telnet_auto_complete(), and telnet_insert().

◆ telnet_can_insert()

static bool telnet_can_insert ( struct connection connection,
size_t  len 
)
inlinestatic

Definition at line 388 of file telnet_server.c.

References telnet_connection::line_size, connection::priv, and TELNET_LINE_MAX_SIZE.

Referenced by telnet_insert().

◆ telnet_clear_line()

static void telnet_clear_line ( struct connection connection,
struct telnet_connection t_con 
)
static

◆ telnet_connection_closed()

◆ telnet_cut_line_to_end()

static void telnet_cut_line_to_end ( struct connection connection)
static

◆ telnet_delete_character()

static void telnet_delete_character ( struct connection connection)
static

◆ telnet_exec_line()

◆ telnet_history_add()

static void telnet_history_add ( struct connection connection)
static

◆ telnet_history_down()

static void telnet_history_down ( struct connection connection)
static

◆ telnet_history_go()

◆ telnet_history_print()

◆ telnet_history_up()

static void telnet_history_up ( struct connection connection)
static

◆ telnet_init()

int telnet_init ( char *  banner)

◆ telnet_input()

◆ telnet_insert()

static bool telnet_insert ( struct connection connection,
const void *  data,
size_t  len 
)
static

◆ telnet_interrupt()

static void telnet_interrupt ( struct connection connection)
static

◆ telnet_load_history()

◆ telnet_log_callback()

static void telnet_log_callback ( void *  priv,
const char *  file,
unsigned  line,
const char *  function,
const char *  string 
)
static

◆ telnet_move_cursor()

static void telnet_move_cursor ( struct connection connection,
size_t  pos 
)
static

◆ telnet_new_connection()

◆ telnet_output()

static int telnet_output ( struct command_context cmd_ctx,
const char *  line 
)
static

◆ telnet_outputline()

static int telnet_outputline ( struct connection connection,
const char *  line 
)
static

Definition at line 65 of file telnet_server.c.

References ERROR_OK, telnet_connection::line, and telnet_write().

Referenced by telnet_log_callback(), and telnet_output().

◆ telnet_prompt()

static int telnet_prompt ( struct connection connection)
static

◆ telnet_register_commands()

int telnet_register_commands ( struct command_context cmd_ctx)

Definition at line 1001 of file telnet_server.c.

References NULL, register_commands(), telnet_command_handlers, and telnet_port.

Referenced by server_register_commands().

◆ telnet_remove_character()

static void telnet_remove_character ( struct connection connection)
static

◆ telnet_save_history()

static void telnet_save_history ( struct telnet_connection t_con)
static

◆ telnet_service_free()

void telnet_service_free ( void  )

Definition at line 1007 of file telnet_server.c.

References telnet_port.

Referenced by server_free().

◆ telnet_write()

Variable Documentation

◆ negotiate

char* negotiate
static
Initial value:
=
"\xFF\xFB\x03"
"\xFF\xFB\x01"
"\xFF\xFD\x03"
"\xFF\xFE\x01"

Definition at line 25 of file telnet_server.c.

Referenced by telnet_new_connection().

◆ telnet_command_handlers

const struct command_registration telnet_command_handlers[]
static
Initial value:
= {
{
.name = "exit",
.handler = handle_exit_command,
.mode = COMMAND_EXEC,
.usage = "",
.help = "exit telnet session",
},
{
.name = "telnet_port",
.handler = handle_telnet_port_command,
.mode = COMMAND_CONFIG,
.help = "Specify port on which to listen "
"for incoming telnet connections. "
"Read help on 'gdb_port'.",
.usage = "[port_num]",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 976 of file telnet_server.c.

Referenced by telnet_register_commands().

◆ telnet_port

char* telnet_port
static

◆ telnet_service_driver

const struct service_driver telnet_service_driver
static
Initial value:
= {
.name = "telnet",
.new_connection_during_keep_alive_handler = NULL,
.new_connection_handler = telnet_new_connection,
.input_handler = telnet_input,
.connection_closed_handler = telnet_connection_closed,
.keep_client_alive_handler = NULL,
}
static int telnet_input(struct connection *connection)
static int telnet_new_connection(struct connection *connection)
static int telnet_connection_closed(struct connection *connection)
#define NULL
Definition: usb.h:16

Definition at line 906 of file telnet_server.c.

Referenced by telnet_init().