Defines | Functions | Variables
httpgce.c File Reference

Google Compute Engine (GCE) metadata retrieval. More...

#include <strings.h>
#include <stdio.h>
#include <ipxe/http.h>

Go to the source code of this file.


#define GCE_METADATA_HOST_NAME   "metadata.google.internal"
 Metadata host name.


static int http_format_metadata_flavor (struct http_transaction *http, char *buf, size_t len)
 Construct HTTP "Metadata-Flavor" header.


struct http_request_header
 HTTP "Metadata-Flavor" header.

Detailed Description

Google Compute Engine (GCE) metadata retrieval.

For some unspecified "security" reason, the Google Compute Engine metadata server will refuse any requests that do not include the non-standard HTTP header "Metadata-Flavor: Google".

Definition in file httpgce.c.

Define Documentation

#define GCE_METADATA_HOST_NAME   "metadata.google.internal"

Metadata host name.

This is used to identify metadata requests, in the absence of any more robust mechanism.

Definition at line 45 of file httpgce.c.

Referenced by http_format_metadata_flavor().

Function Documentation

static int http_format_metadata_flavor ( struct http_transaction http,
char *  buf,
size_t  len 
) [static]

Construct HTTP "Metadata-Flavor" header.

httpHTTP transaction
lenLength of buffer
Return values:
lenLength of header value, or negative error

Definition at line 55 of file httpgce.c.

References GCE_METADATA_HOST_NAME, http_request::host, http_transaction::request, snprintf(), and strcasecmp().


        /* Do nothing unless this appears to be a Google Compute
         * Engine metadata request.
        if ( strcasecmp ( http->request.host, GCE_METADATA_HOST_NAME ) != 0 )
                return 0;

        /* Construct host URI */
        return snprintf ( buf, len, "Google" );

Variable Documentation

struct http_request_header http_request_metadata_flavor __http_request_header
Initial value:
        .name = "Metadata-Flavor",
        .format = http_format_metadata_flavor,

HTTP "Metadata-Flavor" header.

Definition at line 69 of file httpgce.c.