summaryrefslogtreecommitdiffstats
path: root/src/appl/telnet/kern.diff
blob: 3c1153bab5292095b547dd3788ae9e90e5b16008 (plain)
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
*** h/ioctl.h.old	Tue May 23 14:50:42 1989
--- h/ioctl.h	Tue Aug 29 18:24:49 1989
***************
*** 214,219 ****
--- 214,220 ----
  #define		TIOCPKT_START		0x08	/* start output */
  #define		TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
  #define		TIOCPKT_DOSTOP		0x20	/* now do ^S ^Q */
+ #define		TIOCPKT_IOCTL		0x40	/* state change of pty driver */
  #define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
  #define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
  #define	TIOCMSET	_IOW('t', 109, int)	/* set all modem bits */
***************
*** 226,231 ****
--- 227,235 ----
  #define	TIOCUCNTL	_IOW('t', 102, int)	/* pty: set/clr usr cntl mode */
  #define		UIOCCMD(n)	_IO('u', n)		/* usr cntl op "n" */
  #define	TIOCCONS	_IO('t', 98)		/* become virtual console */
+ #define	TIOCEXT		_IOW('t', 97, int)	/* pty: external processing */
+ #define	TIOCGSTATE	_IOR('t', 96, int)	/* pty: get internal state */
+ #define	TIOCSIG		_IO('t', 95)		/* pty: generate signal */
  
  #define	OTTYDISC	0		/* old, v7 std tty driver */
  #define	NETLDISC	1		/* line discip for berk net */
*** h/tty.h.old	Tue May 23 14:51:01 1989
--- h/tty.h	Wed Aug 23 11:30:40 1989
***************
*** 70,75 ****
--- 70,76 ----
  	struct	ttychars t_chars;	/* tty */
  	struct	winsize t_winsize;	/* window size */
  /* be careful of tchars & co. */
+ #ifndef	NO_T_CHARS_DEFINES
  #define	t_erase		t_chars.tc_erase
  #define	t_kill		t_chars.tc_kill
  #define	t_intrc		t_chars.tc_intrc
***************
*** 84,89 ****
--- 85,91 ----
  #define	t_flushc	t_chars.tc_flushc
  #define	t_werasc	t_chars.tc_werasc
  #define	t_lnextc	t_chars.tc_lnextc
+ #endif
  };
  
  #define	TTIPRI	28
***************
*** 124,129 ****
--- 126,132 ----
  #define	TS_LNCH		0x080000	/* next character is literal */
  #define	TS_TYPEN	0x100000	/* retyping suspended input (PENDIN) */
  #define	TS_CNTTB	0x200000	/* counting tab width; leave FLUSHO alone */
+ #define	TS_EXTPROC	0x400000	/* external processing of data */
  
  #define	TS_LOCAL	(TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
  
*** sys/tty.c.old	Tue May 23 14:52:28 1989
--- sys/tty.c	Thu Aug 24 09:31:49 1989
***************
*** 275,280 ****
--- 275,285 ----
  	 */
  	switch (com) {
  
+ 	/* get internal state - needed for TS_EXTPROC bit */
+ 	case TIOCGSTATE:
+ 		*(int *)data = tp->t_state;
+ 		break;
+ 
  	/* get discipline number */
  	case TIOCGETD:
  		*(int *)data = tp->t_line;
***************
*** 752,757 ****
--- 757,763 ----
  	 */
  	if ((tp->t_state&TS_TYPEN) == 0 && (t_flags&PASS8) == 0)
  		c &= 0177;
+     if ((tp->t_state&TS_EXTPROC) == 0) {
  	/*
  	 * Check for literal nexting very first
  	 */
***************
*** 834,839 ****
--- 840,846 ----
  		else if (c == '\\')
  			tp->t_state |= TS_BKSL;
  	}
+     }
  
  	/*
  	 * Cbreak mode, don't process line editing
***************
*** 851,856 ****
--- 858,864 ----
  		goto endcase;
  	}
  
+     if ((tp->t_state&TS_EXTPROC) == 0) {
  	/*
  	 * From here on down cooked mode character
  	 * processing takes place.
***************
*** 911,916 ****
--- 919,925 ----
  			goto endcase;
  		}
  	}
+     }
  
  	/*
  	 * Check for input buffer overflow
***************
*** 933,938 ****
--- 942,948 ----
  		} else if (tp->t_rocount++ == 0)
  			tp->t_rocol = tp->t_col;
  		tp->t_state &= ~TS_QUOT;
+ 	    if ((tp->t_state&TS_EXTPROC) == 0) {
  		if (c == '\\')
  			tp->t_state |= TS_QUOT;
  		if (tp->t_state&TS_ERASE) {
***************
*** 948,953 ****
--- 958,964 ----
  				i--;
  			}
  		}
+ 	    }
  	}
  endcase:
  	/*
***************
*** 998,1005 ****
  		return (-1);
  	/*
  	 * Turn tabs to spaces as required
  	 */
! 	if (c == '\t' && (tp->t_flags&TBDELAY) == XTABS) {
  		register int s;
  
  		c = 8 - (tp->t_col&7);
--- 1009,1022 ----
  		return (-1);
  	/*
  	 * Turn tabs to spaces as required
+ 	 *
+ 	 * Special case if we have external processing, we don't
+ 	 * do the tab expansion because we'll probably get it
+ 	 * wrong.  If tab expansion needs to be done, let it
+ 	 * happen externally.
  	 */
! 	if ((tp->t_state&TS_EXTPROC) == 0 &&
! 	    c == '\t' && (tp->t_flags&TBDELAY) == XTABS) {
  		register int s;
  
  		c = 8 - (tp->t_col&7);
***************
*** 1497,1503 ****
  	int s;
  	char *nextc();
  
! 	if ((tp->t_flags&ECHO) == 0)
  		return;
  	tp->t_flags &= ~FLUSHO;
  	c &= 0377;
--- 1514,1520 ----
  	int s;
  	char *nextc();
  
! 	if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC))
  		return;
  	tp->t_flags &= ~FLUSHO;
  	c &= 0377;
***************
*** 1618,1624 ****
  
  	if ((tp->t_state&TS_CNTTB) == 0)
  		tp->t_flags &= ~FLUSHO;
! 	if ((tp->t_flags&ECHO) == 0)
  		return;
  	c &= 0377;
  	if (tp->t_flags&RAW) {
--- 1635,1641 ----
  
  	if ((tp->t_state&TS_CNTTB) == 0)
  		tp->t_flags &= ~FLUSHO;
! 	if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC))
  		return;
  	c &= 0377;
  	if (tp->t_flags&RAW) {
*** sys/tty_pty.c.old	Tue May 23 14:52:43 1989
--- sys/tty_pty.c	Tue Aug 29 18:48:36 1989
***************
*** 208,213 ****
--- 208,214 ----
  		return (EIO);
  	tp->t_oproc = ptsstart;
  	(void)(*linesw[tp->t_line].l_modem)(tp, 1);
+ 	tp->t_state &= ~TS_EXTPROC;
  	pti = &pt_ioctl[minor(dev)];
  	pti->pt_flags = 0;
  	pti->pt_send = 0;
***************
*** 247,252 ****
--- 248,275 ----
  				error = ureadc((int)pti->pt_send, uio);
  				if (error)
  					return (error);
+ 				if (pti->pt_send & TIOCPKT_IOCTL) {
+ 					struct xx {
+ 						struct sgttyb a;
+ 						struct tchars b;
+ 						struct ltchars c;
+ 						int d;
+ 						int e;
+ 					} cb;
+ 					cb.a.sg_ispeed = tp->t_ispeed;
+ 					cb.a.sg_ospeed = tp->t_ospeed;
+ 					cb.a.sg_erase = tp->t_erase;
+ 					cb.a.sg_kill = tp->t_kill;
+ 					cb.a.sg_flags = tp->t_flags;
+ 					bcopy((caddr_t)&tp->t_intrc,
+ 					      (caddr_t)&cb.b, sizeof(cb.b));
+ 					bcopy((caddr_t)&tp->t_suspc,
+ 					      (caddr_t)&cb.c, sizeof(cb.c));
+ 					cb.d = tp->t_state;
+ 					cb.e = ((unsigned)tp->t_flags)>>16;
+ 					cc = MIN(uio->uio_resid, sizeof(cb));
+ 					uiomove(&cb, cc, UIO_READ, uio);
+ 				}
  				pti->pt_send = 0;
  				return (0);
  			}
***************
*** 483,488 ****
--- 506,533 ----
  	 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
  	 * ttywflush(tp) will hang if there are characters in the outq.
  	 */
+ 	if (cmd == TIOCEXT) {
+ 		/*
+ 		 * When the TS_EXTPROC bit is being toggled, we need
+ 		 * to send an TIOCPKT_IOCTL if the packet driver
+ 		 * is turned on.
+ 		 */
+ 		if (*(int *)data) {
+ 			if (pti->pt_flags & PF_PKT) {
+ 				pti->pt_send |= TIOCPKT_IOCTL;
+ 				ptcwakeup(tp);
+ 			}
+ 			tp->t_state |= TS_EXTPROC;
+ 		} else {
+ 			if ((tp->t_state & TS_EXTPROC) &&
+ 			    (pti->pt_flags & PF_PKT)) {
+ 				pti->pt_send |= TIOCPKT_IOCTL;
+ 				ptcwakeup(tp);
+ 			}
+ 			tp->t_state &= ~TS_EXTPROC;
+ 		}
+ 		return (0);
+ 	} else
  	if (cdevsw[major(dev)].d_open == ptcopen)
  		switch (cmd) {
  
***************
*** 525,530 ****
--- 570,583 ----
  			while (getc(&tp->t_outq) >= 0)
  				;
  			break;
+ 
+ 		case TIOCSIG:
+ 			if (*(unsigned int *)data >= NSIG)
+ 				return(EINVAL);
+ 			if ((tp->t_flags&NOFLSH) == 0)
+ 				ttyflush(tp, FREAD|FWRITE);
+ 			gsignal(tp->t_pgrp, *(unsigned int *)data);
+ 			return(0);
  		}
  	error = ttioctl(tp, cmd, data, flag);
  	/*
***************
*** 549,554 ****
--- 602,624 ----
  			return (0);
  		}
  		error = ENOTTY;
+ 	}
+ 	/*
+ 	 * If external processing and packet mode send ioctl packet.
+ 	 */
+ 	if ((tp->t_state & TS_EXTPROC) && (pti->pt_flags & PF_PKT)) {
+ 		switch(cmd) {
+ 		case TIOCSETP:
+ 		case TIOCSETN:
+ 		case TIOCSETC:
+ 		case TIOCSLTC:
+ 		case TIOCLBIS:
+ 		case TIOCLBIC:
+ 		case TIOCLSET:
+ 			pti->pt_send |= TIOCPKT_IOCTL;
+ 		default:
+ 			break;
+ 		}
  	}
  	stop = (tp->t_flags & RAW) == 0 &&
  	    tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q');