15 #define RLOGIN_MAX_BACKLOG 4096
17 static Socket s = NULL;
18 static int rlogin_bufsize;
20 static void rlogin_size(void);
22 static void c_write(char *buf, int len)
24 int backlog = from_backend(0, buf, len);
25 sk_set_frozen(s, backlog > RLOGIN_MAX_BACKLOG);
28 static int rlogin_closing(Plug plug, char *error_msg, int error_code,
36 /* A socket error has occurred. */
38 connection_fatal("%s", error_msg);
39 } /* Otherwise, the remote side closed the connection normally. */
43 static int rlogin_receive(Plug plug, int urgent, char *data, int len)
53 * We should flush everything (aka Telnet SYNCH) if we see
54 * 0x02, and we should turn off and on _local_ flow control
55 * on 0x10 and 0x20 respectively. I'm not convinced it's
60 * Main rlogin protocol. This is really simple: the first
61 * byte is expected to be NULL and is ignored, and the rest
64 static int firstbyte = 1;
66 if (data[0] == '\0') {
78 static void rlogin_sent(Plug plug, int bufsize)
80 rlogin_bufsize = bufsize;
84 * Called to set up the rlogin connection.
86 * Returns an error message, or NULL on success.
88 * Also places the canonical host name into `realhost'. It must be
89 * freed by the caller.
91 static char *rlogin_init(char *host, int port, char **realhost, int nodelay)
93 static struct plug_function_table fn_table = {
97 }, *fn_table_ptr = &fn_table;
107 sprintf(buf, "Looking up host \"%.170s\"", host);
110 addr = sk_namelookup(host, realhost);
111 if ((err = sk_addr_error(addr)))
115 port = 513; /* default rlogin port */
121 char buf[200], addrbuf[100];
122 sk_getaddr(addr, addrbuf, 100);
123 sprintf(buf, "Connecting to %.100s port %d", addrbuf, port);
126 s = new_connection(addr, *realhost, port, 1, 0, nodelay, &fn_table_ptr);
127 if ((err = sk_socket_error(s)))
133 * Send local username, remote username, terminal/speed
140 sk_write(s, cfg.localusername, strlen(cfg.localusername));
142 sk_write(s, cfg.username, strlen(cfg.username));
144 sk_write(s, cfg.termtype, strlen(cfg.termtype));
146 for (p = cfg.termspeed; isdigit(*p); p++);
147 sk_write(s, cfg.termspeed, p - cfg.termspeed);
148 rlogin_bufsize = sk_write(s, &z, 1);
155 * Called to send data down the rlogin connection.
157 static int rlogin_send(char *buf, int len)
162 rlogin_bufsize = sk_write(s, buf, len);
164 return rlogin_bufsize;
168 * Called to query the current socket sendability status.
170 static int rlogin_sendbuffer(void)
172 return rlogin_bufsize;
176 * Called to set the size of the window
178 static void rlogin_size(void)
180 char b[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
189 rlogin_bufsize = sk_write(s, b, 12);
194 * Send rlogin special codes.
196 static void rlogin_special(Telnet_Special code)
202 static Socket rlogin_socket(void)
207 static int rlogin_sendok(void)
212 static void rlogin_unthrottle(int backlog)
214 sk_set_frozen(s, backlog > RLOGIN_MAX_BACKLOG);
217 static int rlogin_ldisc(int option)
222 static int rlogin_exitcode(void)
224 /* If we ever implement RSH, we'll probably need to do this properly */
228 Backend rlogin_backend = {