aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2020-12-08 14:55:44 +0000
committerMichael Brown <mcb30@ipxe.org>2020-12-08 15:04:28 +0000
commitbe47c2c72cd3cdecc146eca5a200d454643bcf06 (patch)
treed9f42086d3bb7048f06bbb0da6e03a4ebc6e6ee8
parent1b112e9d18bb9c874b87ce5feabb7906f62351b3 (diff)
downloadipxe-be47c2c72cd3cdecc146eca5a200d454643bcf06.zip
ipxe-be47c2c72cd3cdecc146eca5a200d454643bcf06.tar.gz
ipxe-be47c2c72cd3cdecc146eca5a200d454643bcf06.tar.bz2
[http] Hide HTTP transport-layer filter implementation details
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/http.h6
-rw-r--r--src/net/tcp/httpconn.c3
-rw-r--r--src/net/tcp/https.c14
3 files changed, 17 insertions, 6 deletions
diff --git a/src/include/ipxe/http.h b/src/include/ipxe/http.h
index 117f174..5a9badd 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 <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 */
diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c
index 2804e09..f9221b2 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 e910003..5a44bde 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 <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,
};