]> git.meshlink.io Git - catta/commitdiff
Make protocol an attribute instead of an element. (Sorry Lathiat, but you broke the...
authorLennart Poettering <lennart@poettering.net>
Mon, 22 Aug 2005 23:11:22 +0000 (23:11 +0000)
committerLennart Poettering <lennart@poettering.net>
Mon, 22 Aug 2005 23:11:22 +0000 (23:11 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@401 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-daemon/avahi-service.dtd
avahi-daemon/example.service
avahi-daemon/static-services.c
man/avahi.service.5.xml.in

index c8477f19405bf4716cc7726009721b1d818418bc..8ac1ca62078cddbf3a4502e1c5949a1c3e355e30 100644 (file)
@@ -5,7 +5,7 @@
 <!ELEMENT name (#PCDATA)>
 <!ATTLIST name replace-wildcards (yes|no) "no">
 <!ELEMENT service (type,domain-name?,host-name?,port,txt-record*)>
-<!ATTLIST service>
+<!ATTLIST service protocol (ipv4|ipv6|any) "any">
 <!ELEMENT type (#PCDATA)>
 <!ATTLIST type>
 <!ELEMENT domain-name (#PCDATA)>
@@ -14,7 +14,5 @@
 <!ATTLIST host-name>
 <!ELEMENT port (#PCDATA)>
 <!ATTLIST port>
-<!ELEMENT protocol (#PCDATA)>
-<!ATTLIST protocol>
 <!ELEMENT txt-record (#PCDATA)>
 <!ATTLIST txt-record>
index 72ab8ea3b4eec198cf0108dc8d8f53dd92ba74b3..0e565b9a0523fa9268f6f88b79f7b6383b560a11 100644 (file)
     <port>631</port>
   </service>
 
-  <service>
+  <service protocol="ipv6">
     <type>_uberprinter._tcp</type>
     <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>
index e402a9853de94b07c70118e340b5d25554718282..09d7b1bac6f190ed5223564dffef3cd70b67d26c 100644 (file)
@@ -251,7 +251,6 @@ typedef enum {
     XML_TAG_DOMAIN_NAME,
     XML_TAG_HOST_NAME,
     XML_TAG_PORT,
-    XML_TAG_PROTOCOL,
     XML_TAG_TXT_RECORD
 } xml_tag_name;
 
@@ -285,19 +284,41 @@ static void XMLCALL xml_start(void *data, const char *el, const char *attr[]) {
                 u->group->replace_wildcards = strcmp(attr[1], "yes") == 0;
             else
                 goto invalid_attr;
-        }
 
-        if (attr[2])
-            goto invalid_attr;
+            if (attr[2])
+                goto invalid_attr;
+        }
         
     } else if (u->current_tag == XML_TAG_SERVICE_GROUP && strcmp(el, "service") == 0) {
-        if (attr[0])
-            goto invalid_attr;
+        u->current_tag = XML_TAG_SERVICE;
 
         assert(!u->service);
         u->service = static_service_new(u->group);
 
-        u->current_tag = XML_TAG_SERVICE;
+        if (attr[0]) {
+            if (strcmp(attr[0], "protocol") == 0) {
+                AvahiProtocol protocol;
+                
+                if (strcmp(attr[1], "ipv4") == 0) {
+                    protocol = AVAHI_PROTO_INET;
+                } else if (strcmp(attr[1], "ipv6") == 0) {
+                    protocol = AVAHI_PROTO_INET6;
+                } else if (strcmp(attr[1], "any") == 0) {
+                    protocol = AVAHI_PROTO_UNSPEC;
+                } else {
+                    avahi_log_error("%s: parse failure: invalid protocol specification \"%s\".", u->group->filename, attr[1]);
+                    u->failed = 1;
+                    return;
+                }
+
+                u->service->protocol = protocol;
+            } else
+                goto invalid_attr;
+
+            if (attr[2])
+                goto invalid_attr;
+        }
+
     } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "type") == 0) {
         if (attr[0])
             goto invalid_attr;
@@ -318,11 +339,6 @@ 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;
@@ -394,27 +410,6 @@ static void XMLCALL xml_end(void *data, const char *el) {
             break;
         }
 
-        case XML_TAG_PROTOCOL: {
-            int protocol;
-            assert(u->service);
-
-            if (u->buf && strcasecmp (u->buf, "ipv4") == 0) {
-                protocol = AVAHI_PROTO_INET;
-            } else if (u->buf && strcasecmp (u->buf, "ipv6") == 0) {
-                protocol = AVAHI_PROTO_INET6;
-            } else if (u->buf && strcasecmp (u->buf, "any") == 0) {
-                protocol = AVAHI_PROTO_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;
-           u->current_tag = XML_TAG_SERVICE;
-            break;
-        }
-
         case XML_TAG_TXT_RECORD: {
             assert(u->service);
             
@@ -484,7 +479,6 @@ 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);
index 5260ef29017bd34999725907b4e26437df29b8bf..7580d63cd409f4278f349c617514a9f28b095a69 100644 (file)
@@ -45,7 +45,7 @@
       </option>
 
       <option>
-        <p><opt>&lt;name replace-wildcards="yes|no"/&gt;</opt> The
+        <p><opt>&lt;name replace-wildcards="yes|no"&gt;</opt> The
         service name. If <opt>replace-wildcards</opt> is "yes", any
         occurence of the string "%h" will be replaced by the local
         host name. This can be used for service names like "Remote
       </option>
 
       <option>
-        <p><opt>&lt;service&gt;</opt> Contains the service information
-        for exactly one service type. Should contain one
-        <opt>&lt;type&gt;</opt> and one <opt>&lt;port&gt;</opt>
-        element. Optionally it may contain one
+        <p><opt>&lt;service protocol="ipv4|ipv6|any"&gt;</opt>
+        Contains the service information for exactly one service
+        type. Should contain one <opt>&lt;type&gt;</opt> and one
+        <opt>&lt;port&gt;</opt> element. Optionally it may contain one
         <opt>&lt;domain-name&gt;</opt>, one
         <opt>&lt;host-name&gt;</opt> and multiple
-        <opt>&lt;txt-record&gt;</opt> elements.</p>
+        <opt>&lt;txt-record&gt;</opt> elements. The attribute
+        <opt>protocol</opt> specifies the protocol to
+        advertise the service on. If <opt>any</opt> is used (which is
+        the default), the service will be advertised on both IPv4 and
+        IPv6.</p>
       </option>
 
-
       <option>
         <p><opt>&lt;type&gt;</opt> Contains the DNS-SD service type for this service. e.g. "_http._tcp".</p>
       </option>
         <p><opt>&lt;port&gt;</opt> The IP port number the service listens on.</p>
       </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>