]> git.ozlabs.org Git - petitboot/blobdiff - lib/pb-protocol/pb-protocol.c
Support HTTP(S) proxies when downloading resources
[petitboot] / lib / pb-protocol / pb-protocol.c
index 0d83bde0d11fca8f7b4902755cfa13e458a6277f..64bd16175723536423f2e1a73b3324b9fc4a1d05 100644 (file)
@@ -305,6 +305,9 @@ int pb_protocol_config_len(const struct config *config)
        for (i = 0; i < config->network.n_dns_servers; i++)
                len += 4 + optional_strlen(config->network.dns_servers[i]);
 
+       len += 4 + optional_strlen(config->http_proxy);
+       len += 4 + optional_strlen(config->https_proxy);
+
        len += 4;
        for (i = 0; i < config->n_autoboot_opts; i++) {
                if (config->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE)
@@ -323,6 +326,7 @@ int pb_protocol_config_len(const struct config *config)
                len += 4 + optional_strlen(config->consoles[i]);
 
        len += 4 + optional_strlen(config->boot_console);
+       len += 4; /* manual_console */
 
        len += 4 + optional_strlen(config->lang);
 
@@ -549,6 +553,9 @@ int pb_protocol_serialise_config(const struct config *config,
                                config->network.dns_servers[i]);
        }
 
+       pos += pb_protocol_serialise_string(pos, config->http_proxy);
+       pos += pb_protocol_serialise_string(pos, config->https_proxy);
+
        *(uint32_t *)pos = __cpu_to_be32(config->n_autoboot_opts);
        pos += 4;
        for (i = 0; i < config->n_autoboot_opts; i++) {
@@ -579,6 +586,8 @@ int pb_protocol_serialise_config(const struct config *config,
                pos += pb_protocol_serialise_string(pos, config->consoles[i]);
 
        pos += pb_protocol_serialise_string(pos, config->boot_console);
+       *(uint32_t *)pos = config->manual_console;
+       pos += 4;
 
        pos += pb_protocol_serialise_string(pos, config->lang);
 
@@ -1079,6 +1088,13 @@ int pb_protocol_deserialise_config(struct config *config,
                config->network.dns_servers[i] = str;
        }
 
+       if (read_string(config, &pos, &len, &str))
+               goto out;
+       config->http_proxy = str;
+       if (read_string(config, &pos, &len, &str))
+               goto out;
+       config->https_proxy = str;
+
        if (read_u32(&pos, &len, &config->n_autoboot_opts))
                goto out;
        config->autoboot_opts = talloc_array(config, struct autoboot_option,
@@ -1124,6 +1140,10 @@ int pb_protocol_deserialise_config(struct config *config,
 
        config->boot_console = str;
 
+       if (read_u32(&pos, &len, &tmp))
+               goto out;
+       config->manual_console = !!tmp;
+
        if (read_string(config, &pos, &len, &str))
                goto out;