In SSH, we now send terminal speeds to the server when requesting a pty
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Sat, 24 Apr 2004 20:05:03 +0000 (20:05 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Sat, 24 Apr 2004 20:05:03 +0000 (20:05 +0000)
(we didn't before) - `ssh-termspeed'.
In the process, I've removed the individual controls on the Telnet and
Rlogin panels and replaced them with one on the Connection panel (since they
were backed by the same storage anyway).
The terminal speeds sent in SSH are logged in the Event Log.

git-svn-id: svn://svn.tartarus.org/sgt/putty@4133 cda61777-01e9-0310-a592-d414129be87e

config.c
doc/config.but
ssh.c
winhelp.h

index 25c6f47..03dcbf7 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1261,6 +1261,10 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
                         HELPCTX(connection_termtype),
                         dlg_stdeditbox_handler, I(offsetof(Config,termtype)),
                         I(sizeof(((Config *)0)->termtype)));
+           ctrl_editbox(s, "Terminal speeds", 's', 50,
+                        HELPCTX(connection_termspeed),
+                        dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
+                        I(sizeof(((Config *)0)->termspeed)));
            ctrl_editbox(s, "Auto-login username", 'u', 50,
                         HELPCTX(connection_username),
                         dlg_stdeditbox_handler, I(offsetof(Config,username)),
@@ -1365,10 +1369,6 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
        if (!midsession) {
            s = ctrl_getset(b, "Connection/Telnet", "data",
                            "Data to send to the server");
-           ctrl_editbox(s, "Terminal-speed string", 's', 50,
-                        HELPCTX(telnet_termspeed),
-                        dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
-                        I(sizeof(((Config *)0)->termspeed)));
            ctrl_text(s, "Environment variables:", HELPCTX(telnet_environ));
            ctrl_columns(s, 2, 80, 20);
            ed = (struct environ_data *)
@@ -1437,10 +1437,6 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
 
        s = ctrl_getset(b, "Connection/Rlogin", "data",
                        "Data to send to the server");
-       ctrl_editbox(s, "Terminal-speed string", 's', 50,
-                    HELPCTX(rlogin_termspeed),
-                    dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
-                    I(sizeof(((Config *)0)->termspeed)));
        ctrl_editbox(s, "Local username:", 'l', 50,
                     HELPCTX(rlogin_localuser),
                     dlg_stdeditbox_handler, I(offsetof(Config,localusername)),
index 0d88ef7..9dc8ae1 100644 (file)
@@ -1,4 +1,4 @@
-\versionid $Id: config.but,v 1.76 2004/03/05 19:01:45 jacob Exp $
+\versionid $Id: config.but,v 1.77 2004/04/24 20:05:03 jacob Exp $
 
 \C{config} Configuring PuTTY
 
@@ -1380,6 +1380,30 @@ If you're not sure whether a problem is due to the terminal type
 setting or not, you probably need to consult the manual for your
 application or your server.
 
+\S{config-termspeed} \q{Terminal speeds}
+
+\cfg{winhelp-topic}{connection.termspeed}
+
+The Telnet, Rlogin, and SSH protocols allow the client to specify
+terminal speeds to the server.
+
+This parameter does \e{not} affect the actual speed of the connection,
+which is always \q{as fast as possible}; it is just a hint that is
+sometimes used by server software to modify its behaviour. For
+instance, if a slow speed is indicated, the server may switch to a
+less bandwidth-hungry display mode.
+
+The value is usually meaningless in a network environment, but
+PuTTY lets you configure it, in case you find the server is reacting
+badly to the default value.
+
+The format is a pair of numbers separated by a comma, for instance,
+\c{38400,38400}. The first number represents the output speed
+(\e{from} the server), and the second is the input speed (\e{to} the
+server). (Only the first is used in the Rlogin protocol.)
+
+This option has no effect on Raw connections.
+
 \S{config-username} \q{Auto-login username}
 
 \cfg{winhelp-topic}{connection.username}
@@ -1615,20 +1639,11 @@ configuration fields will be ignored.
 The Telnet panel allows you to configure options that only apply to
 Telnet sessions.
 
-\S{config-termspeed} \q{Terminal-speed string}
-
-\cfg{winhelp-topic}{telnet.termspeed}
-
-Telnet allows the client to send a text string that describes the
-terminal speed. PuTTY lets you configure this, in case you find the
-server is reacting badly to the default value. (I'm not aware of any
-servers that do have a problem with it.)
-
 \S{config-environ} Setting environment variables on the server
 
 \cfg{winhelp-topic}{telnet.environ}
 
-The Telnet protocol also provides a means for the client to pass
+The Telnet protocol provides a means for the client to pass
 environment variables to the server. Many Telnet servers have
 stopped supporting this feature due to security flaws, but PuTTY
 still supports it for the benefit of any servers which have found
@@ -1720,15 +1735,6 @@ turning this option off to see if it helps.
 The Rlogin panel allows you to configure options that only apply to
 Rlogin sessions.
 
-\S{config-rlogin-termspeed} \q{Terminal-speed string}
-
-\cfg{winhelp-topic}{rlogin.termspeed}
-
-Like Telnet, Rlogin allows the client to send a text string that
-describes the terminal speed. PuTTY lets you configure this, in case
-you find the server is reacting badly to the default value. (I'm not
-aware of any servers that do have a problem with it.)
-
 \S{config-rlogin-localuser} \q{Local username}
 
 \cfg{winhelp-topic}{rlogin.localuser}
diff --git a/ssh.c b/ssh.c
index 89fa785..ea008dd 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -3401,11 +3401,19 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
     }
 
     if (!ssh->cfg.nopty) {
+       /* Unpick the terminal-speed string. */
+       /* XXX perhaps we should allow no speeds to be sent. */
+       int ospeed = 38400, ispeed = 38400; /* last-resort defaults */
+       sscanf(ssh->cfg.termspeed, "%d,%d", &ospeed, &ispeed);
+       /* Send the pty request. */
        send_packet(ssh, SSH1_CMSG_REQUEST_PTY,
                    PKT_STR, ssh->cfg.termtype,
                    PKT_INT, ssh->term_height,
                    PKT_INT, ssh->term_width,
-                   PKT_INT, 0, PKT_INT, 0, PKT_CHAR, 0, PKT_END);
+                   PKT_INT, 0, PKT_INT, 0, /* width,height in pixels */
+                   PKT_CHAR, 192, PKT_INT, ispeed, /* TTY_OP_ISPEED */
+                   PKT_CHAR, 193, PKT_INT, ospeed, /* TTY_OP_OSPEED */
+                   PKT_CHAR, 0, PKT_END);
        ssh->state = SSH_STATE_INTERMED;
        do {
            crReturnV;
@@ -3418,7 +3426,8 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
            c_write_str(ssh, "Server refused to allocate pty\r\n");
            ssh->editing = ssh->echoing = 1;
        }
-       logevent("Allocated pty");
+       logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
+                 ospeed, ispeed);
     } else {
        ssh->editing = ssh->echoing = 1;
     }
@@ -5583,6 +5592,11 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
      * Now allocate a pty for the session.
      */
     if (!ssh->cfg.nopty) {
+       /* Unpick the terminal-speed string. */
+       /* XXX perhaps we should allow no speeds to be sent. */
+       int ospeed = 38400, ispeed = 38400; /* last-resort defaults */
+       sscanf(ssh->cfg.termspeed, "%d,%d", &ospeed, &ispeed);
+       /* Build the pty request. */
        ssh2_pkt_init(ssh, SSH2_MSG_CHANNEL_REQUEST);
        ssh2_pkt_adduint32(ssh, ssh->mainchan->remoteid);       /* recipient channel */
        ssh2_pkt_addstring(ssh, "pty-req");
@@ -5593,7 +5607,11 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
        ssh2_pkt_adduint32(ssh, 0);            /* pixel width */
        ssh2_pkt_adduint32(ssh, 0);            /* pixel height */
        ssh2_pkt_addstring_start(ssh);
-       ssh2_pkt_addstring_data(ssh, "\0", 1);  /* TTY_OP_END, no special options */
+       ssh2_pkt_addbyte(ssh, 128);            /* TTY_OP_ISPEED */
+       ssh2_pkt_adduint32(ssh, ispeed);
+       ssh2_pkt_addbyte(ssh, 129);            /* TTY_OP_OSPEED */
+       ssh2_pkt_adduint32(ssh, ospeed);
+       ssh2_pkt_addstring_data(ssh, "\0", 1); /* TTY_OP_END */
        ssh2_pkt_send(ssh);
        ssh->state = SSH_STATE_INTERMED;
 
@@ -5618,7 +5636,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
            c_write_str(ssh, "Server refused to allocate pty\r\n");
            ssh->editing = ssh->echoing = 1;
        } else {
-           logevent("Allocated pty");
+           logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
+                     ospeed, ispeed);
        }
     } else {
        ssh->editing = ssh->echoing = 1;
index 8d69573..3f72fce 100644 (file)
--- a/winhelp.h
+++ b/winhelp.h
@@ -57,6 +57,7 @@
 #define WINHELP_CTX_appearance_hidemouse "appearance.hidemouse"
 #define WINHELP_CTX_appearance_border "appearance.border"
 #define WINHELP_CTX_connection_termtype "connection.termtype"
+#define WINHELP_CTX_connection_termspeed "connection.termspeed"
 #define WINHELP_CTX_connection_username "connection.username"
 #define WINHELP_CTX_connection_keepalive "connection.keepalive"
 #define WINHELP_CTX_connection_nodelay "connection.nodelay"
 #define WINHELP_CTX_proxy_auth "proxy.auth"
 #define WINHELP_CTX_proxy_command "proxy.command"
 #define WINHELP_CTX_proxy_socksver "proxy.socksver"
-#define WINHELP_CTX_telnet_termspeed "telnet.termspeed"
 #define WINHELP_CTX_telnet_environ "telnet.environ"
 #define WINHELP_CTX_telnet_oldenviron "telnet.oldenviron"
 #define WINHELP_CTX_telnet_passive "telnet.passive"
 #define WINHELP_CTX_telnet_specialkeys "telnet.specialkeys"
 #define WINHELP_CTX_telnet_newline "telnet.newline"
-#define WINHELP_CTX_rlogin_termspeed "rlogin.termspeed"
 #define WINHELP_CTX_rlogin_localuser "rlogin.localuser"
 #define WINHELP_CTX_ssh_nopty "ssh.nopty"
 #define WINHELP_CTX_ssh_ciphers "ssh.ciphers"