Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Jun 2007 12:26:30 GMT
From:      Fredrik Lindberg <fli@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 120774 for review
Message-ID:  <200706021226.l52CQUNV009482@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=120774

Change 120774 by fli@fli_genesis on 2007/06/02 12:25:30

	- Add a mDNS record cache (record database consumer).
	- Add structures related to self-claimed records (not complete).
	- Add some interface specific flags,
	   MIF_DYING Interface was lost, waiting for resources to free. 
	   MIF_LINKCHG Link up/down switch in progress. 
	- Add a list of per-interface active events. 

Affected files ...

.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/cache.c#1 add
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/mdnsd.h#2 edit

Differences ...

==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/mdnsd.h#2 (text+ko) ====

@@ -31,10 +31,13 @@
 #ifdef HAVE_PTHREAD
 #include <pthread.h>
 #endif
+#include <time.h>
 
 #include "wqueue.h"
 #include "event.h"
 #include "mdns.h"
+#include "record.h"
+#include "debug.h"
 
 #ifdef HAVE_PTHREAD
 #define RW_RLOCK(g,f) pthread_rwlock_rdlock(&(g)->f)
@@ -71,18 +74,97 @@
 };
 
 /*
+ * Cache resouce record
+ */
+struct cache_res {
+	MAGIC(cr_magic);
+	struct record_res cr_res;
+	TAILQ_ENTRY(cache_res) cr_next;
+	uint32_t cr_ttl_rel;
+	uint32_t cr_ttl_abs;
+	time_t cr_ctime;
+};
+
+/*
+ * Cache record set
+ */
+struct cache {
+	struct records c_recs;
+	int c_timer;
+	TAILQ_HEAD(, cache_res) c_list; /* time delta list */
+};
+
+/* Event identifier */
+struct md_if_ev {
+	TAILQ_ENTRY(md_if_ev) ifev_next;
+	int ifev_id;
+};
+
+/*
  * Interface state information
  */
 struct md_if {
+	MAGIC(mif_magic);
 	TAILQ_ENTRY(md_if) mif_next;
 #ifdef HAVE_PTHREAD
 	pthread_rwlock_t mif_lock;
 #endif
 	struct md_glob *mif_glob; /* back pointer */
+	int mif_refcnt;
 	int mif_index; /* interface index */
 	int mif_flags;
-#define MDIF_LINKUP	0x0001
+#define MIF_DYING	0x0001	/* Interface is going away */
+#define MIF_LINKUP	0x0002	/* Link is up (carrier) */
+#define MIF_LINKCHG	0x0004	/* Link state change pending */
+	TAILQ_HEAD(, md_if_ev) mif_evlist; /* Events on this iface */
+	int mif_tmr;
 	struct mdns mif_handle; /* low-level mdns stack handle */
+	struct cache mif_cache;
+	char mif_ifnam[IFNAMSIZ];
+};
+
+
+/*
+ * Self-claimed record state
+ */
+enum {
+    DBRES_PROBING, /* Probing for uniqness */
+    DBRES_ANNOUNCING, /* Annonucing a uniq name */
+    DBRES_OK, /* Record is OK */
+    DBRES_CONFLICT, /* Conflict with other peer */
+    DBRES_UNKNOWN, /* Unknown state */
+    DBRES_INVALID /* Has invalid rdata */
+};
+
+struct db_res {
+	struct record_res ds_res;
+	uint32_t ds_ttl;
+	int ds_state;
+#define DBRES_SHARED 0x0001
+#define DBRES_UNIQUE 0x0002
+	int ds_flags;
+	/* vartag rdata */
 };
 
+struct db_rec {
+	struct record dc_rec;
+	/* vartag name */
+};
+
+struct db {
+	struct records db_recs;
+};
+
+
+/* cache.c */
+void cache_init(struct cache *);
+void cache_destroy(struct cache *);
+int cache_add(struct cache *, struct mdns_rrset *, struct record_res **);
+int cache_del(struct cache *, struct record_res *);
+struct record_res * cache_find(struct cache *, char *, uint16_t);
+struct record_res * cache_find_next(struct record_res *);
+void cache_purge(struct cache *, time_t, char *, uint16_t);
+void cache_clean(struct cache *);
+void cache_set_ttl(struct cache *, struct record_res *, uint32_t);
+
 #endif /* _MDNSD_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706021226.l52CQUNV009482>