bus-dump.c revision 0258159049d5b381c6097533a69a1b29c3ba7ce2
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering This file is part of systemd.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Copyright 2013 Lennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is free software; you can redistribute it and/or modify it
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering under the terms of the GNU Lesser General Public License as published by
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering (at your option) any later version.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is distributed in the hope that it will be useful, but
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Lesser General Public License for more details.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering You should have received a copy of the GNU Lesser General Public License
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersenstatic char *indent(unsigned level, unsigned flags) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering unsigned n, i = 0;
f18ca9dcdeda247e208f7143e834fd2fb2070d80Kay Sievers if (flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY && level > 0)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (flags & BUS_MESSAGE_DUMP_WITH_HEADER)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringint bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers "%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%lli",
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_highlight_off(),
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers (long long) m->priority);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers /* Display synthetic message serial number in a more readable
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers * format than (uint32_t) -1 */
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers fprintf(f, " Cookie=%" PRIu64, BUS_MESSAGE_COOKIE(m));
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers fprintf(f, " ReplyCookie=%" PRIu64, m->reply_cookie);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers fprintf(f, " Sender=%s%s%s", ansi_highlight(), m->sender, ansi_highlight_off());
f18ca9dcdeda247e208f7143e834fd2fb2070d80Kay Sievers fprintf(f, " Destination=%s%s%s", ansi_highlight(), m->destination, ansi_highlight_off());
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers fprintf(f, " Path=%s%s%s", ansi_highlight(), m->path, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, " Interface=%s%s%s", ansi_highlight(), m->interface, ansi_highlight_off());
480a61ae742378a6a9a0eb84cf29c6c1e4ea22ffLennart Poettering fprintf(f, " Member=%s%s%s", ansi_highlight(), m->member, ansi_highlight_off());
480a61ae742378a6a9a0eb84cf29c6c1e4ea22ffLennart Poettering if (m->sender || m->destination || m->path || m->interface || m->member)
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering " ErrorName=%s%s%s"
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers " ErrorMessage=%s\"%s\"%s\n",
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers ansi_highlight_red(), strna(m->error.name), ansi_highlight_off(),
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John ansi_highlight_red(), strna(m->error.message), ansi_highlight_off());
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers fprintf(f, " Monotonic="USEC_FMT, m->monotonic);
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden fprintf(f, " Realtime="USEC_FMT, m->realtime);
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden fprintf(f, " SequenceNumber=%"PRIu64, m->seqnum);
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden if (m->monotonic != 0 || m->realtime != 0 || m->seqnum != 0)
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY));
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden log_error("Failed to rewind: %s", strerror(-r));
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature));
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_peek_type(m, &type, &contents);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen log_error("Failed to peek type: %s", strerror(-r));
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers if (r < 0) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering log_error("Failed to exit container: %s", strerror(-r));
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen prefix = indent(level, flags);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen fprintf(f, "%s};\n", prefix);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen prefix = indent(level, flags);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen if (bus_type_is_container(type) > 0) {
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_enter_container(m, type, contents);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen log_error("Failed to enter container: %s", strerror(-r));
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen if (type == SD_BUS_TYPE_ARRAY)
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen else if (type == SD_BUS_TYPE_VARIANT)
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen fprintf(f, "%sVARIANT \"%s\" {\n", prefix, contents);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen else if (type == SD_BUS_TYPE_STRUCT)
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen fprintf(f, "%sSTRUCT \"%s\" {\n", prefix, contents);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen else if (type == SD_BUS_TYPE_DICT_ENTRY)
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen fprintf(f, "%sDICT_ENTRY \"%s\" {\n", prefix, contents);
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John log_error("Failed to get basic: %s", strerror(-r));
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers fprintf(f, "%sBYTE %s%u%s;\n", prefix, ansi_highlight(), basic.u8, ansi_highlight_off());
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), true_false(basic.i), ansi_highlight_off());
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers fprintf(f, "%sINT16 %s%i%s;\n", prefix, ansi_highlight(), basic.s16, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sUINT16 %s%u%s;\n", prefix, ansi_highlight(), basic.u16, ansi_highlight_off());
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers fprintf(f, "%sINT32 %s%i%s;\n", prefix, ansi_highlight(), basic.s32, ansi_highlight_off());
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers fprintf(f, "%sUINT32 %s%u%s;\n", prefix, ansi_highlight(), basic.u32, ansi_highlight_off());
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers fprintf(f, "%sINT64 %s%"PRIi64"%s;\n", prefix, ansi_highlight(), basic.s64, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sUINT64 %s%"PRIu64"%s;\n", prefix, ansi_highlight(), basic.u64, ansi_highlight_off());
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen fprintf(f, "%sDOUBLE %s%g%s;\n", prefix, ansi_highlight(), basic.d64, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSTRING \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sOBJECT_PATH \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSIGNATURE \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen fprintf(f, "%sUNIX_FD %s%i%s;\n", prefix, ansi_highlight(), basic.i, ansi_highlight_off());
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen assert_not_reached("Unknown basic type.");
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen fprintf(f, "%s};\n\n", indent(0, flags));
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersenstatic void dump_capabilities(
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering int (*has)(sd_bus_creds *c, int capability)) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering unsigned long i, last_cap;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%s%s=%s", terse ? " " : "", name, terse ? "" : ansi_highlight());
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersenint bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
e5609878d8802e2469c433be418bcbcf55fbe63bLennart Poettering bool audit_sessionid_is_set = false, audit_loginuid_is_set = false;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering const char *u = NULL, *uu = NULL, *s = NULL, *sl = NULL;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering char **cmdline = NULL, **well_known = NULL;
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen suffix = strappenda(off, "\n");
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen if (c->mask & SD_BUS_CREDS_PID)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sPID=%s"PID_FMT"%s", prefix, color, c->pid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (c->mask & SD_BUS_CREDS_PID_STARTTIME)
f75cb30bf97f623417cc7ee4b1bcc5c36cdbeb20Dave Reisner fprintf(f, "%sPIDStartTime=%s"USEC_FMT"%s", prefix, color, c->pid_starttime, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sTID=%s"PID_FMT"%s", prefix, color, c->tid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))))
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sUID=%s"UID_FMT"%s", prefix, color, c->uid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sEUID=%s"UID_FMT"%s", prefix, color, c->euid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSUID=%s"UID_FMT"%s", prefix, color, c->suid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sFSUID=%s"UID_FMT"%s", prefix, color, c->fsuid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering r = sd_bus_creds_get_owner_uid(c, &owner);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sOwnerUID=%s"UID_FMT"%s", prefix, color, owner, suffix);
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John fprintf(f, "%sGID=%s"GID_FMT"%s", prefix, color, c->gid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sEGID=%s"GID_FMT"%s", prefix, color, c->egid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSGID=%s"GID_FMT"%s", prefix, color, c->sgid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sFSGID=%s"GID_FMT"%s", prefix, color, c->fsgid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (c->mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSupplementaryGIDs=%s", prefix, color);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering for (i = 0; i < c->n_supplementary_gids; i++)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%s" GID_FMT, i > 0 ? " " : "", c->supplementary_gids[i]);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (terse && ((c->mask & (SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering SD_BUS_CREDS_SUPPLEMENTARY_GIDS)) || r >= 0))
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sComm=%s%s%s", prefix, color, c->comm, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sTIDComm=%s%s%s", prefix, color, c->tid_comm, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sExe=%s%s%s", prefix, color, c->exe, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (terse && (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM)))
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (sd_bus_creds_get_cmdline(c, &cmdline) >= 0) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sCommandLine=%s", prefix, color);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (c->mask & SD_BUS_CREDS_SELINUX_CONTEXT)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sLabel=%s%s%s", prefix, color, c->label, suffix);
7591abd48079edc1f2adbd922e4b83eb73abeabeLennart Poettering fprintf(f, "%sDescription=%s%s%s", prefix, color, c->description, suffix);
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John if (terse && (c->mask & (SD_BUS_CREDS_SELINUX_CONTEXT|SD_BUS_CREDS_DESCRIPTION)))
4f8f66cb4236783cd3cbee97fefc9aaa8469ac08Zbigniew Jędrzejewski-Szmek if (c->mask & SD_BUS_CREDS_CGROUP)
4f8f66cb4236783cd3cbee97fefc9aaa8469ac08Zbigniew Jędrzejewski-Szmek fprintf(f, "%sCGroup=%s%s%s", prefix, color, c->cgroup, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sUnit=%s%s%s", prefix, color, u, suffix);
4f8f66cb4236783cd3cbee97fefc9aaa8469ac08Zbigniew Jędrzejewski-Szmek sd_bus_creds_get_user_unit(c, &uu);
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John fprintf(f, "%sUserUnit=%s%s%s", prefix, color, uu, suffix);
4f8f66cb4236783cd3cbee97fefc9aaa8469ac08Zbigniew Jędrzejewski-Szmek fprintf(f, "%sSlice=%s%s%s", prefix, color, sl, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sSession=%s%s%s", prefix, color, s, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (terse && ((c->mask & SD_BUS_CREDS_CGROUP) || u || uu || sl || s))
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (sd_bus_creds_get_audit_login_uid(c, &audit_loginuid) >= 0) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sAuditLoginUID=%s"UID_FMT"%s", prefix, color, audit_loginuid, suffix);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (sd_bus_creds_get_audit_session_id(c, &audit_sessionid) >= 0) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sAuditSessionID=%s%"PRIu32"%s", prefix, color, audit_sessionid, suffix);
c978343015c787713651dff571acb5207367f5f2Lennart Poettering if (terse && (audit_loginuid_is_set || audit_sessionid_is_set))
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen if (c->mask & SD_BUS_CREDS_UNIQUE_NAME)
c978343015c787713651dff571acb5207367f5f2Lennart Poettering fprintf(f, "%sUniqueName=%s%s%s", prefix, color, c->unique_name, suffix);
eb9da376d76b48585b3b63b4f91903b54f7abd36Lennart Poettering if (sd_bus_creds_get_well_known_names(c, &well_known) >= 0) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering fprintf(f, "%sWellKnownNames=%s", prefix, color);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering if (terse && (c->mask & SD_BUS_CREDS_UNIQUE_NAME || well_known))
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering dump_capabilities(c, f, "EffectiveCapabilities", terse, sd_bus_creds_has_effective_cap);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering dump_capabilities(c, f, "PermittedCapabilities", terse, sd_bus_creds_has_permitted_cap);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering dump_capabilities(c, f, "InheritableCapabilities", terse, sd_bus_creds_has_inheritable_cap);
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen dump_capabilities(c, f, "BoundingCapabilities", terse, sd_bus_creds_has_bounding_cap);
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen * For details about the file format, see:
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering * http://wiki.wireshark.org/Development/LibpcapFileFormat
546158bc6f46f8004cc11e81d19d223e0da56730Jan Janssen uint16_t version_major; /* major version number */
c978343015c787713651dff571acb5207367f5f2Lennart Poettering uint16_t version_minor; /* minor version number */
c978343015c787713651dff571acb5207367f5f2Lennart Poettering int32_t thiszone; /* GMT to local correction */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering uint32_t sigfigs; /* accuracy of timestamps */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering uint32_t snaplen; /* max length of captured packets, in octets */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering uint32_t ts_usec; /* timestamp microseconds */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering uint32_t incl_len; /* number of octets of packet saved in file */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering uint32_t orig_len; /* actual length of packet */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringint bus_pcap_header(size_t snaplen, FILE *f) {
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen assert((size_t) (uint32_t) snaplen == snaplen);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringint bus_message_pcap_frame(sd_bus_message *m, size_t snaplen, FILE *f) {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering assert((size_t) (uint32_t) snaplen == snaplen);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering hdr.incl_len = MIN(hdr.orig_len, snaplen);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /* write the pcap header */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /* write the dbus header */
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering w = MIN(BUS_MESSAGE_BODY_BEGIN(m), snaplen);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /* write the dbus body */