Qore TelnetClient Module Reference: doxygen/qlib/TelnetClient.qm.dox.h Source File

Qore TelnetClient Module Reference 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
TelnetClient.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file TelnetClient.qm Telnet module definition
3
4 /* TelnetClient.qm Copyright 2012 - 2014 Qore Technologies sro
5
6 Original Author: Pavol Potancok
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 */
26
27 // minimum required Qore version
28
29
30 /* Version History
31 * 1.1: David Nichols <david@qore.org>: added socket instrumention support from Qore 0.8.9
32 * 1.0: David Nichols <david@qore.org>: updated to a user module
33 * 0.9: Pavol Potancok <ppotancok@gmail.com>: original author
34 */
35
53 namespace TelnetClient {
58 // default telnet port
59 const DefaultTelnetPort = 23;
60
61 // default connection timeout
62 const DefaultConnTimeout = 15s;
63
64 // default poll timeout
65 const DefaultTimeout = 100ms;
66
67 // default terminal type
68 const DefaultTerminalType = "xterm";
69
70 // default terminal speed
71 const DefaultTerminalSpeed = 38400;
73
77 const IAC = 255;
78 const DONT = 254;
79 const DO = 253;
80 const WONT = 252;
81 const WILL = 251;
82 const SE = 240;
83 const NOP = 241;
84 const DM = 242;
85 const BRK = 243;
86 const IP = 244;
87 const AO = 245;
88 const AYT = 246;
89 const EC = 247;
90 const EL = 248;
91 const GA = 249;
92 const SB = 250;
93
95 const CmdMap = (
96 IAC : "IAC",
97 DONT : "DONT",
98 DO : "DO",
99 WONT : "WONT",
100 WILL: "WILL",
101 SE : "SubnegotiationEnd",
102 NOP : "NoOperation",
103 DM: "DataMark",
104 BRK : "Break",
105 IP : "Interruptprocess",
106 AO : "Abortoutput",
107 AYT : "AreYouThere",
108 EC : "EraseCharacter",
109 EL : "EraseLine",
110 GA : "GoAhead",
111 SB : "SubnegotiationBegin",
112 );
114
115 const SUPDUP_OPT = 21; // SUPDUP_OPT display protocol
116
120 const TOPT_BIN = 0;
121 const TOPT_ECHO = 1;
122 const TOPT_RECN = 2;
123 const TOPT_SUPP = 3;
124 const TOPT_APRX = 4;
125 const TOPT_STAT = 5;
126 const TOPT_TIM = 6;
127 const TOPT_REM = 7;
128 const TOPT_OLW = 8;
129 const TOPT_OPS = 9;
130 const TOPT_OCRD = 10;
131 const TOPT_OHT = 11;
132 const TOPT_OHTD = 12;
133 const TOPT_OFD = 13;
134 const TOPT_OVT = 14;
135 const TOPT_OVTD = 15;
136 const TOPT_OLD = 16;
137 const TOPT_EXT = 17;
138 const TOPT_LOGO = 18;
139 const TOPT_BYTE = 19;
140 const TOPT_DATA = 20;
141 const TOPT_SUP = 21;
142 const TOPT_SUPO = 22;
143 const TOPT_SNDL = 23;
144 const TOPT_TERM = 24;
145 const TOPT_EOR = 25;
146 const TOPT_TACACS = 26;
147 const TOPT_OM = 27;
148 const TOPT_TLN = 28;
149 const TOPT_3270 = 29;
150 const TOPT_X3 = 30;
151 const TOPT_NAWS = 31;
152 const TOPT_TS = 32;
153 const TOPT_RFC = 33;
154 const TOPT_LINE = 34;
155 const TOPT_XDL = 35;
156 const TOPT_ENVIR = 36;
157 const TOPT_AUTH = 37;
158 const TOPT_ENVIR_NEW = 39;
159 const TOPT_TN3270 = 40;
160 const TOPT_X_AUTH = 41;
161 const TOPT_CHARSET = 42;
162 const TOPT_RSP = 43;
163 const TOPT_COMPORT = 44;
164 const TOPT_SLE = 45;
165 const TOPT_STARTTLS = 46;
166 const TOPT_KERMIT = 47;
167 const TOPT_SEND_URL = 48;
168 const TOPT_EXTOP = 255;
169
171 const OptMap = (
172 TOPT_BIN : "BinaryTransmission",
173 TOPT_ECHO : "Echo|Is|Send",
174 TOPT_RECN : "Reconnection",
175 TOPT_SUPP : "SuppressGoAhead",
176 TOPT_APRX : "ApproxMessageSizeNegotiation",
177 TOPT_STAT : "Status",
178 TOPT_TIM : "TimingMark",
179 TOPT_REM : "RemoteControlledTransandEcho",
180 TOPT_OLW : "OutputLineWidth",
181 TOPT_OPS : "OutputPageSize",
182 TOPT_OCRD : "OutputCarriage-ReturnDisposition",
183 TOPT_OHT : "OutputHorizontalTabstops",
184 TOPT_OHTD : "OutputHorizontalTabDisposition",
185 TOPT_OFD : "OutputFormfeedDisposition",
186 TOPT_OVT : "OutputVerticalTabstops",
187 TOPT_OVTD : "OutputVerticalTabDisposition",
188 TOPT_OLD : "OutputLinefeedDisposition",
189 TOPT_EXT : "ExtendedASCII",
190 TOPT_LOGO : "Logout",
191 TOPT_BYTE : "ByteMacro",
192 TOPT_DATA : "DataEntryTerminal",
193 TOPT_SUP : "SUPDUP",
194 TOPT_SUPO : "SUPDUPOutput",
195 TOPT_SNDL : "SendLocation",
196 TOPT_TERM : "TerminalType",
197 TOPT_EOR : "EndofRecord",
198 TOPT_TACACS : "TACACSUserIdent",
199 TOPT_OM : "OutputMarking",
200 TOPT_TLN : "TerminalLocationNumber",
201 TOPT_3270 : "Telnet3270Regime",
202 TOPT_X3 : "X.3PAD",
203 TOPT_NAWS : "NegotiateAboutWindowSize",
204 TOPT_TS : "TerminalSpeed",
205 TOPT_RFC : "RemoteFlowControl",
206 TOPT_LINE : "Linemode",
207 TOPT_XDL : "XDisplayLocation",
208 TOPT_ENVIR : "TelnetEnvironmentOption",
209 TOPT_AUTH : "TelnetAuthenticationOption",
210 TOPT_ENVIR_NEW : "TelnetNewEnvironmentOption",
211 TOPT_TN3270 : "TN3270Enhancements",
212 TOPT_X_AUTH : "TelnetXAUTH",
213 TOPT_CHARSET : "TelnetCHARSET",
214 TOPT_RSP : "TelnetRemoteSerialPort",
215 TOPT_COMPORT : "TelnetComPortControl",
216 TOPT_SLE : "TelnetSuppressLocalEcho",
217 TOPT_STARTTLS : "TelnetStartTLS",
218 TOPT_KERMIT : "TelnetKERMIT",
219 TOPT_SEND_URL : "Send-URL",
220 TOPT_EXTOP : "Extended-Options-List",
221 );
223
225
228 class TelnetClient {
229
230 public:
232 private :
233 // the connection string
234 string connect;
235
236 // the socket for all communication with the server
237 Socket conn();
238
239 // to manage contention on the Socket
240 Mutex m();
241
242 // login user
243 *string user;
244
245 // logging closures
246 *code log_info;
247 *code log_debug;
248
249 // hash of features the telnet server has asked for
250 hash fh;
251
252 public:
254
255 // no public members
256 private:
257
258 public:
259
261
266 constructor(string host, softint port, *code log, *code dbgLog);
267
268
270
274 constructor(string connect, *code log, *code dbglog);
275
276
278 destructor();
279
280
282 private log(string msg);
283
284
286 private logDbg(string msg);
287
288
290
293 connect(timeout timeout = DefaultConnTimeout);
294
295
297 bool isConnected();
298
299
301
303 setUser(*string user);
304
305
307 *string getUser();
308
309
311
313 disconnect();
314
315
317
329 sendData(softlist arr);
330
331
333
341 sendTextData(string str);
342
343
345
351 *string getAvailableData(timeout t = DefaultTimeout);
352
353
355
363 bool hasFeature(int fc);
364
365
367
369 windowSizeUpdated();
370
371
373
375 private *string getDisplay();
376
377
379
381 private *string getTerminalType();
382
383
385
387 private hash getEnvironment();
388
389
391
393 private int getTerminalSpeed();
394
395
397
404 private hash getWindowSize();
405
406
408
417 nothing clearWarningQueue();
418
419
421
451 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
452
453
455
473 hash getUsageInfo();
474
475
477
486 clearStats();
487
488
490 // don't override this method, fix/enhance it with a patch to the module
491 private final disconnectIntern();
492
493
494 private checkConnIntern();
495
496
497 // don't override this method, fix/enhance it with a patch to the module
498 private final sendDataIntern(softlist arr, bool double_aic = False);
499
500
501 private sendTextDataIntern(string str);
502
503
504 // don't override this method, fix/enhance it with a patch to the module
505 private final *string getAvailableDataIntern(timeout t = DefaultTimeout);
506
507
508 // don't override this method, fix/enhance it with a patch to the module
509 private final updateWindowSizeIntern(hash wh);
510
511
512 // don't override this method, fix/enhance it with a patch to the module
513 private final processCmd(reference rv);
514
515
516 // don't override this method, fix/enhance it with a patch to the module
517 private final doSubNegotiation();
518
520 };
521 };
TelnetClient::TOPT_OCRD
const TOPT_OCRD
OutputCarriage-ReturnDisposition.
Definition: TelnetClient.qm.dox.h:130
TelnetClient::TOPT_OHTD
const TOPT_OHTD
OutputHorizontalTabDisposition.
Definition: TelnetClient.qm.dox.h:132
TelnetClient::BRK
const BRK
Break.
Definition: TelnetClient.qm.dox.h:85
TelnetClient::TOPT_SUPO
const TOPT_SUPO
SUPDUPOutput.
Definition: TelnetClient.qm.dox.h:142
TelnetClient::GA
const GA
Go Ahead.
Definition: TelnetClient.qm.dox.h:91
TelnetClient::TOPT_EXTOP
const TOPT_EXTOP
Extended-Options-List.
Definition: TelnetClient.qm.dox.h:168
TelnetClient::TOPT_APRX
const TOPT_APRX
ApproxMessageSizeNegotiation.
Definition: TelnetClient.qm.dox.h:124
TelnetClient::TOPT_NAWS
const TOPT_NAWS
NegotiateAboutWindowSize.
Definition: TelnetClient.qm.dox.h:151
TelnetClient::TOPT_OVTD
const TOPT_OVTD
OutputVerticalTabDisposition.
Definition: TelnetClient.qm.dox.h:135
TelnetClient::TOPT_TS
const TOPT_TS
TerminalSpeed.
Definition: TelnetClient.qm.dox.h:152
TelnetClient::TOPT_SUP
const TOPT_SUP
SUPDUP.
Definition: TelnetClient.qm.dox.h:141
TelnetClient::TOPT_STAT
const TOPT_STAT
Status.
Definition: TelnetClient.qm.dox.h:125
TelnetClient::TOPT_STARTTLS
const TOPT_STARTTLS
TelnetStartTLS.
Definition: TelnetClient.qm.dox.h:165
TelnetClient::TOPT_SUPP
const TOPT_SUPP
SuppressGoAhead.
Definition: TelnetClient.qm.dox.h:123
TelnetClient::TOPT_DATA
const TOPT_DATA
DataEntryTerminal.
Definition: TelnetClient.qm.dox.h:140
TelnetClient::TOPT_COMPORT
const TOPT_COMPORT
TelnetComPortControl.
Definition: TelnetClient.qm.dox.h:163
TelnetClient::WILL
const WILL
WILL.
Definition: TelnetClient.qm.dox.h:81
TelnetClient::TOPT_X_AUTH
const TOPT_X_AUTH
TelnetXAUTH.
Definition: TelnetClient.qm.dox.h:160
TelnetClient::EL
const EL
Erase Line.
Definition: TelnetClient.qm.dox.h:90
False
const False
TelnetClient::TOPT_OM
const TOPT_OM
OutputMarking.
Definition: TelnetClient.qm.dox.h:147
TelnetClient::TOPT_CHARSET
const TOPT_CHARSET
TelnetCHARSET.
Definition: TelnetClient.qm.dox.h:161
TelnetClient::DO
const DO
DO.
Definition: TelnetClient.qm.dox.h:79
TelnetClient::TOPT_SNDL
const TOPT_SNDL
SendLocation.
Definition: TelnetClient.qm.dox.h:143
TelnetClient::TelnetClient
The TelnetClient class allows communication with a telnet server; it can be used directly or subclass...
Definition: TelnetClient.qm.dox.h:228
TelnetClient::TOPT_OFD
const TOPT_OFD
OutputFormfeedDisposition.
Definition: TelnetClient.qm.dox.h:133
TelnetClient::TOPT_OPS
const TOPT_OPS
OutputPageSize.
Definition: TelnetClient.qm.dox.h:129
TelnetClient::SB
const SB
Subnegotiation Begin.
Definition: TelnetClient.qm.dox.h:92
TelnetClient::TOPT_REM
const TOPT_REM
RemoteControlledTransandEcho.
Definition: TelnetClient.qm.dox.h:127
TelnetClient::TOPT_BIN
const TOPT_BIN
BinaryTransmission.
Definition: TelnetClient.qm.dox.h:120
TelnetClient::TOPT_LOGO
const TOPT_LOGO
Logout.
Definition: TelnetClient.qm.dox.h:138
TelnetClient::EC
const EC
Erase Character.
Definition: TelnetClient.qm.dox.h:89
TelnetClient::TOPT_OLW
const TOPT_OLW
OutputLineWidth.
Definition: TelnetClient.qm.dox.h:128
TelnetClient::AYT
const AYT
Are You There.
Definition: TelnetClient.qm.dox.h:88
TelnetClient::TOPT_SEND_URL
const TOPT_SEND_URL
Send-URL.
Definition: TelnetClient.qm.dox.h:167
TelnetClient::TOPT_TERM
const TOPT_TERM
TerminalType.
Definition: TelnetClient.qm.dox.h:144
TelnetClient::TOPT_ECHO
const TOPT_ECHO
Echo|Is|Send.
Definition: TelnetClient.qm.dox.h:121
TelnetClient::TOPT_TACACS
const TOPT_TACACS
TACACSUserIdent.
Definition: TelnetClient.qm.dox.h:146
TelnetClient::TOPT_TLN
const TOPT_TLN
TerminalLocationNumber.
Definition: TelnetClient.qm.dox.h:148
TelnetClient::CmdMap
const CmdMap
command name map
Definition: TelnetClient.qm.dox.h:95
TelnetClient::TOPT_XDL
const TOPT_XDL
XDisplayLocation.
Definition: TelnetClient.qm.dox.h:155
TelnetClient::TOPT_TN3270
const TOPT_TN3270
TN3270Enhancements.
Definition: TelnetClient.qm.dox.h:159
TelnetClient::TOPT_LINE
const TOPT_LINE
Linemode.
Definition: TelnetClient.qm.dox.h:154
TelnetClient::TOPT_AUTH
const TOPT_AUTH
TelnetAuthenticationOption.
Definition: TelnetClient.qm.dox.h:157
TelnetClient::IP
const IP
Interrupt process.
Definition: TelnetClient.qm.dox.h:86
TelnetClient::TOPT_EOR
const TOPT_EOR
EndofRecord.
Definition: TelnetClient.qm.dox.h:145
TelnetClient::TOPT_ENVIR
const TOPT_ENVIR
TelnetEnvironmentOption.
Definition: TelnetClient.qm.dox.h:156
TelnetClient::TOPT_BYTE
const TOPT_BYTE
ByteMacro.
Definition: TelnetClient.qm.dox.h:139
TelnetClient::TOPT_ENVIR_NEW
const TOPT_ENVIR_NEW
TelnetNewEnvironmentOption.
Definition: TelnetClient.qm.dox.h:158
TelnetClient::TOPT_OLD
const TOPT_OLD
OutputLinefeedDisposition.
Definition: TelnetClient.qm.dox.h:136
TelnetClient::AO
const AO
Abort output.
Definition: TelnetClient.qm.dox.h:87
TelnetClient::TOPT_OVT
const TOPT_OVT
OutputVerticalTabstops.
Definition: TelnetClient.qm.dox.h:134
TelnetClient::NOP
const NOP
No Operation.
Definition: TelnetClient.qm.dox.h:83
TelnetClient::TOPT_X3
const TOPT_X3
X.3PAD.
Definition: TelnetClient.qm.dox.h:150
hash
hash hash(object obj)
TelnetClient::TOPT_OHT
const TOPT_OHT
OutputHorizontalTabstops.
Definition: TelnetClient.qm.dox.h:131
TelnetClient::IAC
const IAC
IAC.
Definition: TelnetClient.qm.dox.h:77
TelnetClient::TOPT_RSP
const TOPT_RSP
TelnetRemoteSerialPort.
Definition: TelnetClient.qm.dox.h:162
TelnetClient::TOPT_SLE
const TOPT_SLE
TelnetSuppressLocalEcho.
Definition: TelnetClient.qm.dox.h:164
TelnetClient::TOPT_RFC
const TOPT_RFC
RemoteFlowControl.
Definition: TelnetClient.qm.dox.h:153
TelnetClient::WONT
const WONT
WONT.
Definition: TelnetClient.qm.dox.h:80
TelnetClient::DONT
const DONT
DONT.
Definition: TelnetClient.qm.dox.h:78
TelnetClient::TOPT_RECN
const TOPT_RECN
Reconnection.
Definition: TelnetClient.qm.dox.h:122
TelnetClient::SE
const SE
Subnegotiation End.
Definition: TelnetClient.qm.dox.h:82
TelnetClient::TOPT_KERMIT
const TOPT_KERMIT
TelnetKERMIT.
Definition: TelnetClient.qm.dox.h:166
TelnetClient::DM
const DM
Data Mark.
Definition: TelnetClient.qm.dox.h:84
TelnetClient::OptMap
const OptMap
option map, maps codes to text descriptions
Definition: TelnetClient.qm.dox.h:171
TelnetClient::TOPT_EXT
const TOPT_EXT
ExtendedASCII.
Definition: TelnetClient.qm.dox.h:137
TelnetClient::TOPT_3270
const TOPT_3270
Telnet3270Regime.
Definition: TelnetClient.qm.dox.h:149
TelnetClient::TOPT_TIM
const TOPT_TIM
TimingMark.
Definition: TelnetClient.qm.dox.h:126