Skip to content
Snippets Groups Projects
Commit ce266335 authored by rswindell's avatar rswindell
Browse files

New Zmodem header based on zmtx/zmrx (no rzsz).

Added Zmodem context struct definition (zmodem_t).
parent a8ad5c67
No related branches found
No related tags found
No related merge requests found
/* /*
* Z M O D E M . H Manifest constants for ZMODEM * zmodem.h
* application to application file transfer protocol * zmodem constants
* Copyright 1991 Omen Technology Inc All Rights Reserved * (C) Mattheij Computer Service 1994
* 04-17-89 Chuck Forsberg Omen Technology Inc */
*/
#define ZPAD '*' /* 052 Padding character begins frames */ #ifndef _ZMODEM_H
#define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
#define ZDLEE (ZDLE^0100) /* Escaped ZDLE as transmitted */ #define _ZMODEM_H
#define ZBIN 'A' /* Binary frame indicator (CRC-16) */
#define ZHEX 'B' /* HEX frame indicator */ /*
#define ZBIN32 'C' /* Binary frame with 32 bit FCS */ * ascii constants
#define ZBINR32 'D' /* RLE packed Binary frame with 32 bit FCS */ */
#define ZVBIN 'a' /* Binary frame indicator (CRC-16) */
#define ZVHEX 'b' /* HEX frame indicator */ #ifndef SOH
#define ZVBIN32 'c' /* Binary frame with 32 bit FCS */ #define SOH 0x01
#define ZVBINR32 'd' /* RLE packed Binary frame with 32 bit FCS */ #define STX 0x02
#define ZRESC 0176 /* RLE flag/escape character */ #define EOT 0x04
#define ZMAXHLEN 16 /* Max header information length NEVER CHANGE */ #define ENQ 0x05
#define ZMAXSPLEN 1024 /* Max subpacket length NEVER CHANGE */ #define ACK 0x06
#if 0
/* Frame types (see array "frametypes" in zm.c) */ #define LF 0x0a
#define ZRQINIT 0 /* Request receive init */ #define CR 0x0d
#define ZRINIT 1 /* Receive init */ #endif
#define ZSINIT 2 /* Send init sequence (optional) */ #define XON 0x11
#define ZACK 3 /* ACK to above */ #define XOFF 0x13
#define ZFILE 4 /* File name from sender */ #define NAK 0x15
#define ZSKIP 5 /* To sender: skip this file */ #define CAN 0x18
#define ZNAK 6 /* Last packet was garbled */ #endif
#define ZABORT 7 /* Abort batch transfers */
#define ZFIN 8 /* Finish session */ /*
#define ZRPOS 9 /* Resume data trans at this position */ * zmodem constants
#define ZDATA 10 /* Data packet(s) follow */ */
#define ZEOF 11 /* End of file */
#define ZFERR 12 /* Fatal Read or Write error Detected */ #define ZMAXHLEN 0x10 /* maximum header information length */
#define ZCRC 13 /* Request for file CRC and response */ #define ZMAXSPLEN 0x400 /* maximum subpacket length */
#define ZCHALLENGE 14 /* Receiver's Challenge */
#define ZCOMPL 15 /* Request is complete */
#define ZCAN 16 /* Other end canned session with CAN*5 */ #define ZPAD 0x2a /* pad character; begins frames */
#define ZFREECNT 17 /* Request for free bytes on filesystem */ #define ZDLE 0x18 /* ctrl-x zmodem escape */
#define ZCOMMAND 18 /* Command from sending program */ #define ZDLEE 0x58 /* escaped ZDLE */
#define ZSTDERR 19 /* Output to standard error, data follows */
#define ZBIN 0x41 /* binary frame indicator (CRC16) */
/* ZDLE sequences */ #define ZHEX 0x42 /* hex frame indicator */
#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ #define ZBIN32 0x43 /* binary frame indicator (CRC32) */
#define ZCRCG 'i' /* CRC next, frame continues nonstop */ #define ZBINR32 0x44 /* run length encoded binary frame (CRC32) */
#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */
#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ #define ZVBIN 0x61 /* binary frame indicator (CRC16) */
#define ZRUB0 'l' /* Translate to rubout 0177 */ #define ZVHEX 0x62 /* hex frame indicator */
#define ZRUB1 'm' /* Translate to rubout 0377 */ #define ZVBIN32 0x63 /* binary frame indicator (CRC32) */
#define ZVBINR32 0x64 /* run length encoded binary frame (CRC32) */
/* zdlread return values (internal) */
/* -1 is general error, -2 is timeout */ #define ZRESC 0x7e /* run length encoding flag / escape character */
#define GOTOR 0400
#define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */ /*
#define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */ * zmodem frame types
#define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */ */
#define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */
#define GOTCAN (GOTOR|030) /* CAN*5 seen */ #define ZRQINIT 0x00 /* request receive init (s->r) */
#define ZRINIT 0x01 /* receive init (r->s) */
/* Byte positions within header array */ #define ZSINIT 0x02 /* send init sequence (optional) (s->r) */
#define ZF0 3 /* First flags byte */ #define ZACK 0x03 /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */
#define ZF1 2 #define ZFILE 0x04 /* file name (s->r) */
#define ZF2 1 #define ZSKIP 0x05 /* skip this file (r->s) */
#define ZF3 0 #define ZNAK 0x06 /* last packet was corrupted (?) */
#define ZP0 0 /* Low order 8 bits of position */ #define ZABORT 0x07 /* abort batch transfers (?) */
#define ZP1 1 #define ZFIN 0x08 /* finish session (s<->r) */
#define ZP2 2 #define ZRPOS 0x09 /* resume data transmission here (r->s) */
#define ZP3 3 /* High order 8 bits of file position */ #define ZDATA 0x0a /* data packet(s) follow (s->r) */
#define ZEOF 0x0b /* end of file reached (s->r) */
/* Bit Masks for ZRINIT flags byte ZF0 */ #define ZFERR 0x0c /* fatal read or write error detected (?) */
#define CANFDX 01 /* Rx can send and receive true FDX */ #define ZCRC 0x0d /* request for file CRC and response (?) */
#define CANOVIO 02 /* Rx can receive data during disk I/O */ #define ZCHALLENGE 0x0e /* security challenge (r->s) */
#define CANBRK 04 /* Rx can send a break signal */ #define ZCOMPL 0x0f /* request is complete (?) */
#define CANRLE 010 /* Receiver can decode RLE */ #define ZCAN 0x10 /* pseudo frame;
#define CANLZW 020 /* Receiver can uncompress */ other end cancelled session with 5* CAN */
#define CANFC32 040 /* Receiver can use 32 bit Frame Check */ #define ZFREECNT 0x11 /* request free bytes on file system (s->r) */
#define ESCCTL 0100 /* Receiver expects ctl chars to be escaped */ #define ZCOMMAND 0x12 /* issue command (s->r) */
#define ESC8 0200 /* Receiver expects 8th bit to be escaped */ #define ZSTDERR 0x13 /* output data to stderr (??) */
/* Bit Masks for ZRINIT flags byte ZF1 */ /*
#define CANVHDR 01 /* Variable headers OK */ * ZDLE sequences
*/
/* Parameters for ZSINIT frame */
#define ZATTNLEN 32 /* Max length of attention string */ #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 */ #define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */
/* Bit Masks for ZSINIT flags byte ZF0 */
#define TESCCTL 0100 /* Transmitter expects ctl chars to be escaped */ /*
#define TESC8 0200 /* Transmitter expects 8th bit to be escaped */ * ZFILE frame
*/
/* Parameters for ZFILE frame */
/* Conversion options one of these in ZF0 */ /*
#define ZCBIN 1 /* Binary transfer - inhibit conversion */ * Conversion options one of these in ZF0
#define ZCNL 2 /* Convert NL to local end of line convention */ */
#define ZCRESUM 3 /* Resume interrupted file transfer */
/* Management include options, one of these ored in ZF1 */ #define ZF0_ZCBIN 1 /* Binary transfer - inhibit conversion */
#define ZMSKNOLOC 0200 /* Skip file if not present at rx */ #define ZF0_ZCNL 2 /* Convert NL to local end of line convention */
/* Management options, one of these ored in ZF1 */ #define ZF0_ZCRESUM 3 /* Resume interrupted file transfer */
#define ZMMASK 037 /* Mask for the choices below */
#define ZMNEWL 1 /* Transfer if source newer or longer */ /*
#define ZMCRC 2 /* Transfer if different file CRC or length */ * Management include options, one of these ored in ZF1
#define ZMAPND 3 /* Append contents to existing file (if any) */ */
#define ZMCLOB 4 /* Replace existing file */
#define ZMNEW 5 /* Transfer if source newer */ #define ZF1_ZMSKNOLOC 0x80 /* Skip file if not present at rx */
/* Number 5 is alive ... */ #define ZF1_ZMMASK 0x1f /* Mask for the choices below */
#define ZMDIFF 6 /* Transfer if dates or lengths different */ #define ZF1_ZMNEWL 1 /* Transfer if source newer or longer */
#define ZMPROT 7 /* Protect destination file */ #define ZF1_ZMCRC 2 /* Transfer if different file CRC or length */
#define ZMCHNG 8 /* Change filename if destination exists */ #define ZF1_ZMAPND 3 /* Append contents to existing file (if any) */
/* Transport options, one of these in ZF2 */ #define ZF1_ZMCLOB 4 /* Replace existing file */
#define ZTLZW 1 /* Lempel-Ziv compression */ #define ZF1_ZMNEW 5 /* Transfer if source newer */
#define ZTRLE 3 /* Run Length encoding */ #define ZF1_ZMDIFF 6 /* Transfer if dates or lengths different */
/* Extended options for ZF3, bit encoded */ #define ZF1_ZMPROT 7 /* Protect destination file */
#define ZXSPARS 64 /* Encoding for sparse file operations */ #define ZF1_ZMCHNG 8 /* Change filename if destination exists */
#define ZCANVHDR 01 /* Variable headers OK */
/*
* 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 */ /* Receiver window size override */
#define ZRWOVR 4 /* byte position for receive window override/256 */ #define ZF3_ZRWOVR 0x04 /* byte position for receive window override/256 */
#define ZF3_ZXSPARS 0x40 /* encoding for sparse file operations */
/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */ /*
#define ZCACK1 1 /* Acknowledge, then do command */ * ZCOMMAND frame
*/
#define ZF0_ZCACK1 0x01 /* Acknowledge, then do command */
typedef struct {
#ifndef STP SOCKET sock; /* socket descriptor */
long rclhdr(); unsigned char rxd_header[ZMAXHLEN]; /* last received header */
int rxd_header_len; /* last received header size */
/*
* receiver capability flags
* extracted from the ZRINIT frame as received
*/
int can_full_duplex;
int can_overlap_io;
int can_break;
int can_fcs_32;
int want_fcs_16;
int escape_all_control_characters; /* guess */
int escape_8th_bit;
int use_variable_headers; /* use variable length headers */
/*
* file management options.
* only one should be on
*/
/* Globals used by ZMODEM functions */ int management_newer;
extern Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ int management_clobber;
extern Rxtype; /* Type of header received */ int management_protect;
extern Rxcount; /* Count of data bytes received */
extern Rxtimeout; /* Tenths of seconds to wait for something */ /* from zmtx.c */
extern long Rxpos; /* Received file position */
extern long Txpos; /* Transmitted file position */ #define MAX_SUBPACKETSIZE 1024
extern Txfcs32; /* TURE means send binary frames with 32 bit FCS */
extern Crc32t; /* Display flag indicating 32 bit CRC being sent */ int n_files_remaining;
extern Crc32; /* Display flag indicating 32 bit CRC being received */ int n_bytes_remaining;
extern Znulls; /* Number of nulls to send at beginning of ZDATA hdr */ unsigned char tx_data_subpacket[MAX_SUBPACKETSIZE];
extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
extern char *Altcan; /* Alternate canit string */ long current_file_size;
time_t transfer_start;
int receive_32_bit_data;
int raw_trace;
int use_crc16;
long ack_file_pos; /* file position used in acknowledgement of correctly */
/* received data subpackets */
int last_sent;
int n_cans;
long mode;
} zmodem_t;
#endif #endif
/* End of ZMODEM.H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment