-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckctel.h
1337 lines (1211 loc) · 44.2 KB
/
ckctel.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
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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ckctel.h -- Symbol and macro definitions for C-Kermit telnet support */
/*
Authors: Jeffrey E Altman <[email protected]>,
Secure Endpoints Inc., New York City
Frank da Cruz <[email protected]>
Columbia University Academic Information Systems, New York City.
Copyright (C) 1985, 2009,
Trustees of Columbia University in the City of New York.
All rights reserved. See the C-Kermit COPYING.TXT file or the
copyright text in the ckcmai.c module for disclaimer and permissions.
Notes:
. This file should be used in place of "arpa/telnet.h"
. Only one source file should include #defines for
TELCMDS, TELOPTS, TELOPT_STATES, SLC_NAMES, and AUTH_NAMES.
*/
#ifndef CKCTEL_H
#define CKCTEL_H
#ifdef TNCODE
/*
Definitions for the TELNET protocol.
can't rely on library header files for any of them.
*/
#ifdef COMMENT
/* In some compilers these are prone to sign extension */
#ifndef IAC /* First the telnet commands */
#define IAC 255
#endif /* IAC */
#ifndef DONT
#define DONT 254
#endif /* DONT */
#ifndef DO
#define DO 253
#endif /* DO */
#ifndef WONT
#define WONT 252
#endif /* WONT */
#ifndef WILL
#define WILL 251
#endif /* WILL */
#ifndef SB
#define SB 250
#endif /* SB */
#ifndef TN_GA
#define TN_GA 249
#endif /* TN_GA */
#ifndef TN_EL
#define TN_EL 248
#endif /* TN_EL */
#ifndef TN_EC
#define TN_EC 247
#endif /* TN_EC */
#ifndef TN_AYT
#define TN_AYT 246
#endif /* TN_AYT */
#ifndef TN_AO
#define TN_AO 245
#endif /* TN_AO */
#ifndef TN_IP
#define TN_IP 244
#endif /* TN_IP */
#ifndef BREAK
#define BREAK 243
#endif /* BREAK */
#ifndef TN_DM
#define TN_DM 242
#endif /* TN_DM */
#ifndef TN_NOP
#define TN_NOP 241
#endif /* TN_NOP */
#ifndef SE
#define SE 240
#endif /* SE */
#ifndef TN_EOR
#define TN_EOR 239
#endif /* TN_EOR */
#ifndef TN_ABORT
#define TN_ABORT 238
#endif /* TN_ABORT */
#ifndef TN_SUSP
#define TN_SUSP 237
#endif /* TN_SUSP */
#ifndef TN_EOF
#define TN_EOF 236
#endif /* TN_EOF */
#ifndef LAST_TN_CMD
#define LAST_TN_CMD 236
#define TN_SAK 200 /* IBM Secure Attention Key */
#endif /* LAST_TN_CMD */
#define SYNCH 242 /* for telfunc calls */
#else
/* Hex notation seems to suppress the sugn extension effect */
#ifndef IAC /* First the telnet commands */
#define IAC 0xff
#endif /* IAC */
#ifndef DONT
#define DONT 0xfe /* 254 */
#endif /* DONT */
#ifndef DO
#define DO 0xfd /* 253 */
#endif /* DO */
#ifndef WONT
#define WONT 0xfc /* 252 */
#endif /* WONT */
#ifndef WILL
#define WILL 0xfb /* 251 */
#endif /* WILL */
#ifndef SB
#define SB 0xfa /* 250 */
#endif /* SB */
#ifndef TN_GA
#define TN_GA 0xf9 /* 249 */
#endif /* TN_GA */
#ifndef TN_EL
#define TN_EL 0xf8 /* 248 */
#endif /* TN_EL */
#ifndef TN_EC
#define TN_EC 0xf7 /* 247 */
#endif /* TN_EC */
#ifndef TN_AYT
#define TN_AYT 0xf6 /* 246 */
#endif /* TN_AYT */
#ifndef TN_AO
#define TN_AO 0xf5 /* 245 */
#endif /* TN_AO */
#ifndef TN_IP
#define TN_IP 0xf4 /* 244 */
#endif /* TN_IP */
#ifndef BREAK
#define BREAK 0xf3 /* 243 */
#endif /* BREAK */
#ifndef TN_DM
#define TN_DM 0xf2 /* 242 */
#endif /* TN_DM */
#ifndef TN_NOP
#define TN_NOP 0xf1 /* 241 */
#endif /* TN_NOP */
#ifndef SE
#define SE 0xf0 /* 240 */
#endif /* SE */
#ifndef TN_EOR
#define TN_EOR 0xef /* 239 */
#endif /* TN_EOR */
#ifndef TN_ABORT
#define TN_ABORT 0xee /* 238 */
#endif /* TN_ABORT */
#ifndef TN_SUSP
#define TN_SUSP 0xed /* 237 */
#endif /* TN_SUSP */
#ifndef TN_EOF
#define TN_EOF 0xec /* 236 */
#endif /* TN_EOF */
#ifndef LAST_TN_CMD
#define LAST_TN_CMD 0xec /* 236 */
#define TN_SAK 0xc8 /* 200 - IBM Secure Attention Key */
#endif /* LAST_TN_CMD */
#define SYNCH 0xf2 /* 242 - for telfunc calls */
#endif /* COMMENT */
#ifdef TELCMDS
char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0
};
#else /* TELCMDS */
extern char *telcmds[];
#endif /* TELCMDS */
#define TELCMD_FIRST TN_EOF
#define TELCMD_LAST IAC
#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
(unsigned int)(x) >= TELCMD_FIRST || \
(unsigned int)(x) == TN_SAK)
#define TELCMD(x) (TELCMD_OK(x)? ((x) == TN_SAK?"SAK": \
telcmds[(x)-TELCMD_FIRST]):"UNKNOWN")
/* Then the options */
/* NB: the following platforms have TELOPT_AUTHENTICATION defined as */
/* 45 instead of 37. */
#ifdef TELOPT_AUTHENTICATION
#ifdef __osf__
#undef TELOPT_AUTHENTICATION
#endif /* __osf__ */
#ifndef IRIX
#undef TELOPT_AUTHENTICATION
#endif /* IRIX */
#ifndef ultrix
#undef TELOPT_AUTHENTICATION
#endif /* ultrix */
#endif /* TELOPT_AUTHENTICATION */
/* telnet options */
#ifndef TELOPT_BINARY
#define TELOPT_BINARY 0 /* 8-bit data path (RFC 856)*/
#endif
#ifndef TELOPT_ECHO
#define TELOPT_ECHO 1 /* echo (RFC 857)*/
#endif
#ifndef TELOPT_RCP
#define TELOPT_RCP 2 /* prepare to reconnect (NIC 50005)*/
#endif
#ifndef TELOPT_SGA
#define TELOPT_SGA 3 /* suppress go ahead (RFC 858) */
#endif
#ifndef TELOPT_NAMS
#define TELOPT_NAMS 4 /* approximate message size (ETHERNET) */
#endif
#ifndef TELOPT_STATUS
#define TELOPT_STATUS 5 /* give status (RFC 859) */
#endif
#ifndef TELOPT_TM
#define TELOPT_TM 6 /* timing mark (RFC 860) */
#endif
#ifndef TELOPT_RCTE
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
#endif /* (RFC 726) */
#ifndef TELOPT_NAOL
#define TELOPT_NAOL 8 /* negotiate about output line width */
#endif /* (NIC 50005) */
#ifndef TELOPT_NAOP
#define TELOPT_NAOP 9 /* negotiate about output page size */
#endif /* (NIC 50005) */
#ifndef TELOPT_NAOCRD
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition (RFC 652) */
#endif /* [Historic] */
#ifndef TELOPT_NAOHTS
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
#endif /* (RFC 653) [Historic] */
#ifndef TELOPT_NAOHTD
#define TELOPT_NAOHTD 12 /* negotiate about horiz tab disposition */
#endif /* (RFC 654) [Historic] */
#ifndef TELOPT_NAOFFD
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
#endif /* (RFC 655) [Historic] */
#ifndef TELOPT_NAOVTS
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
#endif /* (RFC 656) [Historic] */
#ifndef TELOPT_NAOVTD
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
#endif /* (RFC 657) [Historic] */
#ifndef TELOPT_NAOLFD
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
#endif /* (RFC 658) [Historic] */
#ifndef TELOPT_XASCII
#define TELOPT_XASCII 17 /* extended ascii character set */
#endif /* (RFC 698) */
#ifndef TELOPT_LOGOUT
#define TELOPT_LOGOUT 18 /* force logout (RFC 727) */
#endif
#ifndef TELOPT_BM
#define TELOPT_BM 19 /* byte macro (RFC 735) */
#endif
#ifndef TELOPT_DET
#define TELOPT_DET 20 /* data entry terminal (RFC 1043, 732) */
#endif
#ifndef TELOPT_SUPDUP
#define TELOPT_SUPDUP 21 /* supdup protocol (RFC 736, 734) */
#endif
#ifndef TELOPT_SUPDUPOUTPUT
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output (RFC 749) */
#endif
#ifndef TELOPT_SNDLOC
#define TELOPT_SNDLOC 23 /* send location (RFC 779) */
#endif
#ifndef TELOPT_TTYPE
#define TELOPT_TTYPE 24 /* terminal type (RFC 1091) */
#endif
#ifndef TELOPT_EOR
#define TELOPT_EOR 25 /* end of record (RFC 885) */
#endif
#ifndef TELOPT_TUID
#define TELOPT_TUID 26 /* TACACS user identification (RFC 927) */
#endif
#ifndef TELOPT_OUTMRK
#define TELOPT_OUTMRK 27 /* output marking (RFC 933) */
#endif
#ifndef TELOPT_TTYLOC
#define TELOPT_TTYLOC 28 /* terminal location number (RFC 946) */
#endif
#ifndef TELOPT_3270REGIME
#define TELOPT_3270REGIME 29 /* 3270 regime (RFC 1041) */
#endif
#ifndef TELOPT_X3PAD
#define TELOPT_X3PAD 30 /* X.3 PAD (RFC 1053) */
#endif
#ifndef TELOPT_NAWS
#define TELOPT_NAWS 31 /* window size (RFC 1073) */
#endif
#ifndef TELOPT_TSPEED
#define TELOPT_TSPEED 32 /* terminal speed (RFC 1079) */
#endif
#ifndef TELOPT_LFLOW
#define TELOPT_LFLOW 33 /* remote flow control (RFC 1372) */
#endif
#ifndef TELOPT_LINEMODE
#define TELOPT_LINEMODE 34 /* Linemode option (RFC 1184) */
#endif
#ifndef TELOPT_XDISPLOC
#define TELOPT_XDISPLOC 35 /* X Display Location (RFC 1096) */
#endif
#ifndef TELOPT_OLD_ENVIRON
#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables (RFC 1408) */
#endif
#ifndef TELOPT_AUTHENTICATION
#define TELOPT_AUTHENTICATION 37/* Authenticate (RFC 2941) */
#endif
#ifndef TELOPT_ENCRYPTION
#define TELOPT_ENCRYPTION 38 /* Encryption option (RFC 2946) */
#endif
#ifndef TELOPT_NEWENVIRON
#define TELOPT_NEWENVIRON 39 /* New - Environment variables (RFC 1572) */
#endif
#ifndef TELOPT_3270E
#define TELOPT_3270E 40 /* 3270 Extended (RFC 1647) */
#endif
#ifndef TELOPT_XAUTH
#define TELOPT_XAUTH 41 /* ??? (Earhart) */
#endif
#ifndef TELOPT_CHARSET
#define TELOPT_CHARSET 42 /* Character-set (RFC 2066) */
#endif
#ifndef TELOPT_RSP
#define TELOPT_RSP 43 /* Remote Serial Port (Barnes) */
#endif
#ifndef TELOPT_COMPORT
#define TELOPT_COMPORT 44 /* Com Port Control (RFC 2217) */
#endif
#ifndef TELOPT_SLE
#define TELOPT_SLE 45 /* Suppress Local Echo (Atmar) - [rejected] */
#endif
#ifndef TELOPT_START_TLS
#define TELOPT_START_TLS 46 /* Telnet over Transport Layer Security */
#endif /* (Boe) */
#ifndef TELOPT_KERMIT
#define TELOPT_KERMIT 47 /* Kermit (RFC 2840) */
#endif
#ifndef TELOPT_SEND_URL
#define TELOPT_SEND_URL 48 /* Send URL */
#endif
#ifndef TELOPT_FORWARD_X
#define TELOPT_FORWARD_X 49 /* X Windows Forwarding (Altman) */
#endif /* TELOPT_FORWARD_X */
#ifndef TELOPT_STDERR
#define TELOPT_STDERR 50 /* Redirected Stderr (Altman) */
#endif /* TELOPT_STDERR */
#ifndef TELOPT_PRAGMA_LOGON
#define TELOPT_PRAGMA_LOGON 138 /* Encrypted Logon option (PragmaSys) */
#endif
#ifndef TELOPT_SSPI_LOGON
#define TELOPT_SSPI_LOGON 139 /* MS SSPI Logon option (PragmaSys) */
#endif
#ifndef TELOPT_PRAGMA_HEARTBEAT
/* Server Send Heartbeat option (PragmaSys) */
#define TELOPT_PRAGMA_HEARTBEAT 140
#endif
#define TELOPT_IBM_SAK 200 /* IBM Secure Attention Key */
/*
IBM Secure Attention Key (SAK) Option
In addition to terminal negotiation, the telnet command allows
negotiation for the Secure Attention Key (SAK)
option. This option, when supported, provides the local user with
a secure communication path to the remote
host for tasks such as changing user IDs or passwords. If the remote
host supports the SAK function, a trusted
shell is opened on the remote host when the telnet send sak
subcommand is issued. The SAK function can
also be assigned to a single key available in telnet input mode,
using the set sak subcommand.
TN_SAK
Sends the TELNET SAK (Secure Attention Key) sequence, which causes
the remote system to invoke the trusted shell. If the SAK is not
supported, then an error message is displayed that reads:
Remote side does not support SAK.
*/
#ifndef TELOPT_EXOPL
#define TELOPT_EXOPL 255 /* Extended-options-list (RFC 861) */
#endif
#ifdef NTELOPTS
#undef NTELOPTS
#endif /* NTELOPTS */
/* The Telnet Option space is no longer being allocated by ICANN as a */
/* continuous list. In other words it is becoming sparse. But we do */
/* not want to have to allocate memory for a long list of strings and */
/* structs which will never be used. Therefore, the NTELOPTS define */
/* can no longer be equal to TELOPT_LAST+1. In fact, the notion of */
/* TELOPT_FIRST and TELOPT_LAST no longer make sense. */
#define NTELOPTS 55
#define TELOPT_FIRST TELOPT_BINARY
#define TELOPT_LAST TELOPT_IBM_SAK
/*
The following macros speed us up at runtime but are too complex
for some preprocessors / compilers; if your compiler bombs on ckctel.c
with "Instruction table overflow" or somesuch, rebuild with -DNOTOMACROS.
*/
#ifndef NOTOMACROS
#ifndef TELOPT_MACRO
#define TELOPT_MACRO
#endif /* TELOPT_MACRO */
#endif /* NOTOMACROS */
#ifdef TELOPT_MACRO
#define TELOPT_INDEX(x) (((x)>=0 && (x)<= TELOPT_STDERR)?(x):\
((x)>=TELOPT_PRAGMA_LOGON && (x)<=TELOPT_PRAGMA_HEARTBEAT)?(x)-87: \
((x) == TELOPT_IBM_SAK)?(x)-146: NTELOPTS)
#define TELOPT_OK(x) (((x) >= TELOPT_BINARY && (x) <= TELOPT_STDERR) ||\
((x) >= TELOPT_PRAGMA_LOGON && (x) <= TELOPT_PRAGMA_HEARTBEAT) ||\
((x) == TELOPT_IBM_SAK))
#define TELOPT(x) (TELOPT_OK(x)?telopts[TELOPT_INDEX(x)]:"UNKNOWN")
#else /* TELOPT_MACRO */
_PROTOTYP(int telopt_index,(int));
_PROTOTYP(int telopt_ok,(int));
_PROTOTYP(CHAR * telopt, (int));
#define TELOPT_INDEX(x) telopt_index(x)
#define TELOPT_OK(x) telopt_ok(x)
#define TELOPT(x) telopt(x)
#endif /* TELOPT_MACRO */
#ifdef TELOPTS
char *telopts[NTELOPTS+2] = {
/* 0 */ "BINARY", "ECHO", "RCP", "SUPPRESS-GO-AHEAD",
/* 4 */ "NAME", "STATUS", "TIMING-MARK", "RCTE",
/* 8 */ "NAOL", "NAOP", "NAOCRD", "NAOHTS",
/* 12 */ "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD",
/* 16 */ "NAOLFD", "EXTEND-ASCII", "LOGOUT", "BYTE-MACRO",
/* 20 */ "DATA-ENTRY-TERMINAL", "SUPDUP", "SUPDUP-OUTPUT", "SEND-LOCATION",
/* 24 */ "TERMINAL-TYPE", "END-OF-RECORD", "TACACS-UID", "OUTPUT-MARKING",
/* 28 */ "TTYLOC", "3270-REGIME", "X.3-PAD", "NAWS",
/* 32 */ "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC",
/* 36 */ "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPTION", "NEW-ENVIRONMENT",
/* 40 */ "TN3270E","xauth","CHARSET", "remote-serial-port",
/* 44 */ "COM-PORT-CONTROL","suppress-local-echo","START-TLS","KERMIT",
/* 48 */ "send-url","FORWARD-X","stderr",
/* 138 */ "pragma-logon", "sspi-logon", "pragma-heartbeat",
/* 200 */ "ibm-sak",
"unknown",
0
};
#else /*TELOPTS */
extern char * telopts[];
#endif /* TELOPTS */
/* TELNET Newline Mode */
#define TNL_CR 0 /* CR sends bare carriage return */
#define TNL_CRNUL 1 /* CR and NUL */
#define TNL_CRLF 2 /* CR and LF */
#define TNL_LF 3 /* LF instead of CR */
/* TELNET Negotiation Mode */
#define TN_NG_RF 0 /* Negotiation REFUSED */
#define TN_NG_AC 1 /* Negotiation ACCEPTED */
#define TN_NG_RQ 2 /* Negotiation REQUESTED */
#define TN_NG_MU 3 /* Negotiation REQUIRED (must) */
/* Systems where we know we can define TELNET NAWS automatically. */
#ifndef CK_NAWS /* In other words, if both */
#ifdef CK_TTGWSIZ /* TNCODE and TTGWSIZ are defined */
#define CK_NAWS /* then we can do NAWS. */
#endif /* CK_TTGWSIZ */
#endif /* CK_NAWS */
#ifdef CK_FORWARD_X
#ifndef MAXFWDX
#define MAXFWDX 64 /* Num of X windows to be fwd'd */
#endif /* MAXFWDX */
#endif /* CK_FORWARD_X */
/* Telnet State structures and definitions */
struct _telopt_state {
unsigned char def_server_me_mode; /* Default Negotiation Mode */
unsigned char def_server_u_mode; /* Default Negotiation Mode */
unsigned char def_client_me_mode; /* Default Negotiation Mode */
unsigned char def_client_u_mode; /* Default Negotiation Mode */
unsigned char me_mode; /* Telnet Negotiation Mode */
unsigned char u_mode; /* Telnet Negotiation Mode */
unsigned char me; /* Am I ? */
unsigned char u; /* Are you? */
unsigned char unanswered_will; /* Sent Will, Waiting for DO/DONT */
unsigned char unanswered_do; /* Send DO, Waiting for WILL/WONT */
unsigned char unanswered_wont; /* Sent WONT, Waiting for DONT */
unsigned char unanswered_dont; /* Sent DONT, Waiting for WONT */
unsigned char unanswered_sb; /* Sent SB, Waiting for SB (server) */
union {
#ifdef IKS_OPTION
struct _telopt_kermit { /* Kermit Option States */
unsigned char me_start; /* I have a Server active */
unsigned char me_req_start; /* Sent Req-Start, Waiting for response */
unsigned char me_req_stop; /* Sent Req-Stop, Waiting for response */
unsigned char u_start; /* You have a Server active */
unsigned char sop; /* Have we received the SOP char? */
} kermit;
#endif /* IKS_OPTION */
#ifdef CK_ENCRYPTION
struct _telopt_encrypt { /* Encryption Option States */
unsigned char need_to_send;
unsigned char stop; /* Is encryption stopped? */
} encrypt;
#endif /* CK_ENCRYPTION */
#ifdef CK_NAWS
struct _telopt_naws { /* NAWS Option Information */
unsigned char need_to_send;
int x; /* Last Width */
int y; /* Last Height */
} naws;
#endif /* CK_NAWS */
#ifdef CK_SSL
struct _telopt_start_tls { /* Start TLS Option */
unsigned char u_follows; /* u ready for TLS negotiation */
unsigned char me_follows; /* me ready for TLS negotiation */
unsigned char auth_request; /* Rcvd WILL AUTH before WONT START_TLS */
} start_tls;
#endif /* CK_SSL */
struct _telopt_term { /* Terminal Type */
unsigned char need_to_send;
unsigned char type[41]; /* Last terminal type */
} term;
#ifdef CK_ENVIRONMENT
struct _telopt_new_env {
unsigned char need_to_send;
unsigned char * str;
int len;
} env;
#ifdef CK_XDISPLOC
struct _telopt_xdisp {
unsigned char need_to_send;
} xdisp;
#endif /* CK_XDISPLOC */
#endif /* CK_ENVIRONMENT */
#ifdef CK_SNDLOC
struct _telopt_sndloc {
unsigned char need_to_send;
} sndloc;
#endif /* CK_SNDLOC */
#ifdef CK_FORWARD_X
struct _telopt_fwd_x {
unsigned char need_to_send;
int listen_socket;
struct _channel {
int fd;
int id;
unsigned char need_to_send_xauth;
unsigned char suspend;
} channel[MAXFWDX];
#ifdef NT
int thread_started;
#endif /* NT */
} forward_x;
#endif /* CK_FORWARD_X */
#ifdef TN_COMPORT
struct _telopt_comport {
unsigned char need_to_send;
unsigned char wait_for_sb;
unsigned char wait_for_ms;
} comport;
#endif /* TN_COMPORT */
/* additional options such as New Environment or Send Location */
} sb;
};
typedef struct _telopt_state telopt_state, *p_telopt_state;
/* telopt_states[] is the array of structs which the state of each telnet */
/* option is stored. We allocate one more than we need in case we are */
/* sent telnet options that we do not recognize. If by some chance the */
/* TELOPT_OK() check is skipped, TELOPT_INDEX() will force the option to */
/* use the extra cell. */
#ifdef TELOPT_STATES
telopt_state telopt_states[NTELOPTS+1];
#else /* TELOPT_STATES */
extern telopt_state telopt_states[];
#endif /* TELOPT_STATES */
#define TELOPT_ME(x) (telopt_states[TELOPT_INDEX(x)].me)
#define TELOPT_U(x) (telopt_states[TELOPT_INDEX(x)].u)
#define TELOPT_ME_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].me_mode)
#define TELOPT_U_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].u_mode)
#define TELOPT_UNANSWERED_WILL(x) \
(telopt_states[TELOPT_INDEX(x)].unanswered_will)
#define TELOPT_UNANSWERED_DO(x) \
(telopt_states[TELOPT_INDEX(x)].unanswered_do)
#define TELOPT_UNANSWERED_WONT(x) \
(telopt_states[TELOPT_INDEX(x)].unanswered_wont)
#define TELOPT_UNANSWERED_DONT(x) \
(telopt_states[TELOPT_INDEX(x)].unanswered_dont)
#define TELOPT_UNANSWERED_SB(x) \
(telopt_states[TELOPT_INDEX(x)].unanswered_sb)
#define TELOPT_SB(x) \
(telopt_states[TELOPT_INDEX(x)].sb)
#define TELOPT_DEF_S_ME_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].def_server_me_mode)
#define TELOPT_DEF_S_U_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].def_server_u_mode)
#define TELOPT_DEF_C_ME_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].def_client_me_mode)
#define TELOPT_DEF_C_U_MODE(x) \
(telopt_states[TELOPT_INDEX(x)].def_client_u_mode)
#ifdef TELOPT_MODES
char * telopt_modes[4] = {
"REFUSED", "ACCEPTED", "REQUESTED", "REQUIRED"
};
#else /* TELOPT_MODES */
extern char * telopt_modes[];
#endif /* TELOPT_MODES */
#ifdef TELOPT_MACRO
#define TELOPT_MODE_OK(x) ((unsigned int)(x) <= TN_NG_MU)
#define TELOPT_MODE(x) (TELOPT_MODE_OK(x)?telopt_modes[(x)-TN_NG_RF]:"UNKNOWN")
#else /* TELOPT_MACRO */
_PROTOTYP(int telopt_mode_ok,(int));
_PROTOTYP(CHAR * telopt_mode,(int));
#define TELOPT_MODE_OK(x) telopt_mode_ok(x)
#define TELOPT_MODE(x) telopt_mode(x)
#endif /* TELOPT_MACRO */
/* Sub-option qualifiers */
#define TELQUAL_IS 0 /* option is... */
#define TELQUAL_SEND 1 /* send option */
#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
#define TEL_ENV_VAR 0
#define TEL_ENV_VALUE 1
#define TEL_ENV_ESC 2
#define TEL_ENV_USERVAR 3
#define LFLOW_OFF 0 /* Disable remote flow control */
#define LFLOW_ON 1 /* Enable remote flow control */
#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
/*
* LINEMODE suboptions
*/
#define LM_MODE 1
#define LM_FORWARDMASK 2
#define LM_SLC 3
#define MODE_EDIT 0x01
#define MODE_TRAPSIG 0x02
#define MODE_ACK 0x04
#define MODE_SOFT_TAB 0x08
#define MODE_LIT_ECHO 0x10
#define MODE_MASK 0x1f
/* Not part of protocol, but needed to simplify things... */
#define MODE_FLOW 0x0100
#define MODE_ECHO 0x0200
#define MODE_INBIN 0x0400
#define MODE_OUTBIN 0x0800
#define MODE_FORCE 0x1000
#define SLC_SYNCH 1
#define SLC_BRK 2
#define SLC_IP 3
#define SLC_AO 4
#define SLC_AYT 5
#define SLC_EOR 6
#define SLC_ABORT 7
#define SLC_EOF 8
#define SLC_SUSP 9
#define SLC_EC 10
#define SLC_EL 11
#define SLC_EW 12
#define SLC_RP 13
#define SLC_LNEXT 14
#define SLC_XON 15
#define SLC_XOFF 16
#define SLC_FORW1 17
#define SLC_FORW2 18
#define SLC_MCL 19
#define SLC_MCR 20
#define SLC_MCWL 21
#define SLC_MCWR 22
#define SLC_MCBOL 23
#define SLC_MCEOL 24
#define SLC_INSRT 25
#define SLC_OVER 26
#define SLC_ECR 27
#define SLC_EWR 28
#define SLC_EBOL 29
#define SLC_EEOL 30
#define NSLC 30
/*
* For backwards compatability, we define SLC_NAMES to be the
* list of names if SLC_NAMES is not defined.
*/
#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
"LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
"MCL", "MCR", "MCWL", "MCWR", "MCBOL", "MCEOL", \
"INSRT", "OVER", "ECR", "EWR", "EBOL", "EEOL", 0
#ifdef SLC_NAMES
char *slc_names[] = {
SLC_NAMELIST
};
#else
extern char *slc_names[];
#define SLC_NAMES SLC_NAMELIST
#endif
#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
#define SLC_NAME(x) (SLC_NAME_OK(x)?slc_names[x]:"UNKNOWN")
#define SLC_NOSUPPORT 0
#define SLC_CANTCHANGE 1
#define SLC_VARIABLE 2
#define SLC_DEFAULT 3
#define SLC_LEVELBITS 0x03
#define SLC_FUNC 0
#define SLC_FLAGS 1
#define SLC_VALUE 2
#define SLC_ACK 0x80
#define SLC_FLUSHIN 0x40
#define SLC_FLUSHOUT 0x20
#define OLD_ENV_VAR 1
#define OLD_ENV_VALUE 0
#define NEW_ENV_VAR 0
#define NEW_ENV_VALUE 1
#define ENV_ESC 2
#define ENV_USERVAR 3
#define FWDX_SCREEN 0
#define FWDX_OPEN 1
#define FWDX_CLOSE 2
#define FWDX_DATA 3
#define FWDX_OPTIONS 4
#define FWDX_OPT_DATA 5
#define FWDX_XOFF 6
#define FWDX_XON 7
#define FWDX_OPT_NONE 0
#define FWDX_OPT_XAUTH 1
/*
* AUTHENTICATION suboptions
*/
/*
* Who is authenticating who ...
*/
#define AUTH_CLIENT_TO_SERVER 0 /* Client authenticating server */
#define AUTH_SERVER_TO_CLIENT 1 /* Server authenticating client */
#define AUTH_WHO_MASK 1
/*
* amount of authentication done
*/
#define AUTH_HOW_ONE_WAY 0
#define AUTH_HOW_MUTUAL 2
#define AUTH_HOW_MASK 2
/*
* should we be encrypting?
*/
#define AUTH_ENCRYPT_OFF 0
#define AUTH_ENCRYPT_USING_TELOPT 4
#define AUTH_ENCRYPT_AFTER_EXCHANGE 16
#define AUTH_ENCRYPT_START_TLS 20
#define AUTH_ENCRYPT_MASK 20
/*
* will we be forwarding?
* if we want to activate the use of this flag then
* #define USE_INI_CRED_FWD
*/
#define INI_CRED_FWD_OFF 0
#define INI_CRED_FWD_ON 8
#define INI_CRED_FWD_MASK 8
#define USE_INI_CRED_FWD
#define AUTHTYPE_NULL 0
#define AUTHTYPE_KERBEROS_V4 1
#define AUTHTYPE_KERBEROS_V5 2
#define AUTHTYPE_SPX 3
#define AUTHTYPE_MINK 4
#define AUTHTYPE_SRP 5
#define AUTHTYPE_RSA 6
#define AUTHTYPE_SSL 7
#define AUTHTYPE_LOKI 10
#define AUTHTYPE_SSA 11
#define AUTHTYPE_KEA_SJ 12
#define AUTHTYPE_KEA_INTEG 13
#define AUTHTYPE_DSS 14
#define AUTHTYPE_NTLM 15
#define AUTHTYPE_GSSAPI_KRB5 16 /* Not allocated by IANA */
#ifdef AUTHTYPE_CNT
#undef AUTHTYPE_CNT
#endif /* AUTHTYPE_CNT */
#define AUTHTYPE_CNT 17
/*
* AUTHTYPEs Last updated 21 March 1999
* from http://www.isi.edu/in-notes/iana/assignments/telnet-options
*/
#define AUTHTYPE_AUTO 99
#ifdef AUTH_NAMES
char *authtype_names[] = {
"NULL", /* RFC 2941 */
"KERBEROS_V4", /* RFC 2941 / 1411 */
"KERBEROS_V5", /* RFC 2941 */
"SPX", /* RFC 2941 (not Internet Standard) */
"MINK", /* RFC 2941 (not Internet Standard) */
"SRP", /* RFC 2944 */
"RSA", /* RFC 2941 (not Internet Standard) */
"SSL", /* RFC 2941 (not Internet Standard) */
"IANA_8", /* not assigned by IANA */
"IANA_9", /* not assigned by IANA */
"LOKI", /* RFC 2941 (not Internet Standard) */
"SSA", /* Schoch */
"KEA_SJ", /* RFC 2951 */
"KEA_SJ_INTEG", /* RFC 2951 */
"DSS", /* RFC 2943 */
"NTLM", /* Kahn <[email protected]> */
"GSSAPI-KRB5", /* experimental - altman */
0
};
char * authmode_names[] = {
"CLIENT_TO_SERVER|ONE_WAY",
"SERVER_TO_CLIENT|ONE_WAY",
"CLIENT_TO_SERVER|MUTUAL",
"SERVER_TO_CLIENT|MUTUAL",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT",
"CLIENT_TO_SERVER|ONE_WAY|CRED_FWD",
"SERVER_TO_CLIENT|ONE_WAY|CRED_FWD",
"CLIENT_TO_SERVER|MUTUAL|CRED_FWD",
"SERVER_TO_CLIENT|MUTUAL|CRED_FWD",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
"CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
"SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
"CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
"SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
0
};
#else
extern char *authtype_names[];
extern char *authmode_names[];
#endif
#define AUTHMODE_CNT 32
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
#define AUTHTYPE_NAME(x) (AUTHTYPE_NAME_OK(x)?authtype_names[x]:"UNKNOWN")
#define AUTHMODE_NAME_OK(x) ((unsigned int)(x) < AUTHMODE_CNT)
#define AUTHMODE_NAME(x) (AUTHMODE_NAME_OK(x)?authmode_names[x]:"UNKNOWN")
/* Kerberos Authentication Message Identifiers */
#define KRB_AUTH 0 /* Authentication data follows */
#define KRB_REJECT 1 /* Rejected (reason might follow) */
#define KRB_ACCEPT 2 /* Accepted */
#define KRB4_CHALLENGE 3
#define KRB4_RESPONSE 4
#define KRB5_RESPONSE 3 /* Response for mutual auth. */
#define KRB5_FORWARD 4 /* Forwarded credentials follow */
#define KRB5_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */
#define KRB5_FORWARD_REJECT 6 /* Forwarded credentials rejected */
#define KRB5_TLS_VERIFY 7 /* TLS Finished Msg verifier */
/* GSSAPI-KRB5 Authentication Message Identifiers */
#define GSS_AUTH_DATA 0 /* Authentication data follows */
#define GSS_REJECT 1 /* Rejected (reason might follow) */
#define GSS_ACCEPT 2 /* Accepted (username might follow) */
#define GSS_CONTINUE 3
/* Secure Remote Password Authentication Message Identifiers */
#define SRP_AUTH 0 /* Authentication data follows */
#define SRP_REJECT 1 /* Rejected (reason might follow) */
#define SRP_ACCEPT 2 /* Accepted */
#define SRP_CHALLENGE 3
#define SRP_RESPONSE 4
#define SRP_EXP 8 /* */
#define SRP_PARAMS 9 /* */
/* Telnet Auth using KEA and SKIPJACK */
#define KEA_CERTA_RA 1
#define KEA_CERTB_RB_IVB_NONCEB 2
#define KEA_IVA_RESPONSEB_NONCEA 3
#define KEA_RESPONSEA 4
/* Tim Hudson's SSL Authentication Message Identifiers */
#define SSL_START 1
#define SSL_ACCEPT 2
#define SSL_REJECT 3
/* Microsoft NTLM Authentication Message Identifiers */
#define NTLM_AUTH 0
#define NTLM_CHALLENGE 1
#define NTLM_RESPONSE 2
#define NTLM_ACCEPT 3
#define NTLM_REJECT 4
/* Generic Constants */
#define AUTH_SUCCESS 0
#define AUTH_FAILURE 255
/*
* ENCRYPTion suboptions
*/
#define ENCRYPT_IS 0 /* I pick encryption type ... */
#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
#define ENCRYPT_REPLY 2 /* Initial setup response */
#define ENCRYPT_START 3 /* Am starting to send encrypted */
#define ENCRYPT_END 4 /* Am ending encrypted */
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
#define ENCRYPT_REQEND 6 /* Request you send encrypting */
#define ENCRYPT_ENC_KEYID 7
#define ENCRYPT_DEC_KEYID 8
#define ENCRYPT_CNT 9
#define ENCTYPE_ANY 0
#define ENCTYPE_DES_CFB64 1
#define ENCTYPE_DES_OFB64 2
#define ENCTYPE_DES3_CFB64 3
#define ENCTYPE_DES3_OFB64 4
#define ENCTYPE_CAST5_40_CFB64 8
#define ENCTYPE_CAST5_40_OFB64 9
#define ENCTYPE_CAST128_CFB64 10
#define ENCTYPE_CAST128_OFB64 11
#ifdef ENCTYPE_CNT
#undef ENCTYPE_CNT
#endif
#define ENCTYPE_CNT 12
#ifdef ENCRYPT_NAMES
char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0
};
char *enctype_names[] = {
"ANY",
"DES_CFB64", /* RFC 2952 */
"DES_OFB64", /* RFC 2953 */
"DES3_CFB64", /* RFC 2947 */
"DES3_OFB64", /* RFC 2948 */
"UNKNOWN-5",
"UNKNOWN-6",
"UNKNOWN-7",
"CAST5_40_CFB64", /* RFC 2950 */
"CAST5_40_OFB64", /* RFC 2949 */