netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
atp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
3 * All Rights Reserved.
4 *
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation, and that the name of The University
10 * of Michigan not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. This software is supplied as is without expressed or
13 * implied warranties of any kind.
14 *
15 * Research Systems Unix Group
16 * The University of Michigan
17 * c/o Mike Clark
18 * 535 W. William Street
19 * Ann Arbor, Michigan
20 * +1-313-763-0525
22 */
23
24#ifndef _ATALK_ATP_H
25#define _ATALK_ATP_H 1
26
27#ifndef NO_DDP
28
29#include <stdint.h>
30#include <sys/types.h>
31#include <sys/time.h>
32#include <netatalk/at.h>
33
34/* ATP packet format
35
36 |----------------|
37 | link header |
38 | ... |
39 |----------------|
40 | DDP header |
41 | ... |
42 | type = 3 |
43 |----------------|
44 | control info | --> bits 7,6: function code
45 |----------------| 5: XO bit
46 | bitmap/seq no. | 4: EOM bit
47 |----------------| 3: STS bit
48 | TID (MSB) | 2,1,0: release timer code (ignored under phase I)
49 |----------------|
50 | TID (LSB) |
51 |----------------|
52 | user bytes (4) |
53 |----------------|
54 | data (0-578) |
55 | ... |
56 |----------------|
57*/
58struct atphdr {
59 uint8_t atphd_ctrlinfo; /* control information */
60 uint8_t atphd_bitmap; /* bitmap or sequence number */
61 uint16_t atphd_tid; /* transaction id. */
62};
63
64/* ATP protocol parameters
65*/
66#define ATP_MAXDATA (578+4) /* maximum ATP data size */
67#define ATP_BUFSIZ 587 /* maximum packet size */
68#define ATP_HDRSIZE 5 /* includes DDP type field */
69
70#define ATP_TRELMASK 0x07 /* mask all but TREL */
71#define ATP_RELTIME 30 /* base release timer (in secs) */
72
73#define ATP_TREL30 0x0 /* release time codes */
74#define ATP_TREL1M 0x1 /* these are passed in flags of */
75#define ATP_TREL2M 0x2 /* atp_sreq call, and set in the */
76#define ATP_TREL4M 0x3 /* packet control info. */
77#define ATP_TREL8M 0x4
78
79#define ATP_TRIES_INFINITE -1 /* for atp_sreq, etc */
80
81struct atpxobuf {
82 uint16_t atpxo_tid;
83 struct timeval atpxo_tv;
85 struct atpbuf *atpxo_packet[8];
86};
87
88struct atpbuf {
89 struct atpbuf *atpbuf_next; /* next buffer in chain */
90 size_t atpbuf_dlen; /* data length <= ATP_BUFSIZ */
91 struct sockaddr_at atpbuf_addr; /* net address sent/recvd */
92 union {
93 char atpbuf_data[ATP_BUFSIZ]; /* the data */
94 struct atpxobuf atpbuf_xo; /* for XO requests */
96};
97
98struct atp_handle {
99 int atph_socket; /* ddp socket */
100 struct sockaddr_at atph_saddr; /* address */
101 uint16_t atph_tid; /* last tid used */
102 uint16_t atph_rtid; /* last received (rreq) */
103 uint8_t atph_rxo; /* XO flag from last rreq */
104 int atph_rreltime; /* release time (secs) */
105 struct atpbuf *atph_sent; /* packets we send (XO) */
106 struct atpbuf *atph_queue; /* queue of pending packets */
107 int atph_reqtries; /* retry count for request */
108 int atph_reqto; /* retry timeout for request */
109 int atph_rrespcount; /* expected # of responses */
110 uint8_t atph_rbitmap; /* bitmap for request */
111 struct atpbuf *atph_reqpkt; /* last request packet */
112 struct timeval atph_reqtv; /* when we last sent request */
113 struct atpbuf *atph_resppkt[8]; /* response to request */
114};
115
116typedef struct atp_handle *ATP;
117
118#define atp_sockaddr( h ) (&(h)->atph_saddr)
119#define atp_fileno(x) ((x)->atph_socket)
120
121struct sreq_st {
122 char *atpd_data; /* request data */
124 int atpd_tries; /* max. retry count */
125 int atpd_to; /* retry interval */
126};
127
128struct rres_st {
129 struct iovec *atpd_iov; /* for response */
131};
132
133struct rreq_st {
134 char *atpd_data; /* request data */
136};
137
138struct sres_st {
139 struct iovec *atpd_iov; /* for response */
141};
142
143struct atp_block {
144 struct sockaddr_at *atp_saddr; /* from/to address */
145 union {
147#define atp_sreqdata atp_data.sreqdata.atpd_data
148#define atp_sreqdlen atp_data.sreqdata.atpd_dlen
149#define atp_sreqtries atp_data.sreqdata.atpd_tries
150#define atp_sreqto atp_data.sreqdata.atpd_to
151
153#define atp_rresiov atp_data.rresdata.atpd_iov
154#define atp_rresiovcnt atp_data.rresdata.atpd_iovcnt
155
157#define atp_rreqdata atp_data.rreqdata.atpd_data
158#define atp_rreqdlen atp_data.rreqdata.atpd_dlen
159
161#define atp_sresiov atp_data.sresdata.atpd_iov
162#define atp_sresiovcnt atp_data.sresdata.atpd_iovcnt
164 uint8_t atp_bitmap; /* response buffer bitmap */
165};
166
167
168/* flags for ATP options (and control byte)
169*/
170#define ATP_STS (1<<3) /* Send Transaction Status */
171#define ATP_EOM (1<<4) /* End Of Message */
172#define ATP_XO (1<<5) /* eXactly Once mode */
173
174/* function codes
175*/
176#define ATP_FUNCMASK (3<<6) /* mask all but function */
177
178#define ATP_TREQ (1<<6) /* Trans. REQuest */
179#define ATP_TRESP (2<<6) /* Trans. RESPonse */
180#define ATP_TREL (3<<6) /* Trans. RELease */
181
182extern ATP atp_open(uint8_t, const struct at_addr *);
183extern int atp_close(ATP);
184extern int atp_sreq(ATP, struct atp_block *, int, uint8_t);
185extern int atp_rresp(ATP, struct atp_block *);
186extern int atp_rsel(ATP, struct sockaddr_at *, int);
187extern int atp_rreq(ATP, struct atp_block *);
188extern int atp_sresp(ATP, struct atp_block *);
189
190#endif /* NO_DDP */
191#endif
ATP atp_open(uint8_t, const struct at_addr *)
Definition atp_open.c:47
int atp_close(ATP)
Definition atp_close.c:23
struct atp_handle * ATP
Definition atp.h:116
#define ATP_BUFSIZ
Definition atp.h:67
int atp_rreq(ATP, struct atp_block *)
Definition atp_rreq.c:48
int atp_sreq(ATP, struct atp_block *, int, uint8_t)
Definition atp_sreq.c:56
int atp_sresp(ATP, struct atp_block *)
Definition atp_sresp.c:50
int atp_rresp(ATP, struct atp_block *)
Definition atp_rresp.c:47
int atp_rsel(ATP, struct sockaddr_at *, int)
Definition atp_rsel.c:74
Definition at.h:68
Definition atp.h:143
struct sockaddr_at * atp_saddr
Definition atp.h:144
struct rreq_st rreqdata
Definition atp.h:156
struct sreq_st sreqdata
Definition atp.h:146
uint8_t atp_bitmap
Definition atp.h:164
struct rres_st rresdata
Definition atp.h:152
union atp_block::@073263217065046156372326366051357056273016107223 atp_data
struct sres_st sresdata
Definition atp.h:160
Definition atp.h:98
struct atpbuf * atph_reqpkt
Definition atp.h:111
uint8_t atph_rbitmap
Definition atp.h:110
int atph_rreltime
Definition atp.h:104
struct atpbuf * atph_queue
Definition atp.h:106
struct timeval atph_reqtv
Definition atp.h:112
int atph_rrespcount
Definition atp.h:109
uint8_t atph_rxo
Definition atp.h:103
struct atpbuf * atph_resppkt[8]
Definition atp.h:113
int atph_reqto
Definition atp.h:108
int atph_reqtries
Definition atp.h:107
struct atpbuf * atph_sent
Definition atp.h:105
uint16_t atph_rtid
Definition atp.h:102
uint16_t atph_tid
Definition atp.h:101
int atph_socket
Definition atp.h:99
struct sockaddr_at atph_saddr
Definition atp.h:100
Definition atp.h:88
union atpbuf::@234010067115357036205066174107246143205070337331 atpbuf_info
size_t atpbuf_dlen
Definition atp.h:90
struct atpxobuf atpbuf_xo
Definition atp.h:94
struct sockaddr_at atpbuf_addr
Definition atp.h:91
char atpbuf_data[ATP_BUFSIZ]
Definition atp.h:93
struct atpbuf * atpbuf_next
Definition atp.h:89
Definition atp.h:58
uint16_t atphd_tid
Definition atp.h:61
uint8_t atphd_ctrlinfo
Definition atp.h:59
uint8_t atphd_bitmap
Definition atp.h:60
Definition atp.h:81
struct timeval atpxo_tv
Definition atp.h:83
int atpxo_reltime
Definition atp.h:84
uint16_t atpxo_tid
Definition atp.h:82
struct atpbuf * atpxo_packet[8]
Definition atp.h:85
Definition atp.h:133
char * atpd_data
Definition atp.h:134
int atpd_dlen
Definition atp.h:135
Definition atp.h:128
struct iovec * atpd_iov
Definition atp.h:129
int atpd_iovcnt
Definition atp.h:130
Definition at.h:88
Definition atp.h:121
int atpd_tries
Definition atp.h:124
int atpd_to
Definition atp.h:125
int atpd_dlen
Definition atp.h:123
char * atpd_data
Definition atp.h:122
Definition atp.h:138
int atpd_iovcnt
Definition atp.h:140
struct iovec * atpd_iov
Definition atp.h:139