summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-message.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-26 21:48:08 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-26 21:52:07 +0100
commitb381de4197157748ed96e469fcc372c23f842ae1 (patch)
tree5f5fa7cc7a4a703c294d92b9501772857a286fdb /src/libsystemd/sd-bus/bus-message.h
parentee04388a54f0e045377eeaf33c17eb357fe12d69 (diff)
sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects
Previously, we only minimally altered the dbus1 framing for kdbus, and while the header and its fields where compliant Gvariant objects, and so was the body, the entire message together was not. As result of discussions with Ryan Lortie this is now changed, so that the messages in there entirely are fully compliant GVariants. This follows the framing description described here: https://wiki.gnome.org/Projects/GLib/GDBus/Version2 Note that this change changes the framing of *all* messages sent via kdbus, this means you have to reboot your kdbus system, after compiling and installing this new version.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-message.h')
-rw-r--r--src/libsystemd/sd-bus/bus-message.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.h b/src/libsystemd/sd-bus/bus-message.h
index b4cdce7bf..32955329b 100644
--- a/src/libsystemd/sd-bus/bus-message.h
+++ b/src/libsystemd/sd-bus/bus-message.h
@@ -99,7 +99,18 @@ struct sd_bus_message {
bool release_kdbus:1;
bool poisoned:1;
+ /* The first and last bytes of the message */
struct bus_header *header;
+ void *footer;
+
+ /* How many bytes are accessible in the above pointers */
+ size_t header_accessible;
+ size_t footer_accessible;
+
+ size_t fields_size;
+ size_t body_size;
+ size_t user_body_size;
+
struct bus_body_part body;
struct bus_body_part *body_end;
unsigned n_body_parts;
@@ -112,7 +123,7 @@ struct sd_bus_message {
int *fds;
struct bus_container root_container, *containers;
- unsigned n_containers;
+ size_t n_containers;
size_t containers_allocated;
struct iovec *iovec;
@@ -138,7 +149,9 @@ struct sd_bus_message {
unsigned n_header_offsets;
};
-#define BUS_MESSAGE_NEED_BSWAP(m) ((m)->header->endian != BUS_NATIVE_ENDIAN)
+static inline bool BUS_MESSAGE_NEED_BSWAP(sd_bus_message *m) {
+ return m->header->endian != BUS_NATIVE_ENDIAN;
+}
static inline uint16_t BUS_MESSAGE_BSWAP16(sd_bus_message *m, uint16_t u) {
return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_16(u) : u;
@@ -153,29 +166,23 @@ static inline uint64_t BUS_MESSAGE_BSWAP64(sd_bus_message *m, uint64_t u) {
}
static inline uint64_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
- /* Note that we return the serial converted to a 64bit value here */
- return BUS_MESSAGE_BSWAP32(m, m->header->serial);
-}
+ if (m->header->version == 2)
+ return BUS_MESSAGE_BSWAP64(m, m->header->dbus2.cookie);
-static inline uint32_t BUS_MESSAGE_BODY_SIZE(sd_bus_message *m) {
- return BUS_MESSAGE_BSWAP32(m, m->header->body_size);
+ return BUS_MESSAGE_BSWAP32(m, m->header->dbus1.serial);
}
-static inline uint32_t BUS_MESSAGE_FIELDS_SIZE(sd_bus_message *m) {
- return BUS_MESSAGE_BSWAP32(m, m->header->fields_size);
-}
-
-static inline uint32_t BUS_MESSAGE_SIZE(sd_bus_message *m) {
+static inline size_t BUS_MESSAGE_SIZE(sd_bus_message *m) {
return
sizeof(struct bus_header) +
- ALIGN8(BUS_MESSAGE_FIELDS_SIZE(m)) +
- BUS_MESSAGE_BODY_SIZE(m);
+ ALIGN8(m->fields_size) +
+ m->body_size;
}
-static inline uint32_t BUS_MESSAGE_BODY_BEGIN(sd_bus_message *m) {
+static inline size_t BUS_MESSAGE_BODY_BEGIN(sd_bus_message *m) {
return
sizeof(struct bus_header) +
- ALIGN8(BUS_MESSAGE_FIELDS_SIZE(m));
+ ALIGN8(m->fields_size);
}
static inline void* BUS_MESSAGE_FIELDS(sd_bus_message *m) {
@@ -193,7 +200,10 @@ int bus_message_read_strv_extend(sd_bus_message *m, char ***l);
int bus_message_from_header(
sd_bus *bus,
void *header,
- size_t length,
+ size_t header_accessible,
+ void *footer,
+ size_t footer_accessible,
+ size_t message_size,
int *fds,
unsigned n_fds,
const struct ucred *ucred,
@@ -217,9 +227,6 @@ int bus_message_append_ap(sd_bus_message *m, const char *types, va_list ap);
int bus_message_parse_fields(sd_bus_message *m);
-bool bus_header_is_complete(struct bus_header *h, size_t size);
-int bus_header_message_size(struct bus_header *h, size_t *sum);
-
struct bus_body_part *message_append_part(sd_bus_message *m);
#define MESSAGE_FOREACH_PART(part, i, m) \