]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[http] Hide HTTP transport-layer filter implementation details
authorMichael Brown <mcb30@ipxe.org>
Tue, 8 Dec 2020 14:55:44 +0000 (14:55 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 Dec 2020 15:04:28 +0000 (15:04 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/http.h
src/net/tcp/httpconn.c
src/net/tcp/https.c

index 117f174af2391f858997f5febab2e13c104ae7ae..5a9baddcb4366f159d9a61887ceb87bbdb66944f 100644 (file)
@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/ntlm.h>
 
 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 */
index 2804e09d54da781fa0c51e3f64ca4ebbbd0c674d..f9221b27eb7311273a911108958dc2eb73750395 100644 (file)
@@ -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 */
index e9100032200cd0ef125c96d63c3017291f133cfc..5a44bdebf36c8c71eab00bd0668d3043158e0504 100644 (file)
@@ -31,12 +31,24 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  */
 
 #include <ipxe/open.h>
+#include <ipxe/uri.h>
 #include <ipxe/tls.h>
 #include <ipxe/http.h>
 #include <ipxe/features.h>
 
 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,
 };