X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=telnet.c;h=c4b0413272be222e5e3c0806805c0f13a6a90ad6;hb=510f49e405e71ba5c97875e7a019364e1ef5fac9;hp=8717a9723d3689c3dd9a97304c6b9b3cdbdc09f4;hpb=d0ca84935e7f1ea686b57f75c13d883c4093e758;p=PuTTY.git diff --git a/telnet.c b/telnet.c index 8717a972..c4b04132 100644 --- a/telnet.c +++ b/telnet.c @@ -113,7 +113,7 @@ enum { TELOPTS(telnet_enum) dummy=0 }; ( (x) != IAC && \ (telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR)) -static char *telopt(int opt) +static const char *telopt(int opt) { #define telnet_str(x,y) case TELOPT_##x: return #x; switch (opt) { @@ -197,6 +197,7 @@ typedef struct telnet_tag { int sb_opt, sb_len; unsigned char *sb_buf; int sb_size; + int session_started; enum { TOP_LEVEL, SEENIAC, SEENWILL, SEENWONT, SEENDO, SEENDONT, @@ -212,14 +213,14 @@ typedef struct telnet_tag { #define SB_DELTA 1024 -static void c_write(Telnet telnet, char *buf, int len) +static void c_write(Telnet telnet, const char *buf, int len) { int backlog; backlog = from_backend(telnet->frontend, 0, buf, len); sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG); } -static void log_option(Telnet telnet, char *sender, int cmd, int option) +static void log_option(Telnet telnet, const char *sender, int cmd, int option) { char *buf; /* @@ -652,17 +653,9 @@ static void telnet_log(Plug plug, int type, SockAddr addr, int port, const char *error_msg, int error_code) { Telnet telnet = (Telnet) plug; - char addrbuf[256], *msg; - - sk_getaddr(addr, addrbuf, lenof(addrbuf)); - - if (type == 0) - msg = dupprintf("Connecting to %s port %d", addrbuf, port); - else - msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg); - - logevent(telnet->frontend, msg); - sfree(msg); + backend_socket_log(telnet->frontend, type, addr, port, + error_msg, error_code, telnet->conf, + telnet->session_started); } static int telnet_closing(Plug plug, const char *error_msg, int error_code, @@ -696,6 +689,7 @@ static int telnet_receive(Plug plug, int urgent, char *data, int len) Telnet telnet = (Telnet) plug; if (urgent) telnet->in_synch = TRUE; + telnet->session_started = TRUE; do_telnet_read(telnet, data, len); return 1; } @@ -715,7 +709,7 @@ static void telnet_sent(Plug plug, int bufsize) * freed by the caller. */ static const char *telnet_init(void *frontend_handle, void **backend_handle, - Conf *conf, char *host, int port, + Conf *conf, const char *host, int port, char **realhost, int nodelay, int keepalive) { static const struct plug_function_table fn_table = { @@ -746,22 +740,15 @@ static const char *telnet_init(void *frontend_handle, void **backend_handle, telnet->state = TOP_LEVEL; telnet->ldisc = NULL; telnet->pinger = NULL; + telnet->session_started = TRUE; *backend_handle = telnet; /* * Try to find host. */ - { - char *buf; - addressfamily = conf_get_int(telnet->conf, CONF_addressfamily); - buf = dupprintf("Looking up host \"%s\"%s", host, - (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" : - (addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" : - ""))); - logevent(telnet->frontend, buf); - sfree(buf); - } - addr = name_lookup(host, port, realhost, telnet->conf, addressfamily); + addressfamily = conf_get_int(telnet->conf, CONF_addressfamily); + addr = name_lookup(host, port, realhost, telnet->conf, addressfamily, + telnet->frontend, "Telnet connection"); if ((err = sk_addr_error(addr)) != NULL) { sk_addr_free(addr); return err; @@ -855,7 +842,7 @@ static void telnet_reconfig(void *handle, Conf *conf) /* * Called to send data down the Telnet connection. */ -static int telnet_send(void *handle, char *buf, int len) +static int telnet_send(void *handle, const char *buf, int len) { Telnet telnet = (Telnet) handle; unsigned char *p, *end; @@ -1129,6 +1116,7 @@ Backend telnet_backend = { telnet_provide_logctx, telnet_unthrottle, telnet_cfg_info, + NULL /* test_for_upstream */, "telnet", PROT_TELNET, 23