X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fstatus.c;h=4aa134e9f78c15c55cb87a68f1a346bb5f18ef62;hb=df7560dfdb12b06090dc4b2c6e88d0858930b591;hp=acb363a3e9d4ef8ecb9076e79ab93894b0ffce2e;hpb=8448400556f92eae2e399d29bad89939c5581c03;p=netatalk.git diff --git a/etc/afpd/status.c b/etc/afpd/status.c index acb363a3..4aa134e9 100644 --- a/etc/afpd/status.c +++ b/etc/afpd/status.c @@ -28,12 +28,9 @@ #endif /* BSD4_4 */ #endif -#include -#include +#include + #include -#include -#include -#include #include #include #include @@ -77,7 +74,7 @@ static int status_server(char *data, const char *server, const struct afp_option char *start = data; char *Obj, *Type, *Zone; char buf[32]; - u_int16_t status; + uint16_t status; size_t len; /* make room for all offsets before server name */ @@ -85,9 +82,6 @@ static int status_server(char *data, const char *server, const struct afp_option /* extract the obj part of the server */ Obj = (char *) server; -#ifndef NO_DDP - nbp_name(server, &Obj, &Type, &Zone); -#endif if ((size_t)-1 == (len = convert_string( options->unixcharset, options->maccharset, Obj, -1, buf, sizeof(buf))) ) { @@ -125,7 +119,7 @@ static int status_server(char *data, const char *server, const struct afp_option static void status_machine(char *data) { char *start = data; - u_int16_t status; + uint16_t status; int len; #ifdef AFS const char *machine = "afs"; @@ -160,11 +154,11 @@ static void status_machine(char *data) } /* server signature is a 16-byte quantity */ -static u_int16_t status_signature(char *data, int *servoffset, +static uint16_t status_signature(char *data, int *servoffset, const struct afp_options *options) { char *status; - u_int16_t offset, sigoff; + uint16_t offset, sigoff; status = data; @@ -187,14 +181,11 @@ static u_int16_t status_signature(char *data, int *servoffset, } static size_t status_netaddress(char *data, int *servoffset, -#ifndef NO_DDP - const ASP asp, -#endif - const DSI *dsi, - const struct afp_options *options) + const DSI *dsi, + const struct afp_options *options) { char *begin; - u_int16_t offset; + uint16_t offset; size_t addresses_len = 0; begin = data; @@ -215,9 +206,6 @@ static size_t status_netaddress(char *data, int *servoffset, connection, but we don't have the ip address. to get around this, we turn off the status flag for tcp/ip. */ *data++ = ((options->fqdn && dsi)? 1 : 0) + (dsi ? 1 : 0) + -#ifndef NO_DDP - (asp ? 1 : 0) + -#endif (((options->flags & OPTION_ANNOUNCESSH) && options->fqdn && dsi)? 1 : 0); /* ip address */ @@ -291,23 +279,6 @@ static size_t status_netaddress(char *data, int *servoffset, } } -#ifndef NO_DDP - if (asp) { - const struct sockaddr_at *ddpaddr = atp_sockaddr(asp->asp_atp); - - /* ddp address */ - *data++ = 6; - *data++ = 0x03; /* ddp address */ - memcpy(data, &ddpaddr->sat_addr.s_net, sizeof(ddpaddr->sat_addr.s_net)); - data += sizeof(ddpaddr->sat_addr.s_net); - memcpy(data, &ddpaddr->sat_addr.s_node, - sizeof(ddpaddr->sat_addr.s_node)); - data += sizeof(ddpaddr->sat_addr.s_node); - memcpy(data, &ddpaddr->sat_port, sizeof(ddpaddr->sat_port)); - data += sizeof(ddpaddr->sat_port); - } -#endif /* ! NO_DDP */ - /* calculate/store Directory Services Names offset */ offset = htons(data - begin); *servoffset += sizeof(offset); @@ -322,7 +293,7 @@ static size_t status_directorynames(char *data, int *diroffset, const struct afp_options *options) { char *begin = data; - u_int16_t offset; + uint16_t offset; memcpy(&offset, data + *diroffset, sizeof(offset)); offset = ntohs(offset); data += offset; @@ -362,9 +333,9 @@ static size_t status_directorynames(char *data, int *diroffset, } /* Calculate and store offset for UTF8ServerName */ - *diroffset += sizeof(u_int16_t); + *diroffset += sizeof(uint16_t); offset = htons(data - begin); - memcpy(begin + *diroffset, &offset, sizeof(u_int16_t)); + memcpy(begin + *diroffset, &offset, sizeof(uint16_t)); /* return length of buffer */ return (data - begin); @@ -375,10 +346,10 @@ static size_t status_utf8servername(char *data, int *nameoffset, const struct afp_options *options) { char *Obj, *Type, *Zone; - u_int16_t namelen; + uint16_t namelen; size_t len; char *begin = data; - u_int16_t offset, status; + uint16_t offset, status; memcpy(&offset, data + *nameoffset, sizeof(offset)); offset = ntohs(offset); @@ -394,25 +365,21 @@ static size_t status_utf8servername(char *data, int *nameoffset, /* extract the obj part of the server */ Obj = (char *) (options->server ? options->server : options->hostname); -#ifndef NO_DDP - nbp_name(options->server ? options->server : options->hostname, &Obj, &Type, &Zone); -#endif if ((size_t) -1 == (len = convert_string ( - options->unixcharset, CH_UTF8_MAC, - Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) { - LOG ( log_error, logtype_afpd, "Could not set utf8 servername"); + options->unixcharset, CH_UTF8_MAC, + Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) { + LOG ( log_error, logtype_afpd, "Could not set utf8 servername"); - /* set offset to 0 */ - memset(begin + *nameoffset, 0, sizeof(offset)); + /* set offset to 0 */ + memset(begin + *nameoffset, 0, sizeof(offset)); data = begin + offset; - } - else { + } else { namelen = htons(len); memcpy( data, &namelen, sizeof(namelen)); data += sizeof(namelen); data += len; offset = htons(offset); - memcpy(begin + *nameoffset, &offset, sizeof(u_int16_t)); + memcpy(begin + *nameoffset, &offset, sizeof(uint16_t)); } /* return length of buffer */ @@ -426,7 +393,7 @@ static void status_icon(char *data, const unsigned char *icondata, { char *start = data; char *sigdata = data + sigoffset; - u_int16_t ret, status; + uint16_t ret, status; memcpy(&status, start + AFPSTATUS_ICONOFF, sizeof(status)); if ( icondata == NULL ) { @@ -446,34 +413,22 @@ static void status_icon(char *data, const unsigned char *icondata, /* --------------------- */ -void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig, +void status_init(AFPConfig *dsiconfig, const struct afp_options *options) { -#ifndef NO_DDP - ASP asp; -#endif DSI *dsi; char *status = NULL; size_t statuslen; int c, sigoff, ipok; - if (!(aspconfig || dsiconfig) || !options) + if (!dsiconfig || !options) return; - -#ifndef NO_DDP - if (aspconfig) { - status = aspconfig->status; - maxstatuslen=sizeof(aspconfig->status); - asp = aspconfig->obj.handle; - } else - asp = NULL; -#endif ipok = 0; if (dsiconfig) { status = dsiconfig->status; maxstatuslen=sizeof(dsiconfig->status); - dsi = dsiconfig->obj.handle; + dsi = dsiconfig->obj.dsi; if (dsi->server.ss_family == AF_INET) { /* IPv4 */ const struct sockaddr_in *sa4 = (struct sockaddr_in *)&dsi->server; ipok = sa4->sin_addr.s_addr ? 1 : 0; @@ -519,11 +474,7 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig, c = status_server(status, options->server ? options->server : options->hostname, options); status_machine(status); - status_versions(status, -#ifndef NO_DDP - asp, -#endif - dsi); + status_versions(status, dsi); status_uams(status, options->uamlist); if (options->flags & OPTION_CUSTOMICON) status_icon(status, icon, sizeof(icon), c); @@ -533,11 +484,7 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig, sigoff = status_signature(status, &c, options); /* c now contains the offset where the netaddress offset lives */ - status_netaddress(status, &c, -#ifndef NO_DDP - asp, -#endif - dsi, options); + status_netaddress(status, &c, dsi, options); /* c now contains the offset where the Directory Names Count offset lives */ statuslen = status_directorynames(status, &c, dsi, options); @@ -546,16 +493,6 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig, if ( statuslen < maxstatuslen) statuslen = status_utf8servername(status, &c, dsi, options); -#ifndef NO_DDP - if (aspconfig) { - if (dsiconfig) /* status is dsiconfig->status */ - memcpy(aspconfig->status, status, statuslen); - asp_setstatus(asp, status, statuslen); - aspconfig->signature = status + sigoff; - aspconfig->statuslen = statuslen; - } -#endif /* ! NO_DDP */ - if (dsiconfig) { if ((options->flags & OPTION_CUSTOMICON) == 0) { status_icon(status, apple_tcp_icon, sizeof(apple_tcp_icon), 0);