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. */
37 connection_fatal(error_msg
);
38 } /* Otherwise, the remote side closed the connection normally. */
42 static int rlogin_receive(Plug plug
, int urgent
, char *data
, int len
)
52 * We should flush everything (aka Telnet SYNCH) if we see
53 * 0x02, and we should turn off and on _local_ flow control
54 * on 0x10 and 0x20 respectively. I'm not convinced it's
59 * Main rlogin protocol. This is really simple: the first
60 * byte is expected to be NULL and is ignored, and the rest
63 static int firstbyte
= 1;
65 if (data
[0] == '\0') {
77 * Called to set up the rlogin connection.
79 * Returns an error message, or NULL on success.
81 * Also places the canonical host name into `realhost'. It must be
82 * freed by the caller.
84 static char *rlogin_init(char *host
, int port
, char **realhost
)
86 static struct plug_function_table fn_table
= {
89 }, *fn_table_ptr
= &fn_table
;
97 addr
= sk_namelookup(host
, realhost
);
98 if ((err
= sk_addr_error(addr
)))
102 port
= 513; /* default rlogin port */
107 s
= sk_new(addr
, port
, 1, 0, &fn_table_ptr
);
108 if ((err
= sk_socket_error(s
)))
114 * Send local username, remote username, terminal/speed
121 sk_write(s
, cfg
.localusername
, strlen(cfg
.localusername
));
123 sk_write(s
, cfg
.username
, strlen(cfg
.username
));
125 sk_write(s
, cfg
.termtype
, strlen(cfg
.termtype
));
127 for (p
= cfg
.termspeed
; isdigit(*p
); p
++);
128 sk_write(s
, cfg
.termspeed
, p
- cfg
.termspeed
);
129 rlogin_bufsize
= sk_write(s
, &z
, 1);
136 * Called to send data down the rlogin connection.
138 static int rlogin_send(char *buf
, int len
)
143 rlogin_bufsize
= sk_write(s
, buf
, len
);
145 return rlogin_bufsize
;
149 * Called to query the current socket sendability status.
151 static int rlogin_sendbuffer(void)
153 return rlogin_bufsize
;
157 * Called to set the size of the window
159 static void rlogin_size(void)
161 char b
[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
167 rlogin_bufsize
= sk_write(s
, b
, 12);
172 * Send rlogin special codes.
174 static void rlogin_special(Telnet_Special code
)
180 static Socket
rlogin_socket(void)
185 static int rlogin_sendok(void)
190 static void rlogin_unthrottle(int backlog
)
192 sk_set_frozen(s
, backlog
> RLOGIN_MAX_BACKLOG
);
195 static int rlogin_ldisc(int option
)
200 Backend rlogin_backend
= {