chiark / gitweb /
sd-bus, shared: fix includes
[elogind.git] / src / libsystemd / sd-bus / bus-message.h
index 5fbe3e60307ab7fc50a1725fbed807f67138e1b5..d784e603dd7bdeddbb897ba311a854e2ebe2d3c6 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "macro.h"
 #include "sd-bus.h"
-#include "kdbus.h"
 #include "time-util.h"
 #include "bus-creds.h"
 #include "bus-protocol.h"
@@ -52,26 +51,14 @@ struct bus_container {
         char *peeked_signature;
 };
 
-struct bus_header {
-        uint8_t endian;
-        uint8_t type;
-        uint8_t flags;
-        uint8_t version;
-        uint32_t body_size;
-
-        /* Note that what the bus spec calls "serial" we'll call
-        "cookie" instead, because we don't want to imply that the
-        cookie was in any way monotonically increasing. */
-        uint32_t serial;
-        uint32_t fields_size;
-} _packed_;
-
 struct bus_body_part {
         struct bus_body_part *next;
         void *data;
+        void *mmap_begin;
         size_t size;
         size_t mapped;
         size_t allocated;
+        uint64_t memfd_offset;
         int memfd;
         bool free_this:1;
         bool munmap_this:1;
@@ -84,7 +71,7 @@ struct sd_bus_message {
 
         sd_bus *bus;
 
-        uint32_t reply_cookie;
+        uint64_t reply_cookie;
 
         const char *path;
         const char *interface;
@@ -100,6 +87,7 @@ struct sd_bus_message {
         usec_t realtime;
         uint64_t seqnum;
         int64_t priority;
+        uint64_t verify_destination_id;
 
         bool sealed:1;
         bool dont_send:1;
@@ -110,7 +98,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;
@@ -123,7 +122,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;
@@ -143,12 +142,15 @@ struct sd_bus_message {
 
         char sender_buffer[3 + DECIMAL_STR_MAX(uint64_t) + 1];
         char destination_buffer[3 + DECIMAL_STR_MAX(uint64_t) + 1];
+        char *destination_ptr;
 
         size_t header_offsets[_BUS_MESSAGE_HEADER_MAX];
         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;
@@ -162,29 +164,24 @@ static inline uint64_t BUS_MESSAGE_BSWAP64(sd_bus_message *m, uint64_t u) {
         return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_64(u) : u;
 }
 
-static inline uint32_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
-        return BUS_MESSAGE_BSWAP32(m, m->header->serial);
-}
-
-static inline uint32_t BUS_MESSAGE_BODY_SIZE(sd_bus_message *m) {
-        return BUS_MESSAGE_BSWAP32(m, m->header->body_size);
-}
+static inline uint64_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
+        if (m->header->version == 2)
+                return BUS_MESSAGE_BSWAP64(m, m->header->dbus2.cookie);
 
-static inline uint32_t BUS_MESSAGE_FIELDS_SIZE(sd_bus_message *m) {
-        return BUS_MESSAGE_BSWAP32(m, m->header->fields_size);
+        return BUS_MESSAGE_BSWAP32(m, m->header->dbus1.serial);
 }
 
-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) {
@@ -202,7 +199,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,
@@ -220,15 +220,12 @@ int bus_message_from_malloc(
                 const char *label,
                 sd_bus_message **ret);
 
-const char* bus_message_get_arg(sd_bus_message *m, unsigned i);
+int bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str, char ***strv);
 
 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) \
@@ -244,3 +241,6 @@ int bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_e
 int bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
 
 int bus_message_append_sender(sd_bus_message *m, const char *sender);
+
+void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m);
+void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m);