2022-06-26 23:26:22 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
2006-06-02 10:36:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Dominic Rath *
|
|
|
|
* Dominic.Rath@gmx.de *
|
|
|
|
* *
|
2009-07-17 19:54:25 +00:00
|
|
|
* Copyright (C) 2007,2008 Øyvind Harboe *
|
2008-07-25 06:54:17 +00:00
|
|
|
* oyvind.harboe@zylin.com *
|
|
|
|
* *
|
2008-09-20 10:50:53 +00:00
|
|
|
* Copyright (C) 2008 by Spencer Oliver *
|
|
|
|
* spen@spen-soft.co.uk *
|
2006-06-02 10:36:31 +00:00
|
|
|
***************************************************************************/
|
2012-01-30 12:05:19 +00:00
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#ifndef OPENOCD_SERVER_TELNET_SERVER_H
|
|
|
|
#define OPENOCD_SERVER_TELNET_SERVER_H
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2009-12-03 12:15:03 +00:00
|
|
|
#include <server/server.h>
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2017-05-10 14:37:51 +00:00
|
|
|
#define TELNET_BUFFER_SIZE (10*1024)
|
2006-06-02 10:36:31 +00:00
|
|
|
|
|
|
|
#define TELNET_LINE_HISTORY_SIZE (128)
|
2017-05-10 14:37:51 +00:00
|
|
|
#define TELNET_LINE_MAX_SIZE (10*256)
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2012-01-30 12:05:19 +00:00
|
|
|
enum telnet_states {
|
2006-06-02 10:36:31 +00:00
|
|
|
TELNET_STATE_DATA,
|
|
|
|
TELNET_STATE_IAC,
|
|
|
|
TELNET_STATE_SB,
|
|
|
|
TELNET_STATE_SE,
|
|
|
|
TELNET_STATE_WILL,
|
|
|
|
TELNET_STATE_WONT,
|
|
|
|
TELNET_STATE_DO,
|
|
|
|
TELNET_STATE_DONT,
|
|
|
|
TELNET_STATE_ESCAPE,
|
|
|
|
};
|
|
|
|
|
2012-01-30 12:05:19 +00:00
|
|
|
struct telnet_connection {
|
2006-06-02 10:36:31 +00:00
|
|
|
char *prompt;
|
2016-04-13 09:00:19 +00:00
|
|
|
bool prompt_visible;
|
2006-06-02 10:36:31 +00:00
|
|
|
enum telnet_states state;
|
|
|
|
char line[TELNET_LINE_MAX_SIZE];
|
2016-04-13 09:00:19 +00:00
|
|
|
size_t line_size;
|
|
|
|
size_t line_cursor;
|
2006-06-02 10:36:31 +00:00
|
|
|
char last_escape;
|
|
|
|
char *history[TELNET_LINE_HISTORY_SIZE];
|
2016-04-13 09:00:19 +00:00
|
|
|
size_t next_history;
|
|
|
|
size_t current_history;
|
|
|
|
bool closed;
|
2009-11-13 16:07:36 +00:00
|
|
|
};
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2012-01-30 12:05:19 +00:00
|
|
|
struct telnet_service {
|
2006-06-02 10:36:31 +00:00
|
|
|
char *banner;
|
2009-11-13 16:06:56 +00:00
|
|
|
};
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2009-11-09 11:38:34 +00:00
|
|
|
int telnet_init(char *banner);
|
2009-11-13 21:25:47 +00:00
|
|
|
int telnet_register_commands(struct command_context *command_context);
|
2018-02-14 23:22:42 +00:00
|
|
|
void telnet_service_free(void);
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#endif /* OPENOCD_SERVER_TELNET_SERVER_H */
|