D-Bus: Add path, interface, member to responses

Add generated fields with the value from the request. D-Bus response
frames don't include fields like "member", i.e. the method name. By
adding generated fields it's easier to filter method calls and its
method return by name.
This commit is contained in:
Simon Holesch 2021-12-10 22:45:12 +01:00 committed by AndersBroman
parent 8f6a640337
commit 60aec65e9f
1 changed files with 22 additions and 2 deletions

View File

@ -240,6 +240,9 @@ typedef struct {
guint32 req_frame;
guint32 rep_frame;
nstime_t req_time;
const char *path;
const char *interface;
const char *member;
} dbus_transaction_t;
typedef struct {
@ -1015,6 +1018,9 @@ add_conversation(dbus_packet_t *packet, proto_tree *header_field_tree) {
*trans = (dbus_transaction_t){
.req_frame = packet->pinfo->num,
.req_time = packet->pinfo->fd->abs_ts,
.path = wmem_strdup(wmem_file_scope(), packet->path),
.interface = wmem_strdup(wmem_file_scope(), packet->interface),
.member = wmem_strdup(wmem_file_scope(), packet->member),
};
wmem_map_insert(conv_info->packets, GUINT_TO_POINTER(packet->serial), (void *)trans);
} else {
@ -1037,12 +1043,26 @@ add_conversation(dbus_packet_t *packet, proto_tree *header_field_tree) {
proto_item_set_generated(it);
} else {
nstime_t ns;
proto_item *it;
tvbuff_t *tvb = ptvcursor_tvbuff(packet->cursor);
proto_item *it = proto_tree_add_uint(header_field_tree, hf_dbus_response_to, ptvcursor_tvbuff(packet->cursor), 0, 0, trans->req_frame);
it = proto_tree_add_string(header_field_tree, hf_dbus_path, tvb, 0, 0, trans->path);
proto_item_set_generated(it);
packet->path = trans->path;
it = proto_tree_add_string(header_field_tree, hf_dbus_interface, tvb, 0, 0, trans->interface);
proto_item_set_generated(it);
packet->interface = trans->interface;
it = proto_tree_add_string(header_field_tree, hf_dbus_member, tvb, 0, 0, trans->member);
proto_item_set_generated(it);
packet->member = trans->member;
it = proto_tree_add_uint(header_field_tree, hf_dbus_response_to, tvb, 0, 0, trans->req_frame);
proto_item_set_generated(it);
nstime_delta(&ns, &packet->pinfo->fd->abs_ts, &trans->req_time);
it = proto_tree_add_time(header_field_tree, hf_dbus_response_time, ptvcursor_tvbuff(packet->cursor), 0, 0, &ns);
it = proto_tree_add_time(header_field_tree, hf_dbus_response_time, tvb, 0, 0, &ns);
proto_item_set_generated(it);
}
}