netatalk 4.4.3
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 (asun@zoology.washington.edu)
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
44 struct 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. */
57 typedef struct DSI {
58 struct dsi_block header;
59 struct sockaddr_in server, client;
60 sigset_t sigblockset;
61 struct itimerval timer, savetimer;
62 uint32_t attn_quantum, datasize, server_quantum;
63 uint16_t serverID, clientID;
64 uint8_t *status, commands[DSI_CMDSIZ], data[DSI_DATASIZ];
65 int statuslen;
66 size_t datalen, cmdlen;
67 size_t read_count, write_count;
68 int asleep;
69 /* inited = initialized?, child = a child?, noreply = send reply? */
70 char child, inited, noreply;
71 const char *program;
72 int socket, serversock;
73
74 /* protocol specific open/close */
75 pid_t (*proto_open)(struct DSI *);
76 void (*proto_close)(struct DSI *);
77} DSI;
78
79/* DSI flags */
80#define DSIFL_REQUEST 0x00
81#define DSIFL_REPLY 0x01
82#define DSIFL_MAX 0x01
83
84/* DSI session options */
85#define DSIOPT_SERVQUANT 0x00
86#define DSIOPT_ATTNQUANT 0x01
87
88/* DSI Commands */
89#define DSIFUNC_CLOSE 1
90#define DSIFUNC_CMD 2
91#define DSIFUNC_STAT 3
92#define DSIFUNC_OPEN 4
93#define DSIFUNC_TICKLE 5
94#define DSIFUNC_WRITE 6
95#define DSIFUNC_ATTN 8
96#define DSIFUNC_MAX 8
97
98/* DSI Error codes: most of these aren't used. */
99#define DSIERR_OK 0x0000
100#define DSIERR_BADVERS 0xfbd6
101#define DSIERR_BUFSMALL 0xfbd5
102#define DSIERR_NOSESS 0xfbd4
103#define DSIERR_NOSERV 0xfbd3
104#define DSIERR_PARM 0xfbd2
105#define DSIERR_SERVBUSY 0xfbd1
106#define DSIERR_SESSCLOS 0xfbd0
107#define DSIERR_SIZERR 0xfbcf
108#define DSIERR_TOOMANY 0xfbce
109#define DSIERR_NOACK 0xfbcd
110
111/* server and client quanta */
112#define DSI_DEFQUANT 2
113#define DSI_SERVQUANT_MAX 0xffffffffL
114#define DSI_SERVQUANT_MIN 0x0004A2E0L
115#define DSI_SERVQUANT_DEF DSI_SERVQUANT_MIN
116
118#define DSI_AFPOVERTCP_PORT 548
119
121 extern DSI *dsi_init(
122 const char * /*program*/,
123 const char * /*host*/, const char * /*address*/,
124 const int /*port*/, const int /*proxy*/,
125 const uint32_t /* server quantum */);
126 extern void dsi_setstatus(DSI *, uint8_t *, const int);
127
128/* in dsi_getsess.c */
129 extern void dsi_kill(int);
130
131/* low-level stream commands -- in dsi_stream.c */
132 extern size_t dsi_stream_write(DSI *, void *, const size_t);
133 extern size_t dsi_stream_read(DSI *, void *, const size_t);
134 extern int dsi_stream_send(DSI *, void *, size_t);
135 extern int dsi_stream_receive(DSI *, void *, const size_t, size_t *);
136
137/* client writes -- dsi_write.c */
138 extern size_t dsi_writeinit(DSI *, void *, const size_t);
139 extern size_t dsi_write(DSI *, void *, const size_t);
140 extern void dsi_writeflush(DSI *);
141#define dsi_wrtreply(a,b) dsi_cmdreply(a,b)
142
143/* client reads -- dsi_read.c */
144 extern ssize_t dsi_readinit(DSI *, void *, const size_t, const size_t,
145 const int);
146 extern ssize_t dsi_read(DSI *, void *, const size_t);
147 extern void dsi_readdone(DSI *);
148
149/* some useful macros */
150#define dsi_serverID(x) ((x)->serverID++)
151#define dsi_send(x) do { \
152 (x)->header.dsi_len = htonl((x)->cmdlen); \
153 dsi_stream_send((x), (x)->commands, (x)->cmdlen); \
154} while (0)
155#define dsi_receive(x) (dsi_stream_receive((x), (x)->commands, \
156 DSI_CMDSIZ, &(x)->cmdlen))
157#endif /* atalk/dsi.h */
header
static void header(void)
Definition speedtest.c:570
DSI
Definition include/atalk/dsi.h:58
DSI::serverID
uint16_t serverID
Definition include/atalk/dsi.h:74
DSI::noreply
char noreply
Definition test/testsuite/dsi.h:70
DSI::datalen
size_t datalen
Definition include/atalk/dsi.h:77
DSI::client
struct sockaddr_storage server client
Definition include/atalk/dsi.h:65
DSI::cmdlen
size_t cmdlen
Definition include/atalk/dsi.h:77
DSI::savetimer
struct itimerval timer savetimer
Definition test/testsuite/dsi.h:61
DSI::sigblockset
sigset_t sigblockset
Definition test/testsuite/dsi.h:60
DSI::read_count
off_t read_count
Definition include/atalk/dsi.h:78
DSI::proto_open
pid_t(* proto_open)(struct DSI *)
Definition include/atalk/dsi.h:96
DSI::datasize
uint32_t datasize
Definition include/atalk/dsi.h:73
DSI::write_count
off_t write_count
Definition include/atalk/dsi.h:78
DSI::serversock
int serversock
Definition include/atalk/dsi.h:81
DSI::server_quantum
uint32_t server_quantum
Definition include/atalk/dsi.h:73
DSI::clientID
uint16_t clientID
Definition include/atalk/dsi.h:74
DSI::proto_close
void(* proto_close)(struct DSI *)
Definition include/atalk/dsi.h:97
DSI::data
uint8_t data[DSI_DATASIZ]
Definition include/atalk/dsi.h:76
DSI::socket
int socket
Definition include/atalk/dsi.h:80
DSI::status
char status[1400]
Definition include/atalk/dsi.h:62
DSI::attn_quantum
uint32_t attn_quantum
Definition include/atalk/dsi.h:73
DSI::child
char child
Definition test/testsuite/dsi.h:70
DSI::inited
char inited
Definition test/testsuite/dsi.h:70
DSI::timer
struct itimerval timer
Definition include/atalk/dsi.h:66
DSI::program
const char * program
Definition test/testsuite/dsi.h:71
DSI::statuslen
int statuslen
Definition include/atalk/dsi.h:61
DSI::commands
uint8_t * commands
Definition include/atalk/dsi.h:75
DSI::asleep
int asleep
Definition test/testsuite/dsi.h:68
dsi_block
Definition include/atalk/dsi.h:42
dsi_block::dsi_command
uint8_t dsi_command
Definition include/atalk/dsi.h:44
dsi_block::dsi_code
uint32_t dsi_code
Definition include/atalk/dsi.h:47
dsi_block::dsi_len
uint32_t dsi_len
Definition include/atalk/dsi.h:50
dsi_block::dsi_requestID
uint16_t dsi_requestID
Definition include/atalk/dsi.h:45
dsi_block::dsi_reserved
uint32_t dsi_reserved
Definition include/atalk/dsi.h:51
dsi_block::dsi_flags
uint8_t dsi_flags
Definition include/atalk/dsi.h:43
server
Definition cnid_metad.c:111
dsi_write
size_t dsi_write(DSI *, void *, const size_t)
Definition dsi_write.c:57
dsi_stream_read
size_t dsi_stream_read(DSI *, void *, const size_t)
Read data from DSI buffer.
Definition dsi_stream.c:534
dsi_writeinit
size_t dsi_writeinit(DSI *, void *, const size_t)
Definition dsi_write.c:26
dsi_setstatus
void dsi_setstatus(DSI *, uint8_t *, const int)
dsi_stream_send
int dsi_stream_send(DSI *, void *, size_t)
write data.
Definition dsi_stream.c:581
dsi_readinit
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_init
DSI * dsi_init(const char *, const char *, const char *, const int, const int, const uint32_t)
DSI_CMDSIZ
#define DSI_CMDSIZ
Definition test/testsuite/dsi.h:53
dsi_writeflush
void dsi_writeflush(DSI *)
Definition dsi_write.c:75
dsi_stream_receive
int dsi_stream_receive(DSI *, void *, const size_t, size_t *)
dsi_kill
void dsi_kill(int)
DSI_DATASIZ
#define DSI_DATASIZ
Definition test/testsuite/dsi.h:54
dsi_stream_write
size_t dsi_stream_write(DSI *, void *, const size_t)
dsi_read
ssize_t dsi_read(DSI *, void *, const size_t)
Definition dsi_read.c:57
dsi_readdone
void dsi_readdone(DSI *)
Definition dsi_read.c:51