forked from auracaster/openocd
server: change prototype of add_service()
To easily add new methods to a service, pass all the methods through a struct. While there, drop the typedef for the methods and add currently unused new methods to support keep-alive and connections during keep-alive. No change in functionality. Change-Id: I2b5e7140db95021f6e7201e9d631ee340c60b453 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6838 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
This commit is contained in:
@@ -110,6 +110,15 @@ static int rtt_input(struct connection *connection)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static const struct service_driver rtt_service_driver = {
|
||||
.name = "rtt",
|
||||
.new_connection_during_keep_alive_handler = NULL,
|
||||
.new_connection_handler = rtt_new_connection,
|
||||
.input_handler = rtt_input,
|
||||
.connection_closed_handler = rtt_connection_closed,
|
||||
.keep_client_alive_handler = NULL,
|
||||
};
|
||||
|
||||
COMMAND_HANDLER(handle_rtt_start_command)
|
||||
{
|
||||
int ret;
|
||||
@@ -125,8 +134,7 @@ COMMAND_HANDLER(handle_rtt_start_command)
|
||||
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], service->channel);
|
||||
|
||||
ret = add_service("rtt", CMD_ARGV[0], CONNECTION_LIMIT_UNLIMITED,
|
||||
rtt_new_connection, rtt_input, rtt_connection_closed, service);
|
||||
ret = add_service(&rtt_service_driver, CMD_ARGV[0], CONNECTION_LIMIT_UNLIMITED, service);
|
||||
|
||||
if (ret != ERROR_OK) {
|
||||
free(service);
|
||||
|
||||
Reference in New Issue
Block a user