diff --git a/agentf.c b/agentf.c index 4069fee8..dc5bec01 100644 --- a/agentf.c +++ b/agentf.c @@ -147,29 +147,29 @@ static void agentf_send_eof(Channel *chan); static char *agentf_log_close_msg(Channel *chan); static void agentf_set_input_wanted(Channel *chan, bool wanted); -static const struct ChannelVtable agentf_channelvt = { - agentf_free, - chan_remotely_opened_confirmation, - chan_remotely_opened_failure, - agentf_send, - agentf_send_eof, - agentf_set_input_wanted, - agentf_log_close_msg, - chan_default_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable agentf_channelvt = { + .free = agentf_free, + .open_confirmation = chan_remotely_opened_confirmation, + .open_failed = chan_remotely_opened_failure, + .send = agentf_send, + .send_eof = agentf_send_eof, + .set_input_wanted = agentf_set_input_wanted, + .log_close_msg = agentf_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; Channel *agentf_new(SshChannel *c) diff --git a/clicons.c b/clicons.c index 49811a05..2e88544f 100644 --- a/clicons.c +++ b/clicons.c @@ -6,9 +6,9 @@ #include "putty.h" static const LogPolicyVtable console_cli_logpolicy_vt = { - console_eventlog, - console_askappend, - console_logging_error, - cmdline_lp_verbose, + .eventlog = console_eventlog, + .askappend = console_askappend, + .logging_error = console_logging_error, + .verbose = cmdline_lp_verbose, }; LogPolicy console_cli_logpolicy[1] = {{ &console_cli_logpolicy_vt }}; diff --git a/cmdgen.c b/cmdgen.c index 1b46e283..cd469fa0 100644 --- a/cmdgen.c +++ b/cmdgen.c @@ -64,13 +64,13 @@ static void cmdgen_progress_report_phase_complete(ProgressReceiver *prog) } static const ProgressReceiverVtable cmdgen_progress_vt = { - cmdgen_progress_add_linear, - cmdgen_progress_add_probabilistic, - null_progress_ready, - cmdgen_progress_start_phase, - cmdgen_progress_report, - cmdgen_progress_report_attempt, - cmdgen_progress_report_phase_complete, + .add_linear = cmdgen_progress_add_linear, + .add_probabilistic = cmdgen_progress_add_probabilistic, + .ready = null_progress_ready, + .start_phase = cmdgen_progress_start_phase, + .report = cmdgen_progress_report, + .report_attempt = cmdgen_progress_report_attempt, + .report_phase_complete = cmdgen_progress_report_phase_complete, }; static ProgressReceiver cmdgen_progress = { .vt = &cmdgen_progress_vt }; diff --git a/errsock.c b/errsock.c index fc1bb956..6f26629d 100644 --- a/errsock.c +++ b/errsock.c @@ -45,14 +45,11 @@ static SocketPeerInfo *sk_error_peer_info(Socket *s) } static const SocketVtable ErrorSocket_sockvt = { - sk_error_plug, - sk_error_close, - NULL /* write */, - NULL /* write_oob */, - NULL /* write_eof */, - NULL /* set_frozen */, - sk_error_socket_error, - sk_error_peer_info, + .plug = sk_error_plug, + .close = sk_error_close, + .socket_error = sk_error_socket_error, + .peer_info = sk_error_peer_info, + /* other methods are NULL */ }; Socket *new_error_socket_consume_string(Plug *plug, char *errmsg) diff --git a/fuzzterm.c b/fuzzterm.c index b5d98975..f6a6414a 100644 --- a/fuzzterm.c +++ b/fuzzterm.c @@ -101,34 +101,34 @@ static const char *fuzz_get_title(TermWin *tw, bool icon) { return "moo"; } static bool fuzz_is_utf8(TermWin *tw) { return true; } static const TermWinVtable fuzz_termwin_vt = { - fuzz_setup_draw_ctx, - fuzz_draw_text, - fuzz_draw_cursor, - fuzz_draw_trust_sigil, - fuzz_char_width, - fuzz_free_draw_ctx, - fuzz_set_cursor_pos, - fuzz_set_raw_mouse_mode, - fuzz_set_scrollbar, - fuzz_bell, - fuzz_clip_write, - fuzz_clip_request_paste, - fuzz_refresh, - fuzz_request_resize, - fuzz_set_title, - fuzz_set_icon_title, - fuzz_set_minimised, - fuzz_is_minimised, - fuzz_set_maximised, - fuzz_move, - fuzz_set_zorder, - fuzz_palette_get, - fuzz_palette_set, - fuzz_palette_reset, - fuzz_get_pos, - fuzz_get_pixels, - fuzz_get_title, - fuzz_is_utf8, + .setup_draw_ctx = fuzz_setup_draw_ctx, + .draw_text = fuzz_draw_text, + .draw_cursor = fuzz_draw_cursor, + .draw_trust_sigil = fuzz_draw_trust_sigil, + .char_width = fuzz_char_width, + .free_draw_ctx = fuzz_free_draw_ctx, + .set_cursor_pos = fuzz_set_cursor_pos, + .set_raw_mouse_mode = fuzz_set_raw_mouse_mode, + .set_scrollbar = fuzz_set_scrollbar, + .bell = fuzz_bell, + .clip_write = fuzz_clip_write, + .clip_request_paste = fuzz_clip_request_paste, + .refresh = fuzz_refresh, + .request_resize = fuzz_request_resize, + .set_title = fuzz_set_title, + .set_icon_title = fuzz_set_icon_title, + .set_minimised = fuzz_set_minimised, + .is_minimised = fuzz_is_minimised, + .set_maximised = fuzz_set_maximised, + .move = fuzz_move, + .set_zorder = fuzz_set_zorder, + .palette_get = fuzz_palette_get, + .palette_set = fuzz_palette_set, + .palette_reset = fuzz_palette_reset, + .get_pos = fuzz_get_pos, + .get_pixels = fuzz_get_pixels, + .get_title = fuzz_get_title, + .is_utf8 = fuzz_is_utf8, }; void ldisc_send(Ldisc *ldisc, const void *buf, int len, bool interactive) {} diff --git a/mainchan.c b/mainchan.c index 3aad40d6..41c3bb72 100644 --- a/mainchan.c +++ b/mainchan.c @@ -26,29 +26,29 @@ static bool mainchan_rcvd_exit_signal_numeric( Channel *chan, int signum, bool core_dumped, ptrlen msg); static void mainchan_request_response(Channel *chan, bool success); -static const struct ChannelVtable mainchan_channelvt = { - mainchan_free, - mainchan_open_confirmation, - mainchan_open_failure, - mainchan_send, - mainchan_send_eof, - mainchan_set_input_wanted, - mainchan_log_close_msg, - chan_default_want_close, - mainchan_rcvd_exit_status, - mainchan_rcvd_exit_signal, - mainchan_rcvd_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - mainchan_request_response, +static const ChannelVtable mainchan_channelvt = { + .free = mainchan_free, + .open_confirmation = mainchan_open_confirmation, + .open_failed = mainchan_open_failure, + .send = mainchan_send, + .send_eof = mainchan_send_eof, + .set_input_wanted = mainchan_set_input_wanted, + .log_close_msg = mainchan_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = mainchan_rcvd_exit_status, + .rcvd_exit_signal = mainchan_rcvd_exit_signal, + .rcvd_exit_signal_numeric = mainchan_rcvd_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = mainchan_request_response, }; typedef enum MainChanType { diff --git a/nullplug.c b/nullplug.c index 721cedb0..953f0348 100644 --- a/nullplug.c +++ b/nullplug.c @@ -27,11 +27,10 @@ static void nullplug_sent(Plug *plug, size_t bufsize) } static const PlugVtable nullplug_plugvt = { - nullplug_socket_log, - nullplug_closing, - nullplug_receive, - nullplug_sent, - NULL + .log = nullplug_socket_log, + .closing = nullplug_closing, + .receive = nullplug_receive, + .sent = nullplug_sent, }; static Plug nullplug_plug = { &nullplug_plugvt }; diff --git a/pageant.c b/pageant.c index 6a9c43b1..7b1eb207 100644 --- a/pageant.c +++ b/pageant.c @@ -442,9 +442,9 @@ static void signop_coroutine(PageantAsyncOp *pao) crFinishFreedV; } -static struct PageantAsyncOpVtable signop_vtable = { - signop_coroutine, - signop_free, +static const PageantAsyncOpVtable signop_vtable = { + .coroutine = signop_coroutine, + .free = signop_free, }; static void fail_requests_for_key(PageantKey *pk, const char *reason) @@ -572,9 +572,9 @@ static void immop_coroutine(PageantAsyncOp *pao) crFinishFreedV; } -static struct PageantAsyncOpVtable immop_vtable = { - immop_coroutine, - immop_free, +static const PageantAsyncOpVtable immop_vtable = { + .coroutine = immop_coroutine, + .free = immop_free, }; static bool reencrypt_key(PageantKey *pk) @@ -1482,10 +1482,10 @@ static bool pageant_conn_ask_passphrase( return pageant_listener_client_ask_passphrase(pcs->plc, dlgid, msg); } -static const struct PageantClientVtable pageant_connection_clientvt = { - pageant_conn_log, - pageant_conn_got_response, - pageant_conn_ask_passphrase, +static const PageantClientVtable pageant_connection_clientvt = { + .log = pageant_conn_log, + .got_response = pageant_conn_got_response, + .ask_passphrase = pageant_conn_ask_passphrase, }; static void pageant_conn_receive( @@ -1569,11 +1569,9 @@ static void pageant_listen_closing(Plug *plug, const char *error_msg, } static const PlugVtable pageant_connection_plugvt = { - NULL, /* no log function, because that's for outgoing connections */ - pageant_conn_closing, - pageant_conn_receive, - pageant_conn_sent, - NULL /* no accepting function, because we've already done it */ + .closing = pageant_conn_closing, + .receive = pageant_conn_receive, + .sent = pageant_conn_sent, }; static int pageant_listen_accepting(Plug *plug, @@ -1620,11 +1618,8 @@ static int pageant_listen_accepting(Plug *plug, } static const PlugVtable pageant_listener_plugvt = { - NULL, /* no log function, because that's for outgoing connections */ - pageant_listen_closing, - NULL, /* no receive function on a listening socket */ - NULL, /* no sent function on a listening socket */ - pageant_listen_accepting + .closing = pageant_listen_closing, + .accepting = pageant_listen_accepting, }; struct pageant_listen_state *pageant_listener_new( @@ -1680,10 +1675,10 @@ static bool internal_client_ask_passphrase( return false; } -static const struct PageantClientVtable internal_clientvt = { - NULL /* log */, - internal_client_got_response, - internal_client_ask_passphrase, +static const PageantClientVtable internal_clientvt = { + .log = NULL, + .got_response = internal_client_got_response, + .ask_passphrase = internal_client_ask_passphrase, }; typedef struct PageantClientOp { diff --git a/portfwd.c b/portfwd.c index d0c4a50e..f3349b80 100644 --- a/portfwd.c +++ b/portfwd.c @@ -427,11 +427,10 @@ static void pfd_sent(Plug *plug, size_t bufsize) } static const PlugVtable PortForwarding_plugvt = { - pfd_log, - pfd_closing, - pfd_receive, - pfd_sent, - NULL + .log = pfd_log, + .closing = pfd_closing, + .receive = pfd_receive, + .sent = pfd_sent, }; static void pfd_chan_free(Channel *chan); @@ -443,29 +442,29 @@ static void pfd_send_eof(Channel *chan); static void pfd_set_input_wanted(Channel *chan, bool wanted); static char *pfd_log_close_msg(Channel *chan); -static const struct ChannelVtable PortForwarding_channelvt = { - pfd_chan_free, - pfd_open_confirmation, - pfd_open_failure, - pfd_send, - pfd_send_eof, - pfd_set_input_wanted, - pfd_log_close_msg, - chan_default_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable PortForwarding_channelvt = { + .free = pfd_chan_free, + .open_confirmation = pfd_open_confirmation, + .open_failed = pfd_open_failure, + .send = pfd_send, + .send_eof = pfd_send_eof, + .set_input_wanted = pfd_set_input_wanted, + .log_close_msg = pfd_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; Channel *portfwd_raw_new(ConnectionLayer *cl, Plug **plug, bool start_ready) @@ -551,11 +550,9 @@ static int pfl_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) } static const PlugVtable PortListener_plugvt = { - pfl_log, - pfl_closing, - NULL, /* recv */ - NULL, /* send */ - pfl_accepting + .log = pfl_log, + .closing = pfl_closing, + .accepting = pfl_accepting, }; /* diff --git a/proxy.c b/proxy.c index 7d4be079..6f6f05a0 100644 --- a/proxy.c +++ b/proxy.c @@ -371,23 +371,23 @@ SockAddr *name_lookup(const char *host, int port, char **canonicalname, } } -static const struct SocketVtable ProxySocket_sockvt = { - sk_proxy_plug, - sk_proxy_close, - sk_proxy_write, - sk_proxy_write_oob, - sk_proxy_write_eof, - sk_proxy_set_frozen, - sk_proxy_socket_error, - NULL, /* peer_info */ +static const SocketVtable ProxySocket_sockvt = { + .plug = sk_proxy_plug, + .close = sk_proxy_close, + .write = sk_proxy_write, + .write_oob = sk_proxy_write_oob, + .write_eof = sk_proxy_write_eof, + .set_frozen = sk_proxy_set_frozen, + .socket_error = sk_proxy_socket_error, + .peer_info = NULL, }; -static const struct PlugVtable ProxySocket_plugvt = { - plug_proxy_log, - plug_proxy_closing, - plug_proxy_receive, - plug_proxy_sent, - plug_proxy_accepting +static const PlugVtable ProxySocket_plugvt = { + .log = plug_proxy_log, + .closing = plug_proxy_closing, + .receive = plug_proxy_receive, + .sent = plug_proxy_sent, + .accepting = plug_proxy_accepting }; Socket *new_connection(SockAddr *addr, const char *hostname, diff --git a/pscp.c b/pscp.c index 96db467a..b983169f 100644 --- a/pscp.c +++ b/pscp.c @@ -63,27 +63,27 @@ static size_t pscp_output(Seat *, bool is_stderr, const void *, size_t); static bool pscp_eof(Seat *); static const SeatVtable pscp_seat_vt = { - pscp_output, - pscp_eof, - filexfer_get_userpass_input, - nullseat_notify_remote_exit, - console_connection_fatal, - nullseat_update_specials_menu, - nullseat_get_ttymode, - nullseat_set_busy_status, - console_verify_ssh_host_key, - console_confirm_weak_crypto_primitive, - console_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - nullseat_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - nullseat_get_window_pixel_size, - console_stripctrl_new, - nullseat_set_trust_status_vacuously, - cmdline_seat_verbose, - nullseat_interactive_no, - nullseat_get_cursor_position, + .output = pscp_output, + .eof = pscp_eof, + .get_userpass_input = filexfer_get_userpass_input, + .notify_remote_exit = nullseat_notify_remote_exit, + .connection_fatal = console_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = nullseat_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = console_verify_ssh_host_key, + .confirm_weak_crypto_primitive = console_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = console_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = nullseat_get_window_pixel_size, + .stripctrl_new = console_stripctrl_new, + .set_trust_status = nullseat_set_trust_status_vacuously, + .verbose = cmdline_seat_verbose, + .interactive = nullseat_interactive_no, + .get_cursor_position = nullseat_get_cursor_position, }; static Seat pscp_seat[1] = {{ &pscp_seat_vt }}; diff --git a/psftp.c b/psftp.c index 99e0e12e..6bdf01e3 100644 --- a/psftp.c +++ b/psftp.c @@ -45,27 +45,27 @@ static size_t psftp_output(Seat *, bool is_stderr, const void *, size_t); static bool psftp_eof(Seat *); static const SeatVtable psftp_seat_vt = { - psftp_output, - psftp_eof, - filexfer_get_userpass_input, - nullseat_notify_remote_exit, - console_connection_fatal, - nullseat_update_specials_menu, - nullseat_get_ttymode, - nullseat_set_busy_status, - console_verify_ssh_host_key, - console_confirm_weak_crypto_primitive, - console_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - nullseat_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - nullseat_get_window_pixel_size, - console_stripctrl_new, - nullseat_set_trust_status_vacuously, - cmdline_seat_verbose, - nullseat_interactive_yes, - nullseat_get_cursor_position, + .output = psftp_output, + .eof = psftp_eof, + .get_userpass_input = filexfer_get_userpass_input, + .notify_remote_exit = nullseat_notify_remote_exit, + .connection_fatal = console_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = nullseat_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = console_verify_ssh_host_key, + .confirm_weak_crypto_primitive = console_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = console_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = nullseat_get_window_pixel_size, + .stripctrl_new = console_stripctrl_new, + .set_trust_status = nullseat_set_trust_status_vacuously, + .verbose = cmdline_seat_verbose, + .interactive = nullseat_interactive_yes, + .get_cursor_position = nullseat_get_cursor_position, }; static Seat psftp_seat[1] = {{ &psftp_seat_vt }}; diff --git a/psocks.c b/psocks.c index ddf3d4b1..68418fb7 100644 --- a/psocks.c +++ b/psocks.c @@ -72,31 +72,9 @@ static SshChannel *psocks_lportfwd_open( ConnectionLayer *cl, const char *hostname, int port, const char *description, const SocketPeerInfo *pi, Channel *chan); -static const struct ConnectionLayerVtable psocks_clvt = { - NULL /* rportfwd_alloc */, - NULL /* rportfwd_remove */, - psocks_lportfwd_open, - NULL /* session_open */, - NULL /* serverside_x11_open */, - NULL /* serverside_agent_open */, - NULL /* add_x11_display */, - NULL /* add_sharing_x11_display */, - NULL /* remove_sharing_x11_display */, - NULL /* send_packet_from_downstream */, - NULL /* alloc_sharing_channel */, - NULL /* delete_sharing_channel */, - NULL /* sharing_queue_global_request */, - NULL /* sharing_no_more_downstreams */, - NULL /* agent_forwarding_permitted */, - NULL /* terminal_size */, - NULL /* stdout_unthrottle */, - NULL /* stdin_backlog */, - NULL /* throttle_all_channels */, - NULL /* ldisc_option */, - NULL /* set_ldisc_option */, - NULL /* enable_x_fwd */, - NULL /* enable_agent_fwd */, - NULL /* set_wants_user_input */, +static const ConnectionLayerVtable psocks_clvt = { + .lportfwd_open = psocks_lportfwd_open, + /* everything else is NULL */ }; static size_t psocks_sc_write(SshChannel *sc, bool is_stderr, const void *, @@ -105,28 +83,12 @@ static void psocks_sc_write_eof(SshChannel *sc); static void psocks_sc_initiate_close(SshChannel *sc, const char *err); static void psocks_sc_unthrottle(SshChannel *sc, size_t bufsize); -static const struct SshChannelVtable psocks_scvt = { - psocks_sc_write, - psocks_sc_write_eof, - psocks_sc_initiate_close, - psocks_sc_unthrottle, - NULL /* get_conf */, - NULL /* window_override_removed */, - NULL /* x11_sharing_handover */, - NULL /* send_exit_status */, - NULL /* send_exit_signal */, - NULL /* send_exit_signal_numeric */, - NULL /* request_x11_forwarding */, - NULL /* request_agent_forwarding */, - NULL /* request_pty */, - NULL /* send_env_var */, - NULL /* start_shell */, - NULL /* start_command */, - NULL /* start_subsystem */, - NULL /* send_serial_break */, - NULL /* send_signal */, - NULL /* send_terminal_size_change */, - NULL /* hint_channel_is_simple */, +static const SshChannelVtable psocks_scvt = { + .write = psocks_sc_write, + .write_eof = psocks_sc_write_eof, + .initiate_close = psocks_sc_initiate_close, + .unthrottle = psocks_sc_unthrottle, + /* all the rest are NULL */ }; static void psocks_plug_log(Plug *p, PlugLogType type, SockAddr *addr, @@ -138,11 +100,10 @@ static void psocks_plug_receive(Plug *p, int urgent, static void psocks_plug_sent(Plug *p, size_t bufsize); static const PlugVtable psocks_plugvt = { - psocks_plug_log, - psocks_plug_closing, - psocks_plug_receive, - psocks_plug_sent, - NULL /* accepting */, + .log = psocks_plug_log, + .closing = psocks_plug_closing, + .receive = psocks_plug_receive, + .sent = psocks_plug_sent, }; static void psocks_conn_log(psocks_connection *conn, const char *fmt, ...) diff --git a/raw.c b/raw.c index 92f28f94..6058793b 100644 --- a/raw.c +++ b/raw.c @@ -105,10 +105,10 @@ static void raw_sent(Plug *plug, size_t bufsize) } static const PlugVtable Raw_plugvt = { - raw_log, - raw_closing, - raw_receive, - raw_sent + .log = raw_log, + .closing = raw_closing, + .receive = raw_receive, + .sent = raw_sent, }; /* @@ -307,25 +307,25 @@ static int raw_cfg_info(Backend *be) return 0; } -const struct BackendVtable raw_backend = { - raw_init, - raw_free, - raw_reconfig, - raw_send, - raw_sendbuffer, - raw_size, - raw_special, - raw_get_specials, - raw_connected, - raw_exitcode, - raw_sendok, - raw_ldisc, - raw_provide_ldisc, - raw_unthrottle, - raw_cfg_info, - NULL /* test_for_upstream */, - "raw", "Raw", - PROT_RAW, - 0, - 0 +const BackendVtable raw_backend = { + .init = raw_init, + .free = raw_free, + .reconfig = raw_reconfig, + .send = raw_send, + .sendbuffer = raw_sendbuffer, + .size = raw_size, + .special = raw_special, + .get_specials = raw_get_specials, + .connected = raw_connected, + .exitcode = raw_exitcode, + .sendok = raw_sendok, + .ldisc_option_state = raw_ldisc, + .provide_ldisc = raw_provide_ldisc, + .unthrottle = raw_unthrottle, + .cfg_info = raw_cfg_info, + .test_for_upstream = NULL, + .id = "raw", + .displayname = "Raw", + .protocol = PROT_RAW, + .default_port = 0, }; diff --git a/rlogin.c b/rlogin.c index 99fed39d..cc95a3db 100644 --- a/rlogin.c +++ b/rlogin.c @@ -139,10 +139,10 @@ static void rlogin_startup(Rlogin *rlogin, const char *ruser) } static const PlugVtable Rlogin_plugvt = { - rlogin_log, - rlogin_closing, - rlogin_receive, - rlogin_sent + .log = rlogin_log, + .closing = rlogin_closing, + .receive = rlogin_receive, + .sent = rlogin_sent, }; /* @@ -405,25 +405,25 @@ static int rlogin_cfg_info(Backend *be) return 0; } -const struct BackendVtable rlogin_backend = { - rlogin_init, - rlogin_free, - rlogin_reconfig, - rlogin_send, - rlogin_sendbuffer, - rlogin_size, - rlogin_special, - rlogin_get_specials, - rlogin_connected, - rlogin_exitcode, - rlogin_sendok, - rlogin_ldisc, - rlogin_provide_ldisc, - rlogin_unthrottle, - rlogin_cfg_info, - NULL /* test_for_upstream */, - "rlogin", "Rlogin", - PROT_RLOGIN, - 513, - 0 +const BackendVtable rlogin_backend = { + .init = rlogin_init, + .free = rlogin_free, + .reconfig = rlogin_reconfig, + .send = rlogin_send, + .sendbuffer = rlogin_sendbuffer, + .size = rlogin_size, + .special = rlogin_special, + .get_specials = rlogin_get_specials, + .connected = rlogin_connected, + .exitcode = rlogin_exitcode, + .sendok = rlogin_sendok, + .ldisc_option_state = rlogin_ldisc, + .provide_ldisc = rlogin_provide_ldisc, + .unthrottle = rlogin_unthrottle, + .cfg_info = rlogin_cfg_info, + .test_for_upstream = NULL, + .id = "rlogin", + .displayname = "Rlogin", + .protocol = PROT_RLOGIN, + .default_port = 513, }; diff --git a/scpserver.c b/scpserver.c index 3a136286..3c6e4559 100644 --- a/scpserver.c +++ b/scpserver.c @@ -334,15 +334,15 @@ static void scp_reply_attrs( reply->attrs = attrs; } -static const struct SftpReplyBuilderVtable ScpReplyReceiver_vt = { - scp_reply_ok, - scp_reply_error, - scp_reply_simple_name, - scp_reply_name_count, - scp_reply_full_name, - scp_reply_handle, - scp_reply_data, - scp_reply_attrs, +static const SftpReplyBuilderVtable ScpReplyReceiver_vt = { + .reply_ok = scp_reply_ok, + .reply_error = scp_reply_error, + .reply_simple_name = scp_reply_simple_name, + .reply_name_count = scp_reply_name_count, + .reply_full_name = scp_reply_full_name, + .reply_handle = scp_reply_handle, + .reply_data = scp_reply_data, + .reply_attrs = scp_reply_attrs, }; static void scp_reply_setup(ScpReplyReceiver *reply) @@ -487,11 +487,11 @@ static size_t scp_source_send(ScpServer *s, const void *data, size_t length); static void scp_source_eof(ScpServer *s); static void scp_source_throttle(ScpServer *s, bool throttled); -static struct ScpServerVtable ScpSource_ScpServer_vt = { - scp_source_free, - scp_source_send, - scp_source_throttle, - scp_source_eof, +static const ScpServerVtable ScpSource_ScpServer_vt = { + .free = scp_source_free, + .send = scp_source_send, + .throttle = scp_source_throttle, + .eof = scp_source_eof, }; static ScpSource *scp_source_new( @@ -1003,11 +1003,11 @@ static size_t scp_sink_send(ScpServer *s, const void *data, size_t length); static void scp_sink_eof(ScpServer *s); static void scp_sink_throttle(ScpServer *s, bool throttled) {} -static struct ScpServerVtable ScpSink_ScpServer_vt = { - scp_sink_free, - scp_sink_send, - scp_sink_throttle, - scp_sink_eof, +static const ScpServerVtable ScpSink_ScpServer_vt = { + .free = scp_sink_free, + .send = scp_sink_send, + .throttle = scp_sink_throttle, + .eof = scp_sink_eof, }; static void scp_sink_coroutine(ScpSink *scp); @@ -1297,11 +1297,11 @@ static size_t scp_error_send(ScpServer *s, const void *data, size_t length) static void scp_error_eof(ScpServer *s) {} static void scp_error_throttle(ScpServer *s, bool throttled) {} -static struct ScpServerVtable ScpError_ScpServer_vt = { - scp_error_free, - scp_error_send, - scp_error_throttle, - scp_error_eof, +static const ScpServerVtable ScpError_ScpServer_vt = { + .free = scp_error_free, + .send = scp_error_send, + .throttle = scp_error_throttle, + .eof = scp_error_eof, }; static void scp_error_send_message_cb(void *vscp) diff --git a/sesschan.c b/sesschan.c index 223c77d7..e9acaae9 100644 --- a/sesschan.c +++ b/sesschan.c @@ -72,29 +72,29 @@ static bool sesschan_change_window_size( Channel *chan, unsigned width, unsigned height, unsigned pixwidth, unsigned pixheight); -static const struct ChannelVtable sesschan_channelvt = { - sesschan_free, - chan_remotely_opened_confirmation, - chan_remotely_opened_failure, - sesschan_send, - sesschan_send_eof, - sesschan_set_input_wanted, - sesschan_log_close_msg, - sesschan_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - sesschan_run_shell, - sesschan_run_command, - sesschan_run_subsystem, - sesschan_enable_x11_forwarding, - sesschan_enable_agent_forwarding, - sesschan_allocate_pty, - sesschan_set_env, - sesschan_send_break, - sesschan_send_signal, - sesschan_change_window_size, - chan_no_request_response, +static const ChannelVtable sesschan_channelvt = { + .free = sesschan_free, + .open_confirmation = chan_remotely_opened_confirmation, + .open_failed = chan_remotely_opened_failure, + .send = sesschan_send, + .send_eof = sesschan_send_eof, + .set_input_wanted = sesschan_set_input_wanted, + .log_close_msg = sesschan_log_close_msg, + .want_close = sesschan_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = sesschan_run_shell, + .run_command = sesschan_run_command, + .run_subsystem = sesschan_run_subsystem, + .enable_x11_forwarding = sesschan_enable_x11_forwarding, + .enable_agent_forwarding = sesschan_enable_agent_forwarding, + .allocate_pty = sesschan_allocate_pty, + .set_env = sesschan_set_env, + .send_break = sesschan_send_break, + .send_signal = sesschan_send_signal, + .change_window_size = sesschan_change_window_size, + .request_response = chan_no_request_response, }; static size_t sftp_chan_send( @@ -102,29 +102,29 @@ static size_t sftp_chan_send( static void sftp_chan_send_eof(Channel *chan); static char *sftp_log_close_msg(Channel *chan); -static const struct ChannelVtable sftp_channelvt = { - sesschan_free, - chan_remotely_opened_confirmation, - chan_remotely_opened_failure, - sftp_chan_send, - sftp_chan_send_eof, - sesschan_set_input_wanted, - sftp_log_close_msg, - chan_default_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable sftp_channelvt = { + .free = sesschan_free, + .open_confirmation = chan_remotely_opened_confirmation, + .open_failed = chan_remotely_opened_failure, + .send = sftp_chan_send, + .send_eof = sftp_chan_send_eof, + .set_input_wanted = sesschan_set_input_wanted, + .log_close_msg = sftp_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; static size_t scp_chan_send( @@ -133,29 +133,29 @@ static void scp_chan_send_eof(Channel *chan); static void scp_set_input_wanted(Channel *chan, bool wanted); static char *scp_log_close_msg(Channel *chan); -static const struct ChannelVtable scp_channelvt = { - sesschan_free, - chan_remotely_opened_confirmation, - chan_remotely_opened_failure, - scp_chan_send, - scp_chan_send_eof, - scp_set_input_wanted, - scp_log_close_msg, - chan_default_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable scp_channelvt = { + .free = sesschan_free, + .open_confirmation = chan_remotely_opened_confirmation, + .open_failed = chan_remotely_opened_failure, + .send = scp_chan_send, + .send_eof = scp_chan_send_eof, + .set_input_wanted = scp_set_input_wanted, + .log_close_msg = scp_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; static void sesschan_eventlog(LogPolicy *lp, const char *event) {} @@ -165,10 +165,10 @@ static int sesschan_askappend( void (*callback)(void *ctx, int result), void *ctx) { return 2; } static const LogPolicyVtable sesschan_logpolicy_vt = { - sesschan_eventlog, - sesschan_askappend, - sesschan_logging_error, - null_lp_verbose_no, + .eventlog = sesschan_eventlog, + .askappend = sesschan_askappend, + .logging_error = sesschan_logging_error, + .verbose = null_lp_verbose_no, }; static size_t sesschan_seat_output( @@ -179,27 +179,27 @@ static void sesschan_connection_fatal(Seat *seat, const char *message); static bool sesschan_get_window_pixel_size(Seat *seat, int *w, int *h); static const SeatVtable sesschan_seat_vt = { - sesschan_seat_output, - sesschan_seat_eof, - nullseat_get_userpass_input, - sesschan_notify_remote_exit, - sesschan_connection_fatal, - nullseat_update_specials_menu, - nullseat_get_ttymode, - nullseat_set_busy_status, - nullseat_verify_ssh_host_key, - nullseat_confirm_weak_crypto_primitive, - nullseat_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - nullseat_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - sesschan_get_window_pixel_size, - nullseat_stripctrl_new, - nullseat_set_trust_status, - nullseat_verbose_no, - nullseat_interactive_no, - nullseat_get_cursor_position, + .output = sesschan_seat_output, + .eof = sesschan_seat_eof, + .get_userpass_input = nullseat_get_userpass_input, + .notify_remote_exit = sesschan_notify_remote_exit, + .connection_fatal = sesschan_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = nullseat_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = nullseat_verify_ssh_host_key, + .confirm_weak_crypto_primitive = nullseat_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = nullseat_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = sesschan_get_window_pixel_size, + .stripctrl_new = nullseat_stripctrl_new, + .set_trust_status = nullseat_set_trust_status, + .verbose = nullseat_verbose_no, + .interactive = nullseat_interactive_no, + .get_cursor_position = nullseat_get_cursor_position, }; Channel *sesschan_new(SshChannel *c, LogContext *logctx, @@ -383,11 +383,9 @@ static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) } static const PlugVtable xfwd_plugvt = { - fwd_log, - fwd_closing, - NULL, /* recv */ - NULL, /* send */ - xfwd_accepting, + .log = fwd_log, + .closing = fwd_closing, + .accepting = xfwd_accepting, }; bool sesschan_enable_x11_forwarding( @@ -457,11 +455,9 @@ static int agentfwd_accepting( } static const PlugVtable agentfwd_plugvt = { - fwd_log, - fwd_closing, - NULL, /* recv */ - NULL, /* send */ - agentfwd_accepting, + .log = fwd_log, + .closing = fwd_closing, + .accepting = agentfwd_accepting, }; bool sesschan_enable_agent_forwarding(Channel *chan) diff --git a/sftpserver.c b/sftpserver.c index 91711d59..ba216872 100644 --- a/sftpserver.c +++ b/sftpserver.c @@ -267,13 +267,13 @@ static void default_reply_attrs( put_fxp_attrs(d->pkt, attrs); } -const struct SftpReplyBuilderVtable DefaultSftpReplyBuilder_vt = { - default_reply_ok, - default_reply_error, - default_reply_simple_name, - default_reply_name_count, - default_reply_full_name, - default_reply_handle, - default_reply_data, - default_reply_attrs, +const SftpReplyBuilderVtable DefaultSftpReplyBuilder_vt = { + .reply_ok = default_reply_ok, + .reply_error = default_reply_error, + .reply_simple_name = default_reply_simple_name, + .reply_name_count = default_reply_name_count, + .reply_full_name = default_reply_full_name, + .reply_handle = default_reply_handle, + .reply_data = default_reply_data, + .reply_attrs = default_reply_attrs, }; diff --git a/ssh.c b/ssh.c index eafae7e8..46451142 100644 --- a/ssh.c +++ b/ssh.c @@ -692,11 +692,10 @@ static bool ssh_test_for_upstream(const char *host, int port, Conf *conf) } static const PlugVtable Ssh_plugvt = { - ssh_socket_log, - ssh_closing, - ssh_receive, - ssh_sent, - NULL + .log = ssh_socket_log, + .closing = ssh_closing, + .receive = ssh_receive, + .sent = ssh_sent, }; /* @@ -1180,47 +1179,47 @@ void ssh_got_fallback_cmd(Ssh *ssh) ssh->fallback_cmd = true; } -const struct BackendVtable ssh_backend = { - ssh_init, - ssh_free, - ssh_reconfig, - ssh_send, - ssh_sendbuffer, - ssh_size, - ssh_special, - ssh_get_specials, - ssh_connected, - ssh_return_exitcode, - ssh_sendok, - ssh_ldisc, - ssh_provide_ldisc, - ssh_unthrottle, - ssh_cfg_info, - ssh_test_for_upstream, - "ssh", "SSH", - PROT_SSH, - 22, - 0 +const BackendVtable ssh_backend = { + .init = ssh_init, + .free = ssh_free, + .reconfig = ssh_reconfig, + .send = ssh_send, + .sendbuffer = ssh_sendbuffer, + .size = ssh_size, + .special = ssh_special, + .get_specials = ssh_get_specials, + .connected = ssh_connected, + .exitcode = ssh_return_exitcode, + .sendok = ssh_sendok, + .ldisc_option_state = ssh_ldisc, + .provide_ldisc = ssh_provide_ldisc, + .unthrottle = ssh_unthrottle, + .cfg_info = ssh_cfg_info, + .test_for_upstream = ssh_test_for_upstream, + .id = "ssh", + .displayname = "SSH", + .protocol = PROT_SSH, + .default_port = 22, }; -const struct BackendVtable sshconn_backend = { - ssh_init, - ssh_free, - ssh_reconfig, - ssh_send, - ssh_sendbuffer, - ssh_size, - ssh_special, - ssh_get_specials, - ssh_connected, - ssh_return_exitcode, - ssh_sendok, - ssh_ldisc, - ssh_provide_ldisc, - ssh_unthrottle, - ssh_cfg_info, - ssh_test_for_upstream, - "ssh-connection", "Bare ssh-connection", - PROT_SSHCONN, - 0 +const BackendVtable sshconn_backend = { + .init = ssh_init, + .free = ssh_free, + .reconfig = ssh_reconfig, + .send = ssh_send, + .sendbuffer = ssh_sendbuffer, + .size = ssh_size, + .special = ssh_special, + .get_specials = ssh_get_specials, + .connected = ssh_connected, + .exitcode = ssh_return_exitcode, + .sendok = ssh_sendok, + .ldisc_option_state = ssh_ldisc, + .provide_ldisc = ssh_provide_ldisc, + .unthrottle = ssh_unthrottle, + .cfg_info = ssh_cfg_info, + .test_for_upstream = ssh_test_for_upstream, + .id = "ssh-connection", + .displayname = "Bare ssh-connection", + .protocol = PROT_SSHCONN, }; diff --git a/ssh.h b/ssh.h index 5eba5fd8..40641342 100644 --- a/ssh.h +++ b/ssh.h @@ -209,6 +209,8 @@ struct ssh_rportfwd { }; void free_rportfwd(struct ssh_rportfwd *rpf); +typedef struct ConnectionLayerVtable ConnectionLayerVtable; + struct ConnectionLayerVtable { /* Allocate and free remote-to-local port forwardings, called by * PortFwdManager or by connection sharing */ @@ -782,9 +784,9 @@ static inline void ssh_hash_digest_nondestructive(ssh_hash *h, /* Handy macros for defining all those text-name fields at once */ #define HASHALG_NAMES_BARE(base) \ - base, NULL, base -#define HASHALG_NAMES_ANNOTATED(base, annotation) \ - base, annotation, base " (" annotation ")" + .text_basename = base, .annotation = NULL, .text_name = base +#define HASHALG_NAMES_ANNOTATED(base, ann) \ + .text_basename = base, .annotation = ann, .text_name = base " (" ann ")" void hash_simple(const ssh_hashalg *alg, ptrlen data, void *output); diff --git a/ssh1bpp.c b/ssh1bpp.c index 2fd684c5..46eccbeb 100644 --- a/ssh1bpp.c +++ b/ssh1bpp.c @@ -36,13 +36,13 @@ static void ssh1_bpp_queue_disconnect(BinaryPacketProtocol *bpp, const char *msg, int category); static PktOut *ssh1_bpp_new_pktout(int type); -static const struct BinaryPacketProtocolVtable ssh1_bpp_vtable = { - ssh1_bpp_free, - ssh1_bpp_handle_input, - ssh1_bpp_handle_output, - ssh1_bpp_new_pktout, - ssh1_bpp_queue_disconnect, - 0xFFFFFFFF, /* no special packet size limit for this bpp */ +static const BinaryPacketProtocolVtable ssh1_bpp_vtable = { + .free = ssh1_bpp_free, + .handle_input = ssh1_bpp_handle_input, + .handle_output = ssh1_bpp_handle_output, + .new_pktout = ssh1_bpp_new_pktout, + .queue_disconnect = ssh1_bpp_queue_disconnect, + .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */ }; BinaryPacketProtocol *ssh1_bpp_new(LogContext *logctx) diff --git a/ssh1connection-client.c b/ssh1connection-client.c index bc207ce9..b9504940 100644 --- a/ssh1connection-client.c +++ b/ssh1connection-client.c @@ -441,28 +441,21 @@ static void ssh1mainchan_write_eof(SshChannel *sc) pq_push(s->ppl.out_pq, pktout); } -static const struct SshChannelVtable ssh1mainchan_vtable = { - ssh1mainchan_write, - ssh1mainchan_write_eof, - NULL /* unclean_close */, - NULL /* unthrottle */, - NULL /* get_conf */, - NULL /* window_override_removed is only used by SSH-2 sharing */, - NULL /* x11_sharing_handover, likewise */, - NULL /* send_exit_status */, - NULL /* send_exit_signal */, - NULL /* send_exit_signal_numeric */, - ssh1mainchan_request_x11_forwarding, - ssh1mainchan_request_agent_forwarding, - ssh1mainchan_request_pty, - ssh1mainchan_send_env_var, - ssh1mainchan_start_shell, - ssh1mainchan_start_command, - ssh1mainchan_start_subsystem, - ssh1mainchan_send_serial_break, - ssh1mainchan_send_signal, - ssh1mainchan_send_terminal_size_change, - ssh1mainchan_hint_channel_is_simple, +static const SshChannelVtable ssh1mainchan_vtable = { + .write = ssh1mainchan_write, + .write_eof = ssh1mainchan_write_eof, + .request_x11_forwarding = ssh1mainchan_request_x11_forwarding, + .request_agent_forwarding = ssh1mainchan_request_agent_forwarding, + .request_pty = ssh1mainchan_request_pty, + .send_env_var = ssh1mainchan_send_env_var, + .start_shell = ssh1mainchan_start_shell, + .start_command = ssh1mainchan_start_command, + .start_subsystem = ssh1mainchan_start_subsystem, + .send_serial_break = ssh1mainchan_send_serial_break, + .send_signal = ssh1mainchan_send_signal, + .send_terminal_size_change = ssh1mainchan_send_terminal_size_change, + .hint_channel_is_simple = ssh1mainchan_hint_channel_is_simple, + /* other methods are NULL */ }; static void ssh1_session_confirm_callback(void *vctx) diff --git a/ssh1connection-server.c b/ssh1connection-server.c index a03b132d..4d55abe5 100644 --- a/ssh1connection-server.c +++ b/ssh1connection-server.c @@ -21,28 +21,13 @@ static void ssh1sesschan_send_exit_status(SshChannel *c, int status); static void ssh1sesschan_send_exit_signal( SshChannel *c, ptrlen signame, bool core_dumped, ptrlen msg); -static const struct SshChannelVtable ssh1sesschan_vtable = { - ssh1sesschan_write, - ssh1sesschan_write_eof, - ssh1sesschan_initiate_close, - NULL /* unthrottle */, - NULL /* get_conf */, - NULL /* window_override_removed is only used by SSH-2 sharing */, - NULL /* x11_sharing_handover, likewise */, - ssh1sesschan_send_exit_status, - ssh1sesschan_send_exit_signal, - NULL /* send_exit_signal_numeric */, - NULL /* request_x11_forwarding */, - NULL /* request_agent_forwarding */, - NULL /* request_pty */, - NULL /* send_env_var */, - NULL /* start_shell */, - NULL /* start_command */, - NULL /* start_subsystem */, - NULL /* send_serial_break */, - NULL /* send_signal */, - NULL /* send_terminal_size_change */, - NULL /* hint_channel_is_simple */, +static const SshChannelVtable ssh1sesschan_vtable = { + .write = ssh1sesschan_write, + .write_eof = ssh1sesschan_write_eof, + .initiate_close = ssh1sesschan_initiate_close, + .send_exit_status = ssh1sesschan_send_exit_status, + .send_exit_signal = ssh1sesschan_send_exit_signal, + /* everything else is NULL */ }; void ssh1connection_server_configure( diff --git a/ssh1connection.c b/ssh1connection.c index b3e200b3..d2a9039f 100644 --- a/ssh1connection.c +++ b/ssh1connection.c @@ -35,16 +35,16 @@ static bool ssh1_connection_want_user_input(PacketProtocolLayer *ppl); static void ssh1_connection_got_user_input(PacketProtocolLayer *ppl); static void ssh1_connection_reconfigure(PacketProtocolLayer *ppl, Conf *conf); -static const struct PacketProtocolLayerVtable ssh1_connection_vtable = { - ssh1_connection_free, - ssh1_connection_process_queue, - ssh1_common_get_specials, - ssh1_connection_special_cmd, - ssh1_connection_want_user_input, - ssh1_connection_got_user_input, - ssh1_connection_reconfigure, - ssh_ppl_default_queued_data_size, - NULL /* no layer names in SSH-1 */, +static const PacketProtocolLayerVtable ssh1_connection_vtable = { + .free = ssh1_connection_free, + .process_queue = ssh1_connection_process_queue, + .get_specials = ssh1_common_get_specials, + .special_cmd = ssh1_connection_special_cmd, + .want_user_input = ssh1_connection_want_user_input, + .got_user_input = ssh1_connection_got_user_input, + .reconfigure = ssh1_connection_reconfigure, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = NULL, /* no layer names in SSH-1 */ }; static void ssh1_rportfwd_remove( @@ -65,31 +65,25 @@ static void ssh1_enable_x_fwd(ConnectionLayer *cl); static void ssh1_enable_agent_fwd(ConnectionLayer *cl); static void ssh1_set_wants_user_input(ConnectionLayer *cl, bool wanted); -static const struct ConnectionLayerVtable ssh1_connlayer_vtable = { - ssh1_rportfwd_alloc, - ssh1_rportfwd_remove, - ssh1_lportfwd_open, - ssh1_session_open, - ssh1_serverside_x11_open, - ssh1_serverside_agent_open, - ssh1_add_x11_display, - NULL /* add_sharing_x11_display */, - NULL /* remove_sharing_x11_display */, - NULL /* send_packet_from_downstream */, - NULL /* alloc_sharing_channel */, - NULL /* delete_sharing_channel */, - NULL /* sharing_queue_global_request */, - NULL /* sharing_no_more_downstreams */, - ssh1_agent_forwarding_permitted, - ssh1_terminal_size, - ssh1_stdout_unthrottle, - ssh1_stdin_backlog, - ssh1_throttle_all_channels, - ssh1_ldisc_option, - ssh1_set_ldisc_option, - ssh1_enable_x_fwd, - ssh1_enable_agent_fwd, - ssh1_set_wants_user_input, +static const ConnectionLayerVtable ssh1_connlayer_vtable = { + .rportfwd_alloc = ssh1_rportfwd_alloc, + .rportfwd_remove = ssh1_rportfwd_remove, + .lportfwd_open = ssh1_lportfwd_open, + .session_open = ssh1_session_open, + .serverside_x11_open = ssh1_serverside_x11_open, + .serverside_agent_open = ssh1_serverside_agent_open, + .add_x11_display = ssh1_add_x11_display, + .agent_forwarding_permitted = ssh1_agent_forwarding_permitted, + .terminal_size = ssh1_terminal_size, + .stdout_unthrottle = ssh1_stdout_unthrottle, + .stdin_backlog = ssh1_stdin_backlog, + .throttle_all_channels = ssh1_throttle_all_channels, + .ldisc_option = ssh1_ldisc_option, + .set_ldisc_option = ssh1_set_ldisc_option, + .enable_x_fwd = ssh1_enable_x_fwd, + .enable_agent_fwd = ssh1_enable_agent_fwd, + .set_wants_user_input = ssh1_set_wants_user_input, + /* other methods are NULL */ }; static size_t ssh1channel_write( @@ -100,28 +94,14 @@ static void ssh1channel_unthrottle(SshChannel *c, size_t bufsize); static Conf *ssh1channel_get_conf(SshChannel *c); static void ssh1channel_window_override_removed(SshChannel *c) { /* ignore */ } -static const struct SshChannelVtable ssh1channel_vtable = { - ssh1channel_write, - ssh1channel_write_eof, - ssh1channel_initiate_close, - ssh1channel_unthrottle, - ssh1channel_get_conf, - ssh1channel_window_override_removed, - NULL /* x11_sharing_handover is only used by SSH-2 connection sharing */, - NULL /* send_exit_status */, - NULL /* send_exit_signal */, - NULL /* send_exit_signal_numeric */, - NULL /* request_x11_forwarding */, - NULL /* request_agent_forwarding */, - NULL /* request_pty */, - NULL /* send_env_var */, - NULL /* start_shell */, - NULL /* start_command */, - NULL /* start_subsystem */, - NULL /* send_serial_break */, - NULL /* send_signal */, - NULL /* send_terminal_size_change */, - NULL /* hint_channel_is_simple */, +static const SshChannelVtable ssh1channel_vtable = { + .write = ssh1channel_write, + .write_eof = ssh1channel_write_eof, + .initiate_close = ssh1channel_initiate_close, + .unthrottle = ssh1channel_unthrottle, + .get_conf = ssh1channel_get_conf, + .window_override_removed = ssh1channel_window_override_removed, + /* everything else is NULL */ }; static void ssh1_channel_try_eof(struct ssh1_channel *c); diff --git a/ssh1login-server.c b/ssh1login-server.c index d908bf97..a9de19a4 100644 --- a/ssh1login-server.c +++ b/ssh1login-server.c @@ -58,16 +58,16 @@ static void ssh1_login_server_got_user_input(PacketProtocolLayer *ppl) {} static void ssh1_login_server_reconfigure( PacketProtocolLayer *ppl, Conf *conf) {} -static const struct PacketProtocolLayerVtable ssh1_login_server_vtable = { - ssh1_login_server_free, - ssh1_login_server_process_queue, - ssh1_login_server_get_specials, - ssh1_login_server_special_cmd, - ssh1_login_server_want_user_input, - ssh1_login_server_got_user_input, - ssh1_login_server_reconfigure, - ssh_ppl_default_queued_data_size, - NULL /* no layer names in SSH-1 */, +static const PacketProtocolLayerVtable ssh1_login_server_vtable = { + .free = ssh1_login_server_free, + .process_queue = ssh1_login_server_process_queue, + .get_specials = ssh1_login_server_get_specials, + .special_cmd = ssh1_login_server_special_cmd, + .want_user_input = ssh1_login_server_want_user_input, + .got_user_input = ssh1_login_server_got_user_input, + .reconfigure = ssh1_login_server_reconfigure, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = NULL, /* no layer names in SSH-1 */ }; PacketProtocolLayer *ssh1_login_server_new( diff --git a/ssh1login.c b/ssh1login.c index 906abd09..764123c9 100644 --- a/ssh1login.c +++ b/ssh1login.c @@ -72,16 +72,16 @@ static bool ssh1_login_want_user_input(PacketProtocolLayer *ppl); static void ssh1_login_got_user_input(PacketProtocolLayer *ppl); static void ssh1_login_reconfigure(PacketProtocolLayer *ppl, Conf *conf); -static const struct PacketProtocolLayerVtable ssh1_login_vtable = { - ssh1_login_free, - ssh1_login_process_queue, - ssh1_common_get_specials, - ssh1_login_special_cmd, - ssh1_login_want_user_input, - ssh1_login_got_user_input, - ssh1_login_reconfigure, - ssh_ppl_default_queued_data_size, - NULL /* no layer names in SSH-1 */, +static const PacketProtocolLayerVtable ssh1_login_vtable = { + .free = ssh1_login_free, + .process_queue = ssh1_login_process_queue, + .get_specials = ssh1_common_get_specials, + .special_cmd = ssh1_login_special_cmd, + .want_user_input = ssh1_login_want_user_input, + .got_user_input = ssh1_login_got_user_input, + .reconfigure = ssh1_login_reconfigure, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = NULL, /* no layer names in SSH-1 */ }; static void ssh1_login_agent_query(struct ssh1_login_state *s, strbuf *req); diff --git a/ssh2bpp-bare.c b/ssh2bpp-bare.c index dd2f918a..93a7fa16 100644 --- a/ssh2bpp-bare.c +++ b/ssh2bpp-bare.c @@ -25,13 +25,15 @@ static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp); static void ssh2_bare_bpp_handle_output(BinaryPacketProtocol *bpp); static PktOut *ssh2_bare_bpp_new_pktout(int type); -static const struct BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = { - ssh2_bare_bpp_free, - ssh2_bare_bpp_handle_input, - ssh2_bare_bpp_handle_output, - ssh2_bare_bpp_new_pktout, - ssh2_bpp_queue_disconnect, /* in sshcommon.c */ - 0x4000, /* packet size limit, per protocol spec in sshshare.c comment */ +static const BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = { + .free = ssh2_bare_bpp_free, + .handle_input = ssh2_bare_bpp_handle_input, + .handle_output = ssh2_bare_bpp_handle_output, + .new_pktout = ssh2_bare_bpp_new_pktout, + .queue_disconnect = ssh2_bpp_queue_disconnect, /* in sshcommon.c */ + + /* packet size limit, per protocol spec in sshshare.c comment */ + .packet_size_limit = 0x4000, }; BinaryPacketProtocol *ssh2_bare_bpp_new(LogContext *logctx) diff --git a/ssh2bpp.c b/ssh2bpp.c index 97179ca9..756eac47 100644 --- a/ssh2bpp.c +++ b/ssh2bpp.c @@ -46,13 +46,13 @@ static void ssh2_bpp_handle_input(BinaryPacketProtocol *bpp); static void ssh2_bpp_handle_output(BinaryPacketProtocol *bpp); static PktOut *ssh2_bpp_new_pktout(int type); -static const struct BinaryPacketProtocolVtable ssh2_bpp_vtable = { - ssh2_bpp_free, - ssh2_bpp_handle_input, - ssh2_bpp_handle_output, - ssh2_bpp_new_pktout, - ssh2_bpp_queue_disconnect, /* in sshcommon.c */ - 0xFFFFFFFF, /* no special packet size limit for this bpp */ +static const BinaryPacketProtocolVtable ssh2_bpp_vtable = { + .free = ssh2_bpp_free, + .handle_input = ssh2_bpp_handle_input, + .handle_output = ssh2_bpp_handle_output, + .new_pktout = ssh2_bpp_new_pktout, + .queue_disconnect = ssh2_bpp_queue_disconnect, /* in sshcommon.c */ + .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */ }; BinaryPacketProtocol *ssh2_bpp_new( diff --git a/ssh2connection.c b/ssh2connection.c index 557bb2ad..74e96d15 100644 --- a/ssh2connection.c +++ b/ssh2connection.c @@ -22,16 +22,16 @@ static bool ssh2_connection_want_user_input(PacketProtocolLayer *ppl); static void ssh2_connection_got_user_input(PacketProtocolLayer *ppl); static void ssh2_connection_reconfigure(PacketProtocolLayer *ppl, Conf *conf); -static const struct PacketProtocolLayerVtable ssh2_connection_vtable = { - ssh2_connection_free, - ssh2_connection_process_queue, - ssh2_connection_get_specials, - ssh2_connection_special_cmd, - ssh2_connection_want_user_input, - ssh2_connection_got_user_input, - ssh2_connection_reconfigure, - ssh_ppl_default_queued_data_size, - "ssh-connection", +static const PacketProtocolLayerVtable ssh2_connection_vtable = { + .free = ssh2_connection_free, + .process_queue = ssh2_connection_process_queue, + .get_specials = ssh2_connection_get_specials, + .special_cmd = ssh2_connection_special_cmd, + .want_user_input = ssh2_connection_want_user_input, + .got_user_input = ssh2_connection_got_user_input, + .reconfigure = ssh2_connection_reconfigure, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = "ssh-connection", }; static SshChannel *ssh2_lportfwd_open( @@ -65,31 +65,31 @@ static void ssh2_enable_x_fwd(ConnectionLayer *cl); static void ssh2_enable_agent_fwd(ConnectionLayer *cl); static void ssh2_set_wants_user_input(ConnectionLayer *cl, bool wanted); -static const struct ConnectionLayerVtable ssh2_connlayer_vtable = { - ssh2_rportfwd_alloc, - ssh2_rportfwd_remove, - ssh2_lportfwd_open, - ssh2_session_open, - ssh2_serverside_x11_open, - ssh2_serverside_agent_open, - ssh2_add_x11_display, - ssh2_add_sharing_x11_display, - ssh2_remove_sharing_x11_display, - ssh2_send_packet_from_downstream, - ssh2_alloc_sharing_channel, - ssh2_delete_sharing_channel, - ssh2_sharing_queue_global_request, - ssh2_sharing_no_more_downstreams, - ssh2_agent_forwarding_permitted, - ssh2_terminal_size, - ssh2_stdout_unthrottle, - ssh2_stdin_backlog, - ssh2_throttle_all_channels, - ssh2_ldisc_option, - ssh2_set_ldisc_option, - ssh2_enable_x_fwd, - ssh2_enable_agent_fwd, - ssh2_set_wants_user_input, +static const ConnectionLayerVtable ssh2_connlayer_vtable = { + .rportfwd_alloc = ssh2_rportfwd_alloc, + .rportfwd_remove = ssh2_rportfwd_remove, + .lportfwd_open = ssh2_lportfwd_open, + .session_open = ssh2_session_open, + .serverside_x11_open = ssh2_serverside_x11_open, + .serverside_agent_open = ssh2_serverside_agent_open, + .add_x11_display = ssh2_add_x11_display, + .add_sharing_x11_display = ssh2_add_sharing_x11_display, + .remove_sharing_x11_display = ssh2_remove_sharing_x11_display, + .send_packet_from_downstream = ssh2_send_packet_from_downstream, + .alloc_sharing_channel = ssh2_alloc_sharing_channel, + .delete_sharing_channel = ssh2_delete_sharing_channel, + .sharing_queue_global_request = ssh2_sharing_queue_global_request, + .sharing_no_more_downstreams = ssh2_sharing_no_more_downstreams, + .agent_forwarding_permitted = ssh2_agent_forwarding_permitted, + .terminal_size = ssh2_terminal_size, + .stdout_unthrottle = ssh2_stdout_unthrottle, + .stdin_backlog = ssh2_stdin_backlog, + .throttle_all_channels = ssh2_throttle_all_channels, + .ldisc_option = ssh2_ldisc_option, + .set_ldisc_option = ssh2_set_ldisc_option, + .enable_x_fwd = ssh2_enable_x_fwd, + .enable_agent_fwd = ssh2_enable_agent_fwd, + .set_wants_user_input = ssh2_set_wants_user_input, }; static char *ssh2_channel_open_failure_error_text(PktIn *pktin) @@ -132,28 +132,28 @@ static void ssh2channel_x11_sharing_handover( int protomajor, int protominor, const void *initial_data, int initial_len); static void ssh2channel_hint_channel_is_simple(SshChannel *c); -static const struct SshChannelVtable ssh2channel_vtable = { - ssh2channel_write, - ssh2channel_write_eof, - ssh2channel_initiate_close, - ssh2channel_unthrottle, - ssh2channel_get_conf, - ssh2channel_window_override_removed, - ssh2channel_x11_sharing_handover, - ssh2channel_send_exit_status, - ssh2channel_send_exit_signal, - ssh2channel_send_exit_signal_numeric, - ssh2channel_request_x11_forwarding, - ssh2channel_request_agent_forwarding, - ssh2channel_request_pty, - ssh2channel_send_env_var, - ssh2channel_start_shell, - ssh2channel_start_command, - ssh2channel_start_subsystem, - ssh2channel_send_serial_break, - ssh2channel_send_signal, - ssh2channel_send_terminal_size_change, - ssh2channel_hint_channel_is_simple, +static const SshChannelVtable ssh2channel_vtable = { + .write = ssh2channel_write, + .write_eof = ssh2channel_write_eof, + .initiate_close = ssh2channel_initiate_close, + .unthrottle = ssh2channel_unthrottle, + .get_conf = ssh2channel_get_conf, + .window_override_removed = ssh2channel_window_override_removed, + .x11_sharing_handover = ssh2channel_x11_sharing_handover, + .send_exit_status = ssh2channel_send_exit_status, + .send_exit_signal = ssh2channel_send_exit_signal, + .send_exit_signal_numeric = ssh2channel_send_exit_signal_numeric, + .request_x11_forwarding = ssh2channel_request_x11_forwarding, + .request_agent_forwarding = ssh2channel_request_agent_forwarding, + .request_pty = ssh2channel_request_pty, + .send_env_var = ssh2channel_send_env_var, + .start_shell = ssh2channel_start_shell, + .start_command = ssh2channel_start_command, + .start_subsystem = ssh2channel_start_subsystem, + .send_serial_break = ssh2channel_send_serial_break, + .send_signal = ssh2channel_send_signal, + .send_terminal_size_change = ssh2channel_send_terminal_size_change, + .hint_channel_is_simple = ssh2channel_hint_channel_is_simple, }; static void ssh2_channel_check_close(struct ssh2_channel *c); diff --git a/ssh2transport.c b/ssh2transport.c index e7b7a871..cfe64e75 100644 --- a/ssh2transport.c +++ b/ssh2transport.c @@ -52,11 +52,16 @@ static bool ssh_decomp_none_block(ssh_decompressor *handle, { return false; } -const static ssh_compression_alg ssh_comp_none = { - "none", NULL, - ssh_comp_none_init, ssh_comp_none_cleanup, ssh_comp_none_block, - ssh_decomp_none_init, ssh_decomp_none_cleanup, ssh_decomp_none_block, - NULL +static const ssh_compression_alg ssh_comp_none = { + .name = "none", + .delayed_name = NULL, + .compress_new = ssh_comp_none_init, + .compress_free = ssh_comp_none_cleanup, + .compress = ssh_comp_none_block, + .decompress_new = ssh_decomp_none_init, + .decompress_free = ssh_decomp_none_cleanup, + .decompress = ssh_decomp_none_block, + .text_name = NULL, }; const static ssh_compression_alg *const compressions[] = { &ssh_zlib, &ssh_comp_none @@ -77,16 +82,16 @@ static void ssh2_transport_set_max_data_size(struct ssh2_transport_state *s); static unsigned long sanitise_rekey_time(int rekey_time, unsigned long def); static void ssh2_transport_higher_layer_packet_callback(void *context); -static const struct PacketProtocolLayerVtable ssh2_transport_vtable = { - ssh2_transport_free, - ssh2_transport_process_queue, - ssh2_transport_get_specials, - ssh2_transport_special_cmd, - ssh2_transport_want_user_input, - ssh2_transport_got_user_input, - ssh2_transport_reconfigure, - ssh2_transport_queued_data_size, - NULL, /* no protocol name for this layer */ +static const PacketProtocolLayerVtable ssh2_transport_vtable = { + .free = ssh2_transport_free, + .process_queue = ssh2_transport_process_queue, + .get_specials = ssh2_transport_get_specials, + .special_cmd = ssh2_transport_special_cmd, + .want_user_input = ssh2_transport_want_user_input, + .got_user_input = ssh2_transport_got_user_input, + .reconfigure = ssh2_transport_reconfigure, + .queued_data_size = ssh2_transport_queued_data_size, + .name = NULL, /* no protocol name for this layer */ }; #ifndef NO_GSSAPI diff --git a/ssh2userauth-server.c b/ssh2userauth-server.c index 7e67e557..d4dd92b4 100644 --- a/ssh2userauth-server.c +++ b/ssh2userauth-server.c @@ -38,16 +38,12 @@ struct ssh2_userauth_server_state { static void ssh2_userauth_server_free(PacketProtocolLayer *); static void ssh2_userauth_server_process_queue(PacketProtocolLayer *); -static const struct PacketProtocolLayerVtable ssh2_userauth_server_vtable = { - ssh2_userauth_server_free, - ssh2_userauth_server_process_queue, - NULL /* get_specials */, - NULL /* special_cmd */, - NULL /* want_user_input */, - NULL /* got_user_input */, - NULL /* reconfigure */, - ssh_ppl_default_queued_data_size, - "ssh-userauth", +static const PacketProtocolLayerVtable ssh2_userauth_server_vtable = { + .free = ssh2_userauth_server_free, + .process_queue = ssh2_userauth_server_process_queue, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = "ssh-userauth", + /* other methods are NULL */ }; static void free_auth_kbdint(AuthKbdInt *aki) diff --git a/ssh2userauth.c b/ssh2userauth.c index 96b1551d..6d9afb80 100644 --- a/ssh2userauth.c +++ b/ssh2userauth.c @@ -112,16 +112,16 @@ static PktOut *ssh2_userauth_gss_packet( static void ssh2_userauth_antispoof_msg( struct ssh2_userauth_state *s, const char *msg); -static const struct PacketProtocolLayerVtable ssh2_userauth_vtable = { - ssh2_userauth_free, - ssh2_userauth_process_queue, - ssh2_userauth_get_specials, - ssh2_userauth_special_cmd, - ssh2_userauth_want_user_input, - ssh2_userauth_got_user_input, - ssh2_userauth_reconfigure, - ssh_ppl_default_queued_data_size, - "ssh-userauth", +static const PacketProtocolLayerVtable ssh2_userauth_vtable = { + .free = ssh2_userauth_free, + .process_queue = ssh2_userauth_process_queue, + .get_specials = ssh2_userauth_get_specials, + .special_cmd = ssh2_userauth_special_cmd, + .want_user_input = ssh2_userauth_want_user_input, + .got_user_input = ssh2_userauth_got_user_input, + .reconfigure = ssh2_userauth_reconfigure, + .queued_data_size = ssh_ppl_default_queued_data_size, + .name = "ssh-userauth", }; PacketProtocolLayer *ssh2_userauth_new( diff --git a/sshaes.c b/sshaes.c index 34f260cc..97ea9f31 100644 --- a/sshaes.c +++ b/sshaes.c @@ -106,30 +106,54 @@ struct aes_extra { }; #define VTABLES_INNER(cid, pid, bits, name, encsuffix, \ - decsuffix, setiv, flags) \ + decsuffix, setivsuffix, flagsval) \ static void cid##_sw##encsuffix(ssh_cipher *, void *blk, int len); \ static void cid##_sw##decsuffix(ssh_cipher *, void *blk, int len); \ const ssh_cipheralg ssh_##cid##_sw = { \ - aes_sw_new, aes_sw_free, aes_sw_##setiv, aes_sw_setkey, \ - cid##_sw##encsuffix, cid##_sw##decsuffix, NULL, NULL, \ - pid, 16, bits, bits/8, flags, name " (unaccelerated)", \ - NULL, NULL }; \ + .new = aes_sw_new, \ + .free = aes_sw_free, \ + .setiv = aes_sw_##setivsuffix, \ + .setkey = aes_sw_setkey, \ + .encrypt = cid##_sw##encsuffix, \ + .decrypt = cid##_sw##decsuffix, \ + .ssh2_id = pid, \ + .blksize = 16, \ + .real_keybits = bits, \ + .padded_keybytes = bits/8, \ + .flags = flagsval, \ + .text_name = name " (unaccelerated)", \ + }; \ \ static void cid##_hw##encsuffix(ssh_cipher *, void *blk, int len); \ static void cid##_hw##decsuffix(ssh_cipher *, void *blk, int len); \ const ssh_cipheralg ssh_##cid##_hw = { \ - aes_hw_new, aes_hw_free, aes_hw_##setiv, aes_hw_setkey, \ - cid##_hw##encsuffix, cid##_hw##decsuffix, NULL, NULL, \ - pid, 16, bits, bits/8, flags, name HW_NAME_SUFFIX, \ - NULL, NULL }; \ + .new = aes_hw_new, \ + .free = aes_hw_free, \ + .setiv = aes_hw_##setivsuffix, \ + .setkey = aes_hw_setkey, \ + .encrypt = cid##_hw##encsuffix, \ + .decrypt = cid##_hw##decsuffix, \ + .ssh2_id = pid, \ + .blksize = 16, \ + .real_keybits = bits, \ + .padded_keybytes = bits/8, \ + .flags = flagsval, \ + .text_name = name HW_NAME_SUFFIX, \ + }; \ \ static const struct aes_extra extra_##cid = { \ &ssh_##cid##_sw, &ssh_##cid##_hw }; \ \ const ssh_cipheralg ssh_##cid = { \ - aes_select, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \ - pid, 16, bits, bits/8, flags, name " (dummy selector vtable)", \ - NULL, &extra_##cid }; \ + .new = aes_select, \ + .ssh2_id = pid, \ + .blksize = 16, \ + .real_keybits = bits, \ + .padded_keybytes = bits/8, \ + .flags = flagsval, \ + .text_name = name " (dummy selector vtable)", \ + .extra = &extra_##cid \ + }; \ #define VTABLES(keylen) \ VTABLES_INNER(aes ## keylen ## _cbc, "aes" #keylen "-cbc", \ @@ -144,9 +168,14 @@ VTABLES(256) static const ssh_cipheralg ssh_rijndael_lysator = { /* Same as aes256_cbc, but with a different protocol ID */ - aes_select, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - "rijndael-cbc@lysator.liu.se", 16, 256, 256/8, 0, - "AES-256 CBC (dummy selector vtable)", NULL, &extra_aes256_cbc + .new = aes_select, + .ssh2_id = "rijndael-cbc@lysator.liu.se", + .blksize = 16, + .real_keybits = 256, + .padded_keybytes = 256/8, + .flags = 0, + .text_name = "AES-256 CBC (dummy selector vtable)", + .extra = &extra_aes256_cbc, }; static const ssh_cipheralg *const aes_list[] = { diff --git a/ssharcf.c b/ssharcf.c index dd163d4f..53821473 100644 --- a/ssharcf.c +++ b/ssharcf.c @@ -104,19 +104,33 @@ static void arcfour_ssh2_block(ssh_cipher *cipher, void *blk, int len) } const ssh_cipheralg ssh_arcfour128_ssh2 = { - arcfour_new, arcfour_free, arcfour_ssh2_setiv, arcfour_ssh2_setkey, - arcfour_ssh2_block, arcfour_ssh2_block, NULL, NULL, - "arcfour128", - 1, 128, 16, 0, "Arcfour-128", - NULL + .new = arcfour_new, + .free = arcfour_free, + .setiv = arcfour_ssh2_setiv, + .setkey = arcfour_ssh2_setkey, + .encrypt = arcfour_ssh2_block, + .decrypt = arcfour_ssh2_block, + .ssh2_id = "arcfour128", + .blksize = 1, + .real_keybits = 128, + .padded_keybytes = 16, + .flags = 0, + .text_name = "Arcfour-128", }; const ssh_cipheralg ssh_arcfour256_ssh2 = { - arcfour_new, arcfour_free, arcfour_ssh2_setiv, arcfour_ssh2_setkey, - arcfour_ssh2_block, arcfour_ssh2_block, NULL, NULL, - "arcfour256", - 1, 256, 32, 0, "Arcfour-256", - NULL + .new = arcfour_new, + .free = arcfour_free, + .setiv = arcfour_ssh2_setiv, + .setkey = arcfour_ssh2_setkey, + .encrypt = arcfour_ssh2_block, + .decrypt = arcfour_ssh2_block, + .ssh2_id = "arcfour256", + .blksize = 1, + .real_keybits = 256, + .padded_keybytes = 32, + .flags = 0, + .text_name = "Arcfour-256", }; static const ssh_cipheralg *const arcfour_list[] = { diff --git a/sshblowf.c b/sshblowf.c index a48401b6..c74f06c0 100644 --- a/sshblowf.c +++ b/sshblowf.c @@ -648,30 +648,47 @@ static void blowfish_ssh2_sdctr(ssh_cipher *cipher, void *blk, int len) } const ssh_cipheralg ssh_blowfish_ssh1 = { - blowfish_new, blowfish_free, - blowfish_ssh1_setiv, blowfish_ssh_setkey, - blowfish_ssh1_encrypt_blk, blowfish_ssh1_decrypt_blk, - NULL, NULL, NULL, - 8, 128, SSH1_SESSION_KEY_LENGTH, SSH_CIPHER_IS_CBC, "Blowfish-256 CBC", - NULL + .new = blowfish_new, + .free = blowfish_free, + .setiv = blowfish_ssh1_setiv, + .setkey = blowfish_ssh_setkey, + .encrypt = blowfish_ssh1_encrypt_blk, + .decrypt = blowfish_ssh1_decrypt_blk, + .blksize = 8, + .real_keybits = 128, + .padded_keybytes = SSH1_SESSION_KEY_LENGTH, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "Blowfish-256 CBC", }; const ssh_cipheralg ssh_blowfish_ssh2 = { - blowfish_new, blowfish_free, - blowfish_ssh2_setiv, blowfish_ssh_setkey, - blowfish_ssh2_encrypt_blk, blowfish_ssh2_decrypt_blk, NULL, NULL, - "blowfish-cbc", - 8, 128, 16, SSH_CIPHER_IS_CBC, "Blowfish-128 CBC", - NULL + .new = blowfish_new, + .free = blowfish_free, + .setiv = blowfish_ssh2_setiv, + .setkey = blowfish_ssh_setkey, + .encrypt = blowfish_ssh2_encrypt_blk, + .decrypt = blowfish_ssh2_decrypt_blk, + .ssh2_id = "blowfish-cbc", + .blksize = 8, + .real_keybits = 128, + .padded_keybytes = 16, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "Blowfish-128 CBC", }; const ssh_cipheralg ssh_blowfish_ssh2_ctr = { - blowfish_new, blowfish_free, - blowfish_ssh2_setiv, blowfish_ssh_setkey, - blowfish_ssh2_sdctr, blowfish_ssh2_sdctr, NULL, NULL, - "blowfish-ctr", - 8, 256, 32, 0, "Blowfish-256 SDCTR", - NULL + .new = blowfish_new, + .free = blowfish_free, + .setiv = blowfish_ssh2_setiv, + .setkey = blowfish_ssh_setkey, + .encrypt = blowfish_ssh2_sdctr, + .decrypt = blowfish_ssh2_sdctr, + .ssh2_id = "blowfish-ctr", + .blksize = 8, + .real_keybits = 256, + .padded_keybytes = 32, + .flags = 0, + .text_name = "Blowfish-256 SDCTR", }; static const ssh_cipheralg *const blowfish_list[] = { diff --git a/sshbpp.h b/sshbpp.h index 8192d4e2..45662b62 100644 --- a/sshbpp.h +++ b/sshbpp.h @@ -5,6 +5,8 @@ #ifndef PUTTY_SSHBPP_H #define PUTTY_SSHBPP_H +typedef struct BinaryPacketProtocolVtable BinaryPacketProtocolVtable; + struct BinaryPacketProtocolVtable { void (*free)(BinaryPacketProtocol *); void (*handle_input)(BinaryPacketProtocol *); diff --git a/sshccp.c b/sshccp.c index 78129336..dd25b997 100644 --- a/sshccp.c +++ b/sshccp.c @@ -944,11 +944,17 @@ static const char *poly_text_name(ssh2_mac *mac) } const ssh2_macalg ssh2_poly1305 = { - poly_ssh2_new, poly_ssh2_free, poly_setkey, - poly_start, poly_genresult, poly_text_name, - - "", "", /* Not selectable individually, just part of ChaCha20-Poly1305 */ - 16, 0, + .new = poly_ssh2_new, + .free = poly_ssh2_free, + .setkey = poly_setkey, + .start = poly_start, + .genresult = poly_genresult, + .text_name = poly_text_name, + .name = "", + .etm_name = "", /* Not selectable individually, just part of + * ChaCha20-Poly1305 */ + .len = 16, + .keylen = 0, }; static ssh_cipher *ccp_new(const ssh_cipheralg *alg) @@ -1032,20 +1038,21 @@ static void ccp_decrypt_length(ssh_cipher *cipher, void *blk, int len, } const ssh_cipheralg ssh2_chacha20_poly1305 = { - - ccp_new, - ccp_free, - ccp_iv, - ccp_key, - ccp_encrypt, - ccp_decrypt, - ccp_encrypt_length, - ccp_decrypt_length, - - "chacha20-poly1305@openssh.com", - 1, 512, 64, SSH_CIPHER_SEPARATE_LENGTH, "ChaCha20", - - &ssh2_poly1305 + .new = ccp_new, + .free = ccp_free, + .setiv = ccp_iv, + .setkey = ccp_key, + .encrypt = ccp_encrypt, + .decrypt = ccp_decrypt, + .encrypt_length = ccp_encrypt_length, + .decrypt_length = ccp_decrypt_length, + .ssh2_id = "chacha20-poly1305@openssh.com", + .blksize = 1, + .real_keybits = 512, + .padded_keybytes = 64, + .flags = SSH_CIPHER_SEPARATE_LENGTH, + .text_name = "ChaCha20", + .required_mac = &ssh2_poly1305, }; static const ssh_cipheralg *const ccp_list[] = { diff --git a/sshchan.h b/sshchan.h index cedf357e..14dfccb5 100644 --- a/sshchan.h +++ b/sshchan.h @@ -6,6 +6,8 @@ #ifndef PUTTY_SSHCHAN_H #define PUTTY_SSHCHAN_H +typedef struct ChannelVtable ChannelVtable; + struct ChannelVtable { void (*free)(Channel *); @@ -169,6 +171,8 @@ Channel *zombiechan_new(void); * implementation to talk back to. */ +typedef struct SshChannelVtable SshChannelVtable; + struct SshChannelVtable { size_t (*write)(SshChannel *c, bool is_stderr, const void *, size_t); void (*write_eof)(SshChannel *c); diff --git a/sshcommon.c b/sshcommon.c index 09ceb590..9cf2cf6f 100644 --- a/sshcommon.c +++ b/sshcommon.c @@ -290,29 +290,29 @@ static void zombiechan_open_failure(Channel *chan, const char *); static bool zombiechan_want_close(Channel *chan, bool sent_eof, bool rcvd_eof); static char *zombiechan_log_close_msg(Channel *chan) { return NULL; } -static const struct ChannelVtable zombiechan_channelvt = { - zombiechan_free, - zombiechan_do_nothing, /* open_confirmation */ - zombiechan_open_failure, - zombiechan_send, - zombiechan_do_nothing, /* send_eof */ - zombiechan_set_input_wanted, - zombiechan_log_close_msg, - zombiechan_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable zombiechan_channelvt = { + .free = zombiechan_free, + .open_confirmation = zombiechan_do_nothing, + .open_failed = zombiechan_open_failure, + .send = zombiechan_send, + .send_eof = zombiechan_do_nothing, + .set_input_wanted = zombiechan_set_input_wanted, + .log_close_msg = zombiechan_log_close_msg, + .want_close = zombiechan_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; Channel *zombiechan_new(void) diff --git a/sshdes.c b/sshdes.c index 4dcecf77..d2ba9825 100644 --- a/sshdes.c +++ b/sshdes.c @@ -683,16 +683,34 @@ static void des_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len) } const ssh_cipheralg ssh_des = { - des_cbc_new, des_cbc_free, des_cbc_setiv, des_cbc_setkey, - des_cbc_encrypt, des_cbc_decrypt, NULL, NULL, "des-cbc", - 8, 56, 8, SSH_CIPHER_IS_CBC, "single-DES CBC", NULL + .new = des_cbc_new, + .free = des_cbc_free, + .setiv = des_cbc_setiv, + .setkey = des_cbc_setkey, + .encrypt = des_cbc_encrypt, + .decrypt = des_cbc_decrypt, + .ssh2_id = "des-cbc", + .blksize = 8, + .real_keybits = 56, + .padded_keybytes = 8, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "single-DES CBC", }; const ssh_cipheralg ssh_des_sshcom_ssh2 = { /* Same as ssh_des_cbc, but with a different SSH-2 ID */ - des_cbc_new, des_cbc_free, des_cbc_setiv, des_cbc_setkey, - des_cbc_encrypt, des_cbc_decrypt, NULL, NULL, "des-cbc@ssh.com", - 8, 56, 8, SSH_CIPHER_IS_CBC, "single-DES CBC", NULL + .new = des_cbc_new, + .free = des_cbc_free, + .setiv = des_cbc_setiv, + .setkey = des_cbc_setkey, + .encrypt = des_cbc_encrypt, + .decrypt = des_cbc_decrypt, + .ssh2_id = "des-cbc@ssh.com", + .blksize = 8, + .real_keybits = 56, + .padded_keybytes = 8, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "single-DES CBC", }; static const ssh_cipheralg *const des_list[] = { @@ -784,9 +802,18 @@ static void des3_cbc1_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len) } const ssh_cipheralg ssh_3des_ssh2 = { - des3_cbc1_new, des3_cbc1_free, des3_cbc1_setiv, des3_cbc1_setkey, - des3_cbc1_cbc_encrypt, des3_cbc1_cbc_decrypt, NULL, NULL, "3des-cbc", - 8, 168, 24, SSH_CIPHER_IS_CBC, "triple-DES CBC", NULL + .new = des3_cbc1_new, + .free = des3_cbc1_free, + .setiv = des3_cbc1_setiv, + .setkey = des3_cbc1_setkey, + .encrypt = des3_cbc1_cbc_encrypt, + .decrypt = des3_cbc1_cbc_decrypt, + .ssh2_id = "3des-cbc", + .blksize = 8, + .real_keybits = 168, + .padded_keybytes = 24, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "triple-DES CBC", }; /* ---------------------------------------------------------------------- @@ -872,9 +899,18 @@ static void des3_sdctr_encrypt_decrypt(ssh_cipher *ciph, void *vdata, int len) } const ssh_cipheralg ssh_3des_ssh2_ctr = { - des3_sdctr_new, des3_sdctr_free, des3_sdctr_setiv, des3_sdctr_setkey, - des3_sdctr_encrypt_decrypt, des3_sdctr_encrypt_decrypt, - NULL, NULL, "3des-ctr", 8, 168, 24, 0, "triple-DES SDCTR", NULL + .new = des3_sdctr_new, + .free = des3_sdctr_free, + .setiv = des3_sdctr_setiv, + .setkey = des3_sdctr_setkey, + .encrypt = des3_sdctr_encrypt_decrypt, + .decrypt = des3_sdctr_encrypt_decrypt, + .ssh2_id = "3des-ctr", + .blksize = 8, + .real_keybits = 168, + .padded_keybytes = 24, + .flags = 0, + .text_name = "triple-DES SDCTR", }; static const ssh_cipheralg *const des3_list[] = { @@ -998,7 +1034,15 @@ static void des3_cbc3_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len) } const ssh_cipheralg ssh_3des_ssh1 = { - des3_cbc3_new, des3_cbc3_free, des3_cbc3_setiv, des3_cbc3_setkey, - des3_cbc3_cbc_encrypt, des3_cbc3_cbc_decrypt, NULL, NULL, NULL, - 8, 168, 24, SSH_CIPHER_IS_CBC, "triple-DES inner-CBC", NULL + .new = des3_cbc3_new, + .free = des3_cbc3_free, + .setiv = des3_cbc3_setiv, + .setkey = des3_cbc3_setkey, + .encrypt = des3_cbc3_cbc_encrypt, + .decrypt = des3_cbc3_cbc_decrypt, + .blksize = 8, + .real_keybits = 168, + .padded_keybytes = 24, + .flags = SSH_CIPHER_IS_CBC, + .text_name = "triple-DES inner-CBC", }; diff --git a/sshdss.c b/sshdss.c index 549e717e..2f637d89 100644 --- a/sshdss.c +++ b/sshdss.c @@ -483,24 +483,19 @@ static void dss_sign(ssh_key *key, ptrlen data, unsigned flags, BinarySink *bs) } const ssh_keyalg ssh_dss = { - dss_new_pub, - dss_new_priv, - dss_new_priv_openssh, - - dss_freekey, - dss_invalid, - dss_sign, - dss_verify, - dss_public_blob, - dss_private_blob, - dss_openssh_blob, - dss_cache_str, - dss_components, - - dss_pubkey_bits, - - "ssh-dss", - "dss", - NULL, - 0, /* no supported flags */ + .new_pub = dss_new_pub, + .new_priv = dss_new_priv, + .new_priv_openssh = dss_new_priv_openssh, + .freekey = dss_freekey, + .invalid = dss_invalid, + .sign = dss_sign, + .verify = dss_verify, + .public_blob = dss_public_blob, + .private_blob = dss_private_blob, + .openssh_blob = dss_openssh_blob, + .cache_str = dss_cache_str, + .components = dss_components, + .pubkey_bits = dss_pubkey_bits, + .ssh_id = "ssh-dss", + .cache_id = "dss", }; diff --git a/sshecc.c b/sshecc.c index 8114aba6..ba580dbf 100644 --- a/sshecc.c +++ b/sshecc.c @@ -1252,26 +1252,22 @@ static const struct ecsign_extra sign_extra_ed25519 = { NULL, 0, PTRLEN_DECL_LITERAL(""), }; const ssh_keyalg ssh_ecdsa_ed25519 = { - eddsa_new_pub, - eddsa_new_priv, - eddsa_new_priv_openssh, - - eddsa_freekey, - ec_signkey_invalid, - eddsa_sign, - eddsa_verify, - eddsa_public_blob, - eddsa_private_blob, - eddsa_openssh_blob, - eddsa_cache_str, - eddsa_components, - - ec_shared_pubkey_bits, - - "ssh-ed25519", - "ssh-ed25519", - &sign_extra_ed25519, - 0, /* no supported flags */ + .new_pub = eddsa_new_pub, + .new_priv = eddsa_new_priv, + .new_priv_openssh = eddsa_new_priv_openssh, + .freekey = eddsa_freekey, + .invalid = ec_signkey_invalid, + .sign = eddsa_sign, + .verify = eddsa_verify, + .public_blob = eddsa_public_blob, + .private_blob = eddsa_private_blob, + .openssh_blob = eddsa_openssh_blob, + .cache_str = eddsa_cache_str, + .components = eddsa_components, + .pubkey_bits = ec_shared_pubkey_bits, + .ssh_id = "ssh-ed25519", + .cache_id = "ssh-ed25519", + .extra = &sign_extra_ed25519, }; static const struct ecsign_extra sign_extra_ed448 = { @@ -1279,26 +1275,22 @@ static const struct ecsign_extra sign_extra_ed448 = { NULL, 0, PTRLEN_DECL_LITERAL("SigEd448\0\0"), }; const ssh_keyalg ssh_ecdsa_ed448 = { - eddsa_new_pub, - eddsa_new_priv, - eddsa_new_priv_openssh, - - eddsa_freekey, - ec_signkey_invalid, - eddsa_sign, - eddsa_verify, - eddsa_public_blob, - eddsa_private_blob, - eddsa_openssh_blob, - eddsa_cache_str, - eddsa_components, - - ec_shared_pubkey_bits, - - "ssh-ed448", - "ssh-ed448", - &sign_extra_ed448, - 0, /* no supported flags */ + .new_pub = eddsa_new_pub, + .new_priv = eddsa_new_priv, + .new_priv_openssh = eddsa_new_priv_openssh, + .freekey = eddsa_freekey, + .invalid = ec_signkey_invalid, + .sign = eddsa_sign, + .verify = eddsa_verify, + .public_blob = eddsa_public_blob, + .private_blob = eddsa_private_blob, + .openssh_blob = eddsa_openssh_blob, + .cache_str = eddsa_cache_str, + .components = eddsa_components, + .pubkey_bits = ec_shared_pubkey_bits, + .ssh_id = "ssh-ed448", + .cache_id = "ssh-ed448", + .extra = &sign_extra_ed448, }; /* OID: 1.2.840.10045.3.1.7 (ansiX9p256r1) */ @@ -1310,26 +1302,22 @@ static const struct ecsign_extra sign_extra_nistp256 = { nistp256_oid, lenof(nistp256_oid), }; const ssh_keyalg ssh_ecdsa_nistp256 = { - ecdsa_new_pub, - ecdsa_new_priv, - ecdsa_new_priv_openssh, - - ecdsa_freekey, - ec_signkey_invalid, - ecdsa_sign, - ecdsa_verify, - ecdsa_public_blob, - ecdsa_private_blob, - ecdsa_openssh_blob, - ecdsa_cache_str, - ecdsa_components, - - ec_shared_pubkey_bits, - - "ecdsa-sha2-nistp256", - "ecdsa-sha2-nistp256", - &sign_extra_nistp256, - 0, /* no supported flags */ + .new_pub = ecdsa_new_pub, + .new_priv = ecdsa_new_priv, + .new_priv_openssh = ecdsa_new_priv_openssh, + .freekey = ecdsa_freekey, + .invalid = ec_signkey_invalid, + .sign = ecdsa_sign, + .verify = ecdsa_verify, + .public_blob = ecdsa_public_blob, + .private_blob = ecdsa_private_blob, + .openssh_blob = ecdsa_openssh_blob, + .cache_str = ecdsa_cache_str, + .components = ecdsa_components, + .pubkey_bits = ec_shared_pubkey_bits, + .ssh_id = "ecdsa-sha2-nistp256", + .cache_id = "ecdsa-sha2-nistp256", + .extra = &sign_extra_nistp256, }; /* OID: 1.3.132.0.34 (secp384r1) */ @@ -1341,26 +1329,22 @@ static const struct ecsign_extra sign_extra_nistp384 = { nistp384_oid, lenof(nistp384_oid), }; const ssh_keyalg ssh_ecdsa_nistp384 = { - ecdsa_new_pub, - ecdsa_new_priv, - ecdsa_new_priv_openssh, - - ecdsa_freekey, - ec_signkey_invalid, - ecdsa_sign, - ecdsa_verify, - ecdsa_public_blob, - ecdsa_private_blob, - ecdsa_openssh_blob, - ecdsa_cache_str, - ecdsa_components, - - ec_shared_pubkey_bits, - - "ecdsa-sha2-nistp384", - "ecdsa-sha2-nistp384", - &sign_extra_nistp384, - 0, /* no supported flags */ + .new_pub = ecdsa_new_pub, + .new_priv = ecdsa_new_priv, + .new_priv_openssh = ecdsa_new_priv_openssh, + .freekey = ecdsa_freekey, + .invalid = ec_signkey_invalid, + .sign = ecdsa_sign, + .verify = ecdsa_verify, + .public_blob = ecdsa_public_blob, + .private_blob = ecdsa_private_blob, + .openssh_blob = ecdsa_openssh_blob, + .cache_str = ecdsa_cache_str, + .components = ecdsa_components, + .pubkey_bits = ec_shared_pubkey_bits, + .ssh_id = "ecdsa-sha2-nistp384", + .cache_id = "ecdsa-sha2-nistp384", + .extra = &sign_extra_nistp384, }; /* OID: 1.3.132.0.35 (secp521r1) */ @@ -1372,26 +1356,22 @@ static const struct ecsign_extra sign_extra_nistp521 = { nistp521_oid, lenof(nistp521_oid), }; const ssh_keyalg ssh_ecdsa_nistp521 = { - ecdsa_new_pub, - ecdsa_new_priv, - ecdsa_new_priv_openssh, - - ecdsa_freekey, - ec_signkey_invalid, - ecdsa_sign, - ecdsa_verify, - ecdsa_public_blob, - ecdsa_private_blob, - ecdsa_openssh_blob, - ecdsa_cache_str, - ecdsa_components, - - ec_shared_pubkey_bits, - - "ecdsa-sha2-nistp521", - "ecdsa-sha2-nistp521", - &sign_extra_nistp521, - 0, /* no supported flags */ + .new_pub = ecdsa_new_pub, + .new_priv = ecdsa_new_priv, + .new_priv_openssh = ecdsa_new_priv_openssh, + .freekey = ecdsa_freekey, + .invalid = ec_signkey_invalid, + .sign = ecdsa_sign, + .verify = ecdsa_verify, + .public_blob = ecdsa_public_blob, + .private_blob = ecdsa_private_blob, + .openssh_blob = ecdsa_openssh_blob, + .cache_str = ecdsa_cache_str, + .components = ecdsa_components, + .pubkey_bits = ec_shared_pubkey_bits, + .ssh_id = "ecdsa-sha2-nistp521", + .cache_id = "ecdsa-sha2-nistp521", + .extra = &sign_extra_nistp521, }; /* ---------------------------------------------------------------------- diff --git a/sshhmac.c b/sshhmac.c index 85c5b6bb..8f18eb28 100644 --- a/sshhmac.c +++ b/sshhmac.c @@ -162,36 +162,64 @@ static const char *hmac_text_name(ssh2_mac *mac) static const struct hmac_extra ssh_hmac_sha256_extra = { &ssh_sha256, "" }; const ssh2_macalg ssh_hmac_sha256 = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-sha2-256", "hmac-sha2-256-etm@openssh.com", - 32, 32, &ssh_hmac_sha256_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-sha2-256", + .etm_name = "hmac-sha2-256-etm@openssh.com", + .len = 32, + .keylen = 32, + .extra = &ssh_hmac_sha256_extra, }; static const struct hmac_extra ssh_hmac_md5_extra = { &ssh_md5, "" }; const ssh2_macalg ssh_hmac_md5 = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-md5", "hmac-md5-etm@openssh.com", - 16, 16, &ssh_hmac_md5_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-md5", + .etm_name = "hmac-md5-etm@openssh.com", + .len = 16, + .keylen = 16, + .extra = &ssh_hmac_md5_extra, }; static const struct hmac_extra ssh_hmac_sha1_extra = { &ssh_sha1, "" }; const ssh2_macalg ssh_hmac_sha1 = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-sha1", "hmac-sha1-etm@openssh.com", - 20, 20, &ssh_hmac_sha1_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-sha1", + .etm_name = "hmac-sha1-etm@openssh.com", + .len = 20, + .keylen = 20, + .extra = &ssh_hmac_sha1_extra, }; static const struct hmac_extra ssh_hmac_sha1_96_extra = { &ssh_sha1, "-96" }; const ssh2_macalg ssh_hmac_sha1_96 = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-sha1-96", "hmac-sha1-96-etm@openssh.com", - 12, 20, &ssh_hmac_sha1_96_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-sha1-96", + .etm_name = "hmac-sha1-96-etm@openssh.com", + .len = 12, + .keylen = 20, + .extra = &ssh_hmac_sha1_96_extra, }; static const struct hmac_extra ssh_hmac_sha1_buggy_extra = { @@ -199,10 +227,16 @@ static const struct hmac_extra ssh_hmac_sha1_buggy_extra = { }; const ssh2_macalg ssh_hmac_sha1_buggy = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-sha1", NULL, - 20, 16, &ssh_hmac_sha1_buggy_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-sha1", + .len = 20, + .keylen = 16, + .extra = &ssh_hmac_sha1_buggy_extra, }; static const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = { @@ -210,8 +244,14 @@ static const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = { }; const ssh2_macalg ssh_hmac_sha1_96_buggy = { - hmac_new, hmac_free, hmac_key, - hmac_start, hmac_genresult, hmac_text_name, - "hmac-sha1-96", NULL, - 12, 16, &ssh_hmac_sha1_96_buggy_extra, + .new = hmac_new, + .free = hmac_free, + .setkey = hmac_key, + .start = hmac_start, + .genresult = hmac_genresult, + .text_name = hmac_text_name, + .name = "hmac-sha1-96", + .len = 12, + .keylen = 16, + .extra = &ssh_hmac_sha1_96_buggy_extra, }; diff --git a/sshmd5.c b/sshmd5.c index 833c745d..903aef5d 100644 --- a/sshmd5.c +++ b/sshmd5.c @@ -260,6 +260,12 @@ static void md5_digest(ssh_hash *hash, unsigned char *output) } const ssh_hashalg ssh_md5 = { - md5_new, md5_reset, md5_copyfrom, md5_digest, md5_free, - 16, 64, HASHALG_NAMES_BARE("MD5"), + .new = md5_new, + .reset = md5_reset, + .copyfrom = md5_copyfrom, + .digest = md5_digest, + .free = md5_free, + .hlen = 16, + .blocklen = 64, + HASHALG_NAMES_BARE("MD5"), }; diff --git a/sshppl.h b/sshppl.h index cfd6d6be..b339d67c 100644 --- a/sshppl.h +++ b/sshppl.h @@ -8,6 +8,7 @@ #define PUTTY_SSHPPL_H typedef void (*packet_handler_fn_t)(PacketProtocolLayer *ppl, PktIn *pktin); +typedef struct PacketProtocolLayerVtable PacketProtocolLayerVtable; struct PacketProtocolLayerVtable { void (*free)(PacketProtocolLayer *); diff --git a/sshprime.c b/sshprime.c index c2ae94a2..d9bdebba 100644 --- a/sshprime.c +++ b/sshprime.c @@ -738,13 +738,13 @@ void null_progress_report(ProgressReceiver *prog, double progress) {} void null_progress_report_attempt(ProgressReceiver *prog) {} void null_progress_report_phase_complete(ProgressReceiver *prog) {} const ProgressReceiverVtable null_progress_vt = { - null_progress_add_linear, - null_progress_add_probabilistic, - null_progress_ready, - null_progress_start_phase, - null_progress_report, - null_progress_report_attempt, - null_progress_report_phase_complete, + .add_linear = null_progress_add_linear, + .add_probabilistic = null_progress_add_probabilistic, + .ready = null_progress_ready, + .start_phase = null_progress_start_phase, + .report = null_progress_report, + .report_attempt = null_progress_report_attempt, + .report_phase_complete = null_progress_report_phase_complete, }; /* ---------------------------------------------------------------------- diff --git a/sshrsa.c b/sshrsa.c index eec76da8..8ff05afb 100644 --- a/sshrsa.c +++ b/sshrsa.c @@ -817,26 +817,22 @@ static char *rsa2_invalid(ssh_key *key, unsigned flags) } const ssh_keyalg ssh_rsa = { - rsa2_new_pub, - rsa2_new_priv, - rsa2_new_priv_openssh, - - rsa2_freekey, - rsa2_invalid, - rsa2_sign, - rsa2_verify, - rsa2_public_blob, - rsa2_private_blob, - rsa2_openssh_blob, - rsa2_cache_str, - rsa2_components, - - rsa2_pubkey_bits, - - "ssh-rsa", - "rsa2", - NULL, - SSH_AGENT_RSA_SHA2_256 | SSH_AGENT_RSA_SHA2_512, + .new_pub = rsa2_new_pub, + .new_priv = rsa2_new_priv, + .new_priv_openssh = rsa2_new_priv_openssh, + .freekey = rsa2_freekey, + .invalid = rsa2_invalid, + .sign = rsa2_sign, + .verify = rsa2_verify, + .public_blob = rsa2_public_blob, + .private_blob = rsa2_private_blob, + .openssh_blob = rsa2_openssh_blob, + .cache_str = rsa2_cache_str, + .components = rsa2_components, + .pubkey_bits = rsa2_pubkey_bits, + .ssh_id = "ssh-rsa", + .cache_id = "rsa2", + .supported_flags = SSH_AGENT_RSA_SHA2_256 | SSH_AGENT_RSA_SHA2_512, }; RSAKey *ssh_rsakex_newkey(ptrlen data) diff --git a/sshserver.c b/sshserver.c index daf4c65c..6ba8cfcf 100644 --- a/sshserver.c +++ b/sshserver.c @@ -102,27 +102,27 @@ static int server_confirm_weak_cached_hostkey( void (*callback)(void *ctx, int result), void *ctx) { return 1; } static const SeatVtable server_seat_vt = { - nullseat_output, - nullseat_eof, - nullseat_get_userpass_input, - nullseat_notify_remote_exit, - nullseat_connection_fatal, - nullseat_update_specials_menu, - nullseat_get_ttymode, - nullseat_set_busy_status, - nullseat_verify_ssh_host_key, - server_confirm_weak_crypto_primitive, - server_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - nullseat_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - nullseat_get_window_pixel_size, - nullseat_stripctrl_new, - nullseat_set_trust_status, - nullseat_verbose_no, - nullseat_interactive_no, - nullseat_get_cursor_position, + .output = nullseat_output, + .eof = nullseat_eof, + .get_userpass_input = nullseat_get_userpass_input, + .notify_remote_exit = nullseat_notify_remote_exit, + .connection_fatal = nullseat_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = nullseat_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = nullseat_verify_ssh_host_key, + .confirm_weak_crypto_primitive = server_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = server_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = nullseat_get_window_pixel_size, + .stripctrl_new = nullseat_stripctrl_new, + .set_trust_status = nullseat_set_trust_status, + .verbose = nullseat_verbose_no, + .interactive = nullseat_interactive_no, + .get_cursor_position = nullseat_get_cursor_position, }; static void server_socket_log(Plug *plug, PlugLogType type, SockAddr *addr, @@ -234,11 +234,10 @@ Conf *make_ssh_server_conf(void) } static const PlugVtable ssh_server_plugvt = { - server_socket_log, - server_closing, - server_receive, - server_sent, - NULL + .log = server_socket_log, + .closing = server_closing, + .receive = server_receive, + .sent = server_sent, }; Plug *ssh_server_plug( diff --git a/sshsh256.c b/sshsh256.c index 363e50a4..206a976c 100644 --- a/sshsh256.c +++ b/sshsh256.c @@ -98,8 +98,10 @@ static ssh_hash *sha256_select(const ssh_hashalg *alg) } const ssh_hashalg ssh_sha256 = { - sha256_select, NULL, NULL, NULL, NULL, - 32, 64, HASHALG_NAMES_ANNOTATED("SHA-256", "dummy selector vtable"), + .new = sha256_select, + .hlen = 32, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-256", "dummy selector vtable"), }; /* ---------------------------------------------------------------------- @@ -327,9 +329,14 @@ static void sha256_sw_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha256_sw = { - sha256_sw_new, sha256_sw_reset, sha256_sw_copyfrom, sha256_sw_digest, - sha256_sw_free, - 32, 64, HASHALG_NAMES_ANNOTATED("SHA-256", "unaccelerated"), + .new = sha256_sw_new, + .reset = sha256_sw_reset, + .copyfrom = sha256_sw_copyfrom, + .digest = sha256_sw_digest, + .free = sha256_sw_free, + .hlen = 32, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-256", "unaccelerated"), }; /* ---------------------------------------------------------------------- @@ -686,9 +693,14 @@ FUNC_ISA static void sha256_ni_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha256_hw = { - sha256_ni_new, sha256_ni_reset, sha256_ni_copyfrom, sha256_ni_digest, - sha256_ni_free, - 32, 64, HASHALG_NAMES_ANNOTATED("SHA-256", "SHA-NI accelerated"), + .new = sha256_ni_new, + .reset = sha256_ni_reset, + .copyfrom = sha256_ni_copyfrom, + .digest = sha256_ni_digest, + .free = sha256_ni_free, + .hlen = 32, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-256", "SHA-NI accelerated"), }; /* ---------------------------------------------------------------------- @@ -876,9 +888,14 @@ static void sha256_neon_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha256_hw = { - sha256_neon_new, sha256_neon_reset, sha256_neon_copyfrom, - sha256_neon_digest, sha256_neon_free, - 32, 64, HASHALG_NAMES_ANNOTATED("SHA-256", "NEON accelerated"), + .new = sha256_neon_new, + .reset = sha256_neon_reset, + .copyfrom = sha256_neon_copyfrom, + .digest = sha256_neon_digest, + .free = sha256_neon_free, + .hlen = 32, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-256", "NEON accelerated"), }; /* ---------------------------------------------------------------------- @@ -909,10 +926,14 @@ static void sha256_stub_free(ssh_hash *hash) STUB_BODY static void sha256_stub_digest(ssh_hash *hash, uint8_t *digest) STUB_BODY const ssh_hashalg ssh_sha256_hw = { - sha256_stub_new, sha256_stub_reset, sha256_stub_copyfrom, - sha256_stub_digest, sha256_stub_free, - 32, 64, HASHALG_NAMES_ANNOTATED( - "SHA-256", "!NONEXISTENT ACCELERATED VERSION!"), + .new = sha256_stub_new, + .reset = sha256_stub_reset, + .copyfrom = sha256_stub_copyfrom, + .digest = sha256_stub_digest, + .free = sha256_stub_free, + .hlen = 32, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-256", "!NONEXISTENT ACCELERATED VERSION!"), }; #endif /* HW_SHA256 */ diff --git a/sshsh512.c b/sshsh512.c index 7a0eb918..c063997e 100644 --- a/sshsh512.c +++ b/sshsh512.c @@ -325,8 +325,14 @@ static void sha512_digest(ssh_hash *hash, unsigned char *output) } const ssh_hashalg ssh_sha512 = { - sha512_new, sha512_reset, sha512_copyfrom, sha512_digest, sha512_free, - 64, BLKSIZE, HASHALG_NAMES_BARE("SHA-512"), + .new = sha512_new, + .reset = sha512_reset, + .copyfrom = sha512_copyfrom, + .digest = sha512_digest, + .free = sha512_free, + .hlen = 64, + .blocklen = BLKSIZE, + HASHALG_NAMES_BARE("SHA-512"), }; static void sha384_reset(ssh_hash *hash) @@ -342,6 +348,12 @@ static void sha384_digest(ssh_hash *hash, unsigned char *output) } const ssh_hashalg ssh_sha384 = { - sha512_new, sha384_reset, sha512_copyfrom, sha384_digest, sha512_free, - 48, BLKSIZE, HASHALG_NAMES_BARE("SHA-384"), + .new = sha512_new, + .reset = sha384_reset, + .copyfrom = sha512_copyfrom, + .digest = sha384_digest, + .free = sha512_free, + .hlen = 48, + .blocklen = BLKSIZE, + HASHALG_NAMES_BARE("SHA-384"), }; diff --git a/sshsha.c b/sshsha.c index dac393aa..536d474f 100644 --- a/sshsha.c +++ b/sshsha.c @@ -98,8 +98,10 @@ static ssh_hash *sha1_select(const ssh_hashalg *alg) } const ssh_hashalg ssh_sha1 = { - sha1_select, NULL, NULL, NULL, NULL, - 20, 64, HASHALG_NAMES_ANNOTATED("SHA-1", "dummy selector vtable"), + .new = sha1_select, + .hlen = 20, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-1", "dummy selector vtable"), }; /* ---------------------------------------------------------------------- @@ -310,8 +312,14 @@ static void sha1_sw_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha1_sw = { - sha1_sw_new, sha1_sw_reset, sha1_sw_copyfrom, sha1_sw_digest, sha1_sw_free, - 20, 64, HASHALG_NAMES_ANNOTATED("SHA-1", "unaccelerated"), + .new = sha1_sw_new, + .reset = sha1_sw_reset, + .copyfrom = sha1_sw_copyfrom, + .digest = sha1_sw_digest, + .free = sha1_sw_free, + .hlen = 20, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-1", "unaccelerated"), }; /* ---------------------------------------------------------------------- @@ -652,8 +660,14 @@ FUNC_ISA static void sha1_ni_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha1_hw = { - sha1_ni_new, sha1_ni_reset, sha1_ni_copyfrom, sha1_ni_digest, sha1_ni_free, - 20, 64, HASHALG_NAMES_ANNOTATED("SHA-1", "SHA-NI accelerated"), + .new = sha1_ni_new, + .reset = sha1_ni_reset, + .copyfrom = sha1_ni_copyfrom, + .digest = sha1_ni_digest, + .free = sha1_ni_free, + .hlen = 20, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-1", "SHA-NI accelerated"), }; /* ---------------------------------------------------------------------- @@ -868,9 +882,14 @@ static void sha1_neon_digest(ssh_hash *hash, uint8_t *digest) } const ssh_hashalg ssh_sha1_hw = { - sha1_neon_new, sha1_neon_reset, sha1_neon_copyfrom, sha1_neon_digest, - sha1_neon_free, - 20, 64, HASHALG_NAMES_ANNOTATED("SHA-1", "NEON accelerated"), + .new = sha1_neon_new, + .reset = sha1_neon_reset, + .copyfrom = sha1_neon_copyfrom, + .digest = sha1_neon_digest, + .free = sha1_neon_free, + .hlen = 20, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-1", "NEON accelerated"), }; /* ---------------------------------------------------------------------- @@ -901,10 +920,14 @@ static void sha1_stub_free(ssh_hash *hash) STUB_BODY static void sha1_stub_digest(ssh_hash *hash, uint8_t *digest) STUB_BODY const ssh_hashalg ssh_sha1_hw = { - sha1_stub_new, sha1_stub_reset, sha1_stub_copyfrom, sha1_stub_digest, - sha1_stub_free, - 20, 64, HASHALG_NAMES_ANNOTATED( - "SHA-1", "!NONEXISTENT ACCELERATED VERSION!"), + .new = sha1_stub_new, + .reset = sha1_stub_reset, + .copyfrom = sha1_stub_copyfrom, + .digest = sha1_stub_digest, + .free = sha1_stub_free, + .hlen = 20, + .blocklen = 64, + HASHALG_NAMES_ANNOTATED("SHA-1", "!NONEXISTENT ACCELERATED VERSION!"), }; #endif /* HW_SHA1 */ diff --git a/sshsha3.c b/sshsha3.c index 02c53984..83d136bf 100644 --- a/sshsha3.c +++ b/sshsha3.c @@ -280,12 +280,16 @@ static void sha3_reset(ssh_hash *hash) keccak_sha3_init(&kh->state, hash->vt->hlen * 8); } -#define DEFINE_SHA3(bits) \ - const ssh_hashalg ssh_sha3_##bits = { \ - keccak_new, sha3_reset, keccak_copyfrom, \ - keccak_digest, keccak_free, \ - bits/8, 200 - 2*(bits/8), \ - HASHALG_NAMES_BARE("SHA3-" #bits), \ +#define DEFINE_SHA3(bits) \ + const ssh_hashalg ssh_sha3_##bits = { \ + .new = keccak_new, \ + .reset = sha3_reset, \ + .copyfrom = keccak_copyfrom, \ + .digest = keccak_digest, \ + .free = keccak_free, \ + .hlen = bits/8, \ + .blocklen = 200 - 2*(bits/8), \ + HASHALG_NAMES_BARE("SHA3-" #bits), \ } DEFINE_SHA3(224); @@ -310,11 +314,16 @@ static void shake256_reset(ssh_hash *hash) * to be clear which we're talking about */ -#define DEFINE_SHAKE(param, hashbytes) \ - const ssh_hashalg ssh_shake##param##_##hashbytes##bytes = { \ - keccak_new, shake##param##_reset, keccak_copyfrom, \ - keccak_digest, keccak_free, \ - hashbytes, 0, HASHALG_NAMES_BARE("SHAKE" #param), \ +#define DEFINE_SHAKE(param, hashbytes) \ + const ssh_hashalg ssh_shake##param##_##hashbytes##bytes = { \ + .new = keccak_new, \ + .reset = shake##param##_reset, \ + .copyfrom = keccak_copyfrom, \ + .digest = keccak_digest, \ + .free = keccak_free, \ + .hlen = hashbytes, \ + .blocklen = 0, \ + HASHALG_NAMES_BARE("SHAKE" #param), \ } DEFINE_SHAKE(256, 114); diff --git a/sshshare.c b/sshshare.c index e109f873..b5da8657 100644 --- a/sshshare.c +++ b/sshshare.c @@ -1902,11 +1902,9 @@ void share_activate(ssh_sharing_state *sharestate, } static const PlugVtable ssh_sharing_conn_plugvt = { - NULL, /* no log function, because that's for outgoing connections */ - share_closing, - share_receive, - share_sent, - NULL /* no accepting function, because we've already done it */ + .closing = share_closing, + .receive = share_receive, + .sent = share_sent, }; static int share_listen_accepting(Plug *plug, @@ -2046,11 +2044,8 @@ bool ssh_share_test_for_upstream(const char *host, int port, Conf *conf) } static const PlugVtable ssh_sharing_listen_plugvt = { - NULL, /* no log function, because that's for outgoing connections */ - share_listen_closing, - NULL, /* no receive function on a listening socket */ - NULL, /* no sent function on a listening socket */ - share_listen_accepting + .closing = share_listen_closing, + .accepting = share_listen_accepting, }; void ssh_connshare_provide_connlayer(ssh_sharing_state *sharestate, diff --git a/sshverstring.c b/sshverstring.c index 84f23fde..8951e4cb 100644 --- a/sshverstring.c +++ b/sshverstring.c @@ -45,13 +45,13 @@ static PktOut *ssh_verstring_new_pktout(int type); static void ssh_verstring_queue_disconnect(BinaryPacketProtocol *bpp, const char *msg, int category); -static const struct BinaryPacketProtocolVtable ssh_verstring_vtable = { - ssh_verstring_free, - ssh_verstring_handle_input, - ssh_verstring_handle_output, - ssh_verstring_new_pktout, - ssh_verstring_queue_disconnect, - 0xFFFFFFFF, /* no special packet size limit for this bpp */ +static const BinaryPacketProtocolVtable ssh_verstring_vtable = { + .free = ssh_verstring_free, + .handle_input = ssh_verstring_handle_input, + .handle_output = ssh_verstring_handle_output, + .new_pktout = ssh_verstring_new_pktout, + .queue_disconnect = ssh_verstring_queue_disconnect, + .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */ }; static void ssh_detect_bugs(struct ssh_verstring_state *s); diff --git a/sshzlib.c b/sshzlib.c index af559d68..015afba1 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -1241,13 +1241,13 @@ bool zlib_decompress_block(ssh_decompressor *dc, } const ssh_compression_alg ssh_zlib = { - "zlib", - "zlib@openssh.com", /* delayed version */ - zlib_compress_init, - zlib_compress_cleanup, - zlib_compress_block, - zlib_decompress_init, - zlib_decompress_cleanup, - zlib_decompress_block, - "zlib (RFC1950)" + .name = "zlib", + .delayed_name = "zlib@openssh.com", /* delayed version */ + .compress_new = zlib_compress_init, + .compress_free = zlib_compress_cleanup, + .compress = zlib_compress_block, + .decompress_new = zlib_decompress_init, + .decompress_free = zlib_decompress_cleanup, + .decompress = zlib_decompress_block, + .text_name = "zlib (RFC1950)", }; diff --git a/supdup.c b/supdup.c index dcf7e1c2..87d72fd3 100644 --- a/supdup.c +++ b/supdup.c @@ -642,10 +642,10 @@ static const char *supdup_init(const BackendVtable *x, Seat *seat, bool nodelay, bool keepalive) { static const PlugVtable fn_table = { - supdup_log, - supdup_closing, - supdup_receive, - supdup_sent + .log = supdup_log, + .closing = supdup_closing, + .receive = supdup_receive, + .sent = supdup_sent, }; SockAddr *addr; const char *err; @@ -899,26 +899,25 @@ static int supdup_cfg_info(Backend *be) return 0; } -const struct BackendVtable supdup_backend = { - supdup_init, - supdup_free, - supdup_reconfig, - supdup_send, - supdup_sendbuffer, - supdup_size, - supdup_special, - supdup_get_specials, - supdup_connected, - supdup_exitcode, - supdup_sendok, - supdup_ldisc, - supdup_provide_ldisc, - supdup_unthrottle, - supdup_cfg_info, - NULL /* test_for_upstream */, - "supdup", - "SUPDUP", - PROT_SUPDUP, - 0137, - BACKEND_RESIZE_FORBIDDEN | BACKEND_NEEDS_TERMINAL +const BackendVtable supdup_backend = { + .init = supdup_init, + .free = supdup_free, + .reconfig = supdup_reconfig, + .send = supdup_send, + .sendbuffer = supdup_sendbuffer, + .size = supdup_size, + .special = supdup_special, + .get_specials = supdup_get_specials, + .connected = supdup_connected, + .exitcode = supdup_exitcode, + .sendok = supdup_sendok, + .ldisc_option_state = supdup_ldisc, + .provide_ldisc = supdup_provide_ldisc, + .unthrottle = supdup_unthrottle, + .cfg_info = supdup_cfg_info, + .id = "supdup", + .displayname = "SUPDUP", + .protocol = PROT_SUPDUP, + .default_port = 0137, + .flags = BACKEND_RESIZE_FORBIDDEN | BACKEND_NEEDS_TERMINAL, }; diff --git a/telnet.c b/telnet.c index 374b2684..7a94e675 100644 --- a/telnet.c +++ b/telnet.c @@ -664,10 +664,10 @@ static void telnet_sent(Plug *plug, size_t bufsize) } static const PlugVtable Telnet_plugvt = { - telnet_log, - telnet_closing, - telnet_receive, - telnet_sent + .log = telnet_log, + .closing = telnet_closing, + .receive = telnet_receive, + .sent = telnet_sent, }; /* @@ -1047,25 +1047,24 @@ static int telnet_cfg_info(Backend *be) return 0; } -const struct BackendVtable telnet_backend = { - telnet_init, - telnet_free, - telnet_reconfig, - telnet_send, - telnet_sendbuffer, - telnet_size, - telnet_special, - telnet_get_specials, - telnet_connected, - telnet_exitcode, - telnet_sendok, - telnet_ldisc, - telnet_provide_ldisc, - telnet_unthrottle, - telnet_cfg_info, - NULL /* test_for_upstream */, - "telnet", "Telnet", - PROT_TELNET, - 23, - 0 +const BackendVtable telnet_backend = { + .init = telnet_init, + .free = telnet_free, + .reconfig = telnet_reconfig, + .send = telnet_send, + .sendbuffer = telnet_sendbuffer, + .size = telnet_size, + .special = telnet_special, + .get_specials = telnet_get_specials, + .connected = telnet_connected, + .exitcode = telnet_exitcode, + .sendok = telnet_sendok, + .ldisc_option_state = telnet_ldisc, + .provide_ldisc = telnet_provide_ldisc, + .unthrottle = telnet_unthrottle, + .cfg_info = telnet_cfg_info, + .id = "telnet", + .displayname = "Telnet", + .protocol = PROT_TELNET, + .default_port = 23, }; diff --git a/testback.c b/testback.c index 5b733a47..32e2e70a 100644 --- a/testback.c +++ b/testback.c @@ -55,18 +55,48 @@ static void null_provide_ldisc(Backend *, Ldisc *); static void null_unthrottle(Backend *, size_t); static int null_cfg_info(Backend *); -const struct BackendVtable null_backend = { - null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size, - null_special, null_get_specials, null_connected, null_exitcode, null_sendok, - null_ldisc, null_provide_ldisc, null_unthrottle, - null_cfg_info, NULL /* test_for_upstream */, "null", "null", -1, 0, 0 +const BackendVtable null_backend = { + .init = null_init, + .free = null_free, + .reconfig = null_reconfig, + .send = null_send, + .sendbuffer = null_sendbuffer, + .size = null_size, + .special = null_special, + .get_specials = null_get_specials, + .connected = null_connected, + .exitcode = null_exitcode, + .sendok = null_sendok, + .ldisc_option_state = null_ldisc, + .provide_ldisc = null_provide_ldisc, + .unthrottle = null_unthrottle, + .cfg_info = null_cfg_info, + .id = "null", + .displayname = "null", + .protocol = -1, + .default_port = 0, }; -const struct BackendVtable loop_backend = { - loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size, - null_special, null_get_specials, null_connected, null_exitcode, null_sendok, - null_ldisc, null_provide_ldisc, null_unthrottle, - null_cfg_info, NULL /* test_for_upstream */, "loop", "loop", -1, 0, 0 +const BackendVtable loop_backend = { + .init = loop_init, + .free = loop_free, + .reconfig = null_reconfig, + .send = loop_send, + .sendbuffer = null_sendbuffer, + .size = null_size, + .special = null_special, + .get_specials = null_get_specials, + .connected = null_connected, + .exitcode = null_exitcode, + .sendok = null_sendok, + .ldisc_option_state = null_ldisc, + .provide_ldisc = null_provide_ldisc, + .unthrottle = null_unthrottle, + .cfg_info = null_cfg_info, + .id = "loop", + .displayname = "loop", + .protocol = -1, + .default_port = 0, }; struct loop_state { diff --git a/unix/gtkfont.c b/unix/gtkfont.c index f0e7e712..6b711c31 100644 --- a/unix/gtkfont.c +++ b/unix/gtkfont.c @@ -216,18 +216,18 @@ struct x11font { unifont u; }; -static const struct UnifontVtable x11font_vtable = { - x11font_create, - NULL, /* no fallback fonts in X11 */ - x11font_destroy, - x11font_has_glyph, - x11font_draw_text, - x11font_draw_combining, - x11font_enum_fonts, - x11font_canonify_fontname, - x11font_scale_fontname, - x11font_size_increment, - "server", +static const UnifontVtable x11font_vtable = { + .create = x11font_create, + .create_fallback = NULL, /* no fallback fonts in X11 */ + .destroy = x11font_destroy, + .has_glyph = x11font_has_glyph, + .draw_text = x11font_draw_text, + .draw_combining = x11font_draw_combining, + .enum_fonts = x11font_enum_fonts, + .canonify_fontname = x11font_canonify_fontname, + .scale_fontname = x11font_scale_fontname, + .size_increment = x11font_size_increment, + .prefix = "server", }; #define XLFD_STRING_PARTS_LIST(S,I) \ @@ -1353,18 +1353,18 @@ struct pangofont { struct unifont u; }; -static const struct UnifontVtable pangofont_vtable = { - pangofont_create, - pangofont_create_fallback, - pangofont_destroy, - pangofont_has_glyph, - pangofont_draw_text, - pangofont_draw_combining, - pangofont_enum_fonts, - pangofont_canonify_fontname, - pangofont_scale_fontname, - pangofont_size_increment, - "client", +static const UnifontVtable pangofont_vtable = { + .create = pangofont_create, + .create_fallback = pangofont_create_fallback, + .destroy = pangofont_destroy, + .has_glyph = pangofont_has_glyph, + .draw_text = pangofont_draw_text, + .draw_combining = pangofont_draw_combining, + .enum_fonts = pangofont_enum_fonts, + .canonify_fontname = pangofont_canonify_fontname, + .scale_fontname = pangofont_scale_fontname, + .size_increment = pangofont_size_increment, + .prefix = "client", }; /* @@ -2190,18 +2190,18 @@ struct multifont { struct unifont u; }; -static const struct UnifontVtable multifont_vtable = { - NULL, /* creation is done specially */ - NULL, - multifont_destroy, - NULL, - multifont_draw_text, - multifont_draw_combining, - NULL, - NULL, - NULL, - multifont_size_increment, - "client", +static const UnifontVtable multifont_vtable = { + .create = NULL, /* creation is done specially */ + .create_fallback = NULL, + .destroy = multifont_destroy, + .has_glyph = NULL, + .draw_text = multifont_draw_text, + .draw_combining = multifont_draw_combining, + .enum_fonts = NULL, + .canonify_fontname = NULL, + .scale_fontname = NULL, + .size_increment = multifont_size_increment, + .prefix = "client", }; unifont *multifont_create(GtkWidget *widget, const char *name, diff --git a/unix/gtkfont.h b/unix/gtkfont.h index 5b70a3f0..032460e9 100644 --- a/unix/gtkfont.h +++ b/unix/gtkfont.h @@ -49,7 +49,8 @@ /* * Exports from gtkfont.c. */ -struct UnifontVtable; /* contents internal to gtkfont.c */ +typedef struct UnifontVtable UnifontVtable; /* contents internal to + * gtkfont.c */ typedef struct unifont { const struct UnifontVtable *vt; /* diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 15fdaf89..473584c0 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -376,31 +376,31 @@ static bool gtk_seat_set_trust_status(Seat *seat, bool trusted); static bool gtk_seat_get_cursor_position(Seat *seat, int *x, int *y); static const SeatVtable gtk_seat_vt = { - gtk_seat_output, - gtk_seat_eof, - gtk_seat_get_userpass_input, - gtk_seat_notify_remote_exit, - gtk_seat_connection_fatal, - gtk_seat_update_specials_menu, - gtk_seat_get_ttymode, - gtk_seat_set_busy_status, - gtk_seat_verify_ssh_host_key, - gtk_seat_confirm_weak_crypto_primitive, - gtk_seat_confirm_weak_cached_hostkey, - gtk_seat_is_utf8, - nullseat_echoedit_update, - gtk_seat_get_x_display, + .output = gtk_seat_output, + .eof = gtk_seat_eof, + .get_userpass_input = gtk_seat_get_userpass_input, + .notify_remote_exit = gtk_seat_notify_remote_exit, + .connection_fatal = gtk_seat_connection_fatal, + .update_specials_menu = gtk_seat_update_specials_menu, + .get_ttymode = gtk_seat_get_ttymode, + .set_busy_status = gtk_seat_set_busy_status, + .verify_ssh_host_key = gtk_seat_verify_ssh_host_key, + .confirm_weak_crypto_primitive = gtk_seat_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = gtk_seat_confirm_weak_cached_hostkey, + .is_utf8 = gtk_seat_is_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = gtk_seat_get_x_display, #ifdef NOT_X_WINDOWS - nullseat_get_windowid, + .get_windowid = nullseat_get_windowid, #else - gtk_seat_get_windowid, + .get_windowid = gtk_seat_get_windowid, #endif - gtk_seat_get_window_pixel_size, - gtk_seat_stripctrl_new, - gtk_seat_set_trust_status, - nullseat_verbose_yes, - nullseat_interactive_yes, - gtk_seat_get_cursor_position, + .get_window_pixel_size = gtk_seat_get_window_pixel_size, + .stripctrl_new = gtk_seat_stripctrl_new, + .set_trust_status = gtk_seat_set_trust_status, + .verbose = nullseat_verbose_yes, + .interactive = nullseat_interactive_yes, + .get_cursor_position = gtk_seat_get_cursor_position, }; static void gtk_eventlog(LogPolicy *lp, const char *string) @@ -427,10 +427,10 @@ static void gtk_logging_error(LogPolicy *lp, const char *event) } static const LogPolicyVtable gtk_logpolicy_vt = { - gtk_eventlog, - gtk_askappend, - gtk_logging_error, - null_lp_verbose_yes, + .eventlog = gtk_eventlog, + .askappend = gtk_askappend, + .logging_error = gtk_logging_error, + .verbose = null_lp_verbose_yes, }; /* @@ -5152,34 +5152,34 @@ static void get_monitor_geometry(GtkWidget *widget, GdkRectangle *geometry) #endif static const TermWinVtable gtk_termwin_vt = { - gtkwin_setup_draw_ctx, - gtkwin_draw_text, - gtkwin_draw_cursor, - gtkwin_draw_trust_sigil, - gtkwin_char_width, - gtkwin_free_draw_ctx, - gtkwin_set_cursor_pos, - gtkwin_set_raw_mouse_mode, - gtkwin_set_scrollbar, - gtkwin_bell, - gtkwin_clip_write, - gtkwin_clip_request_paste, - gtkwin_refresh, - gtkwin_request_resize, - gtkwin_set_title, - gtkwin_set_icon_title, - gtkwin_set_minimised, - gtkwin_is_minimised, - gtkwin_set_maximised, - gtkwin_move, - gtkwin_set_zorder, - gtkwin_palette_get, - gtkwin_palette_set, - gtkwin_palette_reset, - gtkwin_get_pos, - gtkwin_get_pixels, - gtkwin_get_title, - gtkwin_is_utf8, + .setup_draw_ctx = gtkwin_setup_draw_ctx, + .draw_text = gtkwin_draw_text, + .draw_cursor = gtkwin_draw_cursor, + .draw_trust_sigil = gtkwin_draw_trust_sigil, + .char_width = gtkwin_char_width, + .free_draw_ctx = gtkwin_free_draw_ctx, + .set_cursor_pos = gtkwin_set_cursor_pos, + .set_raw_mouse_mode = gtkwin_set_raw_mouse_mode, + .set_scrollbar = gtkwin_set_scrollbar, + .bell = gtkwin_bell, + .clip_write = gtkwin_clip_write, + .clip_request_paste = gtkwin_clip_request_paste, + .refresh = gtkwin_refresh, + .request_resize = gtkwin_request_resize, + .set_title = gtkwin_set_title, + .set_icon_title = gtkwin_set_icon_title, + .set_minimised = gtkwin_set_minimised, + .is_minimised = gtkwin_is_minimised, + .set_maximised = gtkwin_set_maximised, + .move = gtkwin_move, + .set_zorder = gtkwin_set_zorder, + .palette_get = gtkwin_palette_get, + .palette_set = gtkwin_palette_set, + .palette_reset = gtkwin_palette_reset, + .get_pos = gtkwin_get_pos, + .get_pixels = gtkwin_get_pixels, + .get_title = gtkwin_get_title, + .is_utf8 = gtkwin_is_utf8, }; void new_session_window(Conf *conf, const char *geometry_string) diff --git a/unix/uxfdsock.c b/unix/uxfdsock.c index 2dde8338..e0d436e2 100644 --- a/unix/uxfdsock.c +++ b/unix/uxfdsock.c @@ -304,14 +304,14 @@ static void fdsocket_select_result_input_error(int fd, int event) } static const SocketVtable FdSocket_sockvt = { - fdsocket_plug, - fdsocket_close, - fdsocket_write, - fdsocket_write_oob, - fdsocket_write_eof, - fdsocket_set_frozen, - fdsocket_socket_error, - NULL, /* peer_info */ + .plug = fdsocket_plug, + .close = fdsocket_close, + .write = fdsocket_write, + .write_oob = fdsocket_write_oob, + .write_eof = fdsocket_write_eof, + .set_frozen = fdsocket_set_frozen, + .socket_error = fdsocket_socket_error, + .peer_info = NULL, }; Socket *make_fd_socket(int infd, int outfd, int inerrfd, Plug *plug) diff --git a/unix/uxnet.c b/unix/uxnet.c index b547a95e..bd6ebb1d 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -505,15 +505,15 @@ static void sk_net_set_frozen(Socket *s, bool is_frozen); static SocketPeerInfo *sk_net_peer_info(Socket *s); static const char *sk_net_socket_error(Socket *s); -static struct SocketVtable NetSocket_sockvt = { - sk_net_plug, - sk_net_close, - sk_net_write, - sk_net_write_oob, - sk_net_write_eof, - sk_net_set_frozen, - sk_net_socket_error, - sk_net_peer_info, +static const SocketVtable NetSocket_sockvt = { + .plug = sk_net_plug, + .close = sk_net_close, + .write = sk_net_write, + .write_oob = sk_net_write_oob, + .write_eof = sk_net_write_eof, + .set_frozen = sk_net_set_frozen, + .socket_error = sk_net_socket_error, + .peer_info = sk_net_peer_info, }; static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug) diff --git a/unix/uxpgnt.c b/unix/uxpgnt.c index 6d73bf1f..b83a277d 100644 --- a/unix/uxpgnt.c +++ b/unix/uxpgnt.c @@ -150,8 +150,8 @@ static void passphrase_done(struct uxpgnt_client *upc, bool success) } static const PageantListenerClientVtable uxpgnt_vtable = { - uxpgnt_log, - uxpgnt_ask_passphrase, + .log = uxpgnt_log, + .ask_passphrase = uxpgnt_ask_passphrase, }; /* @@ -916,11 +916,10 @@ void run_client(void) } static const PlugVtable X11Connection_plugvt = { - x11_log, - x11_closing, - x11_receive, - x11_sent, - NULL + .log = x11_log, + .closing = x11_closing, + .receive = x11_receive, + .sent = x11_sent, }; diff --git a/unix/uxplink.c b/unix/uxplink.c index 57b84af8..f5691294 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -387,27 +387,27 @@ static bool plink_seat_interactive(Seat *seat) } static const SeatVtable plink_seat_vt = { - plink_output, - plink_eof, - plink_get_userpass_input, - nullseat_notify_remote_exit, - console_connection_fatal, - nullseat_update_specials_menu, - plink_get_ttymode, - nullseat_set_busy_status, - console_verify_ssh_host_key, - console_confirm_weak_crypto_primitive, - console_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - plink_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - nullseat_get_window_pixel_size, - console_stripctrl_new, - console_set_trust_status, - cmdline_seat_verbose, - plink_seat_interactive, - nullseat_get_cursor_position, + .output = plink_output, + .eof = plink_eof, + .get_userpass_input = plink_get_userpass_input, + .notify_remote_exit = nullseat_notify_remote_exit, + .connection_fatal = console_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = plink_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = console_verify_ssh_host_key, + .confirm_weak_crypto_primitive = console_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = console_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = plink_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = nullseat_get_window_pixel_size, + .stripctrl_new = console_stripctrl_new, + .set_trust_status = console_set_trust_status, + .verbose = cmdline_seat_verbose, + .interactive = plink_seat_interactive, + .get_cursor_position = nullseat_get_cursor_position, }; static Seat plink_seat[1] = {{ &plink_seat_vt }}; diff --git a/unix/uxpsusan.c b/unix/uxpsusan.c index 71b51695..5f32bfad 100644 --- a/unix/uxpsusan.c +++ b/unix/uxpsusan.c @@ -123,10 +123,10 @@ static int server_askappend( } static const LogPolicyVtable server_logpolicy_vt = { - server_eventlog, - server_askappend, - server_logging_error, - null_lp_verbose_no, + .eventlog = server_eventlog, + .askappend = server_askappend, + .logging_error = server_logging_error, + .verbose = null_lp_verbose_no, }; static void show_help(FILE *fp) diff --git a/unix/uxpty.c b/unix/uxpty.c index d20f8fbb..e0a492e5 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -1585,24 +1585,23 @@ static int pty_cfg_info(Backend *be) return 0; } -const struct BackendVtable pty_backend = { - pty_init, - pty_free, - pty_reconfig, - pty_send, - pty_sendbuffer, - pty_size, - pty_special, - pty_get_specials, - pty_connected, - pty_exitcode, - pty_sendok, - pty_ldisc, - pty_provide_ldisc, - pty_unthrottle, - pty_cfg_info, - NULL /* test_for_upstream */, - "pty", "pty", - -1, - 0 +const BackendVtable pty_backend = { + .init = pty_init, + .free = pty_free, + .reconfig = pty_reconfig, + .send = pty_send, + .sendbuffer = pty_sendbuffer, + .size = pty_size, + .special = pty_special, + .get_specials = pty_get_specials, + .connected = pty_connected, + .exitcode = pty_exitcode, + .sendok = pty_sendok, + .ldisc_option_state = pty_ldisc, + .provide_ldisc = pty_provide_ldisc, + .unthrottle = pty_unthrottle, + .cfg_info = pty_cfg_info, + .id = "pty", + .displayname = "pty", + .protocol = -1, }; diff --git a/unix/uxser.c b/unix/uxser.c index da44188e..31658c43 100644 --- a/unix/uxser.c +++ b/unix/uxser.c @@ -559,24 +559,23 @@ static int serial_cfg_info(Backend *be) return 0; } -const struct BackendVtable serial_backend = { - serial_init, - serial_free, - serial_reconfig, - serial_send, - serial_sendbuffer, - serial_size, - serial_special, - serial_get_specials, - serial_connected, - serial_exitcode, - serial_sendok, - serial_ldisc, - serial_provide_ldisc, - serial_unthrottle, - serial_cfg_info, - NULL /* test_for_upstream */, - "serial", "Serial", - PROT_SERIAL, - 0 +const BackendVtable serial_backend = { + .init = serial_init, + .free = serial_free, + .reconfig = serial_reconfig, + .send = serial_send, + .sendbuffer = serial_sendbuffer, + .size = serial_size, + .special = serial_special, + .get_specials = serial_get_specials, + .connected = serial_connected, + .exitcode = serial_exitcode, + .sendok = serial_sendok, + .ldisc_option_state = serial_ldisc, + .provide_ldisc = serial_provide_ldisc, + .unthrottle = serial_unthrottle, + .cfg_info = serial_cfg_info, + .id = "serial", + .displayname = "Serial", + .protocol = PROT_SERIAL, }; diff --git a/unix/uxserver.c b/unix/uxserver.c index 4de9a3ab..eb0056d6 100644 --- a/unix/uxserver.c +++ b/unix/uxserver.c @@ -153,10 +153,10 @@ static int server_askappend( } static const LogPolicyVtable server_logpolicy_vt = { - server_eventlog, - server_askappend, - server_logging_error, - null_lp_verbose_no, + .eventlog = server_eventlog, + .askappend = server_askappend, + .logging_error = server_logging_error, + .verbose = null_lp_verbose_no, }; struct AuthPolicy_ssh1_pubkey { @@ -504,11 +504,9 @@ static int server_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) } static const PlugVtable server_plugvt = { - server_log, - server_closing, - NULL, /* recv */ - NULL, /* send */ - server_accepting + .log = server_log, + .closing = server_closing, + .accepting = server_accepting, }; int main(int argc, char **argv) diff --git a/unix/uxsftpserver.c b/unix/uxsftpserver.c index a90344e0..8835442d 100644 --- a/unix/uxsftpserver.c +++ b/unix/uxsftpserver.c @@ -681,22 +681,22 @@ static void uss_readdir(SftpServer *srv, SftpReplyBuilder *reply, } } -const struct SftpServerVtable unix_live_sftpserver_vt = { - uss_new, - uss_free, - uss_realpath, - uss_open, - uss_opendir, - uss_close, - uss_mkdir, - uss_rmdir, - uss_remove, - uss_rename, - uss_stat, - uss_fstat, - uss_setstat, - uss_fsetstat, - uss_read, - uss_write, - uss_readdir, +const SftpServerVtable unix_live_sftpserver_vt = { + .new = uss_new, + .free = uss_free, + .realpath = uss_realpath, + .open = uss_open, + .opendir = uss_opendir, + .close = uss_close, + .mkdir = uss_mkdir, + .rmdir = uss_rmdir, + .remove = uss_remove, + .rename = uss_rename, + .stat = uss_stat, + .fstat = uss_fstat, + .setstat = uss_setstat, + .fsetstat = uss_fsetstat, + .read = uss_read, + .write = uss_write, + .readdir = uss_readdir, }; diff --git a/windows/windlg.c b/windows/windlg.c index 8d102d0b..b26f8d90 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -1001,10 +1001,10 @@ static int win_gui_askappend(LogPolicy *lp, Filename *filename, } const LogPolicyVtable win_gui_logpolicy_vt = { - win_gui_eventlog, - win_gui_askappend, - win_gui_logging_error, - null_lp_verbose_yes, + .eventlog = win_gui_eventlog, + .askappend = win_gui_askappend, + .logging_error = win_gui_logging_error, + .verbose = null_lp_verbose_yes, }; /* diff --git a/windows/window.c b/windows/window.c index a8634e8a..e3942116 100644 --- a/windows/window.c +++ b/windows/window.c @@ -256,34 +256,34 @@ static const char *wintw_get_title(TermWin *, bool icon); static bool wintw_is_utf8(TermWin *); static const TermWinVtable windows_termwin_vt = { - wintw_setup_draw_ctx, - wintw_draw_text, - wintw_draw_cursor, - wintw_draw_trust_sigil, - wintw_char_width, - wintw_free_draw_ctx, - wintw_set_cursor_pos, - wintw_set_raw_mouse_mode, - wintw_set_scrollbar, - wintw_bell, - wintw_clip_write, - wintw_clip_request_paste, - wintw_refresh, - wintw_request_resize, - wintw_set_title, - wintw_set_icon_title, - wintw_set_minimised, - wintw_is_minimised, - wintw_set_maximised, - wintw_move, - wintw_set_zorder, - wintw_palette_get, - wintw_palette_set, - wintw_palette_reset, - wintw_get_pos, - wintw_get_pixels, - wintw_get_title, - wintw_is_utf8, + .setup_draw_ctx = wintw_setup_draw_ctx, + .draw_text = wintw_draw_text, + .draw_cursor = wintw_draw_cursor, + .draw_trust_sigil = wintw_draw_trust_sigil, + .char_width = wintw_char_width, + .free_draw_ctx = wintw_free_draw_ctx, + .set_cursor_pos = wintw_set_cursor_pos, + .set_raw_mouse_mode = wintw_set_raw_mouse_mode, + .set_scrollbar = wintw_set_scrollbar, + .bell = wintw_bell, + .clip_write = wintw_clip_write, + .clip_request_paste = wintw_clip_request_paste, + .refresh = wintw_refresh, + .request_resize = wintw_request_resize, + .set_title = wintw_set_title, + .set_icon_title = wintw_set_icon_title, + .set_minimised = wintw_set_minimised, + .is_minimised = wintw_is_minimised, + .set_maximised = wintw_set_maximised, + .move = wintw_move, + .set_zorder = wintw_set_zorder, + .palette_get = wintw_palette_get, + .palette_set = wintw_palette_set, + .palette_reset = wintw_palette_reset, + .get_pos = wintw_get_pos, + .get_pixels = wintw_get_pixels, + .get_title = wintw_get_title, + .is_utf8 = wintw_is_utf8, }; static TermWin wintw[1]; @@ -339,27 +339,27 @@ static bool win_seat_set_trust_status(Seat *seat, bool trusted); static bool win_seat_get_cursor_position(Seat *seat, int *x, int *y); static const SeatVtable win_seat_vt = { - win_seat_output, - win_seat_eof, - win_seat_get_userpass_input, - win_seat_notify_remote_exit, - win_seat_connection_fatal, - win_seat_update_specials_menu, - win_seat_get_ttymode, - win_seat_set_busy_status, - win_seat_verify_ssh_host_key, - win_seat_confirm_weak_crypto_primitive, - win_seat_confirm_weak_cached_hostkey, - win_seat_is_utf8, - nullseat_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - win_seat_get_window_pixel_size, - win_seat_stripctrl_new, - win_seat_set_trust_status, - nullseat_verbose_yes, - nullseat_interactive_yes, - win_seat_get_cursor_position, + .output = win_seat_output, + .eof = win_seat_eof, + .get_userpass_input = win_seat_get_userpass_input, + .notify_remote_exit = win_seat_notify_remote_exit, + .connection_fatal = win_seat_connection_fatal, + .update_specials_menu = win_seat_update_specials_menu, + .get_ttymode = win_seat_get_ttymode, + .set_busy_status = win_seat_set_busy_status, + .verify_ssh_host_key = win_seat_verify_ssh_host_key, + .confirm_weak_crypto_primitive = win_seat_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = win_seat_confirm_weak_cached_hostkey, + .is_utf8 = win_seat_is_utf8, + .echoedit_update = nullseat_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = win_seat_get_window_pixel_size, + .stripctrl_new = win_seat_stripctrl_new, + .set_trust_status = win_seat_set_trust_status, + .verbose = nullseat_verbose_yes, + .interactive = nullseat_interactive_yes, + .get_cursor_position = win_seat_get_cursor_position, }; static WinGuiSeat wgs = { .seat.vt = &win_seat_vt, .logpolicy.vt = &win_gui_logpolicy_vt }; diff --git a/windows/winhsock.c b/windows/winhsock.c index 49529444..6fdf2ba2 100644 --- a/windows/winhsock.c +++ b/windows/winhsock.c @@ -304,14 +304,14 @@ static SocketPeerInfo *sk_handle_peer_info(Socket *s) } static const SocketVtable HandleSocket_sockvt = { - sk_handle_plug, - sk_handle_close, - sk_handle_write, - sk_handle_write_oob, - sk_handle_write_eof, - sk_handle_set_frozen, - sk_handle_socket_error, - sk_handle_peer_info, + .plug = sk_handle_plug, + .close = sk_handle_close, + .write = sk_handle_write, + .write_oob = sk_handle_write_oob, + .write_eof = sk_handle_write_eof, + .set_frozen = sk_handle_set_frozen, + .socket_error = sk_handle_socket_error, + .peer_info = sk_handle_peer_info, }; Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H, diff --git a/windows/winnet.c b/windows/winnet.c index 44c98d0f..c548bc45 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -831,14 +831,14 @@ static const char *sk_net_socket_error(Socket *s); static SocketPeerInfo *sk_net_peer_info(Socket *s); static const SocketVtable NetSocket_sockvt = { - sk_net_plug, - sk_net_close, - sk_net_write, - sk_net_write_oob, - sk_net_write_eof, - sk_net_set_frozen, - sk_net_socket_error, - sk_net_peer_info, + .plug = sk_net_plug, + .close = sk_net_close, + .write = sk_net_write, + .write_oob = sk_net_write_oob, + .write_eof = sk_net_write_eof, + .set_frozen = sk_net_set_frozen, + .socket_error = sk_net_socket_error, + .peer_info = sk_net_peer_info, }; static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug) diff --git a/windows/winnps.c b/windows/winnps.c index 36e24d2c..1757cdbb 100644 --- a/windows/winnps.c +++ b/windows/winnps.c @@ -195,14 +195,10 @@ static void named_pipe_connect_callback(void *vps) * be asked to write or set_frozen. */ static const SocketVtable NamedPipeServerSocket_sockvt = { - sk_namedpipeserver_plug, - sk_namedpipeserver_close, - NULL /* write */, - NULL /* write_oob */, - NULL /* write_eof */, - NULL /* set_frozen */, - sk_namedpipeserver_socket_error, - sk_namedpipeserver_peer_info, + .plug = sk_namedpipeserver_plug, + .close = sk_namedpipeserver_close, + .socket_error = sk_namedpipeserver_socket_error, + .peer_info = sk_namedpipeserver_peer_info, }; Socket *new_named_pipe_listener(const char *pipename, Plug *plug) diff --git a/windows/winpgen.c b/windows/winpgen.c index 0c86d7b2..3cf1a1e9 100644 --- a/windows/winpgen.c +++ b/windows/winpgen.c @@ -170,13 +170,13 @@ static void win_progress_report_phase_complete(ProgressReceiver *prog) } static const ProgressReceiverVtable win_progress_vt = { - win_progress_add_linear, - win_progress_add_probabilistic, - win_progress_ready, - win_progress_start_phase, - win_progress_report, - win_progress_report_attempt, - win_progress_report_phase_complete, + .add_linear = win_progress_add_linear, + .add_probabilistic = win_progress_add_probabilistic, + .ready = win_progress_ready, + .start_phase = win_progress_start_phase, + .report = win_progress_report, + .report_attempt = win_progress_report_attempt, + .report_phase_complete = win_progress_report_phase_complete, }; static void win_progress_initialise(struct progress *p) diff --git a/windows/winpgnt.c b/windows/winpgnt.c index e24a54d9..cfdd8f2b 100644 --- a/windows/winpgnt.c +++ b/windows/winpgnt.c @@ -796,9 +796,9 @@ static bool wm_copydata_ask_passphrase( } static const PageantClientVtable wmcpc_vtable = { - NULL, /* no logging in this client */ - wm_copydata_got_response, - wm_copydata_ask_passphrase, + .log = NULL, /* no logging in this client */ + .got_response = wm_copydata_got_response, + .ask_passphrase = wm_copydata_ask_passphrase, }; static char *answer_filemapping_message(const char *mapname) @@ -1188,8 +1188,8 @@ struct winpgnt_client { PageantListenerClient plc; }; static const PageantListenerClientVtable winpgnt_vtable = { - NULL, /* no logging */ - winpgnt_listener_ask_passphrase, + .log = NULL, /* no logging */ + .ask_passphrase = winpgnt_listener_ask_passphrase, }; static struct winpgnt_client wpc[1]; diff --git a/windows/winplink.c b/windows/winplink.c index 45a34688..3172508f 100644 --- a/windows/winplink.c +++ b/windows/winplink.c @@ -81,27 +81,27 @@ static bool plink_seat_interactive(Seat *seat) } static const SeatVtable plink_seat_vt = { - plink_output, - plink_eof, - plink_get_userpass_input, - nullseat_notify_remote_exit, - console_connection_fatal, - nullseat_update_specials_menu, - nullseat_get_ttymode, - nullseat_set_busy_status, - console_verify_ssh_host_key, - console_confirm_weak_crypto_primitive, - console_confirm_weak_cached_hostkey, - nullseat_is_never_utf8, - plink_echoedit_update, - nullseat_get_x_display, - nullseat_get_windowid, - nullseat_get_window_pixel_size, - console_stripctrl_new, - console_set_trust_status, - cmdline_seat_verbose, - plink_seat_interactive, - nullseat_get_cursor_position, + .output = plink_output, + .eof = plink_eof, + .get_userpass_input = plink_get_userpass_input, + .notify_remote_exit = nullseat_notify_remote_exit, + .connection_fatal = console_connection_fatal, + .update_specials_menu = nullseat_update_specials_menu, + .get_ttymode = nullseat_get_ttymode, + .set_busy_status = nullseat_set_busy_status, + .verify_ssh_host_key = console_verify_ssh_host_key, + .confirm_weak_crypto_primitive = console_confirm_weak_crypto_primitive, + .confirm_weak_cached_hostkey = console_confirm_weak_cached_hostkey, + .is_utf8 = nullseat_is_never_utf8, + .echoedit_update = plink_echoedit_update, + .get_x_display = nullseat_get_x_display, + .get_windowid = nullseat_get_windowid, + .get_window_pixel_size = nullseat_get_window_pixel_size, + .stripctrl_new = console_stripctrl_new, + .set_trust_status = console_set_trust_status, + .verbose = cmdline_seat_verbose, + .interactive = plink_seat_interactive, + .get_cursor_position = nullseat_get_cursor_position, }; static Seat plink_seat[1] = {{ &plink_seat_vt }}; diff --git a/windows/winser.c b/windows/winser.c index 5b589c2b..e0ef0475 100644 --- a/windows/winser.c +++ b/windows/winser.c @@ -427,24 +427,23 @@ static int serial_cfg_info(Backend *be) return 0; } -const struct BackendVtable serial_backend = { - serial_init, - serial_free, - serial_reconfig, - serial_send, - serial_sendbuffer, - serial_size, - serial_special, - serial_get_specials, - serial_connected, - serial_exitcode, - serial_sendok, - serial_ldisc, - serial_provide_ldisc, - serial_unthrottle, - serial_cfg_info, - NULL /* test_for_upstream */, - "serial", "Serial", - PROT_SERIAL, - 0 +const BackendVtable serial_backend = { + .init = serial_init, + .free = serial_free, + .reconfig = serial_reconfig, + .send = serial_send, + .sendbuffer = serial_sendbuffer, + .size = serial_size, + .special = serial_special, + .get_specials = serial_get_specials, + .connected = serial_connected, + .exitcode = serial_exitcode, + .sendok = serial_sendok, + .ldisc_option_state = serial_ldisc, + .provide_ldisc = serial_provide_ldisc, + .unthrottle = serial_unthrottle, + .cfg_info = serial_cfg_info, + .id = "serial", + .displayname = "Serial", + .protocol = PROT_SERIAL, }; diff --git a/x11fwd.c b/x11fwd.c index be024804..86f85831 100644 --- a/x11fwd.c +++ b/x11fwd.c @@ -762,11 +762,10 @@ int x11_get_screen_number(char *display) } static const PlugVtable X11Connection_plugvt = { - x11_log, - x11_closing, - x11_receive, - x11_sent, - NULL + .log = x11_log, + .closing = x11_closing, + .receive = x11_receive, + .sent = x11_sent, }; static void x11_chan_free(Channel *chan); @@ -776,29 +775,29 @@ static void x11_send_eof(Channel *chan); static void x11_set_input_wanted(Channel *chan, bool wanted); static char *x11_log_close_msg(Channel *chan); -static const struct ChannelVtable X11Connection_channelvt = { - x11_chan_free, - chan_remotely_opened_confirmation, - chan_remotely_opened_failure, - x11_send, - x11_send_eof, - x11_set_input_wanted, - x11_log_close_msg, - chan_default_want_close, - chan_no_exit_status, - chan_no_exit_signal, - chan_no_exit_signal_numeric, - chan_no_run_shell, - chan_no_run_command, - chan_no_run_subsystem, - chan_no_enable_x11_forwarding, - chan_no_enable_agent_forwarding, - chan_no_allocate_pty, - chan_no_set_env, - chan_no_send_break, - chan_no_send_signal, - chan_no_change_window_size, - chan_no_request_response, +static const ChannelVtable X11Connection_channelvt = { + .free = x11_chan_free, + .open_confirmation = chan_remotely_opened_confirmation, + .open_failed = chan_remotely_opened_failure, + .send = x11_send, + .send_eof = x11_send_eof, + .set_input_wanted = x11_set_input_wanted, + .log_close_msg = x11_log_close_msg, + .want_close = chan_default_want_close, + .rcvd_exit_status = chan_no_exit_status, + .rcvd_exit_signal = chan_no_exit_signal, + .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric, + .run_shell = chan_no_run_shell, + .run_command = chan_no_run_command, + .run_subsystem = chan_no_run_subsystem, + .enable_x11_forwarding = chan_no_enable_x11_forwarding, + .enable_agent_forwarding = chan_no_enable_agent_forwarding, + .allocate_pty = chan_no_allocate_pty, + .set_env = chan_no_set_env, + .send_break = chan_no_send_break, + .send_signal = chan_no_send_signal, + .change_window_size = chan_no_change_window_size, + .request_response = chan_no_request_response, }; /*