File: /usr/include/linux/sdla_x25.h

1     /*****************************************************************************
2     * sdla_x25.h	Sangoma X.25 firmware API definitions.
3     *
4     * Author:	Gene Kozin	<74604.152@compuserve.com>
5     *
6     * Copyright:	(c) 1995-1996 Sangoma Technologies Inc.
7     *
8     *		This program is free software; you can redistribute it and/or
9     *		modify it under the terms of the GNU General Public License
10     *		as published by the Free Software Foundation; either version
11     *		2 of the License, or (at your option) any later version.
12     * ============================================================================
13     * Dec 13, 1996	Gene Kozin	Initial version
14     *****************************************************************************/
15     #ifndef	_SDLA_X25_H
16     #define	_SDLA_X25_H
17     
18     /*----------------------------------------------------------------------------
19      * Notes:
20      * ------
21      * 1. All structures defined in this file are byte-aligned.  To ensure
22      *    portability of this code between different platforms and compilers, one
23      *    of the following defines must be defined before including this file:
24      *
25      *	Compiler	Platform	Define		Use option
26      *	--------	--------	------		----------
27      *	GNU C		Linux		_GNUC_		-
28      *	Microsoft C	DOS/Windows	_MSC_		-
29      *
30      */
31     
32     #ifdef		_GNUC_
33     #  ifndef	PACKED
34     #    define	PACKED	__attribute__((packed))
35     #  endif	/* PACKED */
36     #else
37     #  define	PACKED
38     #endif
39     #ifdef		_MSC_
40     #  pragma	pack(1)
41     #endif
42     
43     /******	CONSTANTS DEFINITIONS ***********************************************/
44     
45     #define	X25_MAX_CHAN	255	/* max number of open X.25 circuits */
46     #define	X25_MAX_DATA	1024	/* max length of X.25 data buffer */
47     
48     /*
49      * X.25 shared memory layout.
50      */
51     #define	X25_MBOX_OFFS	0x16B0	/* general mailbox block */
52     #define	X25_RXMBOX_OFFS	0x1AD0	/* receive mailbox */
53     #define	X25_STATUS_OFFS	0x1EF0	/* X.25 status structure */
54     
55     /****** DATA STRUCTURES *****************************************************/
56     
57     /*----------------------------------------------------------------------------
58      * X.25 Command Block.
59      */
60     typedef struct X25Cmd
61     {
62     	unsigned char command	PACKED;	/* command code */
63     	unsigned short length	PACKED;	/* transfer data length */
64     	unsigned char result	PACKED;	/* return code */
65     	unsigned char pf	PACKED;	/* P/F bit */
66     	unsigned short lcn	PACKED;	/* logical channel */
67     	unsigned char qdm	PACKED;	/* Q/D/M bits */
68     	unsigned char cause	PACKED;	/* cause field */
69     	unsigned char diagn	PACKED;	/* diagnostics */
70     	unsigned char pktType	PACKED;	/* packet type */
71     	unsigned char resrv[4]	PACKED;	/* reserved */
72     } TX25Cmd;
73     
74     /*
75      * Defines for the 'command' field.
76      */
77     /*----- General commands --------------*/
78     #define X25_SET_GLOBAL_VARS	0x0B   	/* set global variables */ 
79     #define X25_READ_MODEM_STATUS	0x0C 	/* read modem status */
80     #define X25_READ_CODE_VERSION	0x15	/* read firmware version number */
81     #define X25_TRACE_CONFIGURE	0x14	/* configure trace facility */
82     #define X25_READ_TRACE_DATA	0x16	/* read trace data */
83     #define	X25_SET_INTERRUPT_MODE	0x17	/* set interrupt generation mode */
84     #define	X25_READ_INTERRUPT_MODE	0x18	/* read interrupt generation mode */
85     /*----- HDLC-level commands -----------*/
86     #define X25_HDLC_LINK_CONFIGURE	0x01	/* configure HDLC link level */   
87     #define X25_HDLC_LINK_OPEN	0x02	/* open HDLC link */         	
88     #define X25_HDLC_LINK_CLOSE	0x03	/* close HDLC link */
89     #define X25_HDLC_LINK_SETUP	0x04	/* set up HDLC link */ 
90     #define X25_HDLC_LINK_DISC	0x05	/* disconnect DHLC link */
91     #define X25_HDLC_LINK_STATUS	0x06	/* read DHLC link status */
92     #define X25_HDLC_READ_STATS	0x07	/* read operational statistics */
93     #define X25_HDLC_FLUSH_STATS	0x08 	/* flush operational statistics */
94     #define X25_HDLC_READ_COMM_ERR	0x09 	/* read error statistics */
95     #define X25_HDLC_FLUSH_COMM_ERR	0x0A	/* flush error statistics */
96     #define X25_HDLC_FLUSH_BUFFERS	0x0D	/* flush HDLC-level data buffers */
97     #define X25_HDLC_SPRVS_CNT_STAT 0x0F	/* read surervisory count status */
98     #define X25_HDLC_SEND_UI_FRAME	0x10	/* send unnumbered information frame */
99     #define X25_HDLC_WRITE		0x11	/* send HDLC information frame */
100     #define X25_HDLC_READ		0x21	/* read HDLC information frame */
101     #define X25_HDLC_READ_CONFIG	0x12	/* read HDLC configuration */
102     #define X25_HDLC_SET_CONFIG	0x13	/* set HDLC configuration */
103     /*----- X.25-level commands -----------*/
104     #define X25_READ		0x22	/* read X.25 packet */
105     #define X25_WRITE		0x23	/* send X.25 packet */
106     #define X25_PLACE_CALL		0x30	/* place a call on SVC */
107     #define X25_ACCEPT_CALL		0x31	/* accept incoming call */
108     #define X25_CLEAR_CALL		0x32	/* clear call */
109     #define X25_CLEAR_CONFRM	0x33	/* send clear confirmation packet */
110     #define X25_RESET		0x34	/* send reset request packet */
111     #define X25_RESET_CONFRM	0x35	/* send reset confirmation packet */
112     #define X25_RESTART		0x36	/* send restart request packet */
113     #define X25_RESTART_CONFRM	0x37	/* send restart confirmation packet */
114     #define X25_INTERRUPT		0x38	/* send interrupt request packet */
115     #define X25_INTERRUPT_CONFRM	0x39	/* send interrupt confirmation pkt */
116     #define X25_REGISTRATION_RQST	0x3A	/* send registration request packet */
117     #define X25_REGISTRATION_CONFRM	0x3B	/* send registration confirmation */
118     #define X25_IS_DATA_AVAILABLE	0x40	/* querry receive queue */
119     #define X25_INCOMING_CALL_CTL	0x41	/* select incoming call options */
120     #define X25_CONFIGURE_PVC	0x42	/* configure PVC */
121     #define X25_GET_ACTIVE_CHANNELS	0x43	/* get a list of active circuits */
122     #define X25_READ_CHANNEL_CONFIG	0x44	/* read virt. circuit configuration */
123     #define X25_FLUSH_DATA_BUFFERS	0x45	/* flush X.25-level data buffers */
124     #define X25_READ_HISTORY_TABLE	0x46	/* read asynchronous event log */
125     #define X25_HISTORY_TABLE_CTL	0x47	/* control asynchronous event log */
126     #define	X25_GET_TX_D_BIT_STATUS	0x48	/* is packet with D-bit acknowledged */
127     #define	X25_READ_STATISTICS	0x49	/* read X.25-level statistics */
128     #define	X25_FLUSH_STATISTICS	0x4A	/* flush X.25-level statistics */
129     #define	X25_READ_CONFIGURATION	0x50	/* read HDLC & X.25 configuration */
130     #define	X25_SET_CONFIGURATION	0x51	/* set HDLC & X.25 configuration */
131     
132     /*
133      * Defines for the 'result' field.
134      */
135     /*----- General results ---------------*/
136     #define X25RES_OK		0x00
137     #define X25RES_ERROR		0x01
138     #define X25RES_LINK_NOT_IN_ABM	0x02	/* link is not in ABM mode */
139     #define X25RES_LINK_CLOSED	0x03
140     #define X25RES_INVAL_LENGTH	0x04
141     #define X25RES_INVAL_CMD	0x05
142     #define X25RES_UNNUMBERED_FRAME	0x06	/* unnumbered frame received */
143     #define X25RES_FRM_REJECT_MODE	0x07	/* link is in Frame Reject mode */
144     #define X25RES_MODEM_FAILURE	0x08	/* DCD and/or CTS dropped */
145     #define X25RES_N2_RETRY_LIMIT	0x09	/* N2 retry limit has been exceeded */
146     #define X25RES_INVAL_LCN	0x30	/* invalid logical channel number */
147     #define X25RES_INVAL_STATE	0x31	/* channel is not in data xfer mode */
148     #define X25RES_INVAL_DATA_LEN	0x32	/* invalid data length */
149     #define X25RES_NOT_READY	0x33	/* no data available / buffers full */
150     #define X25RES_NETWORK_DOWN	0x34
151     #define X25RES_CHANNEL_IN_USE	0x35	/* there is data queued on this LCN */
152     #define X25RES_REGST_NOT_SUPPRT	0x36	/* registration not supported */
153     #define X25RES_INVAL_FORMAT	0x37	/* invalid packet format */
154     #define X25RES_D_BIT_NOT_SUPPRT	0x38	/* D-bit pragmatics not supported */
155     #define X25RES_FACIL_NOT_SUPPRT	0x39	/* Call facility not supported */
156     #define X25RES_INVAL_CALL_ARG	0x3A	/* erroneous call arguments */
157     #define X25RES_INVAL_CALL_DATA	0x3B	/* erroneous call user data */
158     #define X25RES_ASYNC_PACKET	0x40	/* asynchronous packet received */
159     #define X25RES_PROTO_VIOLATION	0x41	/* protocol violation occurred */
160     #define X25RES_PKT_TIMEOUT	0x42	/* X.25 packet time out */
161     #define X25RES_PKT_RETRY_LIMIT	0x43	/* X.25 packet retry limit exceeded */
162     /*----- Command-dependent results -----*/
163     #define X25RES_LINK_DISC	0x00	/* HDLC_LINK_STATUS */
164     #define X25RES_LINK_IN_ABM	0x01	/* HDLC_LINK_STATUS */
165     #define X25RES_NO_DATA		0x01	/* HDLC_READ/READ_TRACE_DATA*/
166     #define X25RES_TRACE_INACTIVE	0x02	/* READ_TRACE_DATA */
167     #define X25RES_LINK_IS_OPEN	0x01	/* HDLC_LINK_OPEN */
168     #define X25RES_LINK_IS_DISC	0x02	/* HDLC_LINK_DISC */
169     #define X25RES_LINK_IS_CLOSED	0x03	/* HDLC_LINK_CLOSE */
170     #define X25RES_INVAL_PARAM	0x31	/* INCOMING_CALL_CTL */
171     #define X25RES_INVAL_CONFIG	0x35	/* REGISTR_RQST/CONFRM */
172     
173     /*
174      * Defines for the 'qdm_bits' field.
175      */
176     #define X25CMD_Q_BIT_MASK	0x04
177     #define X25CMD_D_BIT_MASK	0x02
178     #define X25CMD_M_BIT_MASK	0x01
179     
180     /*
181      * Defines for the 'pkt_type' field.
182      */
183     /*----- Asynchronous events ------*/
184     #define ASE_CLEAR_RQST		0x02
185     #define ASE_RESET_RQST		0x04
186     #define ASE_RESTART_RQST	0x08
187     #define ASE_INTERRUPT		0x10
188     #define ASE_DTE_REGISTR_RQST	0x20
189     #define ASE_CALL_RQST		0x30
190     #define ASE_CALL_ACCEPTED	0x31
191     #define ASE_CLEAR_CONFRM	0x32
192     #define ASE_RESET_CONFRM	0x33
193     #define ASE_RESTART_CONFRM	0x34
194     #define ASE_INTERRUPT_CONFRM	0x35
195     #define ASE_DCE_REGISTR_CONFRM	0x36
196     #define ASE_DIAGNOSTIC		0x37
197     #define ASE_CALL_AUTO_CLEAR	0x38
198     #define AUTO_RESPONSE_FLAG	0x80
199     /*----- Time-Out events ----------*/
200     #define TOE_RESTART_RQST	0x03
201     #define TOE_CALL_RQST		0x05
202     #define TOE_CLEAR_RQST		0x08
203     #define TOE_RESET_RQST		0x0A
204     /*----- Protocol Violation events */
205     #define PVE_CLEAR_RQST		0x32
206     #define PVE_RESET_RQST		0x33
207     #define PVE_RESTART_RQST	0x34
208     #define PVE_DIAGNOSTIC		0x37
209     
210     /*----------------------------------------------------------------------------
211      * X.25 Mailbox.
212      *	This structure is located at offsets X25_MBOX_OFFS and X25_RXMBOX_OFFS
213      *	into shared memory window.
214      */
215     typedef struct X25Mbox
216     {
217     	unsigned char opflag	PACKED;	/* 00h: execution flag */
218     	TX25Cmd cmd		PACKED;	/* 01h: command block */
219     	unsigned char data[1]	PACKED;	/* 10h: data buffer */
220     } TX25Mbox;
221     
222     /*----------------------------------------------------------------------------
223      * X.25 Time Stamp Structure.
224      */
225     typedef struct X25TimeStamp
226     {
227     	unsigned char month	PACKED;
228     	unsigned char date	PACKED;
229     	unsigned char sec	PACKED;
230     	unsigned char min	PACKED;
231     	unsigned char hour	PACKED;
232     } TX25TimeStamp;
233     
234     /*----------------------------------------------------------------------------
235      * X.25 Status Block.
236      *	This structure is located at offset X25_STATUS_OFF into shared memory
237      *	window.
238      */
239     typedef struct X25Status
240     {
241     	unsigned short pvc_map	PACKED;	/* 00h: PVC map */
242     	unsigned short icc_map	PACKED;	/* 02h: Incoming Chan. map */
243     	unsigned short twc_map	PACKED;	/* 04h: Two-way Cnan. map */
244     	unsigned short ogc_map	PACKED;	/* 06h: Outgoing Chan. map */
245     	TX25TimeStamp tstamp	PACKED;	/* 08h: timestamp (BCD) */
246     	unsigned char iflags	PACKED;	/* 0Dh: interrupt flags */
247     	unsigned char imask     PACKED; /* 0Eh: interrupt mask  */
248     	unsigned char resrv	PACKED;	/* 0Eh: */
249     	unsigned char gflags	PACKED;	/* 10h: misc. HDLC/X25 flags */
250     	unsigned char cflags[X25_MAX_CHAN] PACKED; /* channel status bytes */
251     } TX25Status;
252     
253     /*
254      * Bitmasks for the 'iflags' field.
255      */
256     #define X25_RX_INTR	0x01	/* receive interrupt */
257     #define X25_TX_INTR	0x02	/* transmit interrupt */
258     #define X25_MODEM_INTR	0x04	/* modem status interrupt (CTS/DCD) */
259     #define X25_EVENT_INTR	0x10	/* asynchronous event encountered */
260     #define X25_CMD_INTR	0x08	/* interface command complete */
261     
262     /*
263      * Bitmasks for the 'gflags' field.
264      */
265     #define X25_HDLC_ABM	0x01	/* HDLC is in ABM mode */
266     #define X25_RX_READY	0x02	/* X.25 data available */
267     #define X25_TRACE_READY	0x08	/* trace data available */
268     #define X25_EVENT_IND	0x20	/* asynchronous event indicator */
269     #define X25_TX_READY	0x40	/* space is available in Tx buf.*/
270     
271     /*
272      * Bitmasks for the 'cflags' field.
273      */
274     #define X25_XFER_MODE	0x80	/* channel is in data transfer mode */
275     #define X25_TXWIN_OPEN	0x40	/* transmit window open */
276     #define X25_RXBUF_MASK	0x3F	/* number of data buffers available */
277     
278     /*****************************************************************************
279      * Following definitions structurize contents of the TX25Mbox.data field for
280      * different X.25 interface commands.
281      ****************************************************************************/
282     
283     /* ---------------------------------------------------------------------------
284      * X25_SET_GLOBAL_VARS Command.
285      */
286     typedef struct X25GlobalVars
287     {
288     	unsigned char resrv	PACKED;	/* 00h: reserved */
289     	unsigned char dtrCtl	PACKED;	/* 01h: DTR control code */
290     	unsigned char resErr	PACKED;	/* 01h: '1' - reset modem error */
291     } TX25GlobalVars;
292     
293     /*
294      * Defines for the 'dtrCtl' field.
295      */
296     #define X25_RAISE_DTR	0x01
297     #define X25_DROP_DTR	0x02
298     
299     /* ---------------------------------------------------------------------------
300      * X25_READ_MODEM_STATUS Command.
301      */
302     typedef struct X25ModemStatus
303     {
304     	unsigned char	status	PACKED;		/* 00h: modem status */
305     } TX25ModemStatus;
306     
307     /*
308      * Defines for the 'status' field.
309      */
310     #define X25_CTS_MASK	0x20
311     #define X25_DCD_MASK	0x08
312     
313     /* ---------------------------------------------------------------------------
314      * X25_HDLC_LINK_STATUS Command.
315      */
316     typedef struct X25LinkStatus
317     {
318     	unsigned char txQueued	PACKED;	/* 00h: queued Tx I-frames*/
319     	unsigned char rxQueued	PACKED;	/* 01h: queued Rx I-frames*/
320     	unsigned char station	PACKED;	/* 02h: DTE/DCE config. */
321     	unsigned char reserved	PACKED;	/* 03h: reserved */
322     	unsigned char sfTally	PACKED;	/* 04h: supervisory frame tally */
323     } TX25LinkStatus;
324     
325     /*
326      * Defines for the 'station' field.
327      */
328     #define	X25_STATION_DTE	0x01	/* station configured as DTE */
329     #define X25_STATION_DCE	0x02	/* station configured as DCE */
330     
331     /* ---------------------------------------------------------------------------
332      * X25_HDLC_READ_STATS Command.
333      */
334     typedef struct HdlcStats
335     {						/*	a number of ... */
336     	unsigned short rxIFrames	PACKED;	/* 00h: ready Rx I-frames */
337     	unsigned short rxNoseq		PACKED;	/* 02h: frms out-of-sequence */
338     	unsigned short rxNodata		PACKED;	/* 04h: I-frms without data */
339     	unsigned short rxDiscarded	PACKED;	/* 06h: discarded frames */
340     	unsigned short rxTooLong	PACKED;	/* 08h: frames too long */
341     	unsigned short rxBadAddr	PACKED;	/* 0Ah: frms with inval.addr*/
342     	unsigned short txAcked		PACKED;	/* 0Ch: acknowledged I-frms */
343     	unsigned short txRetransm	PACKED;	/* 0Eh: re-transmit. I-frms */
344     	unsigned short t1Timeout	PACKED;	/* 10h: T1 timeouts */
345     	unsigned short rxSABM		PACKED;	/* 12h: received SABM frames */
346     	unsigned short rxDISC		PACKED;	/* 14h: received DISC frames */
347     	unsigned short rxDM		PACKED;	/* 16h: received DM frames */
348     	unsigned short rxFRMR		PACKED;	/* 18h: FRMR frames received */
349     	unsigned short txSABM		PACKED;	/* 1Ah: transm. SABM frames*/
350     	unsigned short txDISC		PACKED;	/* 1Ch: transm. DISC frames*/
351     	unsigned short txDM		PACKED;	/* 1Eh: transm. DM frames */
352     	unsigned short txFRMR		PACKED;	/* 20h: transm. FRMR frames*/
353     } THdlcStats;
354     
355     /* ---------------------------------------------------------------------------
356      * X25_HDLC_READ_COMM_ERR Command.
357      */
358     typedef struct HdlcCommErr
359     {						/*	a number of ... */
360     	unsigned char rxOverrun		PACKED;	/* 00h: Rx overrun errors */
361     	unsigned char rxBadCrc		PACKED;	/* 01h: Rx CRC errors */
362     	unsigned char rxAborted		PACKED;	/* 02h: Rx aborted frames */
363     	unsigned char rxDropped		PACKED;	/* 03h: frames lost */
364     	unsigned char txAborted		PACKED;	/* 04h: Tx aborted frames */
365     	unsigned char txUnderrun	PACKED;	/* 05h: Tx underrun errors */
366     	unsigned char txMissIntr	PACKED;	/* 06h: missed underrun ints */
367     	unsigned char reserved		PACKED;	/* 07h: reserved */
368     	unsigned char droppedDCD	PACKED;	/* 08h: times DCD dropped */
369     	unsigned char droppedCTS	PACKED;	/* 09h: times CTS dropped */
370     } THdlcCommErr;
371     
372     /* ---------------------------------------------------------------------------
373      * X25_SET_CONFIGURATION & X25_READ_CONFIGURATION Commands.
374      */
375     typedef struct X25Config
376     {
377     	unsigned char baudRate		PACKED;	/* 00h:  */
378     	unsigned char t1		PACKED;	/* 01h:  */
379     	unsigned char t2		PACKED;	/* 02h:  */
380     	unsigned char n2		PACKED;	/* 03h:  */
381     	unsigned short hdlcMTU		PACKED;	/* 04h:  */
382     	unsigned char hdlcWindow	PACKED;	/* 06h:  */
383     	unsigned char t4		PACKED;	/* 07h:  */
384     	unsigned char autoModem		PACKED;	/* 08h:  */
385     	unsigned char autoHdlc		PACKED;	/* 09h:  */
386     	unsigned char hdlcOptions	PACKED;	/* 0Ah:  */
387     	unsigned char station		PACKED;	/* 0Bh:  */
388     	unsigned char pktWindow		PACKED;	/* 0Ch:  */
389     	unsigned short defPktSize	PACKED;	/* 0Dh:  */
390     	unsigned short pktMTU		PACKED;	/* 0Fh:  */
391     	unsigned short loPVC		PACKED;	/* 11h:  */
392     	unsigned short hiPVC		PACKED;	/* 13h:  */
393     	unsigned short loIncomingSVC	PACKED;	/* 15h:  */
394     	unsigned short hiIncomingSVC	PACKED;	/* 17h:  */
395     	unsigned short loTwoWaySVC	PACKED;	/* 19h:  */
396     	unsigned short hiTwoWaySVC	PACKED;	/* 1Bh:  */
397     	unsigned short loOutgoingSVC	PACKED;	/* 1Dh:  */
398     	unsigned short hiOutgoingSVC	PACKED;	/* 1Fh:  */
399     	unsigned short options		PACKED;	/* 21h:  */
400     	unsigned char responseOpt	PACKED;	/* 23h:  */
401     	unsigned short facil1		PACKED;	/* 24h:  */
402     	unsigned short facil2		PACKED;	/* 26h:  */
403     	unsigned short ccittFacil	PACKED;	/* 28h:  */
404     	unsigned short otherFacil	PACKED;	/* 2Ah:  */
405     	unsigned short ccittCompat	PACKED;	/* 2Ch:  */
406     	unsigned char t10t20		PACKED;	/* 2Eh:  */
407     	unsigned char t11t21		PACKED;	/* 2Fh:  */
408     	unsigned char t12t22		PACKED;	/* 30h:  */
409     	unsigned char t13t23		PACKED;	/* 31h:  */
410     	unsigned char t16t26		PACKED;	/* 32H:  */
411     	unsigned char t28		PACKED;	/* 33h:  */
412     	unsigned char r10r20		PACKED;	/* 34h:  */
413     	unsigned char r12r22		PACKED;	/* 35h:  */
414     	unsigned char r13r23		PACKED;	/* 36h:  */
415     } TX25Config;
416     
417     /* ---------------------------------------------------------------------------
418      * X25_READ_CHANNEL_CONFIG Command.
419      */
420     typedef struct X25ChanAlloc			/*----- Channel allocation -*/
421     {
422     	unsigned short loPVC		PACKED;	/* 00h: lowest PVC number */
423     	unsigned short hiPVC		PACKED;	/* 02h: highest PVC number */
424     	unsigned short loIncomingSVC	PACKED;	/* 04h: lowest incoming SVC */
425     	unsigned short hiIncomingSVC	PACKED;	/* 06h: highest incoming SVC */
426     	unsigned short loTwoWaySVC	PACKED;	/* 08h: lowest two-way SVC */
427     	unsigned short hiTwoWaySVC	PACKED;	/* 0Ah: highest two-way SVC */
428     	unsigned short loOutgoingSVC	PACKED;	/* 0Ch: lowest outgoing SVC */
429     	unsigned short hiOutgoingSVC	PACKED;	/* 0Eh: highest outgoing SVC */
430     } TX25ChanAlloc;
431     
432     typedef struct X25ChanCfg		/*------ Channel configuration -----*/
433     {
434     	unsigned char type	PACKED;	/* 00h: channel type */
435     	unsigned char txConf	PACKED;	/* 01h: Tx packet and window sizes */
436     	unsigned char rxConf	PACKED;	/* 01h: Rx packet and window sizes */
437     } TX25ChanCfg;
438     
439     /*
440      * Defines for the 'type' field.
441      */
442     #define	X25_PVC  	0x01	/* PVC */
443     #define	X25_SVC_IN	0x03	/* Incoming SVC */
444     #define	X25_SVC_TWOWAY	0x07	/* Two-way SVC */
445     #define	X25_SVC_OUT	0x0B	/* Outgoing SVC */
446     
447     /*----------------------------------------------------------------------------
448      * X25_READ_STATISTICS Command.
449      */
450     typedef struct X25Stats
451     {						/* number of packets Tx/Rx'ed */
452     	unsigned short txRestartRqst	PACKED;	/* 00h: Restart Request */
453     	unsigned short rxRestartRqst	PACKED;	/* 02h: Restart Request */
454     	unsigned short txRestartConf	PACKED;	/* 04h: Restart Confirmation */
455     	unsigned short rxRestartConf	PACKED;	/* 06h: Restart Confirmation */
456     	unsigned short txResetRqst	PACKED;	/* 08h: Reset Request */
457     	unsigned short rxResetRqst	PACKED;	/* 0Ah: Reset Request */
458     	unsigned short txResetConf	PACKED;	/* 0Ch: Reset Confirmation */
459     	unsigned short rxResetConf	PACKED;	/* 0Eh: Reset Confirmation */
460     	unsigned short txCallRequest	PACKED;	/* 10h: Call Request */
461     	unsigned short rxCallRequest	PACKED;	/* 12h: Call Request */
462     	unsigned short txCallAccept	PACKED;	/* 14h: Call Accept */
463     	unsigned short rxCallAccept	PACKED;	/* 16h: Call Accept */
464     	unsigned short txClearRqst	PACKED;	/* 18h: Clear Request */
465     	unsigned short rxClearRqst	PACKED;	/* 1Ah: Clear Request */
466     	unsigned short txClearConf	PACKED;	/* 1Ch: Clear Confirmation */
467     	unsigned short rxClearConf	PACKED;	/* 1Eh: Clear Confirmation */
468     	unsigned short txDiagnostic	PACKED;	/* 20h: Diagnostic */
469     	unsigned short rxDiagnostic	PACKED;	/* 22h: Diagnostic */
470     	unsigned short txRegRqst	PACKED;	/* 24h: Registration Request */
471     	unsigned short rxRegRqst	PACKED;	/* 26h: Registration Request */
472     	unsigned short txRegConf	PACKED;	/* 28h: Registration Confirm.*/
473     	unsigned short rxRegConf	PACKED;	/* 2Ah: Registration Confirm.*/
474     	unsigned short txInterrupt	PACKED;	/* 2Ch: Interrupt */
475     	unsigned short rxInterrupt	PACKED;	/* 2Eh: Interrupt */
476     	unsigned short txIntrConf	PACKED;	/* 30h: Interrupt Confirm. */
477     	unsigned short rxIntrConf	PACKED;	/* 32h: Interrupt Confirm. */
478     	unsigned short txData		PACKED;	/* 34h: Data */
479     	unsigned short rxData		PACKED;	/* 36h: Data */
480     	unsigned short txRR		PACKED;	/* 38h: RR */
481     	unsigned short rxRR		PACKED;	/* 3Ah: RR */
482     	unsigned short txRNR		PACKED;	/* 3Ch: RNR */
483     	unsigned short rxRNR		PACKED;	/* 3Eh: RNR */
484     } TX25Stats;
485     
486     /*----------------------------------------------------------------------------
487      * X25_READ_HISTORY_TABLE Command.
488      */
489     typedef struct X25EventLog
490     {
491     	unsigned char	type	PACKED;	/* 00h: transaction type */
492     	unsigned short	lcn	PACKED;	/* 01h: logical channel num */
493     	unsigned char	packet	PACKED;	/* 03h: async packet type */
494     	unsigned char	cause	PACKED;	/* 04h: X.25 cause field */
495     	unsigned char	diag	PACKED;	/* 05h: X.25 diag field */
496     	TX25TimeStamp	ts	PACKED;	/* 06h: time stamp */
497     } TX25EventLog;
498     
499     /*
500      * Defines for the 'type' field.
501      */
502     #define X25LOG_INCOMING		0x00
503     #define X25LOG_APPLICATION 	0x01
504     #define X25LOG_AUTOMATIC	0x02
505     #define X25LOG_ERROR		0x04
506     #define X25LOG_TIMEOUT		0x08
507     #define X25LOG_RECOVERY		0x10
508     
509     /*
510      * Defines for the 'packet' field.
511      */
512     #define X25LOG_CALL_RQST	0x0B
513     #define X25LOG_CALL_ACCEPTED	0x0F
514     #define X25LOG_CLEAR_RQST	0x13
515     #define X25LOG_CLEAR_CONFRM	0x17
516     #define X25LOG_RESET_RQST	0x1B
517     #define X25LOG_RESET_CONFRM	0x1F
518     #define X25LOG_RESTART_RQST	0xFB
519     #define X25LOG_RESTART_COMFRM	0xFF
520     #define X25LOG_DIAGNOSTIC	0xF1
521     #define X25LOG_DTE_REG_RQST	0xF3
522     #define X25LOG_DTE_REG_COMFRM	0xF7
523     
524     /* ---------------------------------------------------------------------------
525      * X25_TRACE_CONFIGURE Command.
526      */
527     typedef struct X25TraceCfg
528     {
529     	unsigned char flags	PACKED;	/* 00h: trace configuration flags */
530     	unsigned char timeout	PACKED;	/* 01h: timeout for trace delay mode*/
531     } TX25TraceCfg;
532     
533     /*
534      * Defines for the 'flags' field.
535      */
536     #define X25_TRC_ENABLE		0x01	/* bit0: '1' - trace enabled */
537     #define X25_TRC_TIMESTAMP	0x02	/* bit1: '1' - time stamping enabled*/
538     #define X25_TRC_DELAY		0x04	/* bit2: '1' - trace delay enabled */
539     #define X25_TRC_DATA		0x08	/* bit3: '1' - trace data packets */
540     #define X25_TRC_SUPERVISORY	0x10    /* bit4: '1' - trace suprvisory pkts*/
541     #define X25_TRC_ASYNCHRONOUS	0x20	/* bit5: '1' - trace asynch. packets*/
542     #define X25_TRC_HDLC		0x40	/* bit6: '1' - trace all packets */
543     #define X25_TRC_READ		0x80	/* bit7: '1' - get current config. */
544     
545     /* ---------------------------------------------------------------------------
546      * X25_READ_TRACE_DATA Command.
547      */
548     typedef struct X25Trace			/*----- Trace data structure -------*/
549     {
550     	unsigned short length	PACKED;	/* 00h: trace data length */
551     	unsigned char type	PACKED;	/* 02h: trace type */
552     	unsigned char lost_cnt	PACKED;	/* 03h: N of traces lost */
553     	TX25TimeStamp tstamp	PACKED;	/* 04h: mon/date/sec/min/hour */
554     	unsigned short millisec	PACKED;	/* 09h: ms time stamp */
555     	unsigned char data[0]	PACKED;	/* 0Bh: traced frame */
556     } TX25Trace;
557     
558     /*
559      * Defines for the 'type' field.
560      */
561     #define X25_TRC_TYPE_MASK	0x0F	/* bits 0..3: trace type */
562     #define X25_TRC_TYPE_RX_FRAME	0x00	/* received frame trace */
563     #define X25_TRC_TYPE_TX_FRAME	0x01	/* transmitted frame */
564     #define X25_TRC_TYPE_ERR_FRAME	0x02	/* error frame */
565     
566     #define X25_TRC_ERROR_MASK	0xF0	/* bits 4..7: error code */
567     #define X25_TRCERR_RX_ABORT	0x10	/* receive abort error */
568     #define X25_TRCERR_RX_BADCRC	0x20	/* receive CRC error */
569     #define X25_TRCERR_RX_OVERRUN	0x30	/* receiver overrun error */
570     #define X25_TRCERR_RX_TOO_LONG	0x40	/* excessive frame length error */
571     #define X25_TRCERR_TX_ABORT	0x70	/* aborted frame transmission error */
572     #define X25_TRCERR_TX_UNDERRUN	0x80	/* transmit underrun error */
573     
574     /*****************************************************************************
575      * Following definitions describe HDLC frame and X.25 packet formats.
576      ****************************************************************************/
577     
578     typedef struct HDLCFrame		/*----- DHLC Frame Format ----------*/
579     {
580     	unsigned char addr	PACKED;	/* address field */
581     	unsigned char cntl	PACKED;	/* control field */
582     	unsigned char data[0]	PACKED;
583     } THDLCFrame;
584     
585     typedef struct X25Pkt			/*----- X.25 Packet Format ----------*/
586     {
587     	unsigned char lcn_hi	PACKED;	/* 4 MSB of Logical Channel Number */
588     	unsigned char lcn_lo	PACKED;	/* 8 LSB of Logical Channel Number */
589     	unsigned char type	PACKED;
590     	unsigned char data[0]	PACKED;
591     } TX25Pkt;
592     
593     /*
594      * Defines for the 'lcn_hi' field.
595      */
596     #define	X25_Q_BIT_MASK		0x80	/* Data Qualifier Bit mask */
597     #define	X25_D_BIT_MASK		0x40	/* Delivery Confirmation Bit mask */
598     #define	X25_M_BITS_MASK		0x30	/* Modulo Bits mask */
599     #define	X25_LCN_MSB_MASK	0x0F	/* LCN most significant bits mask */
600     
601     /*
602      * Defines for the 'type' field.
603      */
604     #define	X25PKT_DATA		0x01	/* Data packet mask */
605     #define	X25PKT_SUPERVISORY	0x02	/* Supervisory packet mask */
606     #define	X25PKT_CALL_RQST	0x0B	/* Call Request/Incoming */
607     #define	X25PKT_CALL_ACCEPTED	0x0F	/* Call Accepted/Connected */
608     #define	X25PKT_CLEAR_RQST	0x13	/* Clear Request/Indication */
609     #define	X25PKT_CLEAR_CONFRM	0x17	/* Clear Confirmation */
610     #define	X25PKT_RESET_RQST	0x1B	/* Reset Request/Indication */
611     #define	X25PKT_RESET_CONFRM	0x1F	/* Reset Confirmation */
612     #define	X25PKT_RESTART_RQST	0xFB	/* Restart Request/Indication */
613     #define	X25PKT_RESTART_CONFRM	0xFF	/* Restart Confirmation */
614     #define	X25PKT_INTERRUPT	0x23	/* Interrupt */
615     #define	X25PKT_INTERRUPT_CONFRM	0x27	/* Interrupt Confirmation */
616     #define	X25PKT_DIAGNOSTIC	0xF1	/* Diagnostic */
617     #define	X25PKT_REGISTR_RQST	0xF3	/* Registration Request */
618     #define	X25PKT_REGISTR_CONFRM	0xF7	/* Registration Confirmation */
619     #define	X25PKT_RR_MASKED	0x01	/* Receive Ready packet after masking */
620     #define	X25PKT_RNR_MASKED	0x05	/* Receive Not Ready after masking  */
621     
622     #ifdef		_MSC_
623     #  pragma	pack()
624     #endif
625     #endif	/* _SDLA_X25_H */
626