summaryrefslogtreecommitdiffstats
path: root/flx.h
blob: 0f7a0246e426abea6e6144be3bf9390a1850bdd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef fooflxhfoo
#define fooflxhfoo

#include <stdio.h>
#include <glib.h>

typedef struct _flxServer flxServer;
typedef struct _flxEntry flxEntry;
typedef struct _flxEntryGroup flxEntryGroup;

#include "address.h"
#include "rr.h"

typedef enum {
    FLX_ENTRY_NULL = 0,
    FLX_ENTRY_UNIQUE = 1,
    FLX_ENTRY_NOPROBE = 2,
    FLX_ENTRY_NOANNOUNCE = 4
} flxEntryFlags;

typedef enum {
    FLX_ENTRY_GROUP_UNCOMMITED,
    FLX_ENTRY_GROUP_REGISTERING,
    FLX_ENTRY_GROUP_ESTABLISHED,
    FLX_ENTRY_GROUP_COLLISION
} flxEntryGroupState;

typedef void (*flxEntryGroupCallback) (flxServer *s, flxEntryGroup *g, flxEntryGroupState state, gpointer userdata);

flxServer *flx_server_new(GMainContext *c);
void flx_server_free(flxServer* s);

const flxRecord *flx_server_iterate(flxServer *s, flxEntryGroup *g, void **state);
void flx_server_dump(flxServer *s, FILE *f);

flxEntryGroup *flx_entry_group_new(flxServer *s, flxEntryGroupCallback callback, gpointer userdata);
void flx_entry_group_free(flxEntryGroup *g);
void flx_entry_group_commit(flxEntryGroup *g);
flxEntryGroupState flx_entry_group_get_state(flxEntryGroup *g);

void flx_server_add(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    flxRecord *r);

void flx_server_add_ptr(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    const gchar *name,
    const gchar *dest);

void flx_server_add_address(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    const gchar *name,
    flxAddress *a);

void flx_server_add_text(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    const gchar *name,
    ... /* text records, terminated by NULL */);

void flx_server_add_text_va(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    const gchar *name,
    va_list va);

void flx_server_add_text_strlst(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    flxEntryFlags flags,
    const gchar *name,
    flxStringList *strlst);

void flx_server_add_service(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    const gchar *type,
    const gchar *name,
    const gchar *domain,
    const gchar *host,
    guint16 port,
    ...  /* text records, terminated by NULL */);

void flx_server_add_service_va(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    const gchar *type,
    const gchar *name,
    const gchar *domain,
    const gchar *host,
    guint16 port,
    va_list va);

void flx_server_add_service_strlst(
    flxServer *s,
    flxEntryGroup *g,
    gint interface,
    guchar protocol,
    const gchar *type,
    const gchar *name,
    const gchar *domain,
    const gchar *host,
    guint16 port,
    flxStringList *strlst);

typedef enum {
    FLX_SUBSCRIPTION_NEW,
    FLX_SUBSCRIPTION_REMOVE,
    FLX_SUBSCRIPTION_CHANGE
} flxSubscriptionEvent;

typedef struct _flxSubscription flxSubscription;

typedef void (*flxSubscriptionCallback)(flxSubscription *s, flxRecord *record, gint interface, guchar protocol, flxSubscriptionEvent event, gpointer userdata);

flxSubscription *flx_subscription_new(flxServer *s, flxKey *key, gint interface, guchar protocol, flxSubscriptionCallback callback, gpointer userdata);
void flx_subscription_free(flxSubscription *s);

#endif