summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-26 13:57:41 +1100
committerDamien Miller <djm@mindrot.org>2006-03-26 13:57:41 +1100
commitd62f2ca376168c716e4b485512a2b62b461e45b2 (patch)
treeec0388618d158579a58aaec9b880f5bc13cb5b5d /channels.c
parent4ca108d19235c42fcfc69bb05b1f2e85217ec45e (diff)
- deraadt@cvs.openbsd.org 2006/03/19 18:52:11
[auth1.c authfd.c channels.c] spacing
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c51
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 */
726typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset); 725typedef void chan_fn(Channel *c, fd_set *readset, fd_set *writeset);
727chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; 726chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE];
728chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; 727chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE];
729 728
730static void 729static void
731channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) 730channel_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
736static void 735static void
737channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) 736channel_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
743static void 742static void
744channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) 743channel_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
752static void 751static void
753channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) 752channel_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
792static void 791static void
793channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) 792channel_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
804static void 803static void
805channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) 804channel_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
880static void 879static void
881channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) 880channel_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
906static void 905static void
907channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) 906channel_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 */
933static int 932static int
934channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) 933channel_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
1011static int 1010static int
1012channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) 1011channel_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 */
1114static void 1113static void
1115channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) 1114channel_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. */
1158static void 1157static void
1159channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) 1158channel_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 */
1283static void 1282static void
1284channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) 1283channel_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 */
1340static void 1339static void
1341channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) 1340channel_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
1373static void 1372static void
1374channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) 1373channel_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
1419static int 1418static int
1420channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) 1419channel_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}
1459static int 1458static int
1460channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) 1459channel_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}
1546static int 1545static int
1547channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) 1546channel_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}
1589static int 1588static int
1590channel_handle_ctl(Channel *c, fd_set * readset, fd_set * writeset) 1589channel_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
1636static void 1635static void
1637channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) 1636channel_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
1650static void 1649static void
1651channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) 1650channel_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
1767static void 1766static void
1768channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) 1767channel_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 */
1819void 1818void
1820channel_after_select(fd_set * readset, fd_set * writeset) 1819channel_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}