2 * $Id: atp.h,v 1.5 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
27 #define _ATALK_ATP_H 1
31 #include <sys/cdefs.h>
32 #include <sys/types.h>
34 #include <netatalk/at.h>
35 #include <netatalk/endian.h>
47 | control info | --> bits 7,6: function code
48 |----------------| 5: XO bit
49 | bitmap/seq no. | 4: EOM bit
50 |----------------| 3: STS bit
51 | TID (MSB) | 2,1,0: release timer code (ignored under phase I)
62 u_int8_t atphd_ctrlinfo; /* control information */
63 u_int8_t atphd_bitmap; /* bitmap or sequence number */
64 u_int16_t atphd_tid; /* transaction id. */
67 /* ATP protocol parameters
69 #define ATP_MAXDATA (578+4) /* maximum ATP data size */
70 #define ATP_BUFSIZ 587 /* maximum packet size */
71 #define ATP_HDRSIZE 5 /* includes DDP type field */
73 #define ATP_TRELMASK 0x07 /* mask all but TREL */
74 #define ATP_RELTIME 30 /* base release timer (in secs) */
76 #define ATP_TREL30 0x0 /* release time codes */
77 #define ATP_TREL1M 0x1 /* these are passed in flags of */
78 #define ATP_TREL2M 0x2 /* atp_sreq call, and set in the */
79 #define ATP_TREL4M 0x3 /* packet control info. */
80 #define ATP_TREL8M 0x4
82 #define ATP_TRIES_INFINITE -1 /* for atp_sreq, etc */
86 struct timeval atpxo_tv;
88 struct atpbuf *atpxo_packet[8];
92 struct atpbuf *atpbuf_next; /* next buffer in chain */
93 size_t atpbuf_dlen; /* data length <= ATP_BUFSIZ */
94 struct sockaddr_at atpbuf_addr; /* net address sent/recvd */
96 char atpbuf_data[ ATP_BUFSIZ ]; /* the data */
97 struct atpxobuf atpbuf_xo; /* for XO requests */
102 int atph_socket; /* ddp socket */
103 struct sockaddr_at atph_saddr; /* address */
104 u_int16_t atph_tid; /* last tid used */
105 u_int16_t atph_rtid; /* last received (rreq) */
106 u_int8_t atph_rxo; /* XO flag from last rreq */
107 int atph_rreltime; /* release time (secs) */
108 struct atpbuf *atph_sent; /* packets we send (XO) */
109 struct atpbuf *atph_queue; /* queue of pending packets */
110 int atph_reqtries; /* retry count for request */
111 int atph_reqto; /* retry timeout for request */
112 int atph_rrespcount; /* expected # of responses */
113 u_int8_t atph_rbitmap; /* bitmap for request */
114 struct atpbuf *atph_reqpkt; /* last request packet */
115 struct timeval atph_reqtv; /* when we last sent request */
116 struct atpbuf *atph_resppkt[8]; /* response to request */
119 typedef struct atp_handle *ATP;
121 #define atp_sockaddr( h ) (&(h)->atph_saddr)
122 #define atp_fileno(x) ((x)->atph_socket)
125 char *atpd_data; /* request data */
127 int atpd_tries; /* max. retry count */
128 int atpd_to; /* retry interval */
132 struct iovec *atpd_iov; /* for response */
137 char *atpd_data; /* request data */
142 struct iovec *atpd_iov; /* for response */
147 struct sockaddr_at *atp_saddr; /* from/to address */
149 struct sreq_st sreqdata;
150 #define atp_sreqdata atp_data.sreqdata.atpd_data
151 #define atp_sreqdlen atp_data.sreqdata.atpd_dlen
152 #define atp_sreqtries atp_data.sreqdata.atpd_tries
153 #define atp_sreqto atp_data.sreqdata.atpd_to
155 struct rres_st rresdata;
156 #define atp_rresiov atp_data.rresdata.atpd_iov
157 #define atp_rresiovcnt atp_data.rresdata.atpd_iovcnt
159 struct rreq_st rreqdata;
160 #define atp_rreqdata atp_data.rreqdata.atpd_data
161 #define atp_rreqdlen atp_data.rreqdata.atpd_dlen
163 struct sres_st sresdata;
164 #define atp_sresiov atp_data.sresdata.atpd_iov
165 #define atp_sresiovcnt atp_data.sresdata.atpd_iovcnt
167 u_int8_t atp_bitmap; /* response buffer bitmap */
171 /* flags for ATP options (and control byte)
173 #define ATP_STS (1<<3) /* Send Transaction Status */
174 #define ATP_EOM (1<<4) /* End Of Message */
175 #define ATP_XO (1<<5) /* eXactly Once mode */
179 #define ATP_FUNCMASK (3<<6) /* mask all but function */
181 #define ATP_TREQ (1<<6) /* Trans. REQuest */
182 #define ATP_TRESP (2<<6) /* Trans. RESPonse */
183 #define ATP_TREL (3<<6) /* Trans. RELease */
185 extern ATP atp_open (u_int8_t,
186 const struct at_addr *);
187 extern int atp_close (ATP);
188 extern int atp_sreq (ATP, struct atp_block *, int,
190 extern int atp_rresp (ATP, struct atp_block *);
191 extern int atp_rsel (ATP, struct sockaddr_at *, int);
192 extern int atp_rreq (ATP, struct atp_block *);
193 extern int atp_sresp (ATP, struct atp_block *);