1/*
2 * $Id: asp_close.c,v 1.5 2009-10-13 22:55:37 didg Exp $
3 *
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appears in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation, and that the name of The University
12 * of Michigan not be used in advertising or publicity pertaining to
13 * distribution of the software without specific, written prior
14 * permission. This software is supplied as is without expressed or
15 * implied warranties of any kind.
16 *
17 *	Research Systems Unix Group
18 *	The University of Michigan
19 *	c/o Mike Clark
20 *	535 W. William Street
21 *	Ann Arbor, Michigan
22 *	+1-313-763-0525
23 *	netatalk@itd.umich.edu
24 */
25
26#ifdef HAVE_CONFIG_H
27#include "config.h"
28#endif /* HAVE_CONFIG_H */
29
30#include <stdlib.h>
31#include <string.h>
32#include <sys/types.h>
33#include <sys/time.h>
34#include <sys/uio.h>
35#include <sys/socket.h>
36
37#include <netatalk/at.h>
38#include <atalk/atp.h>
39#include <atalk/asp.h>
40
41int asp_close(ASP asp)
42{
43    struct atp_block	atpb;
44    struct iovec	iov[ 1 ];
45    int err = 0;
46
47    memset(asp->commands, 0, sizeof(u_int32_t));
48
49    atpb.atp_saddr = &asp->asp_sat;
50    iov[ 0 ].iov_base = asp->commands;
51    iov[ 0 ].iov_len = sizeof(u_int32_t);
52    atpb.atp_sresiov = iov;
53    atpb.atp_sresiovcnt = 1;
54
55    if (atp_sresp( asp->asp_atp, &atpb ) < 0)
56      err = -1;
57
58    if (atp_close( asp->asp_atp ) < 0)
59      err = -1;
60
61    free( asp );
62    return err;
63}
64