bus-message.h revision 77adde638217112c9e080035197a76f4dc4af700
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering This file is part of systemd.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Copyright 2013 Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering (at your option) any later version.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is distributed in the hope that it will be useful, but
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Lesser General Public License for more details.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* Indexes into the signature string */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* dbus1: pointer to the array size value, if this is a value */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* gvariant: list of offsets to end of children if this is struct/dict entry/array */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering size_t *offsets, n_offsets, offsets_allocated, offset_index;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering struct bus_body_part *cached_rindex_part;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering struct bus_container root_container, *containers;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* If set replies to this message must carry the signature
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * specified here to successfully seal. This is initialized
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * from the vtable data */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering char sender_buffer[3 + DECIMAL_STR_MAX(uint64_t) + 1];
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering char destination_buffer[3 + DECIMAL_STR_MAX(uint64_t) + 1];
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering size_t header_offsets[_BUS_MESSAGE_HEADER_MAX];
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#define BUS_MESSAGE_NEED_BSWAP(m) ((m)->header->endian != BUS_NATIVE_ENDIAN)
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint16_t BUS_MESSAGE_BSWAP16(sd_bus_message *m, uint16_t u) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_16(u) : u;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint32_t BUS_MESSAGE_BSWAP32(sd_bus_message *m, uint32_t u) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_32(u) : u;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint64_t BUS_MESSAGE_BSWAP64(sd_bus_message *m, uint64_t u) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_NEED_BSWAP(m) ? bswap_64(u) : u;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint64_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* Note that we return the serial converted to a 64bit value here */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_BSWAP32(m, m->header->serial);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint32_t BUS_MESSAGE_BODY_SIZE(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_BSWAP32(m, m->header->body_size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint32_t BUS_MESSAGE_FIELDS_SIZE(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return BUS_MESSAGE_BSWAP32(m, m->header->fields_size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint32_t BUS_MESSAGE_SIZE(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering sizeof(struct bus_header) +
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline uint32_t BUS_MESSAGE_BODY_BEGIN(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering sizeof(struct bus_header) +
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline void* BUS_MESSAGE_FIELDS(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return (uint8_t*) m->header + sizeof(struct bus_header);
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmekstatic inline bool BUS_MESSAGE_IS_GVARIANT(sd_bus_message *m) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringint bus_message_seal(sd_bus_message *m, uint64_t serial, usec_t timeout);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringint bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringint bus_message_read_strv_extend(sd_bus_message *m, char ***l);
7b909d7407965c03caaba30daae7aee113627a83Josh Triplettint bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str, char ***strv);
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächlerint bus_message_append_ap(sd_bus_message *m, const char *types, va_list ap);
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidtint bus_message_parse_fields(sd_bus_message *m);
c7fdf44d08e1217d40dc092fb90a65978a0f541fLennart Poetteringbool bus_header_is_complete(struct bus_header *h, size_t size);
c7fdf44d08e1217d40dc092fb90a65978a0f541fLennart Poetteringint bus_header_message_size(struct bus_header *h, size_t *sum);
c7fdf44d08e1217d40dc092fb90a65978a0f541fLennart Poetteringstruct bus_body_part *message_append_part(sd_bus_message *m);
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett for ((i) = 0, (part) = &(m)->body; (i) < (m)->n_body_parts; (i)++, (part) = (part)->next)
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächlerint bus_body_part_map(struct bus_body_part *part);
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächlervoid bus_body_part_unmap(struct bus_body_part *part);
4cd2b2cf8ca585d15ebc859701b346658262b5bbDenis Tikhomirovint bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_error *e, sd_bus_message **m);
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächlerint bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
0c9d8f1d4b5018199cb5a9b57580dc1480a7f915Jani Nikulaint bus_message_append_sender(sd_bus_message *m, const char *sender);