mirror of https://github.com/ipxe/ipxe.git
Quickly hack in DNS resolution as a proof of concept
parent
9af12d5fba
commit
143d14614d
|
@ -311,9 +311,6 @@ static void http_senddata ( struct tcp_application *app,
|
||||||
if ( ! path )
|
if ( ! path )
|
||||||
path = "/";
|
path = "/";
|
||||||
|
|
||||||
if ( ! host )
|
|
||||||
host = "";
|
|
||||||
|
|
||||||
len = snprintf ( buf, len,
|
len = snprintf ( buf, len,
|
||||||
"GET %s HTTP/1.1\r\n"
|
"GET %s HTTP/1.1\r\n"
|
||||||
"User-Agent: gPXE/" VERSION "\r\n"
|
"User-Agent: gPXE/" VERSION "\r\n"
|
||||||
|
@ -386,9 +383,15 @@ static struct async_operations http_async_operations = {
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int http_get ( struct uri *uri, struct buffer *buffer, struct async *parent ) {
|
int http_get ( struct uri *uri, struct buffer *buffer, struct async *parent ) {
|
||||||
struct http_request *http;
|
struct http_request *http = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
if ( ! uri->host ) {
|
||||||
|
rc = -EINVAL;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate and populate HTTP structure */
|
/* Allocate and populate HTTP structure */
|
||||||
http = malloc ( sizeof ( *http ) );
|
http = malloc ( sizeof ( *http ) );
|
||||||
if ( ! http ) {
|
if ( ! http ) {
|
||||||
|
@ -408,10 +411,23 @@ int http_get ( struct uri *uri, struct buffer *buffer, struct async *parent ) {
|
||||||
server.sin.sin_port = htons ( HTTP_PORT );
|
server.sin.sin_port = htons ( HTTP_PORT );
|
||||||
server.sin.sin_family = AF_INET;
|
server.sin.sin_family = AF_INET;
|
||||||
if ( inet_aton ( uri->host, &server.sin.sin_addr ) == 0 ) {
|
if ( inet_aton ( uri->host, &server.sin.sin_addr ) == 0 ) {
|
||||||
rc = -EINVAL;
|
/* Try DNS */
|
||||||
|
struct async async;
|
||||||
|
|
||||||
|
extern int dns_resolv ( const char *name,
|
||||||
|
struct sockaddr_tcpip *st,
|
||||||
|
struct async *parent );
|
||||||
|
|
||||||
|
async_init_orphan ( &async );
|
||||||
|
if ( ( rc = dns_resolv ( uri->host, &server.st,
|
||||||
|
&async ) ) != 0 )
|
||||||
|
goto err;
|
||||||
|
async_wait ( &async, &rc, 1 );
|
||||||
|
if ( rc != 0 )
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( ( rc = tcp_connect ( &http->tcp, &server.st, 0 ) ) != 0 )
|
if ( ( rc = tcp_connect ( &http->tcp, &server.st, 0 ) ) != 0 )
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue