blob: 58f763ffc86c908849956724e346120ae740f446 [file] [log] [blame]
Alistair Delvabeaee832021-02-24 11:27:23 -08001#ifndef MTOOLS_FLOPPYDIO_H
2#define MTOOLS_FLOPPYDIO_H
3
4/* Copyright 1999 Peter Schlaile.
5 * Copyright 1998,2000-2002,2009 Alain Knaff.
6 * This file is part of mtools.
7 *
8 * Mtools is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Mtools is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifdef USE_FLOPPYD
23
24#include "stream.h"
25
26typedef uint8_t Byte;
27typedef uint32_t Dword;
28typedef uint64_t Qword;
29
30#define DWORD_ERR ((Dword) -1)
31
32/*extern int ConnectToFloppyd(const char* name, Class_t** ioclass);*/
33Stream_t *FloppydOpen(struct device *dev,
34 char *name, int mode, char *errmsg,
35 mt_size_t *maxSize);
36
37#define FLOPPYD_DEFAULT_PORT 5703
38
39#define FLOPPYD_PROTOCOL_VERSION_OLD 10
40#define FLOPPYD_PROTOCOL_VERSION 11
41
42#define FLOPPYD_CAP_EXPLICIT_OPEN 1 /* explicit open. Useful for
43 * clean signalling of readonly disks */
44#define FLOPPYD_CAP_LARGE_SEEK 2 /* large seeks */
45
46enum FloppydOpcodes {
47 OP_READ,
48 OP_WRITE,
49 OP_SEEK,
50 OP_FLUSH,
51 OP_CLOSE,
52 OP_IOCTL,
53 OP_OPRO,
54 OP_OPRW,
55 OP_SEEK64
56};
57
58enum AuthErrorsEnum {
59 AUTH_SUCCESS,
60 AUTH_PACKETOVERSIZE,
61 AUTH_AUTHFAILED,
62 AUTH_WRONGVERSION,
63 AUTH_DEVLOCKED,
64 AUTH_BADPACKET,
65 AUTH_IO_ERROR
66};
67
68
69UNUSED(static inline void cork(int sockhandle, int on))
70{
71#ifdef TCP_CORK
72 if(setsockopt(sockhandle, IPPROTO_TCP,
73 TCP_CORK, (char *)&on, sizeof(on)) < 0) {
74 perror("setsockopt cork");
75 }
76#else
77 on = 1 ^ on;
78 if(setsockopt(sockhandle, IPPROTO_TCP,
79 TCP_NODELAY, (char *)&on, sizeof(on)) < 0) {
80 perror("setsockopt nodelay");
81 }
82#endif
83}
84
85
86#endif
87#endif