From 2b6b02ee7eaad2539e26eb9507833aa3c1c9c15e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 7 Dec 2020 13:51:46 +0000 Subject: [tls] Use intf_insert() to add TLS to an interface Restructure the use of add_tls() to insert a TLS filter onto an existing interface. This allows for the possibility of using add_tls() to start TLS on an existing connection (as used in several protocols which will negotiate the choice to use TLS before the ClientHello is sent). Signed-off-by: Michael Brown --- src/include/ipxe/http.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/include/ipxe/http.h') diff --git a/src/include/ipxe/http.h b/src/include/ipxe/http.h index 0893c9537..117f174af 100644 --- a/src/include/ipxe/http.h +++ b/src/include/ipxe/http.h @@ -45,11 +45,9 @@ struct http_scheme { * * @v xfer Data transfer interface * @v name Host name - * @v next Next interface * @ret rc Return status code */ - int ( * filter ) ( struct interface *xfer, const char *name, - struct interface **next ); + int ( * filter ) ( struct interface *xfer, const char *name ); }; /** HTTP scheme table */ -- cgit v1.2.3-55-g7522 From be47c2c72cd3cdecc146eca5a200d454643bcf06 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 Dec 2020 14:55:44 +0000 Subject: [http] Hide HTTP transport-layer filter implementation details Signed-off-by: Michael Brown --- src/include/ipxe/http.h | 6 +++--- src/net/tcp/httpconn.c | 3 +-- src/net/tcp/https.c | 14 +++++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/include/ipxe/http.h') diff --git a/src/include/ipxe/http.h b/src/include/ipxe/http.h index 117f174af..5a9baddcb 100644 --- a/src/include/ipxe/http.h +++ b/src/include/ipxe/http.h @@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include struct http_transaction; +struct http_connection; /****************************************************************************** * @@ -43,11 +44,10 @@ struct http_scheme { unsigned int port; /** Transport-layer filter (if any) * - * @v xfer Data transfer interface - * @v name Host name + * @v conn HTTP connection * @ret rc Return status code */ - int ( * filter ) ( struct interface *xfer, const char *name ); + int ( * filter ) ( struct http_connection *conn ); }; /** HTTP scheme table */ diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c index 2804e09d5..f9221b27e 100644 --- a/src/net/tcp/httpconn.c +++ b/src/net/tcp/httpconn.c @@ -301,8 +301,7 @@ int http_connect ( struct interface *xfer, struct uri *uri ) { goto err_open; /* Add filter, if any */ - if ( scheme->filter && - ( ( rc = scheme->filter ( &conn->socket, uri->host ) ) != 0 ) ) + if ( scheme->filter && ( ( rc = scheme->filter ( conn ) ) != 0 ) ) goto err_filter; /* Attach to parent interface, mortalise self, and return */ diff --git a/src/net/tcp/https.c b/src/net/tcp/https.c index e91000322..5a44bdebf 100644 --- a/src/net/tcp/https.c +++ b/src/net/tcp/https.c @@ -31,12 +31,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #include +#include #include #include #include FEATURE ( FEATURE_PROTOCOL, "HTTPS", DHCP_EB_FEATURE_HTTPS, 1 ); +/** + * Add HTTPS filter + * + * @v conn HTTP connection + * @ret rc Return status code + */ +static int https_filter ( struct http_connection *conn ) { + + return add_tls ( &conn->socket, conn->uri->host ); +} + /** HTTPS URI opener */ struct uri_opener https_uri_opener __uri_opener = { .scheme = "https", @@ -47,5 +59,5 @@ struct uri_opener https_uri_opener __uri_opener = { struct http_scheme https_scheme __http_scheme = { .name = "https", .port = HTTPS_PORT, - .filter = add_tls, + .filter = https_filter, }; -- cgit v1.2.3-55-g7522