version 1.28, 2014/07/20 10:55:26 |
version 1.29, 2014/07/22 07:30:24 |
|
|
* Initialize telnet environment. |
* Initialize telnet environment. |
*/ |
*/ |
|
|
void |
void |
init_telnet() |
init_telnet(void) |
{ |
{ |
env_init(); |
env_init(); |
|
|
|
|
* is in disagreement as to what the current state should be. |
* is in disagreement as to what the current state should be. |
*/ |
*/ |
|
|
void |
void |
send_do(c, init) |
send_do(int c, int init) |
int c, init; |
|
{ |
{ |
if (init) { |
if (init) { |
if (((do_dont_resp[c] == 0) && my_state_is_do(c)) || |
if (((do_dont_resp[c] == 0) && my_state_is_do(c)) || |
|
|
printoption("SENT",DO, c); |
printoption("SENT",DO, c); |
} |
} |
|
|
void |
void |
send_dont(c, init) |
send_dont(int c, int init) |
int c, init; |
|
{ |
{ |
if (init) { |
if (init) { |
if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) || |
if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) || |
|
|
printoption("SENT", DONT, c); |
printoption("SENT", DONT, c); |
} |
} |
|
|
void |
void |
send_will(c, init) |
send_will(int c, int init) |
int c, init; |
|
{ |
{ |
if (init) { |
if (init) { |
if (((will_wont_resp[c] == 0) && my_state_is_will(c)) || |
if (((will_wont_resp[c] == 0) && my_state_is_will(c)) || |
|
|
printoption("SENT", WILL, c); |
printoption("SENT", WILL, c); |
} |
} |
|
|
void |
void |
send_wont(c, init) |
send_wont(int c, int init) |
int c, init; |
|
{ |
{ |
if (init) { |
if (init) { |
if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) || |
if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) || |
|
|
printoption("SENT", WONT, c); |
printoption("SENT", WONT, c); |
} |
} |
|
|
|
|
static void |
static void |
willoption(option) |
willoption(int option) |
int option; |
|
{ |
{ |
int new_state_ok = 0; |
int new_state_ok = 0; |
|
|
|
|
} |
} |
|
|
static void |
static void |
wontoption(option) |
wontoption(int option) |
int option; |
|
{ |
{ |
if (do_dont_resp[option]) { |
if (do_dont_resp[option]) { |
--do_dont_resp[option]; |
--do_dont_resp[option]; |
|
|
} |
} |
|
|
static void |
static void |
dooption(option) |
dooption(int option) |
int option; |
|
{ |
{ |
int new_state_ok = 0; |
int new_state_ok = 0; |
|
|
|
|
} |
} |
|
|
static void |
static void |
dontoption(option) |
dontoption(int option) |
int option; |
|
{ |
{ |
|
|
if (will_wont_resp[option]) { |
if (will_wont_resp[option]) { |
|
|
static char *name_unknown = "UNKNOWN"; |
static char *name_unknown = "UNKNOWN"; |
static char *unknown[] = { NULL, NULL }; |
static char *unknown[] = { NULL, NULL }; |
|
|
char ** |
char ** |
mklist(buf, name) |
mklist(char *buf, char *name) |
char *buf, *name; |
|
{ |
{ |
int n; |
int n; |
char c, *cp, **argvp, *cp2, **argv, **avt; |
char c, *cp, **argvp, *cp2, **argv, **avt; |
|
|
return(unknown); |
return(unknown); |
} |
} |
|
|
int |
int |
is_unique(name, as, ae) |
is_unique(char *name, char **as, char **ae) |
char *name, **as, **ae; |
|
{ |
{ |
char **ap; |
char **ap; |
int n; |
int n; |
|
|
|
|
int resettermname = 1; |
int resettermname = 1; |
|
|
char * |
char * |
gettermname() |
gettermname(void) |
{ |
{ |
char *tname; |
char *tname; |
static char **tnamep = NULL; |
static char **tnamep = NULL; |
|
|
next = tnamep; |
next = tnamep; |
return(*next++); |
return(*next++); |
} |
} |
|
|
/* |
/* |
* suboption() |
* suboption() |
* |
* |
|
|
* Linemode |
* Linemode |
*/ |
*/ |
|
|
static void |
static void |
suboption() |
suboption(void) |
{ |
{ |
unsigned char subchar; |
unsigned char subchar; |
|
|
|
|
static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE }; |
static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE }; |
|
|
static void |
static void |
lm_will(cmd, len) |
lm_will(unsigned char *cmd, int len) |
unsigned char *cmd; |
|
int len; |
|
{ |
{ |
if (len < 1) { |
if (len < 1) { |
/*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */ |
/*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */ |
|
|
} |
} |
|
|
static void |
static void |
lm_wont(cmd, len) |
lm_wont(unsigned char *cmd, int len) |
unsigned char *cmd; |
|
int len; |
|
{ |
{ |
if (len < 1) { |
if (len < 1) { |
/*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */ |
/*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */ |
|
|
} |
} |
|
|
static void |
static void |
lm_do(cmd, len) |
lm_do(unsigned char *cmd, int len) |
unsigned char *cmd; |
|
int len; |
|
{ |
{ |
if (len < 1) { |
if (len < 1) { |
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ |
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ |
|
|
} |
} |
|
|
static void |
static void |
lm_dont(cmd, len) |
lm_dont(unsigned char *cmd, int len) |
unsigned char *cmd; |
|
int len; |
|
{ |
{ |
if (len < 1) { |
if (len < 1) { |
/*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */ |
/*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */ |
|
|
IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE |
IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE |
}; |
}; |
|
|
void |
void |
lm_mode(cmd, len, init) |
lm_mode(unsigned char *cmd, int len, int init) |
unsigned char *cmd; |
|
int len, init; |
|
{ |
{ |
if (len != 1) |
if (len != 1) |
return; |
return; |
|
|
static int slc_mode = SLC_EXPORT; |
static int slc_mode = SLC_EXPORT; |
|
|
static void |
static void |
slc_init() |
slc_init(void) |
{ |
{ |
struct spc *spcp; |
struct spc *spcp; |
|
|
|
|
|
|
} |
} |
|
|
void |
void |
slcstate() |
slcstate(void) |
{ |
{ |
printf("Special characters are %s values\n", |
printf("Special characters are %s values\n", |
slc_mode == SLC_IMPORT ? "remote default" : |
slc_mode == SLC_IMPORT ? "remote default" : |
|
|
"remote"); |
"remote"); |
} |
} |
|
|
void |
void |
slc_mode_export(int unused) |
slc_mode_export(int unused) |
{ |
{ |
slc_mode = SLC_EXPORT; |
slc_mode = SLC_EXPORT; |
|
|
slc_export(); |
slc_export(); |
} |
} |
|
|
void |
void |
slc_mode_import(def) |
slc_mode_import(int def) |
int def; |
|
{ |
{ |
slc_mode = def ? SLC_IMPORT : SLC_RVALUE; |
slc_mode = def ? SLC_IMPORT : SLC_RVALUE; |
if (my_state_is_will(TELOPT_LINEMODE)) |
if (my_state_is_will(TELOPT_LINEMODE)) |
|
|
}; |
}; |
|
|
static void |
static void |
slc_import(def) |
slc_import(int def) |
int def; |
|
{ |
{ |
if (NETROOM() > sizeof(slc_import_val)) { |
if (NETROOM() > sizeof(slc_import_val)) { |
if (def) { |
if (def) { |
|
|
} |
} |
|
|
static void |
static void |
slc_export() |
slc_export(void) |
{ |
{ |
struct spc *spcp; |
struct spc *spcp; |
|
|
|
|
} |
} |
|
|
static void |
static void |
slc(cp, len) |
slc(unsigned char *cp, int len) |
unsigned char *cp; |
|
int len; |
|
{ |
{ |
struct spc *spcp; |
struct spc *spcp; |
int func,level; |
int func,level; |
|
|
setconnmode(1); /* set the new character values */ |
setconnmode(1); /* set the new character values */ |
} |
} |
|
|
void |
void |
slc_check() |
slc_check(void) |
{ |
{ |
struct spc *spcp; |
struct spc *spcp; |
|
|
|
|
static unsigned char slc_reply[2 * SUBBUFSIZE]; |
static unsigned char slc_reply[2 * SUBBUFSIZE]; |
static unsigned char *slc_replyp; |
static unsigned char *slc_replyp; |
|
|
unsigned char |
unsigned char |
slc_add(unsigned char ch) |
slc_add(unsigned char ch) |
{ |
{ |
if (slc_replyp == slc_reply + sizeof(slc_reply)) |
if (slc_replyp == slc_reply + sizeof(slc_reply)) |
|
|
} |
} |
|
|
static void |
static void |
slc_start_reply() |
slc_start_reply(void) |
{ |
{ |
slc_replyp = slc_reply; |
slc_replyp = slc_reply; |
slc_add(IAC); |
slc_add(IAC); |
|
|
} |
} |
|
|
static void |
static void |
slc_add_reply(func, flags, value) |
slc_add_reply(unsigned char func, unsigned char flags, cc_t value) |
unsigned char func; |
|
unsigned char flags; |
|
cc_t value; |
|
{ |
{ |
if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) { |
if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) { |
printf("slc_add_reply: not enough room\n"); |
printf("slc_add_reply: not enough room\n"); |
|
|
} |
} |
|
|
static void |
static void |
slc_end_reply() |
slc_end_reply(void) |
{ |
{ |
int len; |
int len; |
|
|
|
|
} |
} |
|
|
static int |
static int |
slc_update() |
slc_update(void) |
{ |
{ |
struct spc *spcp; |
struct spc *spcp; |
int need_update = 0; |
int need_update = 0; |
|
|
} |
} |
|
|
static void |
static void |
env_opt(buf, len) |
env_opt(unsigned char *buf, int len) |
unsigned char *buf; |
|
int len; |
|
{ |
{ |
unsigned char *ep = 0, *epc = 0; |
unsigned char *ep = 0, *epc = 0; |
int i; |
int i; |
|
|
static unsigned char *opt_replyp; |
static unsigned char *opt_replyp; |
static unsigned char *opt_replyend; |
static unsigned char *opt_replyend; |
|
|
void |
void |
opt_add(unsigned char ch) |
opt_add(unsigned char ch) |
{ |
{ |
if (opt_replyp == opt_replyend) |
if (opt_replyp == opt_replyend) |
return; |
return; |
*opt_replyp++ = ch; |
*opt_replyp++ = ch; |
} |
} |
|
|
static void |
static void |
env_opt_start() |
env_opt_start(void) |
{ |
{ |
unsigned char *p; |
unsigned char *p; |
|
|
|
|
opt_add(TELQUAL_IS); |
opt_add(TELQUAL_IS); |
} |
} |
|
|
void |
void |
env_opt_start_info() |
env_opt_start_info(void) |
{ |
{ |
env_opt_start(); |
env_opt_start(); |
if (opt_replyp) |
if (opt_replyp) |
opt_replyp[-1] = TELQUAL_INFO; |
opt_replyp[-1] = TELQUAL_INFO; |
} |
} |
|
|
void |
void |
env_opt_add(ep) |
env_opt_add(unsigned char *ep) |
unsigned char *ep; |
|
{ |
{ |
unsigned char *vp, c; |
unsigned char *vp, c; |
|
|
|
|
} |
} |
} |
} |
|
|
int |
int |
opt_welldefined(ep) |
opt_welldefined(char *ep) |
char *ep; |
|
{ |
{ |
if ((strcmp(ep, "USER") == 0) || |
if ((strcmp(ep, "USER") == 0) || |
(strcmp(ep, "DISPLAY") == 0) || |
(strcmp(ep, "DISPLAY") == 0) || |
|
|
return(1); |
return(1); |
return(0); |
return(0); |
} |
} |
void |
|
env_opt_end(emptyok) |
void |
int emptyok; |
env_opt_end(int emptyok) |
{ |
{ |
int len; |
int len; |
|
|
|
|
|
|
|
|
|
|
int |
int |
telrcv() |
telrcv(void) |
{ |
{ |
int c; |
int c; |
int scc; |
int scc; |
|
|
|
|
static int bol = 1, local = 0; |
static int bol = 1, local = 0; |
|
|
int |
int |
rlogin_susp() |
rlogin_susp(void) |
{ |
{ |
if (local) { |
if (local) { |
local = 0; |
local = 0; |
|
|
return(0); |
return(0); |
} |
} |
|
|
static int |
static int |
telsnd() |
telsnd(void) |
{ |
{ |
int tcc; |
int tcc; |
int count; |
int count; |
|
|
* |
* |
*/ |
*/ |
|
|
|
int |
int |
Scheduler(int block) /* should we block in the select ? */ |
Scheduler(block) |
|
int block; /* should we block in the select ? */ |
|
{ |
{ |
/* One wants to be a bit careful about setting returnValue |
/* One wants to be a bit careful about setting returnValue |
* to one, since a one implies we did some useful work, |
* to one, since a one implies we did some useful work, |
|
|
/* |
/* |
* Select from tty and network... |
* Select from tty and network... |
*/ |
*/ |
void |
void |
telnet(user) |
telnet(char *user) |
char *user; |
|
{ |
{ |
sys_telnet_init(); |
sys_telnet_init(); |
|
|
|
|
* character. |
* character. |
*/ |
*/ |
|
|
static char * |
static char * |
nextitem(current) |
nextitem(char *current) |
char *current; |
|
{ |
{ |
if ((*current&0xff) != IAC) { |
if ((*current&0xff) != IAC) { |
return current+1; |
return current+1; |
|
|
* us in any case. |
* us in any case. |
*/ |
*/ |
|
|
static void |
static void |
netclear() |
netclear(void) |
{ |
{ |
#if 0 /* XXX */ |
#if 0 /* XXX */ |
char *thisitem, *next; |
char *thisitem, *next; |
|
|
* These routines add various telnet commands to the data stream. |
* These routines add various telnet commands to the data stream. |
*/ |
*/ |
|
|
static void |
static void |
doflush() |
doflush(void) |
{ |
{ |
NET2ADD(IAC, DO); |
NET2ADD(IAC, DO); |
NETADD(TELOPT_TM); |
NETADD(TELOPT_TM); |
|
|
printoption("SENT", DO, TELOPT_TM); |
printoption("SENT", DO, TELOPT_TM); |
} |
} |
|
|
void |
void |
xmitAO() |
xmitAO(void) |
{ |
{ |
NET2ADD(IAC, AO); |
NET2ADD(IAC, AO); |
printoption("SENT", IAC, AO); |
printoption("SENT", IAC, AO); |
|
|
} |
} |
|
|
|
|
void |
void |
xmitEL() |
xmitEL(void) |
{ |
{ |
NET2ADD(IAC, EL); |
NET2ADD(IAC, EL); |
printoption("SENT", IAC, EL); |
printoption("SENT", IAC, EL); |
} |
} |
|
|
void |
void |
xmitEC() |
xmitEC(void) |
{ |
{ |
NET2ADD(IAC, EC); |
NET2ADD(IAC, EC); |
printoption("SENT", IAC, EC); |
printoption("SENT", IAC, EC); |
} |
} |
|
|
|
|
int |
int |
dosynch() |
dosynch(void) |
{ |
{ |
netclear(); /* clear the path to the network */ |
netclear(); /* clear the path to the network */ |
NETADD(IAC); |
NETADD(IAC); |
|
|
|
|
int want_status_response = 0; |
int want_status_response = 0; |
|
|
int |
int |
get_status() |
get_status(void) |
{ |
{ |
unsigned char tmp[16]; |
unsigned char tmp[16]; |
unsigned char *cp; |
unsigned char *cp; |
|
|
return 1; |
return 1; |
} |
} |
|
|
void |
void |
intp() |
intp(void) |
{ |
{ |
NET2ADD(IAC, IP); |
NET2ADD(IAC, IP); |
printoption("SENT", IAC, IP); |
printoption("SENT", IAC, IP); |
|
|
} |
} |
} |
} |
|
|
void |
void |
sendbrk() |
sendbrk(void) |
{ |
{ |
NET2ADD(IAC, BREAK); |
NET2ADD(IAC, BREAK); |
printoption("SENT", IAC, BREAK); |
printoption("SENT", IAC, BREAK); |
|
|
} |
} |
} |
} |
|
|
void |
void |
sendabort() |
sendabort(void) |
{ |
{ |
NET2ADD(IAC, ABORT); |
NET2ADD(IAC, ABORT); |
printoption("SENT", IAC, ABORT); |
printoption("SENT", IAC, ABORT); |
|
|
} |
} |
} |
} |
|
|
void |
void |
sendsusp() |
sendsusp(void) |
{ |
{ |
NET2ADD(IAC, SUSP); |
NET2ADD(IAC, SUSP); |
printoption("SENT", IAC, SUSP); |
printoption("SENT", IAC, SUSP); |
|
|
} |
} |
} |
} |
|
|
void |
void |
sendeof() |
sendeof(void) |
{ |
{ |
NET2ADD(IAC, xEOF); |
NET2ADD(IAC, xEOF); |
printoption("SENT", IAC, xEOF); |
printoption("SENT", IAC, xEOF); |
} |
} |
|
|
void |
void |
sendayt() |
sendayt(void) |
{ |
{ |
NET2ADD(IAC, AYT); |
NET2ADD(IAC, AYT); |
printoption("SENT", IAC, AYT); |
printoption("SENT", IAC, AYT); |
|
|
* Send a window size update to the remote system. |
* Send a window size update to the remote system. |
*/ |
*/ |
|
|
void |
void |
sendnaws() |
sendnaws(void) |
{ |
{ |
long rows, cols; |
long rows, cols; |
unsigned char tmp[16]; |
unsigned char tmp[16]; |
|
|
} |
} |
} |
} |
|
|
void |
void |
tel_enter_binary(rw) |
tel_enter_binary(int rw) |
int rw; |
|
{ |
{ |
if (rw&1) |
if (rw&1) |
send_do(TELOPT_BINARY, 1); |
send_do(TELOPT_BINARY, 1); |
|
|
send_will(TELOPT_BINARY, 1); |
send_will(TELOPT_BINARY, 1); |
} |
} |
|
|
void |
void |
tel_leave_binary(rw) |
tel_leave_binary(int rw) |
int rw; |
|
{ |
{ |
if (rw&1) |
if (rw&1) |
send_dont(TELOPT_BINARY, 1); |
send_dont(TELOPT_BINARY, 1); |