2 * $Id: atp_rresp.c,v 1.6 2009-10-13 22:55:37 didg Exp $
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
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.
17 * Research Systems Unix Group
18 * The University of Michigan
20 * 535 W. William Street
23 * netatalk@itd.umich.edu
28 #endif /* HAVE_CONFIG_H */
32 #include <sys/types.h>
36 #include <sys/socket.h>
38 #include <netatalk/at.h>
39 #include <atalk/atp.h>
40 #include <atalk/util.h>
46 #include "atp_internals.h"
50 ATP ah, /* open atp handle */
51 struct atp_block *atpb) /* parameter block */
57 atp_print_bufuse( ah, "atp_rresp" );
61 if ( atpb->atp_rresiovcnt <= 0 || atpb->atp_rresiovcnt > 8 ) {
66 while (( rc = atp_rsel( ah, atpb->atp_saddr, ATP_TRESP )) == 0 ) {
70 if ( rc != ATP_TRESP ) {
74 for ( i = 0; i < 8; ++i ) {
75 if ( ah->atph_resppkt[ i ] == NULL ) {
78 len = ah->atph_resppkt[ i ]->atpbuf_dlen - ATP_HDRSIZE;
79 if ( i > atpb->atp_rresiovcnt - 1 ||
80 len > atpb->atp_rresiov[ i ].iov_len ) {
85 fprintf( stderr, "atp_rresp copying %ld bytes packet %d\n",
87 bprint( (char *)ah->atph_resppkt[ i ]->atpbuf_info.atpbuf_data,
90 memcpy(atpb->atp_rresiov[ i ].iov_base,
91 ah->atph_resppkt[ i ]->atpbuf_info.atpbuf_data + ATP_HDRSIZE,
93 atpb->atp_rresiov[ i ].iov_len = len;
94 atp_free_buf( ah->atph_resppkt[ i ] );
95 ah->atph_resppkt[ i ] = NULL;
97 atpb->atp_rresiovcnt = i;