2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation, and that the name of The University
10 * of Michigan not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. This software is supplied as is without expressed or
13 * implied warranties of any kind.
15 * Research Systems Unix Group
16 * The University of Michigan
18 * 535 W. William Street
21 * netatalk@itd.umich.edu
29 #include <sys/types.h>
31 #include <netatalk/endian.h>
32 #include <netatalk/at.h>
33 #include <atalk/atp.h>
34 #include <atalk/asp.h>
36 #if defined(BSD) || defined(BSD4_3)
37 #define memmove(a, b, n) bcopy((b), (a), (n))
40 int asp_wrtcont(ASP asp, char *buf, int *buflen)
42 struct iovec iov[ ASP_MAXPACKETS ];
43 struct atp_block atpb;
45 int iovcnt = ASP_MAXPACKETS;
50 *p++ = ASPFUNC_WRTCONT;
52 seq = htons( asp->asp_seq );
53 memcpy( p, &seq, sizeof(seq));
55 blen = htons(*buflen);
56 memcpy( p, &blen, sizeof(blen));
59 for ( iovcnt = 0; iovcnt < ASP_MAXPACKETS; iovcnt++ ) {
60 iov[iovcnt].iov_base = buf + iovcnt*ASP_CMDMAXSIZ;
61 iov[ iovcnt ].iov_len = ASP_CMDMAXSIZ;
64 oport = asp->asp_sat.sat_port;
65 atpb.atp_saddr = &asp->asp_sat;
66 atpb.atp_saddr->sat_port = asp->asp_wss;
67 atpb.atp_sreqdata = buf;
68 atpb.atp_sreqdlen = p - buf;
70 atpb.atp_sreqtries = 5;
72 if ( atp_sreq( asp->asp_atp, &atpb, iovcnt, ATP_XO ) < 0 ) {
73 asp->asp_sat.sat_port = oport;
76 asp->write_count += atpb.atp_sreqdlen;
78 atpb.atp_rresiov = iov;
79 atpb.atp_rresiovcnt = iovcnt;
80 if ( atp_rresp( asp->asp_atp, &atpb ) < 0 ) {
81 asp->asp_sat.sat_port = oport;
85 asp->asp_sat.sat_port = oport;
87 /* get rid of the 4-byte headers */
89 for ( iovcnt = 0; iovcnt < atpb.atp_rresiovcnt; iovcnt++ ) {
90 memmove(p, (char *) iov[ iovcnt ].iov_base + ASP_HDRSIZ,
91 iov[ iovcnt ].iov_len - ASP_HDRSIZ );
92 p += ( iov[ iovcnt ].iov_len - ASP_HDRSIZ );
96 asp->read_count += *buflen;