blob: 57db980e27ad80227a717916ebc5171ed7fd2345 (
plain) (
blame)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
/*****************************************************************************
* sdla_x25.h Sangoma X.25 firmware API definitions.
*
* Author: Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2000 Sangoma Technologies Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
* ============================================================================
* Feb 28, 2000 Nenad Corbic Updated for socket based x25api
* Dec 13, 1996 Gene Kozin Initial version
*****************************************************************************/
#ifndef _SDLA_X25_H
#define _SDLA_X25_H
/*----------------------------------------------------------------------------
* Notes:
* ------
* 1. All structures defined in this file are byte-alined.
* Compiler Platform
* -------- --------
* GNU C Linux
*
*/
#ifndef PACKED
# define PACKED __attribute__((packed))
#endif /* PACKED */
/****** CONSTANTS DEFINITIONS ***********************************************/
#define X25_MAX_CHAN 255 /* max number of open X.25 circuits */
#define X25_MAX_DATA 1024 /* max length of X.25 data buffer */
/*
* X.25 shared memory layout.
*/
#define X25_MBOX_OFFS 0x16B0 /* general mailbox block */
#define X25_RXMBOX_OFFS 0x1AD0 /* receive mailbox */
#define X25_STATUS_OFFS 0x1EF0 /* X.25 status structure */
#define X25_MB_VECTOR 0xE000 /* S514 mailbox window vecotr */
#define X25_MISC_HDLC_BITS 0x1F00 /*X.25 miscallaneous HDLC bits */
/* code levels */
#define HDLC_LEVEL 0x01
#define X25_LEVEL 0x02
#define X25_AND_HDLC_LEVEL 0x03
#define DO_HDLC_LEVEL_ERROR_CHECKING 0x04
/****** DATA STRUCTURES *****************************************************/
/*----------------------------------------------------------------------------
* X.25 Command Block.
*/
typedef struct X25Cmd
{
unsigned char command PACKED; /* command code */
unsigned short length PACKED; /* transfer data length */
unsigned char result PACKED; /* return code */
unsigned char pf PACKED; /* P/F bit */
unsigned short lcn PACKED; /* logical channel */
unsigned char qdm PACKED; /* Q/D/M bits */
unsigned char cause PACKED; /* cause field */
unsigned char diagn PACKED; /* diagnostics */
unsigned char pktType PACKED; /* packet type */
unsigned char resrv[4] PACKED; /* reserved */
} TX25Cmd;
/*
* Defines for the 'command' field.
*/
/*----- General commands --------------*/
#define X25_SET_GLOBAL_VARS 0x0B /* set global variables */
#define X25_READ_MODEM_STATUS 0x0C /* read modem status */
#define X25_READ_CODE_VERSION 0x15 /* read firmware version number */
#define X25_TRACE_CONFIGURE 0x14 /* configure trace facility */
#define X25_READ_TRACE_DATA 0x16 /* read trace data */
#define X25_SET_INTERRUPT_MODE 0x17 /* set interrupt generation mode */
#define X25_READ_INTERRUPT_MODE 0x18 /* read interrupt generation mode */
/*----- HDLC-level commands -----------*/
#define X25_HDLC_LINK_CONFIGURE 0x01 /* configure HDLC link level */
#define X25_HDLC_LINK_OPEN 0x02 /* open HDLC link */
#define X25_HDLC_LINK_CLOSE 0x03 /* close HDLC link */
#define X25_HDLC_LINK_SETUP 0x04 /* set up HDLC link */
#define X25_HDLC_LINK_DISC 0x05 /* disconnect DHLC link */
#define X25_HDLC_LINK_STATUS 0x06 /* read DHLC link status */
#define X25_HDLC_READ_STATS 0x07 /* read operational statistics */
#define X25_HDLC_FLUSH_STATS 0x08 /* flush operational statistics */
#define X25_HDLC_READ_COMM_ERR 0x09 /* read error statistics */
#define X25_HDLC_FLUSH_COMM_ERR 0x0A /* flush error statistics */
#define X25_HDLC_FLUSH_BUFFERS 0x0D /* flush HDLC-level data buffers */
#define X25_HDLC_SPRVS_CNT_STAT 0x0F /* read surervisory count status */
#define X25_HDLC_SEND_UI_FRAME 0x10 /* send unnumbered information frame */
#define X25_HDLC_WRITE 0x11 /* send HDLC information frame */
#define X25_HDLC_READ 0x21 /* read HDLC information frame */
#define X25_HDLC_READ_CONFIG 0x12 /* read HDLC configuration */
#define X25_HDLC_SET_CONFIG 0x13 /* set HDLC configuration */
#define SET_PROTOCOL_LEVEL 0x1F /* set protocol level */
/*----- X.25-level commands -----------*/
#define X25_READ 0x22 /* read X.25 packet */
#define X25_WRITE 0x23 /* send X.25 packet */
#define X25_PLACE_CALL 0x30 /* place a call on SVC */
#define X25_ACCEPT_CALL 0x31 /* accept incomming call */
#define X25_CLEAR_CALL 0x32 /* clear call */
#define X25_CLEAR_CONFRM 0x33 /* send clear confirmation packet */
#define X25_RESET 0x34 /* send reset request packet */
#define X25_RESET_CONFRM 0x35 /* send reset confirmation packet */
#define X25_RESTART 0x36 /* send restart request packet */
#define X25_RESTART_CONFRM 0x37 /* send restart confirmation packet */
#define X25_INTERRUPT 0x38 /* send interrupt request packet */
#define X25_INTERRUPT_CONFRM 0x39 /* send interrupt confirmation pkt */
#define X25_REGISTRATION_RQST 0x3A /* send registration request packet */
#define X25_REGISTRATION_CONFRM 0x3B /* send registration confirmation */
#define X25_IS_DATA_AVAILABLE 0x40 /* querry receive queue */
#define X25_INCOMMING_CALL_CTL 0x41 /* select incomming call options */
#define X25_CONFIGURE_PVC 0x42 /* configure PVC */
#define X25_GET_ACTIVE_CHANNELS 0x43 /* get a list of active circuits */
#define X25_READ_CHANNEL_CONFIG 0x44 /* read virt. circuit configuration */
#define X25_FLUSH_DATA_BUFFERS 0x45 /* flush X.25-level data buffers */
#define X25_READ_HISTORY_TABLE 0x46 /* read asynchronous event log */
#define X25_HISTORY_TABLE_CTL 0x47 /* control asynchronous event log */
#define X25_GET_TX_D_BIT_STATUS 0x48 /* is packet with D-bit acknowleged */
#define X25_READ_STATISTICS 0x49 /* read X.25-level statistics */
#define X25_FLUSH_STATISTICS 0x4A /* flush X.25-level statistics */
#define X25_READ_CONFIGURATION 0x50 /* read HDLC & X.25 configuration */
#define X25_SET_CONFIGURATION 0x51 /* set HDLC & X.25 configuration */
/*
* Defines for the 'result' field.
*/
/*----- General results ---------------*/
#define X25RES_OK 0x00
#define X25RES_ERROR 0x01
#define X25RES_LINK_NOT_IN_ABM 0x02 /* link is not in ABM mode */
#define X25RES_LINK_CLOSED 0x03
#define X25RES_INVAL_LENGTH 0x04
#define X25RES_INVAL_CMD 0x05
#define X25RES_UNNUMBERED_FRAME 0x06 /* unnunbered frame received */
#define X25RES_FRM_REJECT_MODE 0x07 /* link is in Frame Reject mode */
#define X25RES_MODEM_FAILURE 0x08 /* DCD and/or CTS dropped */
#define X25RES_N2_RETRY_LIMIT 0x09 /* N2 retry limit has been exceeded */
#define X25RES_INVAL_LCN 0x30 /* invalid logical channel number */
#define X25RES_INVAL_STATE 0x31 /* channel is not in data xfer mode */
#define X25RES_INVAL_DATA_LEN 0x32 /* invalid data length */
#define X25RES_NOT_READY 0x33 /* no data available / buffers full */
#define X25RES_NETWORK_DOWN 0x34
#define X25RES_CHANNEL_IN_USE 0x35 /* there is data queued on this LCN */
#define X25RES_REGST_NOT_SUPPRT 0x36 /* registration not supported */
#define X25RES_INVAL_FORMAT 0x37 /* invalid packet format */
#define X25RES_D_BIT_NOT_SUPPRT 0x38 /* D-bit pragmatics not supported */
#define X25RES_FACIL_NOT_SUPPRT 0x39 /* Call facility not supported */
#define X25RES_INVAL_CALL_ARG 0x3A /* errorneous call arguments */
#define X25RES_INVAL_CALL_DATA 0x3B /* errorneous call user data */
#define X25RES_ASYNC_PACKET 0x40 /* asynchronous packet received */
#define X25RES_PROTO_VIOLATION 0x41 /* protocol violation occurred */
#define X25RES_PKT_TIMEOUT 0x42 /* X.25 packet time out */
#define X25RES_PKT_RETRY_LIMIT 0x43 /* X.25 packet retry limit exceeded */
/*----- Command-dependent results -----*/
#define X25RES_LINK_DISC 0x00 /* HDLC_LINK_STATUS */
#define X25RES_LINK_IN_ABM 0x01 /* HDLC_LINK_STATUS */
#define X25RES_NO_DATA 0x01 /* HDLC_READ/READ_TRACE_DATA*/
#define X25RES_TRACE_INACTIVE 0x02 /* READ_TRACE_DATA */
#define X25RES_LINK_IS_OPEN 0x01 /* HDLC_LINK_OPEN */
#define X25RES_LINK_IS_DISC 0x02 /* HDLC_LINK_DISC */
#define X25RES_LINK_IS_CLOSED 0x03 /* HDLC_LINK_CLOSE */
#define X25RES_INVAL_PARAM 0x31 /* INCOMMING_CALL_CTL */
#define X25RES_INVAL_CONFIG 0x35 /* REGISTR_RQST/CONFRM */
/*
* Defines for the 'qdm_bits' field.
*/
#define X25CMD_Q_BIT_MASK 0x04
#define X25CMD_D_BIT_MASK 0x02
#define X25CMD_M_BIT_MASK 0x01
/*
* Defines for the 'pkt_type' field.
*/
/*----- Asynchronous events ------*/
#define ASE_CLEAR_RQST 0x02
#define ASE_RESET_RQST 0x04
#define ASE_RESTART_RQST 0x08
#define ASE_INTERRUPT 0x10
#define ASE_DTE_REGISTR_RQST 0x20
#define ASE_CALL_RQST 0x30
#define ASE_CALL_ACCEPTED 0x31
#define ASE_CLEAR_CONFRM 0x32
#define ASE_RESET_CONFRM 0x33
#define ASE_RESTART_CONFRM 0x34
#define ASE_INTERRUPT_CONFRM 0x35
#define ASE_DCE_REGISTR_CONFRM 0x36
#define ASE_DIAGNOSTIC 0x37
#define ASE_CALL_AUTO_CLEAR 0x38
#define AUTO_RESPONSE_FLAG 0x80
/*----- Time-Out events ----------*/
#define TOE_RESTART_RQST 0x03
#define TOE_CALL_RQST 0x05
#define TOE_CLEAR_RQST 0x08
#define TOE_RESET_RQST 0x0A
/*----- Protocol Violation events */
#define PVE_CLEAR_RQST 0x32
#define PVE_RESET_RQST 0x33
#define PVE_RESTART_RQST 0x34
#define PVE_DIAGNOSTIC 0x37
#define INTR_ON_RX_FRAME 0x01
#define INTR_ON_TX_FRAME 0x02
#define INTR_ON_MODEM_STATUS_CHANGE 0x04
#define INTR_ON_COMMAND_COMPLETE 0x08
#define INTR_ON_X25_ASY_TRANSACTION 0x10
#define INTR_ON_TIMER 0x40
#define DIRECT_RX_INTR_USAGE 0x80
#define NO_INTR_PENDING 0x00
#define RX_INTR_PENDING 0x01
#define TX_INTR_PENDING 0x02
#define MODEM_INTR_PENDING 0x04
#define COMMAND_COMPLETE_INTR_PENDING 0x08
#define X25_ASY_TRANS_INTR_PENDING 0x10
#define TIMER_INTR_PENDING 0x40
/*----------------------------------------------------------------------------
* X.25 Mailbox.
* This structure is located at offsets X25_MBOX_OFFS and X25_RXMBOX_OFFS
* into shared memory window.
*/
typedef struct X25Mbox
{
unsigned char opflag PACKED; /* 00h: execution flag */
TX25Cmd cmd PACKED; /* 01h: command block */
unsigned char data[1] PACKED; /* 10h: data buffer */
} TX25Mbox;
/*----------------------------------------------------------------------------
* X.25 Time Stamp Structure.
*/
typedef struct X25TimeStamp
{
unsigned char month PACKED;
unsigned char date PACKED;
unsigned char sec PACKED;
unsigned char min PACKED;
unsigned char hour PACKED;
} TX25TimeStamp;
/*----------------------------------------------------------------------------
* X.25 Status Block.
* This structure is located at offset X25_STATUS_OFF into shared memory
* window.
*/
typedef struct X25Status
{
unsigned short pvc_map PACKED; /* 00h: PVC map */
unsigned short icc_map PACKED; /* 02h: Incomming Chan. map */
unsigned short twc_map PACKED; /* 04h: Two-way Cnan. map */
unsigned short ogc_map PACKED; /* 06h: Outgoing Chan. map */
TX25TimeStamp tstamp PACKED; /* 08h: timestamp (BCD) */
unsigned char iflags PACKED; /* 0Dh: interrupt flags */
unsigned char imask PACKED; /* 0Eh: interrupt mask */
unsigned char resrv PACKED; /* 0Eh: */
unsigned char gflags PACKED; /* 10h: misc. HDLC/X25 flags */
unsigned char cflags[X25_MAX_CHAN] PACKED; /* channel status bytes */
} TX25Status;
/*
* Bitmasks for the 'iflags' field.
*/
#define X25_RX_INTR 0x01 /* receive interrupt */
#define X25_TX_INTR 0x02 /* transmit interrupt */
#define X25_MODEM_INTR 0x04 /* modem status interrupt (CTS/DCD) */
#define X25_EVENT_INTR 0x10 /* asyncronous event encountered */
#define X25_CMD_INTR 0x08 /* interface command complete */
/*
* Bitmasks for the 'gflags' field.
*/
#define X25_HDLC_ABM 0x01 /* HDLC is in ABM mode */
#define X25_RX_READY 0x02 /* X.25 data available */
#define X25_TRACE_READY 0x08 /* trace data available */
#define X25_EVENT_IND 0x20 /* asynchronous event indicator */
#define X25_TX_READY 0x40 /* space is available in Tx buf.*/
/*
* Bitmasks for the 'cflags' field.
*/
#define X25_XFER_MODE 0x80 /* channel is in data transfer mode */
#define X25_TXWIN_OPEN 0x40 /* transmit window open */
#define X25_RXBUF_MASK 0x3F /* number of data buffers available */
/*****************************************************************************
* Following definitions structurize contents of the TX25Mbox.data field for
* different X.25 interface commands.
****************************************************************************/
/* ---------------------------------------------------------------------------
* X25_SET_GLOBAL_VARS Command.
*/
typedef struct X25GlobalVars
{
unsigned char resrv PACKED; /* 00h: reserved */
unsigned char dtrCtl PACKED; /* 01h: DTR control code */
unsigned char resErr PACKED; /* 01h: '1' - reset modem error */
} TX25GlobalVars;
/*
* Defines for the 'dtrCtl' field.
*/
#define X25_RAISE_DTR 0x01
#define X25_DROP_DTR 0x02
/* ---------------------------------------------------------------------------
* X25_READ_MODEM_STATUS Command.
*/
typedef struct X25ModemStatus
{
unsigned char status PACKED; /* 00h: modem status */
} TX25ModemStatus;
/*
* Defines for the 'status' field.
*/
#define X25_CTS_MASK 0x20
#define X25_DCD_MASK 0x08
/* -----------------------------------------------------------------
|