Procházet zdrojové kódy

Allowed HTTPS to be a separately configurable feature.

tags/v0.9.3
Michael Brown před 17 roky
rodič
revize
bf3d8fb1aa
5 změnil soubory, kde provedl 76 přidání a 13 odebrání
  1. 1
    0
      src/config.h
  2. 3
    0
      src/core/config.c
  3. 5
    0
      src/include/gpxe/http.h
  4. 21
    13
      src/net/tcp/http.c
  5. 46
    0
      src/net/tcp/https.c

+ 1
- 0
src/config.h Zobrazit soubor

73
 #define	DOWNLOAD_PROTO_TFTP	/* Trivial File Transfer Protocol */
73
 #define	DOWNLOAD_PROTO_TFTP	/* Trivial File Transfer Protocol */
74
 #undef	DOWNLOAD_PROTO_NFS	/* Network File System */
74
 #undef	DOWNLOAD_PROTO_NFS	/* Network File System */
75
 #define	DOWNLOAD_PROTO_HTTP	/* Hypertext Transfer Protocol */
75
 #define	DOWNLOAD_PROTO_HTTP	/* Hypertext Transfer Protocol */
76
+#undef	DOWNLOAD_PROTO_HTTPS	/* Secure Hypertext Transfer Protocol */
76
 #undef	DOWNLOAD_PROTO_FTP	/* File Transfer Protocol */
77
 #undef	DOWNLOAD_PROTO_FTP	/* File Transfer Protocol */
77
 #undef	DOWNLOAD_PROTO_TFTM	/* Multicast Trivial File Transfer Protocol */
78
 #undef	DOWNLOAD_PROTO_TFTM	/* Multicast Trivial File Transfer Protocol */
78
 #undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */
79
 #undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */

+ 3
- 0
src/core/config.c Zobrazit soubor

87
 #ifdef DOWNLOAD_PROTO_HTTP
87
 #ifdef DOWNLOAD_PROTO_HTTP
88
 REQUIRE_OBJECT ( http );
88
 REQUIRE_OBJECT ( http );
89
 #endif
89
 #endif
90
+#ifdef DOWNLOAD_PROTO_HTTPS
91
+REQUIRE_OBJECT ( https );
92
+#endif
90
 #ifdef DOWNLOAD_PROTO_FTP
93
 #ifdef DOWNLOAD_PROTO_FTP
91
 REQUIRE_OBJECT ( ftp );
94
 REQUIRE_OBJECT ( ftp );
92
 #endif
95
 #endif

+ 5
- 0
src/include/gpxe/http.h Zobrazit soubor

13
 /** HTTPS default port */
13
 /** HTTPS default port */
14
 #define HTTPS_PORT 443
14
 #define HTTPS_PORT 443
15
 
15
 
16
+extern int http_open_filter ( struct xfer_interface *xfer, struct uri *uri,
17
+			      unsigned int default_port,
18
+			      int ( * filter ) ( struct xfer_interface *,
19
+						 struct xfer_interface ** ) );
20
+
16
 #endif /* _GPXE_HTTP_H */
21
 #endif /* _GPXE_HTTP_H */

+ 21
- 13
src/net/tcp/http.c Zobrazit soubor

40
 #include <gpxe/tcpip.h>
40
 #include <gpxe/tcpip.h>
41
 #include <gpxe/process.h>
41
 #include <gpxe/process.h>
42
 #include <gpxe/linebuf.h>
42
 #include <gpxe/linebuf.h>
43
-#include <gpxe/tls.h>
44
 #include <gpxe/http.h>
43
 #include <gpxe/http.h>
45
 
44
 
46
 /** HTTP receive state */
45
 /** HTTP receive state */
459
 };
458
 };
460
 
459
 
461
 /**
460
 /**
462
- * Initiate an HTTP connection
461
+ * Initiate an HTTP connection, with optional filter
463
  *
462
  *
464
  * @v xfer		Data transfer interface
463
  * @v xfer		Data transfer interface
465
  * @v uri		Uniform Resource Identifier
464
  * @v uri		Uniform Resource Identifier
465
+ * @v default_port	Default port number
466
+ * @v filter		Filter to apply to socket, or NULL
466
  * @ret rc		Return status code
467
  * @ret rc		Return status code
467
  */
468
  */
468
-static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
469
+int http_open_filter ( struct xfer_interface *xfer, struct uri *uri,
470
+		       unsigned int default_port,
471
+		       int ( * filter ) ( struct xfer_interface *xfer,
472
+					  struct xfer_interface **next ) ) {
469
 	struct http_request *http;
473
 	struct http_request *http;
470
 	struct sockaddr_tcpip server;
474
 	struct sockaddr_tcpip server;
471
 	struct xfer_interface *socket;
475
 	struct xfer_interface *socket;
487
 
491
 
488
 	/* Open socket */
492
 	/* Open socket */
489
 	memset ( &server, 0, sizeof ( server ) );
493
 	memset ( &server, 0, sizeof ( server ) );
490
-	server.st_port = htons ( uri_port ( http->uri, HTTP_PORT ) );
494
+	server.st_port = htons ( uri_port ( http->uri, default_port ) );
491
 	socket = &http->socket;
495
 	socket = &http->socket;
492
-	if ( strcmp ( http->uri->scheme, "https" ) == 0 ) {
493
-		server.st_port = htons ( uri_port ( http->uri, HTTPS_PORT ) );
494
-		if ( ( rc = add_tls ( socket, &socket ) ) != 0 )
496
+	if ( filter ) {
497
+		if ( ( rc = filter ( socket, &socket ) ) != 0 )
495
 			goto err;
498
 			goto err;
496
 	}
499
 	}
497
 	if ( ( rc = xfer_open_named_socket ( socket, SOCK_STREAM,
500
 	if ( ( rc = xfer_open_named_socket ( socket, SOCK_STREAM,
512
 	return rc;
515
 	return rc;
513
 }
516
 }
514
 
517
 
518
+/**
519
+ * Initiate an HTTP connection
520
+ *
521
+ * @v xfer		Data transfer interface
522
+ * @v uri		Uniform Resource Identifier
523
+ * @ret rc		Return status code
524
+ */
525
+static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
526
+	return http_open_filter ( xfer, uri, HTTP_PORT, NULL );
527
+}
528
+
515
 /** HTTP URI opener */
529
 /** HTTP URI opener */
516
 struct uri_opener http_uri_opener __uri_opener = {
530
 struct uri_opener http_uri_opener __uri_opener = {
517
 	.scheme	= "http",
531
 	.scheme	= "http",
518
 	.open	= http_open,
532
 	.open	= http_open,
519
 };
533
 };
520
-
521
-/** HTTPS URI opener */
522
-struct uri_opener https_uri_opener __uri_opener = {
523
-	.scheme	= "https",
524
-	.open	= http_open,
525
-};

+ 46
- 0
src/net/tcp/https.c Zobrazit soubor

1
+/*
2
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+/**
20
+ * @file
21
+ *
22
+ * Secure Hyper Text Transfer Protocol (HTTPS)
23
+ *
24
+ */
25
+
26
+#include <stddef.h>
27
+#include <gpxe/open.h>
28
+#include <gpxe/tls.h>
29
+#include <gpxe/http.h>
30
+
31
+/**
32
+ * Initiate an HTTPS connection
33
+ *
34
+ * @v xfer		Data transfer interface
35
+ * @v uri		Uniform Resource Identifier
36
+ * @ret rc		Return status code
37
+ */
38
+static int https_open ( struct xfer_interface *xfer, struct uri *uri ) {
39
+	return http_open_filter ( xfer, uri, HTTPS_PORT, add_tls );
40
+}
41
+
42
+/** HTTPS URI opener */
43
+struct uri_opener https_uri_opener __uri_opener = {
44
+	.scheme	= "https",
45
+	.open	= https_open,
46
+};

Načítá se…
Zrušit
Uložit