Date: Wed, 20 Jun 2007 11:39:19 GMT From: Fredrik Lindberg <fli@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122029 for review Message-ID: <200706201139.l5KBdJkK053060@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122029 Change 122029 by fli@fli_genesis on 2007/06/20 11:38:49 - Add/change record database structures - Add record database prototypes - Add configuration prototypes - Removed a (now) unused member of struct cache {} Affected files ... .. //depot/projects/soc2007/fli-mdns_sd/mdnsd/mdnsd.h#3 edit Differences ... ==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/mdnsd.h#3 (text+ko) ==== @@ -37,6 +37,7 @@ #include "event.h" #include "mdns.h" #include "record.h" +#include "var.h" #include "debug.h" #ifdef HAVE_PTHREAD @@ -90,10 +91,21 @@ */ struct cache { struct records c_recs; - int c_timer; TAILQ_HEAD(, cache_res) c_list; /* time delta list */ }; +/* + * Database record set + */ +struct dbr_rec; +struct dbr { + MAGIC(dbr_magic); + void *dbr_ctx; + TAILQ_HEAD(, dbr_rec) dbr_reclist; + struct records dbr_recs; + struct vars dbr_vars; +}; + /* Event identifier */ struct md_if_ev { TAILQ_ENTRY(md_if_ev) ifev_next; @@ -116,46 +128,92 @@ #define MIF_DYING 0x0001 /* Interface is going away */ #define MIF_LINKUP 0x0002 /* Link is up (carrier) */ #define MIF_LINKCHG 0x0004 /* Link state change pending */ +#define MIF_UDP4 0x0008 +#define MIF_TCP4 0x0010 +#define MIF_UDP6 0x0020 +#define MIF_TCP6 0x0040 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; + struct dbr mif_dbr; char mif_ifnam[IFNAMSIZ]; }; /* - * Self-claimed record state + * Database record resource name */ +struct dbr_rec { + struct record dr_rec; + MAGIC(dr_magic); + struct dbr *dr_dbr; + int dr_type; + int dr_state; + wchar_t **dr_names; /* unexpanded source strings */ + int dr_cur; /* current alternative */ + int dr_flags; +#define DR_CLONE 0x01 /* record is a clone */ + size_t dr_clones; /* number of clones */ + union { + TAILQ_HEAD(recclone_head, dbr_rec) head; + TAILQ_ENTRY(dbr_rec) next; + } dr_clone; + struct dbr_rec *dr_chead; /* clone head */ +}; + 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 */ + DR_UNIQUE, + DR_SHARED }; -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 */ +/* + * Record state to unique self-slaimed records + * We always claim name uniquness on the record level + */ +enum { + DR_TENTATIVE, /* Probe step not done */ + DR_INVALID, /* Invalid name */ + DR_PROBING, /* Probing for uniqness */ + DR_ANNOUNCING, /* Annonucing a uniqe name */ + DR_OK, /* Record is OK */ + DR_CONFLICT, /* Conflict with other peer */ }; -struct db_rec { - struct record dc_rec; - /* vartag name */ +/* + * Database record type + */ +struct dbr_type { + struct record_type dt_type; + MAGIC(dt_magic); + struct dbr_rec *dt_rec; + int dt_state; +#define DT_SHARED 0x01 +#define DT_UNIQUE 0x02 + int dt_flags; }; -struct db { - struct records db_recs; +/* + * Database record resource data + */ +struct dbr_res { + struct record_res ds_res; + MAGIC(ds_magic); + struct dbr_type *ds_type; + uint32_t ds_ttl; /* resource ttl */ + wchar_t *ds_vdata; /* unexpanded source string */ + wchar_t *ds_data; /* expanded source string */ +#define DS_CLONE 0x01 /* resource is a clone */ +#define DS_INVALID 0x02 /* unable to expand vdata */ + int ds_flags; + size_t ds_clones; /* number of clones */ + union { + TAILQ_HEAD(clone_head, dbr_res) head; + TAILQ_ENTRY(dbr_res) next; + } ds_clone; + struct dbr_res *ds_chead; /* clone head */ }; - /* cache.c */ void cache_init(struct cache *); void cache_destroy(struct cache *); @@ -167,4 +225,15 @@ void cache_clean(struct cache *); void cache_set_ttl(struct cache *, struct record_res *, uint32_t); +/* dbrec.c */ +void dbr_init(struct dbr *, void *); +void dbr_destroy(struct dbr *); +struct dbr_rec * dbr_add(struct dbr *, wchar_t **, int); +void dbr_del(struct dbr_rec *); +struct dbr_res * dbr_res_add(struct dbr_rec *, uint16_t, uint32_t, wchar_t *); +void dbr_res_del(struct dbr_res *); + +/* parse.y */ +int cfg_read(struct dbr *r, const char *, const char *); + #endif /* _MDNSD_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706201139.l5KBdJkK053060>