+
+int pb_protocol_deserialise_plugin_option(struct plugin_option *opt,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len, i, tmp;
+ const char *pos;
+ int rc = -1;
+ char *str;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->id = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->name = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->vendor = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->vendor_id = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->version = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->date = str;
+
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->plugin_file = str;
+
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ opt->n_executables = tmp;
+
+ opt->executables = talloc_zero_array(opt, char *, opt->n_executables);
+ if (!opt->executables)
+ goto out;
+
+ for (i = 0; i < opt->n_executables; i++) {
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->executables[i] = talloc_strdup(opt, str);
+ }
+
+ rc = 0;
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_temp_autoboot(struct autoboot_option *opt,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len, tmp;
+ const char *pos;
+ int rc = -1;
+ char *str;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+
+ opt->boot_type = tmp;
+ if (opt->boot_type == BOOT_DEVICE_TYPE) {
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ opt->type = tmp;
+
+ } else if (opt->boot_type == BOOT_DEVICE_UUID) {
+ if (read_string(opt, &pos, &len, &str))
+ goto out;
+ opt->uuid = str;
+
+ } else {
+ return -1;
+ }
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_authenticate(struct auth_message *msg,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ msg->op = *(enum auth_msg_type *)pos;
+ pos += sizeof(enum auth_msg_type);
+
+ switch (msg->op) {
+ case AUTH_MSG_REQUEST:
+ if (read_string(msg, &pos, &len, &msg->password))
+ return -1;
+ break;
+ case AUTH_MSG_RESPONSE:
+ msg->authenticated = *(bool *)pos;
+ pos += sizeof(bool);
+ break;
+ case AUTH_MSG_SET:
+ if (read_string(msg, &pos, &len, &msg->set_password.password))
+ return -1;
+ if (read_string(msg, &pos, &len,
+ &msg->set_password.new_password))
+ return -1;
+ break;
+ default:
+ pb_log("%s: unable to parse\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}