]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_mdns.c
Merge 2-2
[netatalk.git] / etc / afpd / afp_mdns.c
index 2088402f05436013c0dd3724079574359213d942..e14791fee2dd93c4db6b8deef1c65f92ba168b77 100644 (file)
 #include <atalk/util.h>
 #include <atalk/dsi.h>
 #include <atalk/unicode.h>
+#include <atalk/netatalk_conf.h>
 
 #include "afp_zeroconf.h"
 #include "afp_mdns.h"
-#include "afp_config.h"
-#include "volume.h"
 
 /*
  * We'll store all the DNSServiceRef's here so that we can
@@ -115,9 +114,8 @@ static void unregister_stuff() {
  * This function tries to register the AFP DNS
  * SRV service type.
  */
-static void register_stuff(const AFPConfig *configs) {
+static void register_stuff(const AFPObj *obj) {
     uint                                        port;
-    const AFPConfig                 *config;
     const struct vol                *volume;
     DSI                                         *dsi;
     char                                        name[MAXINSTANCENAMELEN+1];
@@ -138,7 +136,7 @@ static void register_stuff(const AFPConfig *configs) {
 
     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;
         }
@@ -159,10 +157,10 @@ static void register_stuff(const AFPConfig *configs) {
 
     // Now we can count the configs so we know how many service
     // records to allocate
-    for (config = configs; config; config = config->next) {
+    for (dsi = obj->dsi; dsi; dsi = dsi->next) {
         svc_ref_count++;                    // AFP_DNS_SERVICE_TYPE
-        if(i) svc_ref_count++;      // ADISK_SERVICE_TYPE
-        if (config->obj.options.mimicmodel) svc_ref_count++;        // DEV_INFO_SERVICE_TYPE
+        if (i) svc_ref_count++;      // ADISK_SERVICE_TYPE
+        if (obj->options.mimicmodel) svc_ref_count++;        // DEV_INFO_SERVICE_TYPE
     }
 
     // Allocate the memory to store our service refs
@@ -171,16 +169,13 @@ static void register_stuff(const AFPConfig *configs) {
     svc_ref_count = 0;
 
     /* AFP server */
-    for (config = configs; config; config = config->next) {
+    for (dsi = obj->dsi; dsi; dsi = dsi->next) {
 
-        dsi = (DSI *)config->obj.handle;
         port = getip_port((struct sockaddr *)&dsi->server);
 
-        if (convert_string(config->obj.options.unixcharset,
+        if (convert_string(obj->options.unixcharset,
                            CH_UTF8,
-                           config->obj.options.server ?
-                           config->obj.options.server :
-                           config->obj.options.hostname,
+                           obj->options.hostname,
                            -1,
                            name,
                            MAXINSTANCENAMELEN) <= 0) {
@@ -233,9 +228,11 @@ static void register_stuff(const AFPConfig *configs) {
             }
         }
 
-        if (config->obj.options.mimicmodel) {
+        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", config->obj.options.mimicmodel);
+            TXTRecordPrintf(&txt_devinfo, "model=%s", obj->options.mimicmodel);
             error = DNSServiceRegister(&svc_refs[svc_ref_count++],
                                        0,               // no flags
                                        0,               // all network interfaces
@@ -243,7 +240,7 @@ static void register_stuff(const AFPConfig *configs) {
                                        DEV_INFO_SERVICE_TYPE,
                                        "",            // default domains
                                        NULL,            // default host name
-                                       htons(port),
+                                       0,
                                        TXTRecordGetLength(&txt_devinfo),
                                        TXTRecordGetBytesPtr(&txt_devinfo),
                                        RegisterReply,           // callback
@@ -279,10 +276,10 @@ fail:
  * Tries to setup the Zeroconf thread and any
  * neccessary config setting.
  */
-void md_zeroconf_register(const AFPConfig *configs) {
+void md_zeroconf_register(const AFPObj *obj) {
     int error;
 
-    register_stuff(configs);
+    register_stuff(obj);
     return;
 }