kdbus_conn_unref(conn);
return ret;
}
+
+
+/**
+ * kdbus_conn_has_name() - check if a connection owns a name
+ * @conn: Connection
+ * @name: Well-know name to check for
+ *
+ * Returns true if the name is currently owned by the connection.
+ */
+bool kdbus_conn_has_name(struct kdbus_conn *conn, const char *name)
+{
+ struct kdbus_name_entry *e;
+ bool match = false;
+
+ mutex_lock(&conn->lock);
+ list_for_each_entry(e, &conn->names_list, conn_entry) {
+ if (strcmp(e->name, name) == 0) {
+ match = true;
+ break;
+ }
+ }
+ mutex_unlock(&conn->lock);
+
+ return match;
+}
struct list_head *kmsg_list);
int kdbus_conn_move_messages(struct kdbus_conn *conn_dst,
struct kdbus_conn *conn_src);
+bool kdbus_conn_has_name(struct kdbus_conn *conn, const char *name);
#endif
return 0;
}
-static inline
-bool kdbus_match_name(const char *haystack,
- size_t haystack_size,
- const char *needle)
-{
- size_t i;
-
- for (i = 0; i < haystack_size; i += strlen(haystack) + 1)
- if (strcmp(haystack + i, needle) == 0)
- return true;
-
- return false;
-}
-
-static inline
-bool kdbus_match_bloom(const u64 *filter, const u64 *mask,
+static bool kdbus_match_bloom(const u64 *filter, const u64 *mask,
const struct kdbus_conn *conn)
{
unsigned int i;
break;
case KDBUS_ITEM_NAME:
- if (!kdbus_match_name(kmsg->meta.src_names,
- kmsg->meta.src_names_len,
- r->name))
+ if (!kdbus_conn_has_name(conn_src, r->name))
return false;
break;
return 0;
mutex_lock(&conn->lock);
-
list_for_each_entry(e, &conn->names_list, conn_entry) {
struct kdbus_item *item;
size_t len;
item->name.flags = e->flags;
memcpy(item->name.name, e->name, len);
}
-
mutex_unlock(&conn->lock);
return ret;
* @data: Allocated buffer
* @size: Number of bytes used
* @allocated_size: Size of buffer
- * @src_names: List of \0-separated well-known names
- * @src_names_len: Length of list
*
* Used to collect and store connection metadata in a pre-compiled
* buffer containing struct kdbus_item.
struct kdbus_item *data;
size_t size;
size_t allocated_size;
-
- const char *src_names;
- size_t src_names_len;
};
struct kdbus_conn;