netatalk  4.4.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
test/testsuite/dsi.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1997 Adrian Sun ([email protected])
3 * All rights reserved.
4 *
5 * modified for test-suite
6 */
7
8#ifndef _ATALK_DSI_H
9#define _ATALK_DSI_H
10
11#include <sys/types.h>
12#include <sys/time.h>
13#include <signal.h>
14
15#include <netinet/in.h>
16
42
43#define DSI_BLOCKSIZ 16
44struct dsi_block {
45 uint8_t dsi_flags;
46 uint8_t dsi_command;
47 uint16_t dsi_requestID;
48 uint32_t dsi_code;
49 uint32_t dsi_len;
50 uint32_t dsi_reserved;
51};
52
53#define DSI_CMDSIZ 800
54#define DSI_DATASIZ 8192
55/* child and parent processes might interpret a couple of these
56 * differently. */
57typedef struct DSI {
58 struct dsi_block header;
59 struct sockaddr_in server, client;
60 sigset_t sigblockset;
61 struct itimerval timer, savetimer;
63 uint16_t serverID, clientID;
65 int statuslen;
66 size_t datalen, cmdlen;
68 int asleep;
69 /* inited = initialized?, child = a child?, noreply = send reply? */
71 const char *program;
72 int socket, serversock;
73
74 /* protocol specific open/close, send/receive
75 * send/receive fill in the header and use dsi->commands.
76 * write/read just write/read data */
77 pid_t (*proto_open)(struct DSI *);
78 void (*proto_close)(struct DSI *);
80
81/* DSI flags */
82#define DSIFL_REQUEST 0x00
83#define DSIFL_REPLY 0x01
84#define DSIFL_MAX 0x01
85
86/* DSI session options */
87#define DSIOPT_SERVQUANT 0x00
88#define DSIOPT_ATTNQUANT 0x01
89
90/* DSI Commands */
91#define DSIFUNC_CLOSE 1
92#define DSIFUNC_CMD 2
93#define DSIFUNC_STAT 3
94#define DSIFUNC_OPEN 4
95#define DSIFUNC_TICKLE 5
96#define DSIFUNC_WRITE 6
97#define DSIFUNC_ATTN 8
98#define DSIFUNC_MAX 8
99
100/* DSI Error codes: most of these aren't used. */
101#define DSIERR_OK 0x0000
102#define DSIERR_BADVERS 0xfbd6
103#define DSIERR_BUFSMALL 0xfbd5
104#define DSIERR_NOSESS 0xfbd4
105#define DSIERR_NOSERV 0xfbd3
106#define DSIERR_PARM 0xfbd2
107#define DSIERR_SERVBUSY 0xfbd1
108#define DSIERR_SESSCLOS 0xfbd0
109#define DSIERR_SIZERR 0xfbcf
110#define DSIERR_TOOMANY 0xfbce
111#define DSIERR_NOACK 0xfbcd
112
113/* server and client quanta */
114#define DSI_DEFQUANT 2
115#define DSI_SERVQUANT_MAX 0xffffffffL
116#define DSI_SERVQUANT_MIN 0x0004A2E0L
117#define DSI_SERVQUANT_DEF DSI_SERVQUANT_MIN
118
120#define DSI_AFPOVERTCP_PORT 548
121
123extern DSI *dsi_init(
124 const char * /*program*/,
125 const char * /*host*/, const char * /*address*/,
126 const int /*port*/, const int /*proxy*/,
127 const uint32_t /* server quantum */);
128extern void dsi_setstatus(DSI *, uint8_t *, const int);
129
130/* in dsi_getsess.c */
131extern void dsi_kill(int);
132
133/* low-level stream commands -- in dsi_stream.c */
134extern size_t dsi_stream_write(DSI *, void *, const size_t);
135extern size_t dsi_stream_read(DSI *, void *, const size_t);
136extern int dsi_stream_send(DSI *, void *, size_t);
137extern int dsi_stream_receive(DSI *, void *, const size_t, size_t *);
138
139/* client writes -- dsi_write.c */
140extern size_t dsi_writeinit(DSI *, void *, const size_t);
141extern size_t dsi_write(DSI *, void *, const size_t);
142extern void dsi_writeflush(DSI *);
143#define dsi_wrtreply(a,b) dsi_cmdreply(a,b)
144
145/* client reads -- dsi_read.c */
146extern ssize_t dsi_readinit(DSI *, void *, const size_t, const size_t,
147 const int);
148extern ssize_t dsi_read(DSI *, void *, const size_t);
149extern void dsi_readdone(DSI *);
150
151/* some useful macros */
152#define dsi_serverID(x) ((x)->serverID++)
153#define dsi_send(x) do { \
154 (x)->header.dsi_len = htonl((x)->cmdlen); \
155 dsi_stream_send((x), (x)->commands, (x)->cmdlen); \
156} while (0)
157#define dsi_receive(x) (dsi_stream_receive((x), (x)->commands, \
158 DSI_CMDSIZ, &(x)->cmdlen))
159#endif /* atalk/dsi.h */
static void header(void)
Definition speedtest.c:570
Definition include/atalk/dsi.h:58
uint16_t serverID
Definition include/atalk/dsi.h:74
char noreply
Definition test/testsuite/dsi.h:70
size_t datalen
Definition include/atalk/dsi.h:77
struct sockaddr_storage server client
Definition include/atalk/dsi.h:65
size_t cmdlen
Definition include/atalk/dsi.h:77
struct itimerval timer savetimer
Definition test/testsuite/dsi.h:61
sigset_t sigblockset
Definition test/testsuite/dsi.h:60
off_t read_count
Definition include/atalk/dsi.h:78
pid_t(* proto_open)(struct DSI *)
Definition include/atalk/dsi.h:98
uint32_t datasize
Definition include/atalk/dsi.h:73
off_t write_count
Definition include/atalk/dsi.h:78
int serversock
Definition include/atalk/dsi.h:81
uint32_t server_quantum
Definition include/atalk/dsi.h:73
uint16_t clientID
Definition include/atalk/dsi.h:74
void(* proto_close)(struct DSI *)
Definition include/atalk/dsi.h:99
uint8_t data[DSI_DATASIZ]
Definition include/atalk/dsi.h:76
int socket
Definition include/atalk/dsi.h:80
char status[1400]
Definition include/atalk/dsi.h:62
uint32_t attn_quantum
Definition include/atalk/dsi.h:73
char child
Definition test/testsuite/dsi.h:70
char inited
Definition test/testsuite/dsi.h:70
struct itimerval timer
Definition include/atalk/dsi.h:66
const char * program
Definition test/testsuite/dsi.h:71
int statuslen
Definition include/atalk/dsi.h:61
uint8_t * commands
Definition include/atalk/dsi.h:75
int asleep
Definition test/testsuite/dsi.h:68
Definition include/atalk/dsi.h:42
uint8_t dsi_command
Definition include/atalk/dsi.h:44
uint32_t dsi_code
Definition include/atalk/dsi.h:47
uint32_t dsi_len
Definition include/atalk/dsi.h:50
uint16_t dsi_requestID
Definition include/atalk/dsi.h:45
uint32_t dsi_reserved
Definition include/atalk/dsi.h:51
uint8_t dsi_flags
Definition include/atalk/dsi.h:43
Definition cnid_metad.c:111
size_t dsi_write(DSI *, void *, const size_t)
Definition dsi_write.c:52
size_t dsi_stream_read(DSI *, void *, const size_t)
Read data from DSI buffer.
Definition dsi_stream.c:534
size_t dsi_writeinit(DSI *, void *, const size_t)
Definition dsi_write.c:26
void dsi_setstatus(DSI *, uint8_t *, const int)
int dsi_stream_send(DSI *, void *, size_t)
write data.
Definition dsi_stream.c:581
ssize_t dsi_readinit(DSI *, void *, const size_t, const size_t, const int)
streaming i/o for afp_read.
Definition dsi_read.c:29
DSI * dsi_init(const char *, const char *, const char *, const int, const int, const uint32_t)
#define DSI_CMDSIZ
Definition test/testsuite/dsi.h:53
void dsi_writeflush(DSI *)
Definition dsi_write.c:70
int dsi_stream_receive(DSI *, void *, const size_t, size_t *)
void dsi_kill(int)
#define DSI_DATASIZ
Definition test/testsuite/dsi.h:54
size_t dsi_stream_write(DSI *, void *, const size_t)
ssize_t dsi_read(DSI *, void *, const size_t)
Definition dsi_read.c:57
void dsi_readdone(DSI *)
Definition dsi_read.c:51