free(m->root_container.signature);
free(m->root_container.offsets);
- free(m->peeked_signature);
+ free(m->root_container.peeked_signature);
bus_creds_done(&m->creds);
free(m);
return -ENOMEM;
t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
- t->reply_serial = BUS_MESSAGE_SERIAL(call);
+ t->reply_cookie = BUS_MESSAGE_COOKIE(call);
- r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_serial);
+ r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_cookie);
if (r < 0)
goto fail;
int bus_message_new_synthetic_error(
sd_bus *bus,
- uint64_t serial,
+ uint64_t cookie,
const sd_bus_error *e,
sd_bus_message **m) {
return -ENOMEM;
t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
- t->reply_serial = serial;
+ t->reply_cookie = cookie;
- r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_serial);
+ r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_cookie);
if (r < 0)
goto fail;
return 0;
}
-_public_ int sd_bus_message_get_serial(sd_bus_message *m, uint64_t *serial) {
+_public_ int sd_bus_message_get_cookie(sd_bus_message *m, uint64_t *cookie) {
assert_return(m, -EINVAL);
- assert_return(serial, -EINVAL);
- assert_return(m->header->serial != 0, -ENOENT);
+ assert_return(cookie, -EINVAL);
+ assert_return(m->header->serial != 0, -ENODATA);
- *serial = BUS_MESSAGE_SERIAL(m);
+ *cookie = BUS_MESSAGE_COOKIE(m);
return 0;
}
-_public_ int sd_bus_message_get_reply_serial(sd_bus_message *m, uint64_t *serial) {
+_public_ int sd_bus_message_get_reply_cookie(sd_bus_message *m, uint64_t *cookie) {
assert_return(m, -EINVAL);
- assert_return(serial, -EINVAL);
- assert_return(m->reply_serial != 0, -ENOENT);
+ assert_return(cookie, -EINVAL);
+ assert_return(m->reply_cookie != 0, -ENODATA);
- *serial = m->reply_serial;
+ *cookie = m->reply_cookie;
return 0;
}
return r;
}
- assert(i <= c->n_offsets);
+ assert(!c->need_offsets || i <= c->n_offsets);
/* We need to add an offset for each item that has a
* variable size and that is not the last one in the
p += n;
}
- assert(i == c->n_offsets);
+ assert(!c->need_offsets || i == c->n_offsets);
+ assert(c->need_offsets || n_variable == 0);
if (n_variable <= 0) {
a = message_extend_body(m, 1, 0, add_offset);
return 0;
}
-int bus_message_seal(sd_bus_message *m, uint64_t serial, usec_t timeout) {
+int bus_message_seal(sd_bus_message *m, uint64_t cookie, usec_t timeout) {
struct bus_body_part *part;
size_t l, a;
unsigned i;
if (r < 0)
return r;
- m->header->serial = serial;
+ m->header->serial = (uint32_t) cookie;
m->timeout = m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED ? 0 : timeout;
/* Add padding at the end of the fields part, since we know
w = m->containers + m->n_containers++;
w->enclosing = type;
w->signature = signature;
+ w->peeked_signature = NULL;
w->index = 0;
w->before = before;
}
free(c->signature);
+ free(c->peeked_signature);
free(c->offsets);
m->n_containers--;
if (!sig)
return -ENOMEM;
- free(m->peeked_signature);
- m->peeked_signature = sig;
-
- *contents = sig;
+ free(c->peeked_signature);
+ *contents = c->peeked_signature = sig;
}
if (type)
if (!sig)
return -ENOMEM;
- free(m->peeked_signature);
- m->peeked_signature = sig;
-
- *contents = sig;
+ free(c->peeked_signature);
+ *contents = c->peeked_signature = sig;
}
if (type)
if (k > c->item_size)
return -EBADMSG;
- free(m->peeked_signature);
- m->peeked_signature = strndup((char*) q + 1, k - 1);
- if (!m->peeked_signature)
+ free(c->peeked_signature);
+ c->peeked_signature = strndup((char*) q + 1, k - 1);
+ if (!c->peeked_signature)
return -ENOMEM;
- if (!signature_is_valid(m->peeked_signature, true))
+ if (!signature_is_valid(c->peeked_signature, true))
return -EBADMSG;
- *contents = m->peeked_signature;
+ *contents = c->peeked_signature;
} else {
size_t rindex, l;
}
case BUS_MESSAGE_HEADER_REPLY_SERIAL:
- if (m->reply_serial != 0)
+ if (m->reply_cookie != 0)
return -EBADMSG;
if (!streq(signature, "u"))
return -EBADMSG;
- r = message_peek_field_uint32(m, &ri, item_size, &m->reply_serial);
+ r = message_peek_field_uint32(m, &ri, item_size, &m->reply_cookie);
if (r < 0)
return r;
- if (m->reply_serial == 0)
+ if (m->reply_cookie == 0)
return -EBADMSG;
break;
case SD_BUS_MESSAGE_METHOD_RETURN:
- if (m->reply_serial == 0)
+ if (m->reply_cookie == 0)
return -EBADMSG;
break;
case SD_BUS_MESSAGE_METHOD_ERROR:
- if (m->reply_serial == 0 || !m->error.name)
+ if (m->reply_cookie == 0 || !m->error.name)
return -EBADMSG;
break;
}
if (!n)
return -ENOMEM;
- n->reply_serial = (*m)->reply_serial;
- r = message_append_field_uint32(n, BUS_MESSAGE_HEADER_REPLY_SERIAL, n->reply_serial);
+ n->reply_cookie = (*m)->reply_cookie;
+ r = message_append_field_uint32(n, BUS_MESSAGE_HEADER_REPLY_SERIAL, n->reply_cookie);
if (r < 0)
return r;
if (timeout == 0 && !((*m)->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED))
timeout = BUS_DEFAULT_TIMEOUT;
- r = bus_message_seal(n, (*m)->header->serial, timeout);
+ r = bus_message_seal(n, BUS_MESSAGE_COOKIE(*m), timeout);
if (r < 0)
return r;