summaryrefslogtreecommitdiffstats
path: root/ffd/announce.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/announce.c')
-rw-r--r--ffd/announce.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ffd/announce.c b/ffd/announce.c
index 151d1b3..ae0a406 100644
--- a/ffd/announce.c
+++ b/ffd/announce.c
@@ -138,3 +138,28 @@ ffd_announce_t* ffd_announce_new(void) {
return a;
}
+
+ffd_announce_t* ffd_announce_find(const ffd_node_id_t *node, uint16_t type, uint16_t key) {
+ ffd_announce_t *announce;
+ for (announce = announce_list; announce; announce = announce->next) {
+ if (ffd_are_node_ids_equal(&announce->node, node)
+ && announce->type == type
+ && announce->key == key)
+ return announce;
+ }
+
+ return NULL;
+}
+
+ffd_announce_t* ffd_announce_get(const ffd_node_id_t *node, uint16_t type, uint16_t key) {
+ ffd_announce_t *announce = ffd_announce_find(node, type, key);
+
+ if (!announce) {
+ announce = ffd_announce_new();
+ announce->node = *node;
+ announce->type = type;
+ announce->key = key;
+ }
+
+ return announce;
+}