peer/broadcast: factor out peer_match_filter_from_message()
This fills in a MatchFilter from the metadata given in a message. In
the future we should unify these things to be the same object, rather
than requiring them to be duplicated.
@@ -649,13 +649,7 @@ static int peer_broadcast_to_matches(PolicySnapshot *sender_policy, NameSet *sen
return 0;
}
-int peer_broadcast(PolicySnapshot *sender_policy, NameSet *sender_names, MatchRegistry *matches, uint64_t sender_id, Peer *destination, Bus *bus, MatchFilter *filter, Message *message) {
- MatchFilter fallback_filter = MATCH_FILTER_INIT;
- int r;
-
- if (!filter) {
- filter = &fallback_filter;
-
+static void peer_match_filter_from_message(MatchFilter *filter, uint64_t sender_id, Message *message) {
filter->type = message->metadata.header.type;
filter->sender = sender_id;
filter->interface = message->metadata.fields.interface;
@@ -674,6 +668,16 @@ int peer_broadcast(PolicySnapshot *sender_policy, NameSet *sender_names, MatchRe
}
}
+int peer_broadcast(PolicySnapshot *sender_policy, NameSet *sender_names, MatchRegistry *matches, uint64_t sender_id, Peer *destination, Bus *bus, MatchFilter *filter, Message *message) {
+ MatchFilter fallback_filter = MATCH_FILTER_INIT;
+ int r;
+
+ if (!filter) {
+ filter = &fallback_filter;
+
+ peer_match_filter_from_message(filter, sender_id, message);
+ }
+
/* start a new transaction, to avoid duplicates */
++bus->transaction_ids;
