]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_mdns.c
Fix _device-info service type registered with dns-sd API
[netatalk.git] / etc / afpd / afp_mdns.c
index 7c878d59bbc849b531e3e5dc983560567c446ec7..1dc6cbbb768714637f89e5077f1769abef9cd72b 100644 (file)
@@ -136,7 +136,7 @@ static void register_stuff(const AFPObj *obj) {
 
     for (volume = getvolumes(); volume; volume = volume->v_next) {
 
-        if (convert_string(CH_UCS2, CH_UTF8_MAC, volume->v_name, -1, tmpname, 255) <= 0) {
+        if (convert_string(CH_UCS2, CH_UTF8_MAC, volume->v_u8mname, -1, tmpname, 255) <= 0) {
             LOG ( log_error, logtype_afpd, "Could not set Zeroconf volume name for TimeMachine");
             goto fail;
         }
@@ -229,6 +229,8 @@ static void register_stuff(const AFPObj *obj) {
         }
 
         if (obj->options.mimicmodel) {
+            LOG(log_info, logtype_afpd, "Registering server '%s' with model '%s'",
+                dsi->bonjourname, obj->options.mimicmodel);
             TXTRecordCreate(&txt_devinfo, 0, NULL);
             TXTRecordPrintf(&txt_devinfo, "model", obj->options.mimicmodel);
             error = DNSServiceRegister(&svc_refs[svc_ref_count++],
@@ -238,7 +240,14 @@ static void register_stuff(const AFPObj *obj) {
                                        DEV_INFO_SERVICE_TYPE,
                                        "",            // default domains
                                        NULL,            // default host name
-                                       htons(port),
+                                       /*
+                                        * We would probably use port 0 zero, but we can't, from man DNSServiceRegister:
+                                        *   "A value of 0 for a port is passed to register placeholder services.
+                                        *    Place holder services are not found  when browsing, but other
+                                        *    clients cannot register with the same name as the placeholder service."
+                                        * We therefor use port 9 which is used by the adisk service type.
+                                        */
+                                       htons(9),
                                        TXTRecordGetLength(&txt_devinfo),
                                        TXTRecordGetBytesPtr(&txt_devinfo),
                                        RegisterReply,           // callback