diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/channels.c b/channels.c index 30c6d3870..ce868dc4e 100644 --- a/channels.c +++ b/channels.c | |||
@@ -173,7 +173,7 @@ channel_lookup(int id) | |||
173 | if ((c = channel_by_id(id)) == NULL) | 173 | if ((c = channel_by_id(id)) == NULL) |
174 | return (NULL); | 174 | return (NULL); |
175 | 175 | ||
176 | switch(c->type) { | 176 | switch (c->type) { |
177 | case SSH_CHANNEL_X11_OPEN: | 177 | case SSH_CHANNEL_X11_OPEN: |
178 | case SSH_CHANNEL_LARVAL: | 178 | case SSH_CHANNEL_LARVAL: |
179 | case SSH_CHANNEL_CONNECTING: | 179 | case SSH_CHANNEL_CONNECTING: |
@@ -183,7 +183,6 @@ channel_lookup(int id) | |||
183 | case SSH_CHANNEL_INPUT_DRAINING: | 183 | case SSH_CHANNEL_INPUT_DRAINING: |
184 | case SSH_CHANNEL_OUTPUT_DRAINING: | 184 | case SSH_CHANNEL_OUTPUT_DRAINING: |
185 | return (c); | 185 | return (c); |
186 | break; | ||
187 | } | 186 | } |
188 | logit("Non-public channel %d, type %d.", id, c->type); | 187 | logit("Non-public channel %d, type %d.", id, c->type); |
189 | return (NULL); | 188 | return (NULL); |
@@ -723,25 +722,25 @@ channel_set_fds(int id, int rfd, int wfd, int efd, | |||
723 | * 'channel_post*': perform any appropriate operations for channels which | 722 | * 'channel_post*': perform any appropriate operations for channels which |
724 | * have events pending. | 723 | * have events pending. |
725 | */ | 724 | */ |
726 | typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset); | 725 | typedef void chan_fn(Channel *c, fd_set *readset, fd_set *writeset); |
727 | chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; | 726 | chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; |
728 | chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; | 727 | chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; |
729 | 728 | ||
730 | static void | 729 | static void |
731 | channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) | 730 | channel_pre_listener(Channel *c, fd_set *readset, fd_set *writeset) |
732 | { | 731 | { |
733 | FD_SET(c->sock, readset); | 732 | FD_SET(c->sock, readset); |
734 | } | 733 | } |
735 | 734 | ||
736 | static void | 735 | static void |
737 | channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) | 736 | channel_pre_connecting(Channel *c, fd_set *readset, fd_set *writeset) |
738 | { | 737 | { |
739 | debug3("channel %d: waiting for connection", c->self); | 738 | debug3("channel %d: waiting for connection", c->self); |
740 | FD_SET(c->sock, writeset); | 739 | FD_SET(c->sock, writeset); |
741 | } | 740 | } |
742 | 741 | ||
743 | static void | 742 | static void |
744 | channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) | 743 | channel_pre_open_13(Channel *c, fd_set *readset, fd_set *writeset) |
745 | { | 744 | { |
746 | if (buffer_len(&c->input) < packet_get_maxsize()) | 745 | if (buffer_len(&c->input) < packet_get_maxsize()) |
747 | FD_SET(c->sock, readset); | 746 | FD_SET(c->sock, readset); |
@@ -750,7 +749,7 @@ channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) | |||
750 | } | 749 | } |
751 | 750 | ||
752 | static void | 751 | static void |
753 | channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) | 752 | channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset) |
754 | { | 753 | { |
755 | u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); | 754 | u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); |
756 | 755 | ||
@@ -790,7 +789,7 @@ channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
790 | } | 789 | } |
791 | 790 | ||
792 | static void | 791 | static void |
793 | channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) | 792 | channel_pre_input_draining(Channel *c, fd_set *readset, fd_set *writeset) |
794 | { | 793 | { |
795 | if (buffer_len(&c->input) == 0) { | 794 | if (buffer_len(&c->input) == 0) { |
796 | packet_start(SSH_MSG_CHANNEL_CLOSE); | 795 | packet_start(SSH_MSG_CHANNEL_CLOSE); |
@@ -802,7 +801,7 @@ channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) | |||
802 | } | 801 | } |
803 | 802 | ||
804 | static void | 803 | static void |
805 | channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) | 804 | channel_pre_output_draining(Channel *c, fd_set *readset, fd_set *writeset) |
806 | { | 805 | { |
807 | if (buffer_len(&c->output) == 0) | 806 | if (buffer_len(&c->output) == 0) |
808 | chan_mark_dead(c); | 807 | chan_mark_dead(c); |
@@ -878,7 +877,7 @@ x11_open_helper(Buffer *b) | |||
878 | } | 877 | } |
879 | 878 | ||
880 | static void | 879 | static void |
881 | channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) | 880 | channel_pre_x11_open_13(Channel *c, fd_set *readset, fd_set *writeset) |
882 | { | 881 | { |
883 | int ret = x11_open_helper(&c->output); | 882 | int ret = x11_open_helper(&c->output); |
884 | 883 | ||
@@ -904,7 +903,7 @@ channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) | |||
904 | } | 903 | } |
905 | 904 | ||
906 | static void | 905 | static void |
907 | channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | 906 | channel_pre_x11_open(Channel *c, fd_set *readset, fd_set *writeset) |
908 | { | 907 | { |
909 | int ret = x11_open_helper(&c->output); | 908 | int ret = x11_open_helper(&c->output); |
910 | 909 | ||
@@ -931,7 +930,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
931 | 930 | ||
932 | /* try to decode a socks4 header */ | 931 | /* try to decode a socks4 header */ |
933 | static int | 932 | static int |
934 | channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | 933 | channel_decode_socks4(Channel *c, fd_set *readset, fd_set *writeset) |
935 | { | 934 | { |
936 | char *p, *host; | 935 | char *p, *host; |
937 | u_int len, have, i, found; | 936 | u_int len, have, i, found; |
@@ -1009,7 +1008,7 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | |||
1009 | #define SSH_SOCKS5_SUCCESS 0x00 | 1008 | #define SSH_SOCKS5_SUCCESS 0x00 |
1010 | 1009 | ||
1011 | static int | 1010 | static int |
1012 | channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | 1011 | channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset) |
1013 | { | 1012 | { |
1014 | struct { | 1013 | struct { |
1015 | u_int8_t version; | 1014 | u_int8_t version; |
@@ -1112,7 +1111,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | |||
1112 | 1111 | ||
1113 | /* dynamic port forwarding */ | 1112 | /* dynamic port forwarding */ |
1114 | static void | 1113 | static void |
1115 | channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) | 1114 | channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset) |
1116 | { | 1115 | { |
1117 | u_char *p; | 1116 | u_char *p; |
1118 | u_int have; | 1117 | u_int have; |
@@ -1156,7 +1155,7 @@ channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) | |||
1156 | 1155 | ||
1157 | /* This is our fake X11 server socket. */ | 1156 | /* This is our fake X11 server socket. */ |
1158 | static void | 1157 | static void |
1159 | channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | 1158 | channel_post_x11_listener(Channel *c, fd_set *readset, fd_set *writeset) |
1160 | { | 1159 | { |
1161 | Channel *nc; | 1160 | Channel *nc; |
1162 | struct sockaddr addr; | 1161 | struct sockaddr addr; |
@@ -1281,7 +1280,7 @@ channel_set_reuseaddr(int fd) | |||
1281 | * This socket is listening for connections to a forwarded TCP/IP port. | 1280 | * This socket is listening for connections to a forwarded TCP/IP port. |
1282 | */ | 1281 | */ |
1283 | static void | 1282 | static void |
1284 | channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) | 1283 | channel_post_port_listener(Channel *c, fd_set *readset, fd_set *writeset) |
1285 | { | 1284 | { |
1286 | Channel *nc; | 1285 | Channel *nc; |
1287 | struct sockaddr addr; | 1286 | struct sockaddr addr; |
@@ -1338,7 +1337,7 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1338 | * clients. | 1337 | * clients. |
1339 | */ | 1338 | */ |
1340 | static void | 1339 | static void |
1341 | channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) | 1340 | channel_post_auth_listener(Channel *c, fd_set *readset, fd_set *writeset) |
1342 | { | 1341 | { |
1343 | Channel *nc; | 1342 | Channel *nc; |
1344 | int newsock; | 1343 | int newsock; |
@@ -1371,7 +1370,7 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1371 | } | 1370 | } |
1372 | 1371 | ||
1373 | static void | 1372 | static void |
1374 | channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) | 1373 | channel_post_connecting(Channel *c, fd_set *readset, fd_set *writeset) |
1375 | { | 1374 | { |
1376 | int err = 0; | 1375 | int err = 0; |
1377 | socklen_t sz = sizeof(err); | 1376 | socklen_t sz = sizeof(err); |
@@ -1417,7 +1416,7 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) | |||
1417 | } | 1416 | } |
1418 | 1417 | ||
1419 | static int | 1418 | static int |
1420 | channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | 1419 | channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset) |
1421 | { | 1420 | { |
1422 | char buf[CHAN_RBUF]; | 1421 | char buf[CHAN_RBUF]; |
1423 | int len; | 1422 | int len; |
@@ -1457,7 +1456,7 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1457 | return 1; | 1456 | return 1; |
1458 | } | 1457 | } |
1459 | static int | 1458 | static int |
1460 | channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | 1459 | channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset) |
1461 | { | 1460 | { |
1462 | struct termios tio; | 1461 | struct termios tio; |
1463 | u_char *data = NULL, *buf; | 1462 | u_char *data = NULL, *buf; |
@@ -1544,7 +1543,7 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1544 | return 1; | 1543 | return 1; |
1545 | } | 1544 | } |
1546 | static int | 1545 | static int |
1547 | channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) | 1546 | channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset) |
1548 | { | 1547 | { |
1549 | char buf[CHAN_RBUF]; | 1548 | char buf[CHAN_RBUF]; |
1550 | int len; | 1549 | int len; |
@@ -1587,7 +1586,7 @@ channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1587 | return 1; | 1586 | return 1; |
1588 | } | 1587 | } |
1589 | static int | 1588 | static int |
1590 | channel_handle_ctl(Channel *c, fd_set * readset, fd_set * writeset) | 1589 | channel_handle_ctl(Channel *c, fd_set *readset, fd_set *writeset) |
1591 | { | 1590 | { |
1592 | char buf[16]; | 1591 | char buf[16]; |
1593 | int len; | 1592 | int len; |
@@ -1634,7 +1633,7 @@ channel_check_window(Channel *c) | |||
1634 | } | 1633 | } |
1635 | 1634 | ||
1636 | static void | 1635 | static void |
1637 | channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) | 1636 | channel_post_open(Channel *c, fd_set *readset, fd_set *writeset) |
1638 | { | 1637 | { |
1639 | if (c->delayed) | 1638 | if (c->delayed) |
1640 | return; | 1639 | return; |
@@ -1648,7 +1647,7 @@ channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
1648 | } | 1647 | } |
1649 | 1648 | ||
1650 | static void | 1649 | static void |
1651 | channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) | 1650 | channel_post_output_drain_13(Channel *c, fd_set *readset, fd_set *writeset) |
1652 | { | 1651 | { |
1653 | int len; | 1652 | int len; |
1654 | 1653 | ||
@@ -1765,7 +1764,7 @@ channel_garbage_collect(Channel *c) | |||
1765 | } | 1764 | } |
1766 | 1765 | ||
1767 | static void | 1766 | static void |
1768 | channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) | 1767 | channel_handler(chan_fn *ftab[], fd_set *readset, fd_set *writeset) |
1769 | { | 1768 | { |
1770 | static int did_init = 0; | 1769 | static int did_init = 0; |
1771 | u_int i; | 1770 | u_int i; |
@@ -1817,7 +1816,7 @@ channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | |||
1817 | * events pending. | 1816 | * events pending. |
1818 | */ | 1817 | */ |
1819 | void | 1818 | void |
1820 | channel_after_select(fd_set * readset, fd_set * writeset) | 1819 | channel_after_select(fd_set *readset, fd_set *writeset) |
1821 | { | 1820 | { |
1822 | channel_handler(channel_post, readset, writeset); | 1821 | channel_handler(channel_post, readset, writeset); |
1823 | } | 1822 | } |