Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
aaf100da
Commit
aaf100da
authored
Dec 6, 2008
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Cosmetic fixes.
Rev: lib/modules/Protocols.pmod/TELNET.pmod:1.31
parent
a1368cd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/TELNET.pmod
+202
-210
202 additions, 210 deletions
lib/modules/Protocols.pmod/TELNET.pmod
with
202 additions
and
210 deletions
lib/modules/Protocols.pmod/TELNET.pmod
+
202
−
210
View file @
aaf100da
//
//
// $Id: TELNET.pmod,v 1.3
0
2008/12/06 1
6:50:43
grubba Exp $
// $Id: TELNET.pmod,v 1.3
1
2008/12/06 1
7:07:31
grubba Exp $
//
//
// The TELNET protocol as described by RFC 764 and others.
// The TELNET protocol as described by RFC 764 and others.
//
//
...
@@ -422,7 +422,8 @@ class protocol
...
@@ -422,7 +422,8 @@ class protocol
if (sizeof(to_send))
if (sizeof(to_send))
{
{
DWRITE(sprintf("TELNET: We now have data to send! (%d bytes)\n", sizeof(to_send)));
DWRITE(sprintf("TELNET: We now have data to send! (%d bytes)\n",
sizeof(to_send)));
if (to_send[0] == 242) {
if (to_send[0] == 242) {
// DataMark needs extra quoting... Stupid.
// DataMark needs extra quoting... Stupid.
DWRITE("TELNET: Found datamark @ offset 0!\n");
DWRITE("TELNET: Found datamark @ offset 0!\n");
...
@@ -472,20 +473,21 @@ class protocol
...
@@ -472,20 +473,21 @@ class protocol
//! @param option
//! @param option
//! The option to disable.
//! The option to disable.
#define CONTROL(OPTIONS,DO,DONT,WILL,WONT,YES,NO) \
#define CONTROL(OPTIONS,DO,DONT,WILL,WONT,YES,NO) \
void send_##DO(int option) \
void send_##DO(int option) \
{ \
{ \
if ((option < 0) || (option > 255)) { \
if ((option < 0) || (option > 255)) { \
error( "Bad TELNET option #%d\n", option); \
error( "Bad TELNET option #%d\n", option); \
} \
} \
DWRITE(sprintf("TELNET: send_" #DO "(%s) state is %d\n",lookup_telopt[option] || (string)option,OPTIONS##_options[option])); \
DWRITE(sprintf("TELNET: send_" #DO "(%s) state is %d\n", \
switch(OPTIONS##_options[option]) \
lookup_telopt[option] || (string)option, \
{ \
OPTIONS##_options[option])); \
switch(OPTIONS##_options[option]) { \
case NO: \
case NO: \
case UNKNOWN: \
case UNKNOWN: \
OPTIONS##_options[option]= WANT | YES; \
OPTIONS##_options[option]= WANT | YES; \
DWRITE(sprintf("TELNET: => " #DO " %s\n",lookup_telopt[option] || (string)option)); \
DWRITE(sprintf("TELNET: => " #DO " %s\n", \
lookup_telopt[option] || (string)option)); \
to_send += sprintf("%c%c%c",IAC,DO,option); \
to_send += sprintf("%c%c%c",IAC,DO,option); \
break; \
break; \
\
\
...
@@ -500,7 +502,8 @@ class protocol
...
@@ -500,7 +502,8 @@ class protocol
break; \
break; \
\
\
default: \
default: \
error("TELNET: Strange remote_options[%d]=%d\n",option,remote_options[option]); \
error("TELNET: Strange remote_options[%d]=%d\n", \
option, remote_options[option]); \
/* ERROR: weird state! */ \
/* ERROR: weird state! */ \
break; \
break; \
} \
} \
...
@@ -651,16 +654,7 @@ class protocol
...
@@ -651,16 +654,7 @@ class protocol
protected void got_data(mixed ignored, string line)
protected void got_data(mixed ignored, string line)
{
{
#ifdef TELNET_DEBUG
#ifdef TELNET_DEBUG
werror("TELNET: got_data(\"%s\")\n",Array.map(values(line),lambda(int s) {
werror("TELNET: got_data(%O)\n",line);
switch(s)
{
case ' '..'z':
return sprintf("%c",s);
default:
return sprintf("\\0x%02x",s);
}
})*"");
#endif
#endif
if (sizeof(line) && (line[0] == DM)) {
if (sizeof(line) && (line[0] == DM)) {
...
@@ -679,7 +673,8 @@ class protocol
...
@@ -679,7 +673,8 @@ class protocol
string part = a[i];
string part = a[i];
if (sizeof(part)) {
if (sizeof(part)) {
DWRITE(sprintf("TELNET: Code %s\n", lookup_telnetcodes[part[0]] || (string)part[0]));
DWRITE(sprintf("TELNET: Code %s\n",
lookup_telnetcodes[part[0]] || (string)part[0]));
switch (part[0]) {
switch (part[0]) {
default:
default:
...
@@ -713,15 +708,16 @@ class protocol
...
@@ -713,15 +708,16 @@ class protocol
#endif
#endif
#define HANDLE(OPTIONS,WILL,WONT,DO,DONT) \
#define HANDLE(OPTIONS,WILL,WONT,DO,DONT) \
case WILL:{ \
case WILL: \
{ \
int option = a[i][1]; \
int option = a[i][1]; \
int state = OPTIONS##_options[option]; \
int state = OPTIONS##_options[option]; \
a[i] = a[i][2..]; \
a[i] = a[i][2..]; \
\
\
DWRITE(sprintf(#WILL " %s, state 0x%04x\n", lookup_telopt[option], state)); \
DWRITE(sprintf(#WILL " %s, state 0x%04x\n", \
lookup_telopt[option], state)); \
\
\
switch(state) \
switch(state) { \
{ \
case NO: \
case NO: \
case UNKNOWN: \
case UNKNOWN: \
if (WILL##_callback(option)) \
if (WILL##_callback(option)) \
...
@@ -758,16 +754,20 @@ class protocol
...
@@ -758,16 +754,20 @@ class protocol
option,remote_options[option]); \
option,remote_options[option]); \
/* Weird state ! */ \
/* Weird state ! */ \
} \
} \
DWRITE(sprintf("TELNET: => " #WILL " %s, state 0x%04x\n", lookup_telopt[option], state)); \
DWRITE(sprintf("TELNET: => " #WILL " %s, state 0x%04x\n", \
lookup_telopt[option], state)); \
set_##OPTIONS##_option(option,state); \
set_##OPTIONS##_option(option,state); \
break;} \
break; \
} \
\
\
case WONT:{ \
case WONT: \
{ \
int option = a[i][1]; \
int option = a[i][1]; \
int state = OPTIONS##_options[option]; \
int state = OPTIONS##_options[option]; \
a[i] = a[i][2..]; \
a[i] = a[i][2..]; \
\
\
DWRITE(sprintf(#WONT " %s, state 0x%04x\n", lookup_telopt[option], state)); \
DWRITE(sprintf(#WONT " %s, state 0x%04x\n", \
lookup_telopt[option], state)); \
\
\
switch(state) \
switch(state) \
{ \
{ \
...
@@ -801,11 +801,11 @@ class protocol
...
@@ -801,11 +801,11 @@ class protocol
/* Weird state */ \
/* Weird state */ \
} \
} \
\
\
DWRITE(sprintf("TELNET: => " #WONT " %s, state 0x%04x\n", lookup_telopt[option], state)); \
DWRITE(sprintf("TELNET: => " #WONT " %s, state 0x%04x\n", \
lookup_telopt[option], state)); \
set_##OPTIONS##_option(option,state); \
set_##OPTIONS##_option(option,state); \
}break
} \
break
HANDLE(remote,WILL,WONT,DO,DONT);
HANDLE(remote,WILL,WONT,DO,DONT);
HANDLE(local,DO,DONT,WILL,WONT);
HANDLE(local,DO,DONT,WILL,WONT);
...
@@ -832,16 +832,7 @@ class protocol
...
@@ -832,16 +832,7 @@ class protocol
if ((!synch)) {
if ((!synch)) {
#ifdef TELNET_DEBUG
#ifdef TELNET_DEBUG
werror("TELNET: calling read_callback(X,\"%s\")\n",Array.map(values(line),lambda(int s) {
werror("TELNET: calling read_callback(X,%O)\n", line);
switch(s)
{
case ' '..'z':
return sprintf("%c",s);
default:
return sprintf("\\0x%02x",s);
}
})*"");
#endif
#endif
call_read_cb(line);
call_read_cb(line);
}
}
...
@@ -878,7 +869,7 @@ class protocol
...
@@ -878,7 +869,7 @@ class protocol
//! @param r_cb
//! @param r_cb
//! Function to call when data has arrived.
//! Function to call when data has arrived.
//! @param w_cb
//! @param w_cb
//! Function to call when
data can be sent
.
//! Function to call when
the send buffer is empty
.
//! @param c_cb
//! @param c_cb
//! Function to call when the connection is closed.
//! Function to call when the connection is closed.
//! @param callbacks
//! @param callbacks
...
@@ -910,7 +901,8 @@ class protocol
...
@@ -910,7 +901,8 @@ class protocol
read_cb = r_cb;
read_cb = r_cb;
write_cb = w_cb;
write_cb = w_cb;
close_cb = c_cb;
close_cb = c_cb;
DWRITE(sprintf("TELNET: set_nonblocking(): Calling fd->set_nonblocking() %O %O\n",
DWRITE(sprintf("TELNET: set_nonblocking(): "
"Calling fd->set_nonblocking() %O %O\n",
w_cb, w_cb || send_data));
w_cb, w_cb || send_data));
fd->set_nonblocking(got_data, w_cb && send_data, close_cb, got_oob);
fd->set_nonblocking(got_data, w_cb && send_data, close_cb, got_oob);
nonblocking_write = !!w_cb;
nonblocking_write = !!w_cb;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment