1ldterm(7M) STREAMS Modules ldterm(7M)
2
3
4
6 ldterm - standard STREAMS terminal line discipline module
7
9 #include <sys/stream.h>
10
11
12 #include <sys/termios.h>
13
14
15 int ioctl(fd,I_PUSH,"ldterm");
16
17
19 The ldterm STREAMS module provides most of the termio(7I) terminal
20 interface. The vis module does not perform the low-level device con‐
21 trol functions specified by flags in the c_cflag word of the
22 termio/termios structure, or by the IGNBRK, IGNPAR, PARMRK, or INPCK
23 flags in the c_iflag word of the termio/termios structure. Those func‐
24 tions must be performed by the driver or by modules pushed below the
25 ldterm module. The ldterm module performs all other termio/termios
26 functions, though some may require the cooperation of the driver or
27 modules pushed below ldterm and may not be performed in some cases.
28 These include the IXOFF flag in the c_iflag word and the delays speci‐
29 fied in the c_oflag word.
30
31
32 The ldterm module also handles single and multi-byte characters from
33 various codesets including both Extended Unix Code (EUC) and non-EUC
34 codesets.
35
36
37 The remainder of this section describes the processing of various
38 STREAMS messages on the read- and write-side.
39
40 Read-side Behavior
41 Various types of STREAMS messages are processed as follows:
42
43 M_BREAK Depending on the state of the BRKINT flag, either an inter‐
44 rupt signal is generated or the message is treated as if it
45 were an M_DATA message containing a single ASCII NUL char‐
46 acter when this message is received.
47
48
49 M_DATA This message is normally processed using the standard
50 termio input processing. If the ICANON flag is set, a sin‐
51 gle input record (``line'') is accumulated in an internal
52 buffer and sent upstream when a line-terminating character
53 is received. If the ICANON flag is not set, other input
54 processing is performed and the processed data are passed
55 upstream.
56
57 If output is to be stopped or started as a result of the
58 arrival of characters (usually CNTRL-Q and CNTRL-S), M_STOP
59 and M_START messages are sent downstream. If the IXOFF flag
60 is set and input is to be stopped or started as a result of
61 flow-control considerations, M_STOPI and M_STARTI messages
62 are sent downstream.
63
64 M_DATA messages are sent downstream, as necessary, to per‐
65 form echoing.
66
67 If a signal is to be generated, an M_FLUSH message with a
68 flag byte of FLUSHR is placed on the read queue. If the
69 signal is also to flush output, an M_FLUSH message with a
70 flag byte of FLUSHW is sent downstream.
71
72
73
74 All other messages are passed upstream unchanged.
75
76 Write-side Behavior
77 Various types of STREAMS messages are processed as follows:
78
79 M_FLUSH The write queue of the module is flushed of all its data
80 messages and the message is passed downstream.
81
82
83 M_IOCTL The function of this ioctl is performed and the message is
84 passed downstream in most cases. The TCFLSH and TCXONC
85 ioctls can be performed entirely in the ldterm module, so
86 the reply is sent upstream and the message is not passed
87 downstream.
88
89
90 M_DATA If the OPOST flag is set, or both the XCASE and ICANON
91 flags are set, output processing is performed and the pro‐
92 cessed message is passed downstream along with any M_DELAY
93 messages generated. Otherwise, the message is passed
94 downstream without change.
95
96
97 M_CTL If the size of the data buffer associated with the message
98 is the size of struct iocblk, ldterm will perform func‐
99 tional negotiation to determine where the termio(7I) pro‐
100 cessing is to be done. If the command field of the iocblk
101 structure (ioc_cmd) is set to MC_NO_CANON, the input
102 canonical processing normally performed on M_DATA messages
103 is disabled and those messages are passed upstream unmodi‐
104 fied. (This is for the use of modules or drivers that per‐
105 form their own input processing, such as a pseudo-terminal
106 in TIOCREMOTE mode connected to a program that performs
107 this processing). If the command is MC_DO_CANON, all input
108 processing is enabled. If the command is MC_PART_CANON,
109 then an M_DATA message containing a termios structure is
110 expected to be attached to the original M_CTL message. The
111 ldterm module will examine the iflag, oflag, and lflag
112 fields of the termios structure and from that point on,
113 will process only those flags that have not been turned
114 ON. If none of the above commands are found, the message
115 is ignored. In any case, the message is passed upstream.
116
117
118 M_FLUSH The read queue of the module is flushed of all its data
119 messages and all data in the record being accumulated are
120 also flushed. The message is passed upstream.
121
122
123 M_IOCACK The data contained within the message, which is to be
124 returned to the process, are augmented if necessary, and
125 the message is passed upstream.
126
127
128
129 All other messages are passed downstream unchanged.
130
132 The ldterm module processes the following TRANSPARENT ioctls. All oth‐
133 ers are passed downstream.
134
135 TCGETS/TCGETA
136
137 The message is passed downstream. If an acknowledgment is seen, the
138 data provided by the driver and modules downstream are augmented
139 and the acknowledgement is passed upstream.
140
141
142 TCSETS/TCSETSW/TCSETSF/TCSETA/TCSETAW/TCSETAF
143
144 The parameters that control the behavior of the ldterm module are
145 changed. If a mode change requires options at the stream head to be
146 changed, an M_SETOPTS message is sent upstream. If the ICANON flag
147 is turned on or off, the read mode at the stream head is changed to
148 message-nondiscard or byte-stream mode, respectively. If the TOSTOP
149 flag is turned on or off, the tostop mode at the stream head is
150 turned on or off, respectively. In any case, ldterm passes the
151 ioctl on downstream for possible additional processing.
152
153
154 TCFLSH
155
156 If the argument is 0, an M_FLUSH message with a flag byte of FLUSHR
157 is sent downstream and placed on the read queue. If the argument is
158 1, the write queue is flushed of all its data messages and an
159 M_FLUSH message with a flag byte of FLUSHW is sent upstream and
160 downstream. If the argument is 2, the write queue is flushed of all
161 its data messages and an M_FLUSH message with a flag byte of
162 FLUSHRW is sent downstream and placed on the read queue.
163
164
165 TCXONC
166
167 If the argument is 0 and output is not already stopped, an M_STOP
168 message is sent downstream. If the argument is 1 and output is
169 stopped, an M_START message is sent downstream. If the argument is
170 2 and input is not already stopped, an M_STOPI message is sent
171 downstream. If the argument is 3 and input is stopped, an M_STARTI
172 message is sent downstream.
173
174
175 TCSBRK
176
177 The message is passed downstream, so the driver has a chance to
178 drain the data and then send an M_IOCACK message upstream.
179
180
181 EUC_WSET
182
183 This call takes a pointer to an eucioc structure, and uses it to
184 set the EUC line discipline's local definition for the code set
185 widths to be used for subsequent operations. Within the stream, the
186 line discipline may optionally notify other modules of this setting
187 using M_CTL messages. When this call is received and the eucioc‐
188 structure contains valid data, the line discipline changes into EUC
189 handling mode once the euciocdata is completely transferred to an
190 internal data structure.
191
192
193 EUC_WGET
194
195 This call takes a pointer to an eucioc structure, and returns in it
196 the EUC code set widths currently in use by the EUC line disci‐
197 pline. If the current codeset of the line discipline is not an EUC
198 one, the result is meaningless.
199
200
202 termios(3C), console(7D), termio(7I)
203
204
205 STREAMS Programming Guide
206
207
208
209SunOS 5.11 7 Jun1999 ldterm(7M)