+ goto out;
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_boot_status(struct boot_status *status,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ /* first up, the type enum... */
+ if (len < sizeof(uint32_t))
+ goto out;
+
+ status->type = __be32_to_cpu(*(uint32_t *)(pos));
+
+ switch (status->type) {
+ case BOOT_STATUS_ERROR:
+ case BOOT_STATUS_INFO:
+ break;
+ default:
+ goto out;
+ }
+
+ pos += sizeof(uint32_t);
+ len -= sizeof(uint32_t);
+
+ /* message and detail strings */
+ if (read_string(status, &pos, &len, &status->message))
+ goto out;
+
+ if (read_string(status, &pos, &len, &status->detail))
+ goto out;
+
+ /* and finally, progress */
+ if (len < sizeof(uint32_t))
+ goto out;
+
+ status->progress = __be32_to_cpu(*(uint32_t *)(pos));
+
+ /* clamp to 100% */
+ if (status->progress > 100)
+ status->progress = 100;
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len, i;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ /* type and identifier strings */
+ if (read_string(sysinfo, &pos, &len, &sysinfo->type))
+ goto out;
+
+ if (read_string(sysinfo, &pos, &len, &sysinfo->identifier))
+ goto out;
+
+ /* number of interfaces */
+ if (read_u32(&pos, &len, &sysinfo->n_interfaces))
+ goto out;
+
+ sysinfo->interfaces = talloc_array(sysinfo, struct interface_info *,
+ sysinfo->n_interfaces);
+
+ for (i = 0; i < sysinfo->n_interfaces; i++) {
+ struct interface_info *if_info = talloc(sysinfo,
+ struct interface_info);
+
+ if (read_u32(&pos, &len, &if_info->hwaddr_size))
+ goto out;
+
+ if (len < if_info->hwaddr_size)
+ goto out;
+
+ if_info->hwaddr = talloc_memdup(if_info, pos,
+ if_info->hwaddr_size);
+ pos += if_info->hwaddr_size;
+ len -= if_info->hwaddr_size;
+
+ if (read_string(if_info, &pos, &len, &if_info->name))
+ goto out;
+
+ if_info->link = *(bool *)pos;
+ pos += sizeof(if_info->link);
+
+ sysinfo->interfaces[i] = if_info;
+ }
+
+ /* number of interfaces */
+ if (read_u32(&pos, &len, &sysinfo->n_blockdevs))
+ goto out;
+
+ sysinfo->blockdevs = talloc_array(sysinfo, struct blockdev_info *,
+ sysinfo->n_blockdevs);
+
+ for (i = 0; i < sysinfo->n_blockdevs; i++) {
+ struct blockdev_info *bd_info = talloc(sysinfo,
+ struct blockdev_info);
+
+ if (read_string(bd_info, &pos, &len, &bd_info->name))
+ goto out;
+
+ if (read_string(bd_info, &pos, &len, &bd_info->uuid))
+ goto out;
+
+ if (read_string(bd_info, &pos, &len, &bd_info->mountpoint))
+ goto out;
+
+ sysinfo->blockdevs[i] = bd_info;
+ }
+ rc = 0;
+
+out:
+ return rc;
+}
+
+static int pb_protocol_deserialise_config_interface(const char **buf,
+ unsigned int *len, struct interface_config *iface)
+{
+ unsigned int tmp;
+
+ if (*len < sizeof(iface->hwaddr))
+ return -1;
+
+ memcpy(iface->hwaddr, *buf, sizeof(iface->hwaddr));
+ *buf += sizeof(iface->hwaddr);
+ *len -= sizeof(iface->hwaddr);
+
+ if (read_u32(buf, len, &tmp))
+ return -1;
+ iface->ignore = !!tmp;
+
+ if (iface->ignore)
+ return 0;
+
+ if (read_u32(buf, len, &iface->method))
+ return -1;
+
+ if (iface->method == CONFIG_METHOD_STATIC) {
+ if (read_string(iface, buf, len, &iface->static_config.address))
+ return -1;
+
+ if (read_string(iface, buf, len, &iface->static_config.gateway))
+ return -1;
+ }