-char *cktelv = "Telnet support, 8.0.269, 4 Mar 2004";
+char *cktelv = "Telnet support, 9.0.274, 16 Mar 2010";
#define CKCTEL_C
int sstelnet = 0; /* Do server-side Telnet negotiation */
Telnet KERMIT support by Jeffrey Altman
Other contributions as indicated in the code.
- Copyright (C) 1985, 2004,
+ Copyright (C) 1985, 2010,
Trustees of Columbia University in the City of New York.
All rights reserved. See the C-Kermit COPYING.TXT file or the
copyright text in the ckcmai.c module for disclaimer and permissions.
int tn_begun = 0; /* Telnet protocol started flag */
static int tn_first = 1; /* First time init flag */
extern int tn_exit; /* Exit on disconnect */
+extern int nettype;
extern int inserver; /* Running as IKSD */
char *tn_term = NULL; /* Terminal type override */
extern int ttcarr;
#endif /* TN_COMPORT */
+ /* if (!IS_TELNET()) return(1); */
+
rtimer();
debug(F110,"tn_wait waiting for",where,0);
#ifdef NETLEBUF
extern int tt_push_inited;
#endif /* NETLEBUF */
+ /* if (!IS_TELNET()) return(1); */
+
if (tn_wait_idx) {
- hexdump((CHAR *)"tn_push",tn_wait_buf,tn_wait_idx);
+ ckhexdump((CHAR *)"tn_push",tn_wait_buf,tn_wait_idx);
#ifdef NETLEBUF
if (!tt_push_inited) /* Local handling */
le_init();
CHAR buf[5];
char msg[128];
int rc;
-
if (ttnet != NET_TCPB) return(-1); /* Must be TCP/IP */
if (ttnproto != NP_TELNET) return(-1); /* Must be telnet protocol */
if (!TELCMD_OK(cmd)) return(-1);
extern int ckxech;
int x = 0;
+ /* if (!IS_TELNET()) return(0); */
+
/* Wait up to 5 sec for responses to outstanding telnet negotiations */
while (x >= 0 && ttchk() > 0 && tn_wait_idx < TN_WAIT_BUF_SZ) {
x = ttinc(1);
/* explicitedly requested we try to send one via X-Display Location */
/* But do not send a string at all if FORWARD_X is in use. */
+ /* if (!IS_TELNET()) return(0); */
+
debug(F110,"tn_get_display() myipaddr",myipaddr,0);
#ifdef CK_ENVIRONMENT
debug(F110,"tn_get_display() tn_env_disp",tn_env_disp,0);
p[0] = sb[i++];
p[1] = sb[i++];
hchannel = ntohs(nchannel);
- rc = fwdx_send_xauth_to_xserver(hchannel,(char *)&sb[3],n-5);
+ rc = fwdx_send_xauth_to_xserver(hchannel,(CHAR *)&sb[3],n-5);
if ( rc >= 0 && n-5-rc > 0) {
rc = fwdx_write_data_to_channel(hchannel,(char *)&sb[3+rc],n-5-rc);
if ( rc < 0 ) {
sb_out[i++] = (CHAR) SE; /* marked by IAC SE */
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakxmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
+ ckmakxmsg((char *)fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
TELOPT(TELOPT_FORWARD_X),
" CLOSE CHANNEL=",ckitoa(channel)," IAC SE",
NULL,NULL,NULL,NULL,NULL,NULL,NULL
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol((CHAR *)sb_out,i) < 0); /* Send it. */
#ifdef OS2
sb_out[i++] = (CHAR) SE; /* marked by IAC SE */
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakxmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
+ ckmakxmsg((char *)fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
TELOPT(TELOPT_FORWARD_X),
" OPEN CHANNEL=",ckitoa(channel)," IAC SE",
NULL,NULL,NULL,NULL,NULL,NULL,NULL);
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol((CHAR *)sb_out,i) < 0); /* Send it. */
#ifdef OS2
sb_out[i++] = (CHAR) SE; /* marked by IAC SE */
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakxmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
+ ckmakxmsg((char *)fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
TELOPT(TELOPT_FORWARD_X),
" OPTIONS ",ckctox(sb_out[4],1)," IAC SE",
NULL,NULL,NULL,NULL,NULL,NULL,NULL);
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol((CHAR *)sb_out,i) < 0); /* Send it. */
#ifdef OS2
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakmsg(fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
+ ckmakmsg((char *)fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
TELOPT(TELOPT_FORWARD_X),
" OPTIONS 00 IAC SE",NULL);
}
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol((CHAR *)sb_out,i) < 0); /* Send it. */
#ifdef OS2
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakxmsg( fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
+ ckmakxmsg( (char *)fwdx_msg_out,TN_MSG_LEN,"TELNET SENT SB ",
TELOPT(TELOPT_FORWARD_X),
" DATA CHANNEL=",ckitoa(channel)," ",
NULL,NULL,NULL,NULL,NULL,NULL,NULL );
- tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[j_sav],j-(j_sav+2));
- ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);
+ tn_hex((CHAR *)fwdx_msg_out,
+ TN_MSG_LEN,&sb_priv[j_sav],j-(j_sav+2));
+ ckstrncat((char *)fwdx_msg_out," IAC SE",TN_MSG_LEN);
}
#endif /* DEBUG */
#ifdef OS2
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol(sb_priv,j) < 0); /* Send it. */
#ifdef OS2
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- ckmakxmsg( fwdx_msg_out,TN_MSG_LEN,
+ ckmakxmsg( (char *)fwdx_msg_out,TN_MSG_LEN,
"TELNET SENT SB ",TELOPT(TELOPT_FORWARD_X),
" DATA ",ckctox(p[0],1)," ",ckctox(p[1],1)," ",
NULL,NULL,NULL,NULL,NULL);
- tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[6],j-8);
- ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);
+ tn_hex((CHAR *)fwdx_msg_out,TN_MSG_LEN,&sb_priv[6],j-8);
+ ckstrncat((char *)fwdx_msg_out," IAC SE",TN_MSG_LEN);
}
#endif /* DEBUG */
#ifdef OS2
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = (ttol(sb_priv,j) < 0); /* Send it. */
#ifdef OS2
#ifdef DEBUG
if (deblog || tn_deb || debses) {
- sprintf(fwdx_msg_out,"TELNET SENT SB %s OPTION_DATA XAUTH ",
+ sprintf((char *)fwdx_msg_out,"TELNET SENT SB %s OPTION_DATA XAUTH ",
TELOPT(TELOPT_FORWARD_X));
- tn_hex(fwdx_msg_out,TN_MSG_LEN,&sb_priv[5],(p-sb_priv)-7);
- ckstrncat(fwdx_msg_out," IAC SE",TN_MSG_LEN);
+ tn_hex((char *)fwdx_msg_out,TN_MSG_LEN,&sb_priv[5],(p-sb_priv)-7);
+ ckstrncat((char *)fwdx_msg_out," IAC SE",TN_MSG_LEN);
}
#endif /* DEBUG */
RequestTelnetMutex( SEM_INDEFINITE_WAIT );
#endif
#ifdef DEBUG
- debug(F100,fwdx_msg_out,"",0);
- if (tn_deb || debses) tn_debug(fwdx_msg_out);
+ debug(F100,(char *)fwdx_msg_out,"",0);
+ if (tn_deb || debses) tn_debug((char *)fwdx_msg_out);
#endif /* DEBUG */
rc = ( ttol(sb_priv,p-sb_priv) < 0 ); /* Send it. */
#ifdef OS2
VOID
tn_sdsb() {
+ /* if (!IS_TELNET()) return; */
+
if (TELOPT_SB(TELOPT_TTYPE).term.need_to_send) {
tn_sttyp();
TELOPT_SB(TELOPT_TTYPE).term.need_to_send = 0;
tn_reset() {
int x,opt,cmd;
+ /* if (!IS_TELNET()) return(1); */
+
tn_wait_idx = 0; /* Clear the tn_push() buffer */
tn_wait_tmo = TN_TIMEOUT; /* Reset wait timer stats */
tn_start() {
int wait, x, opt;
+ /* if (!IS_TELNET()) return(0); */
+
if (tn_init && tn_begun)
return(0);
tn_begun = 1;
if (ttnet != NET_TCPB) /* Make sure connection is TCP/IP */
return(0);
+/*
+ if (!IS_TELNET())
+ return(0);
+*/
if (tn_init) /* Have we done this already? */
return(0); /* Don't do it again. */
tn_init = 1;
debug(F100,"tn_ini telnet negotiations ignored","tn_init",tn_init);
return(0);
+#ifdef COMMENT
+ /* Jeff's code from 30 Dec 2005 - doesn't work with SSL POP server */
+ case NP_NONE:
+ case NP_SSL:
+ case NP_TLS:
+ ttnproto = NP_TELNET; /* pretend it's telnet anyway, */
+ oldplex = duplex; /* save old duplex value */
+ duplex = 1; /* and set to half duplex for telnet */
+ if (inserver)
+ debug(F100,"tn_ini skipping telnet negotiations","",0);
+ else
+ tn_wait("tn_ini - waiting to see if telnet negotiations were sent");
+ tn_push();
+ return(0);
+ case NP_SSL_RAW:
+ case NP_TLS_RAW:
+ case NP_TCPRAW: /* Raw socket requested. */
+ debug(F100,"tn_ini telnet negotiations ignored","tn_init",tn_init);
+ return(0);
+#else
+ /* My code from 4 Dec 2005 - works with SSL POP server */
case NP_NONE:
case NP_SSL:
case NP_TLS: /* If not talking to a telnet port, */
+ case NP_SSL_RAW: /* SSL and TLS with Telnet */
+ case NP_TLS_RAW: /* negotiations disabled. */
ttnproto = NP_TELNET; /* pretend it's telnet anyway, */
oldplex = duplex; /* save old duplex value */
duplex = 1; /* and set to half duplex for telnet */
if (inserver)
debug(F100,"tn_ini skipping telnet negotiations","",0);
- else
- tn_wait("tn_ini - waiting to see if telnet negotiations were sent");
+ else
+ tn_wait("tn_ini - waiting to see if telnet negotiations were sent");
tn_push();
return(0);
case NP_TCPRAW: /* Raw socket requested. */
debug(F100,"tn_ini telnet negotiations ignored","tn_init",tn_init);
return(0);
+#endif /* COMMENT */
case NP_KERMIT: /* switching to Telnet protocol */
case NP_SSL_TELNET:
case NP_TLS_TELNET:
if (ttnet != NET_TCPB) return(0); /* Must be TCP/IP */
if (ttnproto != NP_TELNET) return(0); /* Must be telnet protocol */
+
if (cmd < KERMIT_START || cmd > KERMIT_RESP_STOP) /* Illegal subcommand */
return(-1);
#endif /* CK_ANSIC */
/* tn_sb */ {
int c, x, y, n, m, flag;
+ /* if (!IS_TELNET()) return(1); */
+
debug(F100,"Entering tn_sb()","",0);
*len = 0; /* Initialize Len to 0 */
n = flag = 0; /* Flag for when done reading SB */
ckmakmsg( tn_msg,TN_MSG_LEN,
"TELNET RCVD SB ",TELOPT(opt),
" DATA(buffer-full) ",NULL);
- tn_hex(tn_msg,TN_MSG_LEN,&sb[1],n-3);
+ tn_hex((CHAR *)tn_msg,TN_MSG_LEN,&sb[1],n-3);
if (flag == 2)
ckstrncat(tn_msg," SE",TN_MSG_LEN);
else if (flag == 3)
#endif /* NOICP */
#endif /* IKS_OPTION */
+ /* if (!IS_TELNET()) return(7); */
/* Have IAC, read command character. */
#endif /* CK_SSL */
if (!TELOPT_OK(x)) {
- hexdump("unknown telnet subnegotiation",sb,n);
+ ckhexdump("unknown telnet subnegotiation",sb,n);
break;
} else if ( !(TELOPT_ME(x) || TELOPT_U(x)) ) {
- hexdump("telnet option not negotiated",sb,n);
+ ckhexdump("telnet option not negotiated",sb,n);
if (!tn_sb_bug)
break;
if (TELOPT_UNANSWERED_WILL(x)) {
rc = -3;
} else {
#ifndef NOLOCAL
- extern tls_norestore;
+ extern int tls_norestore;
#endif /* NOLOCAL */
printf("TLS failed: Disconnecting...\n");
#ifdef CK_ENCRYPTION
#endif /* CK_AUTHENTICATION */
#ifdef CK_ENCRYPTION
case TELOPT_ENCRYPTION:
- if (ck_tn_sb_encrypt(sb, n) < 0) {
+ if (ck_tn_sb_encrypt((char *)sb, n) < 0) {
if (TELOPT_U_MODE(x) == TN_NG_MU ||
TELOPT_ME_MODE(x) == TN_NG_MU)
{
/* tn_doop */ {
int x=0, y=0;
+ debug(F101,"tn_doop char","",z);
+ debug(F101,"tn_doop ttnproto","",ttnproto);
+
+ if (!IS_TELNET()) return(3);
+
+#ifdef CK_SSL
+ debug(F101,"tn_doop ssl_raw_flag","",ssl_raw_flag);
+ if (ssl_raw_flag || tls_raw_flag) return(7);
+#endif /* CK_SSL */
+ debug(F100,"tn_doop ttnproto proceeding...","",0);
+
if (z != (CHAR) IAC) {
debug(F101,"tn_doop bad call","",z);
return(-1);
uu = localuidbuf;
}
- hexdump((CHAR *)"tn_snenv sb[]",sb,len);
+ ckhexdump((CHAR *)"tn_snenv sb[]",sb,len);
debug(F110,"tn_snenv uidbuf",uidbuf,0);
debug(F110,"tn_snenv localuidbuf",localuidbuf,0);
debug(F110,"tn_snenv tn_env_sys",tn_env_sys,0);
char * disp;
int i,rc;
+ /* if (!IS_TELNET()) return(0); */
+
if (!TELOPT_U(TELOPT_FORWARD_X)) return(0);
#ifdef CK_SSL
if (TELOPT_SB(TELOPT_START_TLS).start_tls.me_follows) {
* the localhost; the screen defaults to 0
*/
- disp = tn_get_display();
+ disp = (char *)tn_get_display();
if (disp) {
int colon,dot;
colon = ckindex(":",disp,0,0,1);
int i,rc; /* Worker. */
char *ttloc;
+ /* if (!IS_TELNET()) return(0); */
+
if (!TELOPT_ME(TELOPT_SNDLOC)) return(0);
#ifdef CK_SSL
/* tnc_init */ {
debug(F100,"tnc_init","",0);
+ /* if (!IS_TELNET()) return(0); */
+
if (tnc_signature) {
free(tnc_signature);
tnc_signature = NULL;
int baud, datasize, parity, stopsize, oflow, iflow;
CONST char * signature;
+ /* if (!IS_TELNET()) return(0); */
+
debug(F100,"tnc_sndcomport","",0);
signature = tnc_get_signature();
baud = tnc_get_baud();
#endif /* CK_ANSIC */
/* tnc_wait */ {
int rc, tn_wait_save = tn_wait_flg;
+
+ /* if (!IS_TELNET()) return(0); */
+
debug(F111,"tnc_wait","begin",ms);
if ( ms )
TELOPT_SB(TELOPT_COMPORT).comport.wait_for_ms = 1;