/*
- * $Id: status.c,v 1.13.6.8 2004-06-24 01:22:36 bfernhomberg Exp $
+ * $Id: status.c,v 1.13.6.9 2004-07-01 01:53:21 bfernhomberg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
/* set offset to 0 */
memset(begin + *nameoffset, 0, sizeof(offset));
- data = begin;
+ data = begin + offset;
}
else {
namelen = htons(len);
/* ---------------------
- * returns 1 if both packets (ASP and DSI) could be set
- * forceasp 1 enforces build of ASP packet
*/
-static int do_status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
- const struct afp_options *options, int forceasp)
+void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
+ const struct afp_options *options)
{
ASP asp;
DSI *dsi;
int ret = 0;
if (!(aspconfig || dsiconfig) || !options)
- return ret;
-
- if (forceasp) {
- if (!aspconfig)
- return ret;
- status = aspconfig->status;
- maxstatuslen=ATP_MAXDATA-4;
- }
- else /* dsi */
- {
- if (!dsiconfig)
- return ret;
- status = dsiconfig->status;
- maxstatuslen=sizeof(dsiconfig->status);
- }
+ return;
if (aspconfig) {
+ status = aspconfig->status;
+ maxstatuslen=sizeof(aspconfig->status);
asp = aspconfig->obj.handle;
} else
asp = NULL;
-
+
if (dsiconfig) {
+ status = dsiconfig->status;
+ maxstatuslen=sizeof(dsiconfig->status);
dsi = dsiconfig->obj.handle;
} else
dsi = NULL;
statuslen = status_utf8servername(status, &c, dsi, options);
#ifndef NO_DDP
- if (forceasp) {
+ 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 (!forceasp) {
- if (aspconfig && statuslen <= ATP_MAXDATA-4) { /* set ASP as well, lenght matches */
- memcpy(aspconfig->status, status, ATP_MAXDATA);
- asp_setstatus(asp, aspconfig->status, statuslen);
- aspconfig->signature = aspconfig->status + sigoff;
- aspconfig->statuslen = statuslen;
- ret=1;
- }
+ if (dsiconfig) {
if ((options->flags & OPTION_CUSTOMICON) == 0) {
status_icon(status, apple_tcp_icon, sizeof(apple_tcp_icon), 0);
}
dsiconfig->signature = status + sigoff;
dsiconfig->statuslen = statuslen;
}
-
- return ret;
-}
-
-void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
- const struct afp_options *options)
-{
- int ret = 0;
-
- if (dsiconfig) {
- ret = do_status_init(aspconfig, dsiconfig, options, 0);
- if (!ret)
- LOG(log_warning, logtype_afpd, "status packet to long for ASP, buildling extra packet");
- }
- if (!ret && aspconfig)
- do_status_init(aspconfig, dsiconfig, options, 1);
}
/* this is the same as asp/dsi_getstatus */
/*
- * $Id: asp_getsess.c,v 1.7.8.3 2004-04-27 22:47:32 didg Exp $
+ * $Id: asp_getsess.c,v 1.7.8.4 2004-07-01 01:53:21 bfernhomberg Exp $
*
* Copyright (c) 1990,1996 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
ASP asp_getsession(ASP asp, server_child *server_children,
const int tickleval)
{
- struct sigaction action;
- struct itimerval timer;
- struct sockaddr_at sat;
- struct atp_block atpb;
+ struct sigaction action;
+ struct itimerval timer;
+ struct sockaddr_at sat;
+ struct atp_block atpb;
ATP atp;
- struct iovec iov[ 8 ];
+ struct iovec iov[ 8 ];
pid_t pid;
- int i, sid;
- u_int16_t asperr;
+ int i, iovcnt, sid;
+ u_int16_t asperr;
+ char *buf;
+ int buflen;
if (!asp->inited) {
if (!(children = server_children))
printf( "asp stat\n" );
#endif /* EBUG */
if ( asp->asp_slen > 0 ) {
- asp->cmdbuf[0] = 0;
- memcpy( asp->cmdbuf + 4, asp->asp_status, asp->asp_slen );
- iov[ 0 ].iov_base = asp->cmdbuf;
- iov[ 0 ].iov_len = 4 + asp->asp_slen;
- atpb.atp_sresiov = iov;
- atpb.atp_sresiovcnt = 1;
- atp_sresp( asp->asp_atp, &atpb );
+ i = 0;
+ while(atpb.atp_bitmap) {
+ i++;
+ atpb.atp_bitmap >>= 1;
+ }
+
+ /* asp->data is big enough ... */
+ memcpy( asp->data, asp->asp_status, MIN(asp->asp_slen, i*ASP_CMDSIZ));
+
+ buflen = MIN(asp->asp_slen, i*ASP_CMDSIZ);
+ buf = asp->data;
+ iovcnt = 0;
+
+ /* If status information is too big to fit into the available
+ * ASP packets, we simply send as much as we can.
+ * Older client versions will most likely not be able to use
+ * the additional information anyway, like directory services
+ * or UTF8 server name. A very long fqdn could be a problem,
+ * we could end up with an invalid address list.
+ */
+ do {
+ iov[ iovcnt ].iov_base = buf;
+ memmove(buf + ASP_HDRSIZ, buf, buflen);
+ memset( iov[ iovcnt ].iov_base, 0, ASP_HDRSIZ );
+
+ if ( buflen > ASP_CMDSIZ ) {
+ buf += ASP_CMDMAXSIZ;
+ buflen -= ASP_CMDSIZ;
+ iov[ iovcnt ].iov_len = ASP_CMDMAXSIZ;
+ } else {
+ iov[ iovcnt ].iov_len = buflen + ASP_HDRSIZ;
+ buflen = 0;
+ }
+ iovcnt++;
+ } while ( iovcnt < i && buflen > 0 );
+
+ atpb.atp_sresiovcnt = iovcnt;
+ atpb.atp_sresiov = iov;
+ atp_sresp( asp->asp_atp, &atpb );
}
break;