Browse Source

Placeholder for TLS insertion

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a3695b1ff6
2 changed files with 31 additions and 8 deletions
  1. 12
    0
      src/include/gpxe/tls.h
  2. 19
    8
      src/net/tcp/http.c

+ 12
- 0
src/include/gpxe/tls.h View File

1
+#ifndef _GPXE_TLS_H
2
+#define _GPXE_TLS_H
3
+
4
+#include <errno.h>
5
+
6
+struct stream_application;
7
+
8
+static inline int add_tls ( struct stream_application *app __unused ) {
9
+	return -ENOTSUP;
10
+}
11
+
12
+#endif /* _GPXE_TLS_H */

+ 19
- 8
src/net/tcp/http.c View File

37
 #include <gpxe/download.h>
37
 #include <gpxe/download.h>
38
 #include <gpxe/resolv.h>
38
 #include <gpxe/resolv.h>
39
 #include <gpxe/tcp.h>
39
 #include <gpxe/tcp.h>
40
+#include <gpxe/tls.h>
40
 #include <gpxe/http.h>
41
 #include <gpxe/http.h>
41
 
42
 
42
 static struct async_operations http_async_operations;
43
 static struct async_operations http_async_operations;
387
  */
388
  */
388
 int http_get ( struct uri *uri, struct buffer *buffer, struct async *parent ) {
389
 int http_get ( struct uri *uri, struct buffer *buffer, struct async *parent ) {
389
 	struct http_request *http = NULL;
390
 	struct http_request *http = NULL;
391
+	struct sockaddr_tcpip *st;
390
 	int rc;
392
 	int rc;
391
 
393
 
392
 	/* Allocate and populate HTTP structure */
394
 	/* Allocate and populate HTTP structure */
398
 	http->buffer = buffer;
400
 	http->buffer = buffer;
399
 	async_init ( &http->async, &http_async_operations, parent );
401
 	async_init ( &http->async, &http_async_operations, parent );
400
 	http->stream.op = &http_stream_operations;
402
 	http->stream.op = &http_stream_operations;
403
+	st = ( struct sockaddr_tcpip * ) &http->server;
404
+	st->st_port = htons ( uri_port ( http->uri, HTTP_PORT ) );
405
+
406
+	/* Open TCP connection */
407
+	if ( ( rc = tcp_open ( &http->stream ) ) != 0 )
408
+		goto err;
409
+	if ( strcmp ( http->uri->scheme, "https" ) == 0 ) {
410
+		st->st_port = htons ( uri_port ( http->uri, HTTPS_PORT ) );
411
+		if ( ( rc = add_tls ( &http->stream ) ) != 0 )
412
+			goto err;
413
+	}
401
 
414
 
402
 	/* Start name resolution.  The download proper will start when
415
 	/* Start name resolution.  The download proper will start when
403
 	 * name resolution completes.
416
 	 * name resolution completes.
424
 static void http_sigchld ( struct async *async, enum signal signal __unused ) {
437
 static void http_sigchld ( struct async *async, enum signal signal __unused ) {
425
 	struct http_request *http =
438
 	struct http_request *http =
426
 		container_of ( async, struct http_request, async );
439
 		container_of ( async, struct http_request, async );
427
-	struct sockaddr_tcpip *st = ( struct sockaddr_tcpip * ) &http->server;
428
 	int rc;
440
 	int rc;
429
 
441
 
430
 	/* If name resolution failed, abort now */
442
 	/* If name resolution failed, abort now */
435
 	}
447
 	}
436
 
448
 
437
 	/* Otherwise, start the HTTP connection */
449
 	/* Otherwise, start the HTTP connection */
438
-	if ( ( rc = tcp_open ( &http->stream ) ) != 0 ) {
439
-		DBGC ( http, "HTTP %p could not open stream connection: %s\n",
440
-		       http, strerror ( rc ) );
441
-		http_done ( http, rc );
442
-		return;
443
-	}
444
-	st->st_port = htons ( uri_port ( http->uri, HTTP_PORT ) );
445
 	if ( ( rc = stream_connect ( &http->stream, &http->server ) ) != 0 ) {
450
 	if ( ( rc = stream_connect ( &http->stream, &http->server ) ) != 0 ) {
446
 		DBGC ( http, "HTTP %p could not connect stream: %s\n",
451
 		DBGC ( http, "HTTP %p could not connect stream: %s\n",
447
 		       http, strerror ( rc ) );
452
 		       http, strerror ( rc ) );
472
 	.name = "http",
477
 	.name = "http",
473
 	.start_download = http_get,
478
 	.start_download = http_get,
474
 };
479
 };
480
+
481
+/** HTTPS download protocol */
482
+struct download_protocol https_download_protocol __download_protocol = {
483
+	.name = "https",
484
+	.start_download = http_get,
485
+};

Loading…
Cancel
Save