~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to libatalk/asp/asp_getreq.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: asp_getreq.c,v 1.3 2001/06/29 14:14:46 rufustfirefly 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
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include "config.h"
 
29
#endif /* HAVE_CONFIG_H */
 
30
 
 
31
#include <string.h>
 
32
#include <sys/types.h>
 
33
#include <sys/time.h>
 
34
#include <sys/uio.h>
 
35
#include <netatalk/endian.h>
 
36
#include <netatalk/at.h>
 
37
#include <atalk/atp.h>
 
38
#include <atalk/asp.h>
 
39
 
 
40
int asp_getrequest(ASP asp)
 
41
{
 
42
    struct atp_block    atpb;
 
43
    u_int16_t           seq;
 
44
 
 
45
    asp->asp_sat.sat_port = ATADDR_ANYPORT;
 
46
    atpb.atp_saddr = &asp->asp_sat;
 
47
    atpb.atp_rreqdata = asp->cmdbuf;
 
48
    atpb.atp_rreqdlen = sizeof(asp->cmdbuf);
 
49
 
 
50
    if ( atp_rreq( asp->asp_atp, &atpb ) < 0 ) {
 
51
        return( -1 );
 
52
    }
 
53
 
 
54
    asp->cmdlen = atpb.atp_rreqdlen - 4;
 
55
    asp->read_count += asp->cmdlen;
 
56
    memcpy( &seq, asp->cmdbuf + 2, sizeof(seq));
 
57
    seq = ntohs( seq );
 
58
 
 
59
    if ((asp->cmdbuf[0] != ASPFUNC_CLOSE) && (seq != asp->asp_seq)) {
 
60
        return( -2 );
 
61
    }
 
62
    if ( asp->cmdbuf[1] != asp->asp_sid ) {
 
63
        return( -3 );
 
64
    }
 
65
 
 
66
    return( asp->cmdbuf[0] ); /* the command */
 
67
}