1 /* $Id$ */ 2 /* 3 * Copyright (c) 1990-1996 Sam Leffler 4 * Copyright (c) 1991-1996 Silicon Graphics, Inc. 5 * HylaFAX is a trademark of Silicon Graphics 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and 8 * its documentation for any purpose is hereby granted without fee, provided 9 * that (i) the above copyright notices and this permission notice appear in 10 * all copies of the software and related documentation, and (ii) the names of 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or 12 * publicity relating to the software without the specific, prior written 13 * permission of Sam Leffler and Silicon Graphics. 14 * 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24 * OF THIS SOFTWARE. 25 */ 26 #ifndef _t30_ 27 #define _t30_ 28 /* 29 * The Group 3/T.30 protocol defines pre-, in-, and post- 30 * message phases. During the pre-message phase, the modems 31 * exchange capability information and do "training" to 32 * synchronize transmission. Once this is done, one or more 33 * pages of information may be transmitted, and following this 34 * the post-message phase allows for retransmission, line 35 * turn-around, and so on. 36 * 37 * Consult CCITT recommendation T.30, "Procedures for Document 38 * Facsimile Transmission in the General Switched Telephone 39 * Network" (especially pp. 69-109) for further information. 40 */ 41 42 /* 43 * Note: All the FCF codes after the initial identification 44 * commands should include FCF_SNDR or FCF_RCVR ``or-ed in''. 45 * For example, 46 * Calling Station Called Station 47 * ----------------------------------- 48 * <- FCF_DIS 49 * FCF_DCS|FCF_SNDR -> 50 * <- FCF_CFR|FCF_RCVR 51 * <<send message data>> 52 * FCF_EOP|FCF_SNDR -> 53 * <- FCF_MCF|FCF_RCVR 54 * FCF_DCN|FCF_SNDR -> 55 */ 56 57 // protocol timeouts in milliseconds 58 #define TIMER_T1 ((35+5)*1000) // 35 +/- 5 seconds 59 #define TIMER_T2 ((6+1)*1000) // 6 +/- 1 seconds 60 #define TIMER_T3 ((10+5)*1000) // 10 +/- 5 seconds 61 #define TIMER_T4 3100 // 3.1secs 62 63 #define TCF_DURATION 1500 // 1.5 seconds 64 65 // this is our defined NSF manufacturer code 66 #define HYLAFAX_NSF "\xB5\x00\xAA" 67 68 /* 69 * Facsimile control field (FCF) values 70 */ 71 #define FCF_SNDR 0x80 // station receiving valid DIS 72 #define FCF_RCVR 0x00 // station receiving valid DIS response 73 74 // initial identification commands from the called to calling station 75 #define FCF_DIS 0x01 // digital identification signal 76 #define FCF_CSI 0x02 // called subscriber identification 77 #define FCF_NSF 0x04 // non-standard facilities (optional) 78 79 // responses from calling station wishing to recv 80 #define FCF_DTC (FCF_DIS|FCF_SNDR) // digital transmit command 81 #define FCF_CIG (FCF_CSI|FCF_SNDR) // calling subrscriber id (opt) 82 #define FCF_NSC (FCF_NSF|FCF_SNDR) // non-standard facilities cmd (opt) 83 #define FCF_PPW (0x03|FCF_SNDR) // password for polling (opt) 84 #define FCF_SEP (0x05|FCF_SNDR) // selective polling subaddress (opt) 85 // responses from transmitter to receiver 86 #define FCF_DCS (0x40|FCF_DIS) // digital command signal 87 #define FCF_TSI (0x40|FCF_CSI) // transmitting subscriber id (opt) 88 #define FCF_NSS (0x40|FCF_NSF) // non-standard facilities setup (opt) 89 #define FCF_PWD (0x40|0x05) // password for transmission (opt) 90 #define FCF_SUB (0x40|0x03) // routing information for xmit (opt) 91 92 /* 93 * Digital Identification Signal (DIS) definitions. 94 * 95 * The DIS is sent from the called station to the calling station 96 * to identify its capabilities. This information may also appear 97 * in a DTC frame if the line is to be turned around. 98 * 99 * The values given below assume a 24-bit representation for the DIS; 100 * i.e. the first 3 bytes of the frame are treated as a single 24-bit 101 * value. Additional bytes of the DIS are optional and indicated by 102 * a 1 in the least significant bit of the last byte. There are currently 103 * as many as 6 additional bytes that may follow the required 3-byte 104 * minimum DIS frame; we only process the first 4. 105 */ 106 #define DIS_V8 0x040000 // supports V.8 training 107 #define DIS_FRAMESIZE 0x020000 // preferred ECM frame size indicator 108 #define DIS_T4XMTR 0x008000 // T.4 sender & has docs to poll 109 #define DIS_T4RCVR 0x004000 // T.4 receiver 110 #define DIS_SIGRATE 0x003C00 // data signalling rate 111 #define DISSIGRATE_V27FB 0x0 // V.27ter fallback mode: 2400 BPS 112 #define DISSIGRATE_V27 0x4 // V.27ter: 4800 + 2400 BPS 113 #define DISSIGRATE_V29 0x8 // V.29: 9600 + 7200 BPS 114 #define DISSIGRATE_V2729 0xC // V.27ter+V.29 115 #define DISSIGRATE_V33 0xE // V.27ter+V.29+V.33 116 #define DISSIGRATE_V17 0xD // V.27ter+V.29+V.33+V.17 117 #define DIS_7MMVRES 0x000200 // vertical resolution = 7.7 line/mm 118 #define DIS_2DENCODE 0x000100 // 2-d compression supported 119 #define DIS_PAGEWIDTH 0x0000C0 // recording width capabilities 120 #define DISWIDTH_A4 0 // only 215mm (A4) 121 #define DISWIDTH_A3 1 // 215, 255, and 303 (A4, B4, A3) 122 #define DISWIDTH_B4 2 // 215, and 255 (A4, B4) 123 #define DISWIDTH_INVALID 3 // invalid, but treat as A3 124 #define DIS_PAGELENGTH 0x000030 // max recording length capabilities 125 #define DISLENGTH_A4 0 // A4 (297 mm) 126 #define DISLENGTH_UNLIMITED 1 // no max length 127 #define DISLENGTH_A4B4 2 // A4 and B4 (364 mm) 128 #define DISLENGTH_INVALID 3 129 #define DIS_MINSCAN 0x00000E // receiver min scan line time 130 #define DISMINSCAN_20MS 0x0 131 #define DISMINSCAN_40MS 0x1 132 #define DISMINSCAN_10MS 0x2 133 #define DISMINSCAN_10MS2 0x3 134 #define DISMINSCAN_5MS 0x4 135 #define DISMINSCAN_40MS2 0x5 136 #define DISMINSCAN_20MS2 0x6 137 #define DISMINSCAN_0MS 0x7 138 #define DIS_XTNDFIELD 0x000001 // extended field indicator 139 140 // 1st extension byte (alternative mode capabilities) 141 #define DIS_2400HS (0x80<<24) // 2400 bit/s handshaking 142 #define DIS_2DUNCOMP (0x40<<24) // uncompressed 2-d data supported 143 #define DIS_ECMODE (0x20<<24) // error correction mode supported 144 // NB: bit 0x10 must be zero 145 #define DIS_ELMODE (0x08<<24) // error limiting mode suported 146 #define DIS_G4COMP (0x02<<24) // T.6 compression supported 147 // bit 0x01 indicates an extension byte follows 148 149 // The meaning of the 2nd extension byte changed after the 1993 recommendation. 150 // If DIS_IGNOLD is set, then the 1993 definitions can be understood, otherwise 151 // the current definitions should be understood. 152 153 // 2nd extension byte - 1993 meaning - (alternative paper width capabilities) 154 #define DIS_IGNOLD (0x80<<16) // ignore old paper widths in byte 3 155 #define DIS_1216 (0x40<<16) // 1216 pixels in 151 mm scanline 156 #define DIS_864 (0x20<<16) // 864 pixels in 107 mm scanline 157 #define DIS_1728L (0x10<<16) // 1728 pixels in 151 mm scanline 158 #define DIS_1728H (0x08<<16) // 1728 pixels in 107 mm scanline 159 // bits 0x04 and 0x02 are reserved 160 // bit 0x01 indicates an extension byte follows 161 162 // 2nd extension byte - current meaning 163 // bit 0x80 is not valid and must be unset 164 #define DIS_MULTSEP (0x40<<16) // multiple selective polling capability 165 #define DIS_POLLSUB (0x20<<16) // polled subaddress 166 #define DIS_T43 (0x10<<16) // T.43 coding 167 #define DIS_INTERLV (0x08<<16) // plane interleave 168 #define DIS_VOICE (0x04<<16) // voice coding - G.726 169 #define DIS_VOICEXT (0x02<<16) // extended voice coding 170 // bit 0x01 indicates an extension byte follows 171 172 // 3rd extension byte (alternative resolution capabilities) 173 #define DIS_200X400 (0x80<<8) // 200 x 400 pixels/inch resolution 174 #define DIS_300X300 (0x40<<8) // 300 x 300 pixels/inch resolution 175 #define DIS_400X400 (0x20<<8) // 400 x 400 pixels/inch resolution 176 #define DIS_INCHRES (0x10<<8) // inch-based resolution preferred 177 #define DIS_METRES (0x08<<8) // metric-based resolution preferred 178 #define DIS_400MST2 (0x04<<8) // mst for 400 l/inch = 1/ 200 l/inch 179 #define DIS_SEP (0x02<<8) // selective polling supported 180 // bit 0x01 indicates an extension byte follows 181 182 // 4th extension byte (enhanced features capabilities) 183 #define DIS_SUB (0x80<<0) // sub-address supported (SUB frames) 184 #define DIS_PWD (0x40<<0) // password supported (PWD frames) 185 #define DIS_DATAFILE (0x20<<0) // can emit data file 186 // bit 0x10 is reserved for facsimile service information 187 #define DIS_BFT (0x08<<0) // supports Binary File Transfer (BFT) 188 #define DIS_DTM (0x04<<0) // supports Document Transfer Mode (DTM) 189 #define DIS_EDI (0x02<<0) // supports Edifact Transfer (EDI) 190 // bit 0x01 indicates an extension byte follows 191 192 /* 193 * Digital Command Signal (DCS) definitions. 194 * 195 * The DCS is sent from the calling station to the called station 196 * prior to the training procedure; it identifies the capabilities 197 * to use for session operation. 198 * 199 * The values given below assume a 24-bit representation for the DCS; 200 * i.e. the first 3 bytes of the frame are treated as a single 24-bit 201 * value. Additional bytes of the DCS are optional and indicated by 202 * a 1 in the least significant bit of the last byte. There are currently 203 * as many as 6 additional bytes that may follow the required 3-byte 204 * minimum DCS frame; we only process the first 4. 205 */ 206 #define DCS_T4RCVR 0x004000 // receiver honors T.4 207 #define DCS_SIGRATE 0x003C00 // data signalling rate 208 #define DCSSIGRATE_2400V27 (0x0<<10) 209 #define DCSSIGRATE_4800V27 (0x4<<10) 210 #define DCSSIGRATE_9600V29 (0x8<<10) 211 #define DCSSIGRATE_7200V29 (0xC<<10) 212 #define DCSSIGRATE_14400V33 (0x2<<10) 213 #define DCSSIGRATE_12000V33 (0x6<<10) 214 #define DCSSIGRATE_14400V17 (0x1<<10) 215 #define DCSSIGRATE_12000V17 (0x5<<10) 216 #define DCSSIGRATE_9600V17 (0x9<<10) 217 #define DCSSIGRATE_7200V17 (0xD<<10) 218 #define DCS_7MMVRES 0x000200 // vertical resolution = 7.7 line/mm 219 #define DCS_2DENCODE 0x000100 // use 2-d encoding 220 #define DCS_PAGEWIDTH 0x0000C0 // recording width 221 #define DCSWIDTH_A4 (0<<6) 222 #define DCSWIDTH_A3 (1<<6) 223 #define DCSWIDTH_B4 (2<<6) 224 #define DCS_PAGELENGTH 0x000030 // max recording length 225 #define DCSLENGTH_A4 (0<<4) 226 #define DCSLENGTH_UNLIMITED (1<<4) 227 #define DCSLENGTH_B4 (2<<4) 228 #define DCS_MINSCAN 0x00000E // receiver min scan line time 229 #define DCSMINSCAN_20MS (0x0<<1) 230 #define DCSMINSCAN_40MS (0x1<<1) 231 #define DCSMINSCAN_10MS (0x2<<1) 232 #define DCSMINSCAN_5MS (0x4<<1) 233 #define DCSMINSCAN_0MS (0x7<<1) 234 #define DCS_XTNDFIELD 0x000001 // extended field indicator 235 236 // 1st extension byte (alternative mode capabilities) 237 #define DCS_2400HS (0x80<<24) // 2400 bit/s handshaking 238 #define DCS_2DUNCOMP (0x40<<24) // use uncompressed 2-d data 239 #define DCS_ECMODE (0x20<<24) // use error correction mode 240 #define DCS_FRAMESIZE (0x10<<24) // EC frame size 241 #define DCSFRAME_256 (0<<28) // 256 octets 242 #define DCSFRAME_64 (1<<28) // 64 octets 243 #define DCS_ELMODE (0x08<<24) // use error limiting mode 244 // bit 0x04 is reserved for Group 4 245 #define DCS_G4COMP (0x02<<24) // use T.6 compression 246 // bit 0x01 indicates another information byte follows 247 248 // 2nd extension byte (alternative paper width capabilities) 249 #define DCS_IGNOLD (0x80<<16) // ignore old paper widths in byte 3 250 #define DCS_1216 (0x40<<16) // use 1216 pixels in 151 mm scanline 251 #define DCS_864 (0x20<<16) // use 864 pixels in 107 mm scanline 252 // bits 0x10 and 0x08 are invalid 253 // bits 0x04 and 0x02 are not used 254 // bit 0x01 indicates another information byte follows 255 256 // 3rd extension byte (alternative resolution capabilities) 257 #define DCS_200X400 (0x80<<8) // use 200 x 400 pixels/inch resolution 258 #define DCS_300X300 (0x40<<8) // use 300 x 300 pixels/inch resolution 259 #define DCS_400X400 (0x20<<8) // use 400 x 400 pixels/inch resolution 260 #define DCS_INCHRES (0x10<<8) // use inch-based resolution 261 // bits 0x08 and 0x04 are ``don't care'' 262 // bit 0x02 should be zero 263 // bit 0x01 indicates another information byte follows 264 265 // 4th extension byte (enhanced features capabilities) 266 // bits 0x80 and 0x40 should be zero 267 // bit 0x20 is not used 268 // bit 0x10 is reserved for facsimile service information 269 #define DCS_BFT (0x08<<0) // use Binary File Transfer (BFT) 270 #define DCS_DTM (0x04<<0) // use Document Transfer Mode (DTM) 271 #define DCS_EDI (0x02<<0) // use Edifact Transfer (EDI) 272 // bit 0x01 indicates another information byte follows 273 274 // pre-message responses 275 #define FCF_CFR 0x21 // confirmation to receive 276 #define FCF_FTT 0x22 // failure to train 277 #define FCF_CTR 0x23 // response to CTC (Annex A) 278 279 // post-message commands (from transmitter to receiver) 280 #define FCF_EOM 0x71 // end-of-page, restart phase B on ack 281 #define FCF_MPS 0x72 // end-of-page, restart phase C on ack 282 #define FCF_EOP 0x74 // end-of-procedures, hangup after ack 283 #define FCF_PRI_EOM 0x79 // EOM, but allow operator intervention 284 #define FCF_PRI_MPS 0x7A // MPS, but allow operator intervention 285 #define FCF_PRI_EOP 0x7C // MPS, but allow operator intervention 286 #define FCF_PPS 0x7D // partial page signal (Annex A) 287 #define FCF_EOR 0x73 // end of retransmission (Annex A) 288 #define FCF_RR 0x76 // receive ready (Annex A), was erroniously 0x37 3/93 289 290 // post-message responses (from receiver to transmitter) 291 #define FCF_MCF 0x31 // message confirmation (ack MPS/EOM) 292 #define FCF_RTP 0x33 // ack, continue after retraining 293 #define FCF_RTN 0x32 // nak, retry after retraining 294 #define FCF_PIP 0x35 // ack, continue after operating interv. 295 #define FCF_PIN 0x34 // nak, retry after operation interv. 296 #define FCF_PPR 0x3D // partial page request (Annex A) 297 #define FCF_RNR 0x37 // receive not ready (Annex A) 298 #define FCF_ERR 0x38 // response for EOR (Annex A) 299 300 // other line control signals 301 #define FCF_DCN 0x5F // disconnect - initiate call release 302 #define FCF_CRP 0x58 // command repeat - resend last command 303 304 // command to receive 305 #define FCF_CTC 0x48 // continue to correct (Annex A) 306 #endif /* _t30_ */ 307