]> git.meshlink.io Git - catta/blob - avahi-core/core.h
add a new structure for configuration AvahiServerConfig
[catta] / avahi-core / core.h
1 #ifndef foocorehfoo
2 #define foocorehfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <stdio.h>
26 #include <glib.h>
27
28 typedef struct AvahiServer AvahiServer;
29 typedef struct AvahiEntry AvahiEntry;
30 typedef struct AvahiEntryGroup AvahiEntryGroup;
31
32 #include <avahi-core/address.h>
33 #include <avahi-core/rr.h>
34
35 typedef enum {
36     AVAHI_ENTRY_NULL = 0,
37     AVAHI_ENTRY_UNIQUE = 1,
38     AVAHI_ENTRY_NOPROBE = 2,
39     AVAHI_ENTRY_NOANNOUNCE = 4
40 } AvahiEntryFlags;
41
42 typedef enum {
43     AVAHI_ENTRY_GROUP_UNCOMMITED,
44     AVAHI_ENTRY_GROUP_REGISTERING,
45     AVAHI_ENTRY_GROUP_ESTABLISHED,
46     AVAHI_ENTRY_GROUP_COLLISION
47 } AvahiEntryGroupState;
48
49 typedef void (*AvahiEntryGroupCallback) (AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata);
50
51 typedef struct AvahiServerConfig {
52     gboolean register_hinfo;
53     gboolean register_addresses;
54     gboolean use_ipv4;
55     gboolean use_ipv6;
56     gchar *host_name;
57     gchar *domain_name;
58     gboolean check_response_ttl;
59 } AvahiServerConfig;
60
61 AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc);
62 void avahi_server_free(AvahiServer* s);
63
64 AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c);
65 AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiServerConfig *c);
66 void avahi_server_config_free(AvahiServerConfig *c);
67     
68 const gchar* avahi_server_get_domain(AvahiServer *s);
69 const gchar* avahi_server_get_host_name(AvahiServer *s);
70
71 const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state);
72 void avahi_server_dump(AvahiServer *s, FILE *f);
73
74 AvahiEntryGroup *avahi_entry_group_new(AvahiServer *s, AvahiEntryGroupCallback callback, gpointer userdata);
75 void avahi_entry_group_free(AvahiEntryGroup *g);
76 void avahi_entry_group_commit(AvahiEntryGroup *g);
77 AvahiEntryGroupState avahi_entry_group_get_state(AvahiEntryGroup *g);
78
79 void avahi_server_add(
80     AvahiServer *s,
81     AvahiEntryGroup *g,
82     gint interface,
83     guchar protocol,
84     AvahiEntryFlags flags,
85     AvahiRecord *r);
86
87 void avahi_server_add_ptr(
88     AvahiServer *s,
89     AvahiEntryGroup *g,
90     gint interface,
91     guchar protocol,
92     AvahiEntryFlags flags,
93     const gchar *name,
94     const gchar *dest);
95
96 void avahi_server_add_address(
97     AvahiServer *s,
98     AvahiEntryGroup *g,
99     gint interface,
100     guchar protocol,
101     AvahiEntryFlags flags,
102     const gchar *name,
103     AvahiAddress *a);
104
105 void avahi_server_add_text(
106     AvahiServer *s,
107     AvahiEntryGroup *g,
108     gint interface,
109     guchar protocol,
110     AvahiEntryFlags flags,
111     const gchar *name,
112     ... /* text records, terminated by NULL */);
113
114 void avahi_server_add_text_va(
115     AvahiServer *s,
116     AvahiEntryGroup *g,
117     gint interface,
118     guchar protocol,
119     AvahiEntryFlags flags,
120     const gchar *name,
121     va_list va);
122
123 void avahi_server_add_text_strlst(
124     AvahiServer *s,
125     AvahiEntryGroup *g,
126     gint interface,
127     guchar protocol,
128     AvahiEntryFlags flags,
129     const gchar *name,
130     AvahiStringList *strlst);
131
132 void avahi_server_add_service(
133     AvahiServer *s,
134     AvahiEntryGroup *g,
135     gint interface,
136     guchar protocol,
137     const gchar *type,
138     const gchar *name,
139     const gchar *domain,
140     const gchar *host,
141     guint16 port,
142     ...  /* text records, terminated by NULL */);
143
144 void avahi_server_add_service_va(
145     AvahiServer *s,
146     AvahiEntryGroup *g,
147     gint interface,
148     guchar protocol,
149     const gchar *type,
150     const gchar *name,
151     const gchar *domain,
152     const gchar *host,
153     guint16 port,
154     va_list va);
155
156 void avahi_server_add_service_strlst(
157     AvahiServer *s,
158     AvahiEntryGroup *g,
159     gint interface,
160     guchar protocol,
161     const gchar *type,
162     const gchar *name,
163     const gchar *domain,
164     const gchar *host,
165     guint16 port,
166     AvahiStringList *strlst);
167
168 typedef enum {
169     AVAHI_SUBSCRIPTION_NEW,
170     AVAHI_SUBSCRIPTION_REMOVE,
171 } AvahiSubscriptionEvent;
172
173 typedef struct AvahiSubscription AvahiSubscription;
174
175 typedef void (*AvahiSubscriptionCallback)(AvahiSubscription *s, AvahiRecord *record, gint interface, guchar protocol, AvahiSubscriptionEvent event, gpointer userdata);
176
177 AvahiSubscription *avahi_subscription_new(AvahiServer *s, AvahiKey *key, gint interface, guchar protocol, AvahiSubscriptionCallback callback, gpointer userdata);
178 void avahi_subscription_free(AvahiSubscription *s);
179
180 #endif