]> git.ozlabs.org Git - petitboot/blobdiff - lib/pb-protocol/pb-protocol.c
lib/pb-protocol: Define new 'add-url' action
[petitboot] / lib / pb-protocol / pb-protocol.c
index d39c1c490e1a782bf5a8b9c176e7250b459a5979..866673dba1016dc64f3778dfe13f6973e28ae690 100644 (file)
@@ -284,9 +284,17 @@ int pb_protocol_config_len(const struct config *config)
 
        len += 4 + optional_strlen(config->boot_device);
 
+       len += 4 + optional_strlen(config->lang);
+
        return len;
 }
 
+int pb_protocol_url_len(const char *url)
+{
+       /* url + length field */
+       return 4 + optional_strlen(url);
+}
+
 int pb_protocol_serialise_device(const struct device *dev,
                char *buf, int buf_len)
 {
@@ -480,12 +488,26 @@ int pb_protocol_serialise_config(const struct config *config,
 
        pos += pb_protocol_serialise_string(pos, config->boot_device);
 
+       pos += pb_protocol_serialise_string(pos, config->lang);
+
        assert(pos <= buf + buf_len);
        (void)buf_len;
 
        return 0;
 }
 
+int pb_protocol_serialise_url(const char *url, char *buf, int buf_len)
+{
+       char *pos = buf;
+
+       pos += pb_protocol_serialise_string(pos, url);
+
+       assert(pos <=buf+buf_len);
+       (void)buf_len;
+
+       return 0;
+}
+
 int pb_protocol_write_message(int fd, struct pb_protocol_message *message)
 {
        int total_len, rc;
@@ -915,6 +937,11 @@ int pb_protocol_deserialise_config(struct config *config,
 
        config->boot_device = str;
 
+       if (read_string(config, &pos, &len, &str))
+               goto out;
+
+       config->lang = str;
+
        rc = 0;
 
 out: