]> git.meshlink.io Git - catta/blob - flx.h
* Complete conflict detection stuff (including probing et al)
[catta] / flx.h
1 #ifndef fooflxhfoo
2 #define fooflxhfoo
3
4 #include <stdio.h>
5 #include <glib.h>
6
7 typedef struct _flxServer flxServer;
8 typedef struct _flxEntry flxEntry;
9 typedef struct _flxEntryGroup flxEntryGroup;
10
11 #include "address.h"
12 #include "rr.h"
13
14 typedef enum {
15     FLX_ENTRY_NULL = 0,
16     FLX_ENTRY_UNIQUE = 1,
17     FLX_ENTRY_NOPROBE = 2,
18     FLX_ENTRY_NOANNOUNCE = 4
19 } flxEntryFlags;
20
21 typedef enum {
22     FLX_ENTRY_GROUP_UNCOMMITED,
23     FLX_ENTRY_GROUP_REGISTERING,
24     FLX_ENTRY_GROUP_ESTABLISHED,
25     FLX_ENTRY_GROUP_COLLISION
26 } flxEntryGroupStatus;
27
28 typedef void (*flxEntryGroupCallback) (flxServer *s, flxEntryGroup *g, flxEntryGroupStatus status, gpointer userdata);
29
30 flxServer *flx_server_new(GMainContext *c);
31 void flx_server_free(flxServer* s);
32
33 const flxRecord *flx_server_iterate(flxServer *s, flxEntryGroup *g, void **state);
34 void flx_server_dump(flxServer *s, FILE *f);
35
36 flxEntryGroup *flx_entry_group_new(flxServer *s, flxEntryGroupCallback callback, gpointer userdata);
37 void flx_entry_group_free(flxEntryGroup *g);
38 void flx_entry_group_commit(flxEntryGroup *g);
39 flxEntryGroupStatus flx_entry_group_get_status(flxEntryGroup *g);
40
41 void flx_server_add(
42     flxServer *s,
43     flxEntryGroup *g,
44     gint interface,
45     guchar protocol,
46     flxEntryFlags flags,
47     flxRecord *r);
48
49 void flx_server_add_ptr(
50     flxServer *s,
51     flxEntryGroup *g,
52     gint interface,
53     guchar protocol,
54     flxEntryFlags flags,
55     const gchar *name,
56     const gchar *dest);
57
58 void flx_server_add_address(
59     flxServer *s,
60     flxEntryGroup *g,
61     gint interface,
62     guchar protocol,
63     flxEntryFlags flags,
64     const gchar *name,
65     flxAddress *a);
66
67 void flx_server_add_text(
68     flxServer *s,
69     flxEntryGroup *g,
70     gint interface,
71     guchar protocol,
72     flxEntryFlags flags,
73     const gchar *name,
74     ... /* text records, terminated by NULL */);
75
76 void flx_server_add_text_va(
77     flxServer *s,
78     flxEntryGroup *g,
79     gint interface,
80     guchar protocol,
81     flxEntryFlags flags,
82     const gchar *name,
83     va_list va);
84
85 void flx_server_add_service(
86     flxServer *s,
87     flxEntryGroup *g,
88     gint interface,
89     guchar protocol,
90     const gchar *type,
91     const gchar *name,
92     const gchar *domain,
93     const gchar *host,
94     guint16 port,
95     ...  /* text records, terminated by NULL */);
96
97 void flx_server_add_service_va(
98     flxServer *s,
99     flxEntryGroup *g,
100     gint interface,
101     guchar protocol,
102     const gchar *type,
103     const gchar *name,
104     const gchar *domain,
105     const gchar *host,
106     guint16 port,
107     va_list va);
108
109 typedef enum {
110     FLX_SUBSCRIPTION_NEW,
111     FLX_SUBSCRIPTION_REMOVE,
112     FLX_SUBSCRIPTION_CHANGE
113 } flxSubscriptionEvent;
114
115 typedef struct _flxSubscription flxSubscription;
116
117 typedef void (*flxSubscriptionCallback)(flxSubscription *s, flxRecord *record, gint interface, guchar protocol, flxSubscriptionEvent event, gpointer userdata);
118
119 flxSubscription *flx_subscription_new(flxServer *s, flxKey *key, gint interface, guchar protocol, flxSubscriptionCallback callback, gpointer userdata);
120 void flx_subscription_free(flxSubscription *s);
121
122 #endif