]> git.meshlink.io Git - catta/blobdiff - server.h
fix some memory corruption bugs
[catta] / server.h
index f1a15fc9efc4e8ed2c4535f37ceeb2a439f51b81..d050bcc1574682171244de69484dd712019eaf89 100644 (file)
--- a/server.h
+++ b/server.h
@@ -1,50 +1,29 @@
 #ifndef fooflxserverhfoo
 #define fooflxserverhfoo
 
+typedef struct _flxServerEntry flxServerEntry;
+
 #include "flx.h"
 #include "iface.h"
-
-struct _flxEntry;
-typedef struct _flxEntry flxEntry;
-struct _flxEntry {
-    flxRecord rr;
+#include "prioq.h"
+#include "llist.h"
+#include "timeeventq.h"
+#include "announce.h"
+#include "subscribe.h"
+
+struct _flxServerEntry {
+    flxRecord *record;
     gint id;
     gint interface;
     guchar protocol;
 
     gboolean unique;
 
-    flxEntry *next, *prev;
-    flxEntry *next_by_name, *prev_by_name;
-    flxEntry *next_by_id, *prev_by_id;
-};
-
-typedef struct _flxQueryJob {
-    gint ref;
-    flxQuery query;
-} flxQueryJob;
-
-struct _flxQueryJobInstance;
-typedef struct _flxQueryJobInstance flxQueryJobInstance;
-struct _flxQueryJobInstance {
-    flxQueryJob *job;
-    gint interface;
-    guchar protocol;
-    flxQueryJobInstance *next, *prev;
-};
-
-typedef struct _flxResponseJob {
-    gint ref;
-    flxRecord response;
-} flxResponseJob;
-
-struct _flxResponseJobInstance;
-typedef struct _flxResponseJobInstance flxResponseJobInstance;
-struct _flxResponseJobInstance {
-    flxResponseJob *job;
-    gint interface;
-    guchar protocol;
-    flxResponseJob *next, *prev;
+    FLX_LLIST_FIELDS(flxServerEntry, entry);
+    FLX_LLIST_FIELDS(flxServerEntry, by_key);
+    FLX_LLIST_FIELDS(flxServerEntry, by_id);
+    
+    FLX_LLIST_HEAD(flxAnnouncement, announcements);
 };
 
 struct _flxServer {
@@ -53,25 +32,24 @@ struct _flxServer {
 
     gint current_id;
     
+    FLX_LLIST_HEAD(flxServerEntry, entries);
     GHashTable *rrset_by_id;
-    GHashTable *rrset_by_name;
+    GHashTable *rrset_by_key;
 
-    flxEntry *entries;
-
-    flxResponseJobInstance *first_response_job, *last_response_job;
-    flxQueryJobInstance *first_query_job, *last_query_job;
-};
+    FLX_LLIST_HEAD(flxSubscription, subscriptions);
+    GHashTable *subscription_hashtable;
 
-flxQueryJob* flx_query_job_new(void);
-flxQueryJob* flx_query_job_ref(flxQueryJob *job);
-void flx_query_job_unref(flxQueryJob *job);
-
-void flx_server_post_query_job(flxServer *s, gint interface, guchar protocol, const flxQuery *q);
-void flx_server_drop_query_job(flxServer *s, gint interface, guchar protocol, const flxQuery *q);
+    flxTimeEventQueue *time_event_queue;
+    
+    gchar *hostname;
 
-void flx_server_remove_query_job_instance(flxServer *s, flxQueryJobInstance *i);
+    gint fd_ipv4, fd_ipv6;
 
-gboolean flx_query_equal(const flxQuery *a, const flxQuery *b);
+    GPollFD pollfd_ipv4, pollfd_ipv6;
+    GSource *source;
+    
+};
 
+gboolean flx_server_entry_match_interface(flxServerEntry *e, flxInterface *i);
 
 #endif