-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzmodem.h
186 lines (149 loc) · 5.66 KB
/
zmodem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
* zmodem.h
* zmodem constants
* (C) Mattheij Computer Service 1994
*/
#ifndef _ZMODEM_H
#define _ZMODEM_H
/*
* ascii constants
*/
#define SOH 0x01
#define STX 0x02
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define LF 0x0a
#define CR 0x0d
#define XON 0x11
#define XOFF 0x13
#define NAK 0x15
#define CAN 0x18
/*
* zmodem constants
*/
#define ZMAXHLEN 0x10 /* maximum header information length */
#define ZMAXSPLEN 0x400 /* maximum subpacket length */
#define ZPAD 0x2a /* pad character; begins frames */
#define ZDLE 0x18 /* ctrl-x zmodem escape */
#define ZDLEE 0x58 /* escaped ZDLE */
#define ZBIN 0x41 /* binary frame indicator (CRC16) */
#define ZHEX 0x42 /* hex frame indicator */
#define ZBIN32 0x43 /* binary frame indicator (CRC32) */
#define ZBINR32 0x44 /* run length encoded binary frame (CRC32) */
#define ZVBIN 0x61 /* binary frame indicator (CRC16) */
#define ZVHEX 0x62 /* hex frame indicator */
#define ZVBIN32 0x63 /* binary frame indicator (CRC32) */
#define ZVBINR32 0x64 /* run length encoded binary frame (CRC32) */
#define ZRESC 0x7e /* run length encoding flag / escape character */
/*
* zmodem frame types
*/
enum ZFrameType {
ZRQINIT = 0, /* request receive init (s->r) */
ZRINIT = 1, /* receive init (r->s) */
ZSINIT = 2, /* send init sequence (optional) (s->r) */
ZACK = 3, /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */
ZFILE = 4, /* file name (s->r) */
ZSKIP = 5, /* skip this file (r->s) */
ZNAK = 6, /* last packet was corrupted (?) */
ZABORT = 7, /* abort batch transfers (?) */
ZFIN = 8, /* finish session (s<->r) */
ZRPOS = 9, /* resume data transmission here (r->s) */
ZDATA = 10, /* data packet(s) follow (s->r) */
ZEOF = 11, /* end of file reached (s->r) */
ZFERR = 12, /* fatal read or write error detected (?) */
ZCRC = 13, /* request for file CRC and response (?) */
ZCHALLENGE = 14, /* security challenge (r->s) */
ZCOMPL = 15, /* request is complete (?) */
ZCAN = 16, /* pseudo frame; other end cancelled session with 5* CAN */
ZFREECNT = 17, /* request free bytes on file system (s->r) */
ZCOMMAND = 18, /* issue command (s->r) */
ZSTDERR = 19, /* output data to stderr (??) */
};
/*
* ZDLE sequences
*/
#define ZCRCE 0x68 /* CRC next, frame ends, header packet follows */
#define ZCRCG 0x69 /* CRC next, frame continues nonstop */
#define ZCRCQ 0x6a /* CRC next, frame continuous, ZACK expected */
#define ZCRCW 0x6b /* CRC next, frame ends, ZACK expected */
#define ZRUB0 0x6c /* translate to rubout 0x7f */
#define ZRUB1 0x6d /* translate to rubout 0xff */
/*
* frame specific data.
* entries are prefixed with their location in the header array.
*/
/*
* Byte positions within header array
*/
#define FTYPE 0 /* frame type */
#define ZF0 4 /* First flags byte */
#define ZF1 3
#define ZF2 2
#define ZF3 1
#define ZP0 1 /* Low order 8 bits of position */
#define ZP1 2
#define ZP2 3
#define ZP3 4 /* High order 8 bits of file position */
/*
* ZRINIT frame
* zmodem receiver capability flags
*/
#define ZF0_CANFDX 0x01 /* Receiver can send and receive true full duplex */
#define ZF0_CANOVIO 0x02 /* receiver can receive data during disk I/O */
#define ZF0_CANBRK 0x04 /* receiver can send a break signal */
#define ZF0_CANCRY 0x08 /* Receiver can decrypt DONT USE */
#define ZF0_CANLZW 0x10 /* Receiver can uncompress DONT USE */
#define ZF0_CANFC32 0x20 /* Receiver can use 32 bit Frame Check */
#define ZF0_ESCCTL 0x40 /* Receiver expects ctl chars to be escaped */
#define ZF0_ESC8 0x80 /* Receiver expects 8th bit to be escaped */
#define ZF1_CANVHDR 0x01 /* Variable headers OK */
/*
* ZSINIT frame
* zmodem sender capability
*/
#define ZF0_TESCCTL 0x40 /* Transmitter expects ctl chars to be escaped */
#define ZF0_TESC8 0x80 /* Transmitter expects 8th bit to be escaped */
#define ZATTNLEN 0x20 /* Max length of attention string */
#define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */
/*
* ZFILE frame
*/
/*
* Conversion options one of these in ZF0
*/
#define ZF0_ZCBIN 1 /* Binary transfer - inhibit conversion */
#define ZF0_ZCNL 2 /* Convert NL to local end of line convention */
#define ZF0_ZCRESUM 3 /* Resume interrupted file transfer */
/*
* Management include options, one of these ored in ZF1
*/
#define ZF1_ZMSKNOLOC 0x80 /* Skip file if not present at rx */
#define ZF1_ZMMASK 0x1f /* Mask for the choices below */
#define ZF1_ZMNEWL 1 /* Transfer if source newer or longer */
#define ZF1_ZMCRC 2 /* Transfer if different file CRC or length */
#define ZF1_ZMAPND 3 /* Append contents to existing file (if any) */
#define ZF1_ZMCLOB 4 /* Replace existing file */
#define ZF1_ZMNEW 5 /* Transfer if source newer */
#define ZF1_ZMDIFF 6 /* Transfer if dates or lengths different */
#define ZF1_ZMPROT 7 /* Protect destination file */
#define ZF1_ZMCHNG 8 /* Change filename if destination exists */
/*
* Transport options, one of these in ZF2
*/
#define ZF2_ZTNOR 0 /* no compression */
#define ZF2_ZTLZW 1 /* Lempel-Ziv compression */
#define ZF2_ZTRLE 3 /* Run Length encoding */
/*
* Extended options for ZF3, bit encoded
*/
#define ZF3_ZCANVHDR 0x01 /* Variable headers OK */
/* Receiver window size override */
#define ZF3_ZRWOVR 0x04 /* byte position for receive window override/256 */
#define ZF3_ZXSPARS 0x40 /* encoding for sparse file operations */
/*
* ZCOMMAND frame
*/
#define ZF0_ZCACK1 0x01 /* Acknowledge, then do command */
#endif