2002-11-19 12:29:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Simon Tatham
|
|
|
|
* Copyright (c) 1999 Ben Harris
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use,
|
|
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following
|
|
|
|
* conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
|
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
|
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* PuTTY test backends */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "putty.h"
|
|
|
|
|
2018-09-12 08:10:51 +00:00
|
|
|
static const char *null_init(Frontend *, Backend **, Conf *, const char *, int,
|
2018-09-12 07:55:39 +00:00
|
|
|
char **, int, int);
|
2018-09-12 08:10:51 +00:00
|
|
|
static const char *loop_init(Frontend *, Backend **, Conf *, const char *, int,
|
2018-09-12 07:55:39 +00:00
|
|
|
char **, int, int);
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_free(Backend *);
|
|
|
|
static void loop_free(Backend *);
|
|
|
|
static void null_reconfig(Backend *, Conf *);
|
|
|
|
static int null_send(Backend *, const char *, int);
|
|
|
|
static int loop_send(Backend *, const char *, int);
|
|
|
|
static int null_sendbuffer(Backend *);
|
|
|
|
static void null_size(Backend *, int, int);
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 08:35:52 +00:00
|
|
|
static void null_special(Backend *, SessionSpecialCode, int);
|
|
|
|
static const SessionSpecial *null_get_specials(Backend *);
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_connected(Backend *);
|
|
|
|
static int null_exitcode(Backend *);
|
|
|
|
static int null_sendok(Backend *);
|
|
|
|
static int null_ldisc(Backend *, int);
|
|
|
|
static void null_provide_ldisc(Backend *, Ldisc *);
|
|
|
|
static void null_provide_logctx(Backend *, LogContext *);
|
|
|
|
static void null_unthrottle(Backend *, int);
|
|
|
|
static int null_cfg_info(Backend *);
|
|
|
|
|
2018-10-05 06:03:46 +00:00
|
|
|
const struct BackendVtable null_backend = {
|
2003-01-15 23:30:21 +00:00
|
|
|
null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size,
|
2007-02-18 15:59:38 +00:00
|
|
|
null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
|
2004-12-29 12:32:25 +00:00
|
|
|
null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
|
2015-09-25 10:46:28 +00:00
|
|
|
null_cfg_info, NULL /* test_for_upstream */, "null", -1, 0
|
2002-11-19 12:29:45 +00:00
|
|
|
};
|
|
|
|
|
2018-10-05 06:03:46 +00:00
|
|
|
const struct BackendVtable loop_backend = {
|
2003-01-15 23:30:21 +00:00
|
|
|
loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size,
|
2007-02-18 15:59:38 +00:00
|
|
|
null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
|
2004-12-29 12:32:25 +00:00
|
|
|
null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
|
2015-09-25 10:46:28 +00:00
|
|
|
null_cfg_info, NULL /* test_for_upstream */, "loop", -1, 0
|
2002-11-19 12:29:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct loop_state {
|
2018-09-12 08:10:51 +00:00
|
|
|
Frontend *frontend;
|
2018-09-11 15:23:38 +00:00
|
|
|
Backend backend;
|
2002-11-19 12:29:45 +00:00
|
|
|
};
|
|
|
|
|
2018-09-12 08:10:51 +00:00
|
|
|
static const char *null_init(Frontend *frontend, Backend **backend_handle,
|
2018-09-12 07:55:39 +00:00
|
|
|
Conf *conf, const char *host, int port,
|
2004-06-20 17:07:38 +00:00
|
|
|
char **realhost, int nodelay, int keepalive) {
|
2018-09-11 15:23:38 +00:00
|
|
|
*backend_handle = NULL;
|
2002-11-19 12:29:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-12 08:10:51 +00:00
|
|
|
static const char *loop_init(Frontend *frontend, Backend **backend_handle,
|
2018-09-12 07:55:39 +00:00
|
|
|
Conf *conf, const char *host, int port,
|
2004-06-20 17:07:38 +00:00
|
|
|
char **realhost, int nodelay, int keepalive) {
|
2003-03-29 16:14:26 +00:00
|
|
|
struct loop_state *st = snew(struct loop_state);
|
2002-11-19 12:29:45 +00:00
|
|
|
|
2018-09-12 08:10:51 +00:00
|
|
|
st->frontend = frontend;
|
2018-09-11 15:23:38 +00:00
|
|
|
*backend_handle = &st->backend;
|
2002-11-23 19:58:55 +00:00
|
|
|
return NULL;
|
2002-11-19 12:29:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_free(Backend *be)
|
2003-01-15 23:30:21 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void loop_free(Backend *be)
|
2003-01-15 23:30:21 +00:00
|
|
|
{
|
2018-09-11 15:23:38 +00:00
|
|
|
struct loop_state *st = FROMFIELD(be, struct loop_state, backend);
|
2003-01-15 23:30:21 +00:00
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
sfree(st);
|
2003-01-15 23:30:21 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_reconfig(Backend *be, Conf *conf) {
|
2003-01-12 16:11:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_send(Backend *be, const char *buf, int len) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int loop_send(Backend *be, const char *buf, int len) {
|
|
|
|
struct loop_state *st = FROMFIELD(be, struct loop_state, backend);
|
2002-11-19 12:29:45 +00:00
|
|
|
|
2018-09-12 08:10:51 +00:00
|
|
|
return from_backend(st->frontend, 0, buf, len);
|
2002-11-19 12:29:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_sendbuffer(Backend *be) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_size(Backend *be, int width, int height) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 08:35:52 +00:00
|
|
|
static void null_special(Backend *be, SessionSpecialCode code, int arg) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 08:35:52 +00:00
|
|
|
static const SessionSpecial *null_get_specials (Backend *be) {
|
2003-04-05 14:32:58 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_connected(Backend *be) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
2007-02-18 15:59:38 +00:00
|
|
|
return 0;
|
2002-11-19 12:29:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_exitcode(Backend *be) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_sendok(Backend *be) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_unthrottle(Backend *be, int backlog) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_ldisc(Backend *be, int option) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_provide_ldisc (Backend *be, Ldisc *ldisc) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static void null_provide_logctx(Backend *be, LogContext *logctx) {
|
2002-11-19 12:29:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
static int null_cfg_info(Backend *be)
|
2004-12-29 12:32:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-19 12:29:45 +00:00
|
|
|
/*
|
|
|
|
* Emacs magic:
|
|
|
|
* Local Variables:
|
|
|
|
* c-file-style: "simon"
|
|
|
|
* End:
|
|
|
|
*/
|