summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Lloyd <lathiat@bur.st>2005-08-19 17:55:51 +0000
committerTrent Lloyd <lathiat@bur.st>2005-08-19 17:55:51 +0000
commita52bd64a8db2c07bb2309cf2d8b888cc1a47ec56 (patch)
tree592dc6a9b9faacd293805d105666d0bb2d19c2c9
parent2551f4d1cb1c2dfb02474c3ff4b5c2606076ffba (diff)
* Add support for specifying the protocol in service definition files
* Add support for proper URL encoding of IPv6 addresses to avahi-bookmarks * Cast some calls in dbus-watch-glue to get rid of warnings git-svn-id: file:///home/lennart/svn/public/avahi/trunk@357 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--avahi-common/dbus-watch-glue.c6
-rw-r--r--avahi-daemon/avahi-service.dtd2
-rw-r--r--avahi-daemon/example.service1
-rw-r--r--avahi-daemon/static-services.c32
-rwxr-xr-xavahi-utils/avahi-bookmarks.in7
-rw-r--r--man/avahi.service.5.xml.in4
6 files changed, 47 insertions, 5 deletions
diff --git a/avahi-common/dbus-watch-glue.c b/avahi-common/dbus-watch-glue.c
index 11192f8..7ca1c9d 100644
--- a/avahi-common/dbus-watch-glue.c
+++ b/avahi-common/dbus-watch-glue.c
@@ -286,13 +286,13 @@ int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) {
if (!(d->dispatch_timeout = poll_api->timeout_new(poll_api, NULL, dispatch_timeout_callback, d)))
goto fail;
- if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), connection_data_unref)))
+ if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref)))
goto fail;
- if (!(dbus_connection_set_timeout_functions(c, add_timeout, remove_timeout, timeout_toggled, connection_data_ref(d), connection_data_unref)))
+ if (!(dbus_connection_set_timeout_functions(c, add_timeout, remove_timeout, timeout_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref)))
goto fail;
- dbus_connection_set_dispatch_status_function(c, dispatch_status, connection_data_ref(d), connection_data_unref);
+ dbus_connection_set_dispatch_status_function(c, dispatch_status, connection_data_ref(d), (DBusFreeFunction)connection_data_unref);
if (dbus_connection_get_dispatch_status(c) == DBUS_DISPATCH_DATA_REMAINS)
request_dispatch(d);
diff --git a/avahi-daemon/avahi-service.dtd b/avahi-daemon/avahi-service.dtd
index 3c62764..c8477f1 100644
--- a/avahi-daemon/avahi-service.dtd
+++ b/avahi-daemon/avahi-service.dtd
@@ -14,5 +14,7 @@
<!ATTLIST host-name>
<!ELEMENT port (#PCDATA)>
<!ATTLIST port>
+<!ELEMENT protocol (#PCDATA)>
+<!ATTLIST protocol>
<!ELEMENT txt-record (#PCDATA)>
<!ATTLIST txt-record>
diff --git a/avahi-daemon/example.service b/avahi-daemon/example.service
index 9b2e891..72ab8ea 100644
--- a/avahi-daemon/example.service
+++ b/avahi-daemon/example.service
@@ -21,6 +21,7 @@
<domain-name>local</domain-name>
<host-name>quux.local</host-name>
<port>4711</port>
+ <protocol>any</protocol>
<txt-record>this=is</txt-record>
<txt-record>a=really</txt-record>
<txt-record>bad=example</txt-record>
diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c
index 0c0c563..f659371 100644
--- a/avahi-daemon/static-services.c
+++ b/avahi-daemon/static-services.c
@@ -50,6 +50,7 @@ struct StaticService {
char *domain_name;
char *host_name;
uint16_t port;
+ int protocol;
AvahiStringList *txt_records;
@@ -110,6 +111,7 @@ static StaticService *static_service_new(StaticServiceGroup *group) {
s->type = s->host_name = s->domain_name = NULL;
s->port = 0;
+ s->protocol = AF_UNSPEC;
s->txt_records = NULL;
@@ -215,7 +217,7 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
if (avahi_server_add_service_strlst(
avahi_server,
g->entry_group,
- -1, AF_UNSPEC,
+ -1, s->protocol,
g->chosen_name, s->type,
s->domain_name, s->host_name, s->port,
s->txt_records) < 0) {
@@ -246,6 +248,7 @@ typedef enum {
XML_TAG_DOMAIN_NAME,
XML_TAG_HOST_NAME,
XML_TAG_PORT,
+ XML_TAG_PROTOCOL,
XML_TAG_TXT_RECORD
} xml_tag_name;
@@ -312,6 +315,11 @@ static void XMLCALL xml_start(void *data, const char *el, const char *attr[]) {
goto invalid_attr;
u->current_tag = XML_TAG_PORT;
+ } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "protocol") == 0) {
+ if (attr[0])
+ goto invalid_attr;
+
+ u->current_tag = XML_TAG_PROTOCOL;
} else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "txt-record") == 0) {
if (attr[0])
goto invalid_attr;
@@ -383,6 +391,26 @@ static void XMLCALL xml_end(void *data, const char *el) {
break;
}
+ case XML_TAG_PROTOCOL: {
+ int protocol;
+ assert(u->service);
+
+ if (strcasecmp (u->buf, "ipv4") == 0) {
+ protocol = AF_INET;
+ } else if (strcasecmp (u->buf, "ipv6") == 0) {
+ protocol = AF_INET6;
+ } else if (strcasecmp (u->buf, "any") == 0) {
+ protocol = AF_UNSPEC;
+ } else {
+ avahi_log_error("%s: parse failure: invalid protocol specification \"%s\".", u->group->filename, u->buf);
+ u->failed = 1;
+ return;
+ }
+
+ u->service->protocol = protocol;
+ break;
+ }
+
case XML_TAG_TXT_RECORD: {
assert(u->service);
@@ -452,7 +480,9 @@ static void XMLCALL xml_cdata(void *data, const XML_Char *s, int len) {
break;
case XML_TAG_PORT:
+ case XML_TAG_PROTOCOL:
case XML_TAG_TXT_RECORD:
+ assert(u->service);
u->buf = append_cdata(u->buf, s, len);
break;
diff --git a/avahi-utils/avahi-bookmarks.in b/avahi-utils/avahi-bookmarks.in
index 2dd01be..ce8eba1 100755
--- a/avahi-utils/avahi-bookmarks.in
+++ b/avahi-utils/avahi-bookmarks.in
@@ -96,7 +96,12 @@ class AvahiBookmarks(resource.Resource):
path = self.find_path(v[4])
- t += '<li><a href="%s://%s%s%s">%s</a></li>' % (urlproto[k[3]], v[2], port, path, k[2])
+ if v[1] == avahi.PROTO_INET6:
+ ip = "[" + v[2] + "]"
+ else:
+ ip = v[2]
+
+ t += '<li><a href="%s://%s%s%s">%s</a></li>' % (urlproto[k[3]], ip, port, path, k[2])
t += '</ul>'
diff --git a/man/avahi.service.5.xml.in b/man/avahi.service.5.xml.in
index 89d9c03..5260ef2 100644
--- a/man/avahi.service.5.xml.in
+++ b/man/avahi.service.5.xml.in
@@ -88,6 +88,10 @@
</option>
<option>
+ <p><opt>&lt;protocol&gt;</opt> The protocol to advertise the service on, can be any of <opt>ipv4</opt>, <opt>ipv6</opt> or <opt>any</opt>.</p>
+ </option>
+
+ <option>
<p><opt>&lt;txt-record&gt;</opt> DNS-SD TXT record data.</p>
</option>