2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * Server main loop for handling the interactive session.
7 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is
10 * incompatible with the protocol description in the RFC file, it must be
11 * called by a name other than "ssh" or "Secure Shell".
13 * SSH2 support by Markus Friedl.
14 * Copyright (c) 2000 Markus Friedl. All rights reserved.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 RCSID("$OpenBSD: serverloop.c,v 1.54 2001/03/04 01:46:30 djm Exp $");
53 #include "auth-options.h"
54 #include "serverloop.h"
57 extern ServerOptions options;
59 static Buffer stdin_buffer; /* Buffer for stdin data. */
60 static Buffer stdout_buffer; /* Buffer for stdout data. */
61 static Buffer stderr_buffer; /* Buffer for stderr data. */
62 static int fdin; /* Descriptor for stdin (for writing) */
63 static int fdout; /* Descriptor for stdout (for reading);
64 May be same number as fdin. */
65 static int fderr; /* Descriptor for stderr. May be -1. */
66 static long stdin_bytes = 0; /* Number of bytes written to stdin. */
67 static long stdout_bytes = 0; /* Number of stdout bytes sent to client. */
68 static long stderr_bytes = 0; /* Number of stderr bytes sent to client. */
69 static long fdout_bytes = 0; /* Number of stdout bytes read from program. */
70 static int stdin_eof = 0; /* EOF message received from client. */
71 static int fdout_eof = 0; /* EOF encountered reading from fdout. */
72 static int fderr_eof = 0; /* EOF encountered readung from fderr. */
73 static int fdin_is_tty = 0; /* fdin points to a tty. */
74 static int connection_in; /* Connection to client (input). */
75 static int connection_out; /* Connection to client (output). */
76 static u_int buffer_high;/* "Soft" max buffer size. */
79 * This SIGCHLD kludge is used to detect when the child exits. The server
80 * will exit after that, as soon as forwarded connections have terminated.
83 static pid_t child_pid; /* Pid of the child. */
84 static volatile int child_terminated; /* The child has terminated. */
85 static volatile int child_wait_status; /* Status from wait(). */
87 void server_init_dispatch(void);
90 sigchld_handler(int sig)
92 int save_errno = errno;
95 debug("Received SIGCHLD.");
96 wait_pid = wait((int *) &child_wait_status);
98 if (wait_pid != child_pid)
99 error("Strange, got SIGCHLD and wait returned pid %d but child is %d",
100 wait_pid, child_pid);
101 if (WIFEXITED(child_wait_status) ||
102 WIFSIGNALED(child_wait_status))
103 child_terminated = 1;
105 signal(SIGCHLD, sigchld_handler);
109 sigchld_handler2(int sig)
111 int save_errno = errno;
112 debug("Received SIGCHLD.");
113 child_terminated = 1;
114 mysignal(SIGCHLD, sigchld_handler2);
119 * Make packets from buffered stderr data, and buffer it for sending
123 make_packets_from_stderr_data(void)
127 /* Send buffered stderr data to the client. */
128 while (buffer_len(&stderr_buffer) > 0 &&
129 packet_not_very_much_data_to_write()) {
130 len = buffer_len(&stderr_buffer);
131 if (packet_is_interactive()) {
135 /* Keep the packets at reasonable size. */
136 if (len > packet_get_maxsize())
137 len = packet_get_maxsize();
139 packet_start(SSH_SMSG_STDERR_DATA);
140 packet_put_string(buffer_ptr(&stderr_buffer), len);
142 buffer_consume(&stderr_buffer, len);
148 * Make packets from buffered stdout data, and buffer it for sending to the
152 make_packets_from_stdout_data(void)
156 /* Send buffered stdout data to the client. */
157 while (buffer_len(&stdout_buffer) > 0 &&
158 packet_not_very_much_data_to_write()) {
159 len = buffer_len(&stdout_buffer);
160 if (packet_is_interactive()) {
164 /* Keep the packets at reasonable size. */
165 if (len > packet_get_maxsize())
166 len = packet_get_maxsize();
168 packet_start(SSH_SMSG_STDOUT_DATA);
169 packet_put_string(buffer_ptr(&stdout_buffer), len);
171 buffer_consume(&stdout_buffer, len);
177 * Sleep in select() until we can do something. This will initialize the
178 * select masks. Upon return, the masks will indicate which descriptors
179 * have data or can accept data. Optionally, a maximum time can be specified
180 * for the duration of the wait (0 = infinite).
183 wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
184 u_int max_time_milliseconds)
186 struct timeval tv, *tvp;
189 /* When select fails we restart from here. */
192 /* Allocate and update select() masks for channel descriptors. */
193 channel_prepare_select(readsetp, writesetp, maxfdp);
196 /* wrong: bad condition XXX */
197 if (channel_not_very_much_buffered_data())
198 FD_SET(connection_in, *readsetp);
201 * Read packets from the client unless we have too much
202 * buffered stdin or channel data.
204 if (buffer_len(&stdin_buffer) < buffer_high &&
205 channel_not_very_much_buffered_data())
206 FD_SET(connection_in, *readsetp);
208 * If there is not too much data already buffered going to
209 * the client, try to get some more data from the program.
211 if (packet_not_very_much_data_to_write()) {
213 FD_SET(fdout, *readsetp);
215 FD_SET(fderr, *readsetp);
218 * If we have buffered data, try to write some of that data
221 if (fdin != -1 && buffer_len(&stdin_buffer) > 0)
222 FD_SET(fdin, *writesetp);
226 * If we have buffered packet data going to the client, mark that
229 if (packet_have_data_to_write())
230 FD_SET(connection_out, *writesetp);
233 * If child has terminated and there is enough buffer space to read
234 * from it, then read as much as is available and exit.
236 if (child_terminated && packet_not_very_much_data_to_write())
237 if (max_time_milliseconds == 0)
238 max_time_milliseconds = 100;
240 if (max_time_milliseconds == 0)
243 tv.tv_sec = max_time_milliseconds / 1000;
244 tv.tv_usec = 1000 * (max_time_milliseconds % 1000);
248 debug3("tvp!=NULL kid %d mili %d", child_terminated, max_time_milliseconds);
250 /* Wait for something to happen, or the timeout to expire. */
251 ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp);
255 error("select: %.100s", strerror(errno));
262 * Processes input from the client and the program. Input data is stored
263 * in buffers and processed later.
266 process_input(fd_set * readset)
271 /* Read and buffer any input data from the client. */
272 if (FD_ISSET(connection_in, readset)) {
273 len = read(connection_in, buf, sizeof(buf));
275 verbose("Connection closed by remote host.");
277 } else if (len < 0) {
278 if (errno != EINTR && errno != EAGAIN) {
279 verbose("Read error from remote host: %.100s", strerror(errno));
283 /* Buffer any received data. */
284 packet_process_incoming(buf, len);
290 /* Read and buffer any available stdout data from the program. */
291 if (!fdout_eof && FD_ISSET(fdout, readset)) {
292 len = read(fdout, buf, sizeof(buf));
293 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
295 } else if (len <= 0) {
298 buffer_append(&stdout_buffer, buf, len);
302 /* Read and buffer any available stderr data from the program. */
303 if (!fderr_eof && FD_ISSET(fderr, readset)) {
304 len = read(fderr, buf, sizeof(buf));
305 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
307 } else if (len <= 0) {
310 buffer_append(&stderr_buffer, buf, len);
316 * Sends data from internal buffers to client program stdin.
319 process_output(fd_set * writeset)
324 /* Write buffered data to program stdin. */
325 if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
326 len = write(fdin, buffer_ptr(&stdin_buffer),
327 buffer_len(&stdin_buffer));
328 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
330 } else if (len <= 0) {
337 shutdown(fdin, SHUT_WR); /* We will no longer send. */
341 /* Successful write. */
342 if (fdin_is_tty && tcgetattr(fdin, &tio) == 0 &&
343 !(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
345 * Simulate echo to reduce the impact of
348 packet_send_ignore(len);
351 /* Consume the data from the buffer. */
352 buffer_consume(&stdin_buffer, len);
353 /* Update the count of bytes written to the program. */
357 /* Send any buffered packet data to the client. */
358 if (FD_ISSET(connection_out, writeset))
363 * Wait until all buffered output has been sent to the client.
364 * This is used when the program terminates.
369 /* Send any buffered stdout data to the client. */
370 if (buffer_len(&stdout_buffer) > 0) {
371 packet_start(SSH_SMSG_STDOUT_DATA);
372 packet_put_string(buffer_ptr(&stdout_buffer),
373 buffer_len(&stdout_buffer));
375 /* Update the count of sent bytes. */
376 stdout_bytes += buffer_len(&stdout_buffer);
378 /* Send any buffered stderr data to the client. */
379 if (buffer_len(&stderr_buffer) > 0) {
380 packet_start(SSH_SMSG_STDERR_DATA);
381 packet_put_string(buffer_ptr(&stderr_buffer),
382 buffer_len(&stderr_buffer));
384 /* Update the count of sent bytes. */
385 stderr_bytes += buffer_len(&stderr_buffer);
387 /* Wait until all buffered data has been written to the client. */
392 process_buffered_input_packets(void)
394 dispatch_run(DISPATCH_NONBLOCK, NULL, NULL);
398 * Performs the interactive session. This handles data transmission between
399 * the client and the program. Note that the notion of stdin, stdout, and
400 * stderr in this function is sort of reversed: this function writes to
401 * stdin (of the child program), and reads from stdout and stderr (of the
405 server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
407 fd_set *readset = NULL, *writeset = NULL;
409 int wait_status; /* Status returned by wait(). */
410 pid_t wait_pid; /* pid returned by wait(). */
411 int waiting_termination = 0; /* Have displayed waiting close message. */
412 u_int max_time_milliseconds;
413 u_int previous_stdout_buffer_bytes;
414 u_int stdout_buffer_bytes;
417 debug("Entering interactive session.");
419 /* Initialize the SIGCHLD kludge. */
421 child_terminated = 0;
422 signal(SIGCHLD, sigchld_handler);
423 signal(SIGPIPE, SIG_IGN);
425 /* Initialize our global variables. */
433 /* we don't have stderr for interactive terminal sessions, see below */
437 if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
440 connection_in = packet_get_connection_in();
441 connection_out = packet_get_connection_out();
443 previous_stdout_buffer_bytes = 0;
445 /* Set approximate I/O buffer size. */
446 if (packet_is_interactive())
449 buffer_high = 64 * 1024;
451 /* Initialize max_fd to the maximum of the known file descriptors. */
452 max_fd = MAX(fdin, fdout);
454 max_fd = MAX(max_fd, fderr);
455 max_fd = MAX(max_fd, connection_in);
456 max_fd = MAX(max_fd, connection_out);
458 /* Initialize Initialize buffers. */
459 buffer_init(&stdin_buffer);
460 buffer_init(&stdout_buffer);
461 buffer_init(&stderr_buffer);
464 * If we have no separate fderr (which is the case when we have a pty
465 * - there we cannot make difference between data sent to stdout and
466 * stderr), indicate that we have seen an EOF from stderr. This way
467 * we don\'t need to check the descriptor everywhere.
472 server_init_dispatch();
474 /* Main loop of the server for the interactive session mode. */
477 /* Process buffered packets from the client. */
478 process_buffered_input_packets();
481 * If we have received eof, and there is no more pending
482 * input data, cause a real eof by closing fdin.
484 if (stdin_eof && fdin != -1 && buffer_len(&stdin_buffer) == 0) {
491 shutdown(fdin, SHUT_WR); /* We will no longer send. */
495 /* Make packets from buffered stderr data to send to the client. */
496 make_packets_from_stderr_data();
499 * Make packets from buffered stdout data to send to the
500 * client. If there is very little to send, this arranges to
501 * not send them now, but to wait a short while to see if we
502 * are getting more data. This is necessary, as some systems
503 * wake up readers from a pty after each separate character.
505 max_time_milliseconds = 0;
506 stdout_buffer_bytes = buffer_len(&stdout_buffer);
507 if (stdout_buffer_bytes != 0 && stdout_buffer_bytes < 256 &&
508 stdout_buffer_bytes != previous_stdout_buffer_bytes) {
509 /* try again after a while */
510 max_time_milliseconds = 10;
513 make_packets_from_stdout_data();
515 previous_stdout_buffer_bytes = buffer_len(&stdout_buffer);
517 /* Send channel data to the client. */
518 if (packet_not_very_much_data_to_write())
519 channel_output_poll();
522 * Bail out of the loop if the program has closed its output
523 * descriptors, and we have no more data to send to the
524 * client, and there is no pending buffered data.
526 if (fdout_eof && fderr_eof && !packet_have_data_to_write() &&
527 buffer_len(&stdout_buffer) == 0 && buffer_len(&stderr_buffer) == 0) {
528 if (!channel_still_open())
530 if (!waiting_termination) {
531 const char *s = "Waiting for forwarded connections to terminate...\r\n";
533 waiting_termination = 1;
534 buffer_append(&stderr_buffer, s, strlen(s));
536 /* Display list of open channels. */
537 cp = channel_open_message();
538 buffer_append(&stderr_buffer, cp, strlen(cp));
542 /* Sleep in select() until we can do something. */
543 wait_until_can_do_something(&readset, &writeset, &max_fd,
544 max_time_milliseconds);
546 /* Process any channel events. */
547 channel_after_select(readset, writeset);
549 /* Process input from the client and from program stdout/stderr. */
550 process_input(readset);
552 /* Process output to the client and to program stdin. */
553 process_output(writeset);
560 /* Cleanup and termination code. */
562 /* Wait until all output has been sent to the client. */
565 debug("End of interactive session; stdin %ld, stdout (read %ld, sent %ld), stderr %ld bytes.",
566 stdin_bytes, fdout_bytes, stdout_bytes, stderr_bytes);
568 /* Free and clear the buffers. */
569 buffer_free(&stdin_buffer);
570 buffer_free(&stdout_buffer);
571 buffer_free(&stderr_buffer);
573 /* Close the file descriptors. */
586 /* Stop listening for channels; this removes unix domain sockets. */
587 channel_stop_listening();
589 /* Wait for the child to exit. Get its exit status. */
590 wait_pid = wait(&wait_status);
591 if (wait_pid == -1) {
593 * It is possible that the wait was handled by SIGCHLD
594 * handler. This may result in either: this call
595 * returning with EINTR, or: this call returning ECHILD.
597 if (child_terminated)
598 wait_status = child_wait_status;
600 packet_disconnect("wait: %.100s", strerror(errno));
602 /* Check if it matches the process we forked. */
604 error("Strange, wait returned pid %d, expected %d",
608 /* We no longer want our SIGCHLD handler to be called. */
609 signal(SIGCHLD, SIG_DFL);
611 /* Check if it exited normally. */
612 if (WIFEXITED(wait_status)) {
613 /* Yes, normal exit. Get exit status and send it to the client. */
614 debug("Command exited with status %d.", WEXITSTATUS(wait_status));
615 packet_start(SSH_SMSG_EXITSTATUS);
616 packet_put_int(WEXITSTATUS(wait_status));
621 * Wait for exit confirmation. Note that there might be
622 * other packets coming before it; however, the program has
623 * already died so we just ignore them. The client is
624 * supposed to respond with the confirmation when it receives
629 type = packet_read(&plen);
631 while (type != SSH_CMSG_EXIT_CONFIRMATION);
633 debug("Received exit confirmation.");
636 /* Check if the program terminated due to a signal. */
637 if (WIFSIGNALED(wait_status))
638 packet_disconnect("Command terminated on signal %d.",
639 WTERMSIG(wait_status));
641 /* Some weird exit cause. Just exit. */
642 packet_disconnect("wait returned status %04x.", wait_status);
649 fd_set *readset = NULL, *writeset = NULL;
655 debug("Entering interactive session for SSH2.");
657 mysignal(SIGCHLD, sigchld_handler2);
658 signal(SIGPIPE, SIG_IGN);
659 child_terminated = 0;
660 connection_in = packet_get_connection_in();
661 connection_out = packet_get_connection_out();
663 max_fd = MAX(connection_in, connection_out);
665 server_init_dispatch();
668 process_buffered_input_packets();
669 if (!had_channel && channel_still_open())
671 if (had_channel && !channel_still_open()) {
672 debug("!channel_still_open.");
675 if (packet_not_very_much_data_to_write())
676 channel_output_poll();
677 wait_until_can_do_something(&readset, &writeset, &max_fd, 0);
678 if (child_terminated) {
679 while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
680 session_close_by_pid(pid, status);
681 child_terminated = 0;
683 channel_after_select(readset, writeset);
684 process_input(readset);
685 process_output(writeset);
692 signal(SIGCHLD, SIG_DFL);
693 while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
694 session_close_by_pid(pid, status);
695 channel_stop_listening();
699 server_input_stdin_data(int type, int plen, void *ctxt)
704 /* Stdin data from the client. Append it to the buffer. */
705 /* Ignore any data if the client has closed stdin. */
708 data = packet_get_string(&data_len);
709 packet_integrity_check(plen, (4 + data_len), type);
710 buffer_append(&stdin_buffer, data, data_len);
711 memset(data, 0, data_len);
716 server_input_eof(int type, int plen, void *ctxt)
719 * Eof from the client. The stdin descriptor to the
720 * program will be closed when all buffered data has
723 debug("EOF received for stdin.");
724 packet_integrity_check(plen, 0, type);
729 server_input_window_size(int type, int plen, void *ctxt)
731 int row = packet_get_int();
732 int col = packet_get_int();
733 int xpixel = packet_get_int();
734 int ypixel = packet_get_int();
736 debug("Window change received.");
737 packet_integrity_check(plen, 4 * 4, type);
739 pty_change_window_size(fdin, row, col, xpixel, ypixel);
743 server_request_direct_tcpip(char *ctype)
746 char *target, *originator;
747 int target_port, originator_port;
749 target = packet_get_string(NULL);
750 target_port = packet_get_int();
751 originator = packet_get_string(NULL);
752 originator_port = packet_get_int();
755 debug("server_request_direct_tcpip: originator %s port %d, target %s port %d",
756 originator, originator_port, target, target_port);
758 /* XXX check permission */
759 if (no_port_forwarding_flag || !options.allow_tcp_forwarding) {
764 sock = channel_connect_to(target, target_port);
769 newch = channel_new(ctype, SSH_CHANNEL_CONNECTING,
770 sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT,
771 CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1);
772 return (newch >= 0) ? channel_lookup(newch) : NULL;
776 server_request_session(char *ctype)
780 debug("input_session_request");
783 * A server session has no fd to read or write until a
784 * CHANNEL_REQUEST for a shell is made, so we set the type to
785 * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all
786 * CHANNEL_REQUEST messages is registered.
788 newch = channel_new(ctype, SSH_CHANNEL_LARVAL,
789 -1, -1, -1, 0, CHAN_SES_PACKET_DEFAULT,
790 0, xstrdup("server-session"), 1);
791 if (session_open(newch) == 1) {
792 channel_register_callback(newch, SSH2_MSG_CHANNEL_REQUEST,
793 session_input_channel_req, (void *)0);
794 channel_register_cleanup(newch, session_close_by_channel);
795 return channel_lookup(newch);
797 debug("session open failed, free channel %d", newch);
804 server_input_channel_open(int type, int plen, void *ctxt)
813 ctype = packet_get_string(&len);
814 rchan = packet_get_int();
815 rwindow = packet_get_int();
816 rmaxpack = packet_get_int();
818 debug("server_input_channel_open: ctype %s rchan %d win %d max %d",
819 ctype, rchan, rwindow, rmaxpack);
821 if (strcmp(ctype, "session") == 0) {
822 c = server_request_session(ctype);
823 } else if (strcmp(ctype, "direct-tcpip") == 0) {
824 c = server_request_direct_tcpip(ctype);
827 debug("server_input_channel_open: confirm %s", ctype);
828 c->remote_id = rchan;
829 c->remote_window = rwindow;
830 c->remote_maxpacket = rmaxpack;
832 packet_start(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION);
833 packet_put_int(c->remote_id);
834 packet_put_int(c->self);
835 packet_put_int(c->local_window);
836 packet_put_int(c->local_maxpacket);
839 debug("server_input_channel_open: failure %s", ctype);
840 packet_start(SSH2_MSG_CHANNEL_OPEN_FAILURE);
841 packet_put_int(rchan);
842 packet_put_int(SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED);
843 packet_put_cstring("bla bla");
844 packet_put_cstring("");
851 server_input_global_request(int type, int plen, void *ctxt)
857 rtype = packet_get_string(NULL);
858 want_reply = packet_get_char();
859 debug("server_input_global_request: rtype %s want_reply %d", rtype, want_reply);
861 if (strcmp(rtype, "tcpip-forward") == 0) {
863 char *listen_address;
866 pw = auth_get_user();
868 fatal("server_input_global_request: no user");
869 listen_address = packet_get_string(NULL); /* XXX currently ignored */
870 listen_port = (u_short)packet_get_int();
871 debug("server_input_global_request: tcpip-forward listen %s port %d",
872 listen_address, listen_port);
874 /* check permissions */
875 if (!options.allow_tcp_forwarding ||
876 no_port_forwarding_flag ||
877 (listen_port < IPPORT_RESERVED && pw->pw_uid != 0)) {
879 packet_send_debug("Server has disabled port forwarding.");
881 /* Start listening on the port */
882 success = channel_request_forwarding(
883 listen_address, listen_port,
884 /*unspec host_to_connect*/ "<unspec host>",
885 /*unspec port_to_connect*/ 0,
886 options.gateway_ports, /*remote*/ 1);
888 xfree(listen_address);
891 packet_start(success ?
892 SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
900 server_init_dispatch_20(void)
902 debug("server_init_dispatch_20");
903 dispatch_init(&dispatch_protocol_error);
904 dispatch_set(SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose);
905 dispatch_set(SSH2_MSG_CHANNEL_DATA, &channel_input_data);
906 dispatch_set(SSH2_MSG_CHANNEL_EOF, &channel_input_ieof);
907 dispatch_set(SSH2_MSG_CHANNEL_EXTENDED_DATA, &channel_input_extended_data);
908 dispatch_set(SSH2_MSG_CHANNEL_OPEN, &server_input_channel_open);
909 dispatch_set(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation);
910 dispatch_set(SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
911 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
912 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
913 dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request);
916 server_init_dispatch_13(void)
918 debug("server_init_dispatch_13");
920 dispatch_set(SSH_CMSG_EOF, &server_input_eof);
921 dispatch_set(SSH_CMSG_STDIN_DATA, &server_input_stdin_data);
922 dispatch_set(SSH_CMSG_WINDOW_SIZE, &server_input_window_size);
923 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_close);
924 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_close_confirmation);
925 dispatch_set(SSH_MSG_CHANNEL_DATA, &channel_input_data);
926 dispatch_set(SSH_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation);
927 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
928 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open);
931 server_init_dispatch_15(void)
933 server_init_dispatch_13();
934 debug("server_init_dispatch_15");
935 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof);
936 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose);
939 server_init_dispatch(void)
942 server_init_dispatch_20();
944 server_init_dispatch_13();
946 server_init_dispatch_15();