]> arthur.barton.de Git - netatalk.git/blob - libatalk/asp/asp_shutdown.c
massive commenting/autoconf changes
[netatalk.git] / libatalk / asp / asp_shutdown.c
1 /*
2  * $Id: asp_shutdown.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
3  *
4  * Copyright (c) 1996 Regents of The University of Michigan.
5  * All Rights Reserved.  See COPYRIGHT.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif /* HAVE_CONFIG_H */
11
12 #include <string.h>
13 #include <sys/types.h>
14 #include <sys/time.h>
15 #include <sys/uio.h>
16 #include <netatalk/endian.h>
17 #include <netatalk/at.h>
18 #include <atalk/atp.h>
19 #include <atalk/asp.h>
20
21 int asp_shutdown( asp )
22     ASP                 asp;
23 {
24     struct atp_block    atpb;
25     struct iovec        iov;
26     char                *p;
27     u_int16_t           seq;
28     u_int8_t            oport;
29
30
31     p = asp->commands;
32     *p++ = ASPFUNC_CLOSE;
33     *p++ = asp->asp_sid;
34     seq = 0;
35     memcpy( p, &seq, sizeof(seq));
36     p += sizeof(seq);
37
38     oport = asp->asp_sat.sat_port;
39     atpb.atp_saddr = &asp->asp_sat;
40     atpb.atp_saddr->sat_port = asp->asp_wss;
41     atpb.atp_sreqdata = asp->commands;
42     atpb.atp_sreqdlen = p - asp->commands;
43     atpb.atp_sreqto = 2;
44     atpb.atp_sreqtries = 5;
45
46     if ( atp_sreq( asp->asp_atp, &atpb, 1, ATP_XO ) < 0 ) {
47         asp->asp_sat.sat_port = oport;
48         return( -1 );
49     }
50
51     iov.iov_base = asp->commands;
52     iov.iov_len = ASP_CMDSIZ;
53     atpb.atp_rresiov = &iov;
54     atpb.atp_rresiovcnt = 1;
55
56     if ( atp_rresp( asp->asp_atp, &atpb ) < 0 ) {
57         asp->asp_sat.sat_port = oport;
58         return( -1 );
59     }
60     asp->asp_sat.sat_port = oport;
61
62     return( 0 );
63 }