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:
Antonio Borneo
2022-01-30 18:42:33 +01:00
parent 36e29f49e1
commit 99c77806fe
9 changed files with 107 additions and 46 deletions

View File

@@ -195,19 +195,22 @@ static int jsp_connection_closed(struct connection *connection)
return ERROR_OK;
}
static const struct service_driver jsp_service_driver = {
.name = "jsp",
.new_connection_during_keep_alive_handler = NULL,
.new_connection_handler = jsp_new_connection,
.input_handler = jsp_input,
.connection_closed_handler = jsp_connection_closed,
.keep_client_alive_handler = NULL,
};
int jsp_init(struct or1k_jtag *jtag_info, char *banner)
{
struct jsp_service *jsp_service = malloc(sizeof(struct jsp_service));
jsp_service->banner = banner;
jsp_service->jtag_info = jtag_info;
return add_service("jsp",
jsp_port,
1,
jsp_new_connection,
jsp_input,
jsp_connection_closed,
jsp_service);
return add_service(&jsp_service_driver, jsp_port, 1, jsp_service);
}
COMMAND_HANDLER(handle_jsp_port_command)