#include <atalk/asp.h>
#include <atalk/nbp.h>
#include <atalk/unicode.h>
+#include <atalk/util.h>
#include "globals.h" /* includes <netdb.h> */
#include "status.h"
static void status_flags(char *data, const int notif, const int ipok,
const unsigned char passwdbits, const int dirsrvcs _U_, int flags)
{
- u_int16_t status;
+ uint16_t status;
+
+ status = AFPSRVRINFO_COPY
+ | AFPSRVRINFO_SRVSIGNATURE
+ | AFPSRVRINFO_SRVMSGS
+ | AFPSRVRINFO_FASTBOZO
+ | AFPSRVRINFO_SRVRDIR
+ | AFPSRVRINFO_SRVUTF8
+ | AFPSRVRINFO_EXTSLEEP;
- status = AFPSRVRINFO_COPY;
if (passwdbits & PASSWD_SET) /* some uams may not allow this. */
status |= AFPSRVRINFO_PASSWD;
if (passwdbits & PASSWD_NOSAVE)
status |= AFPSRVRINFO_NOSAVEPASSWD;
- status |= AFPSRVRINFO_SRVSIGNATURE;
- /* only advertise tcp/ip if we have a valid address */
- if (ipok)
+ if (ipok) /* only advertise tcp/ip if we have a valid address */
status |= AFPSRVRINFO_TCPIP;
- status |= AFPSRVRINFO_SRVMSGS;
- /* Allow the user to decide if we should support server notifications.
- * With this turned off, the clients will poll for directory changes every
- * 10 seconds. This might be too costly to network resources, so make
- * this an optional thing. Default will be to _not_ support server
- * notifications. */
- if (notif) {
+ if (notif) /* Default is yes */
status |= AFPSRVRINFO_SRVNOTIFY;
- }
- status |= AFPSRVRINFO_FASTBOZO;
- status |= AFPSRVRINFO_SRVRDIR; /* AFP 3.1 specs says we need to specify this, but may set the count to 0 */
- /* We don't set the UTF8 name flag here, we don't know whether we have enough space ... */
-
- if (flags & OPTION_UUID) /* 05122008 FIXME: can we set AFPSRVRINFO_UUID here ? see AFPSRVRINFO_SRVRDIR*/
- status |= AFPSRVRINFO_UUID;
+ if (flags & OPTION_UUID)
+ status |= AFPSRVRINFO_UUID;
status = htons(status);
memcpy(data + AFPSTATUS_FLAGOFF, &status, sizeof(status));
#ifdef AFS
const char *machine = "afs";
#else /* !AFS */
- const char *machine = "Netatalk";
+ const char *machine = "Netatalk %s";
#endif /* AFS */
+ char buf[64];
memcpy(&status, start + AFPSTATUS_MACHOFF, sizeof(status));
data += ntohs( status );
- len = strlen( machine );
+
+ // len = strlen( machine );
+ len = snprintf(buf, 64, machine, VERSION);
*data++ = len;
- memcpy( data, machine, len );
+ memcpy( data, buf, len );
data += len;
+
status = htons(data - start);
memcpy(start + AFPSTATUS_VERSOFF, &status, sizeof(status));
}
data += len;
offset = htons(offset);
memcpy(begin + *nameoffset, &offset, sizeof(u_int16_t));
-
- /* Now set the flag ... */
- memcpy(&status, begin + AFPSTATUS_FLAGOFF, sizeof(status));
- status = ntohs(status);
- status |= AFPSRVRINFO_SRVUTF8;
- status = htons(status);
- memcpy(begin + AFPSTATUS_FLAGOFF, &status, sizeof(status));
}
/* return length of buffer */
options->sigconffile, strerror(errno));
goto server_signature_random;
}
- } else { /* conf file don't exist */
+ } else { /* conf file don't exist */
if (( fd = creat(options->sigconffile, 0644 )) < 0 ) {
- LOG(log_error, logtype_atalkd, "Cannot create %s (%s). Using one-time signature.",
+ LOG(log_error, logtype_afpd, "ERROR: Cannot create %s (%s). Using one-time signature.",
options->sigconffile, strerror(errno));
goto server_signature_random;
}
if (( fp = fdopen( fd, "w" )) == NULL ) {
- LOG(log_error, logtype_atalkd, "Cannot fdopen %s (%s). Using one-time signature.",
+ LOG(log_error, logtype_afpd, "ERROR: Cannot fdopen %s (%s). Using one-time signature.",
options->sigconffile, strerror(errno));
close(fd);
goto server_signature_random;