diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-06-25 05:01:22 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-06-25 05:01:22 +0000 |
commit | bba81213b972ce15fbbaca60b9ffabb42371ce8f (patch) | |
tree | e6bd40752969f2b93d179cfb9aaae9074ca45956 /channels.c | |
parent | 34f91883a6f3123656b0a8017d68b658f7cf2403 (diff) |
- itojun@cvs.openbsd.org 2001/06/23 15:12:20
[auth1.c auth2.c auth2-chall.c authfd.c authfile.c auth-rhosts.c
canohost.c channels.c cipher.c clientloop.c deattack.c dh.c
hostfile.c kex.c kexdh.c kexgex.c key.c nchan.c packet.c radix.c
readpass.c scp.c servconf.c serverloop.c session.c sftp.c
sftp-client.c sftp-glob.c sftp-int.c sftp-server.c ssh-add.c
ssh-agent.c ssh.c sshconnect1.c sshconnect2.c sshconnect.c sshd.c
ssh-keygen.c ssh-keyscan.c]
more strict prototypes. raise warning level in Makefile.inc.
markus ok'ed
TODO; cleanup headers
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/channels.c b/channels.c index d9513fada..ce4c5952d 100644 --- a/channels.c +++ b/channels.c | |||
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | RCSID("$OpenBSD: channels.c,v 1.126 2001/06/20 13:56:39 markus Exp $"); | 43 | RCSID("$OpenBSD: channels.c,v 1.127 2001/06/23 15:12:17 itojun Exp $"); |
44 | 44 | ||
45 | #include "ssh.h" | 45 | #include "ssh.h" |
46 | #include "ssh1.h" | 46 | #include "ssh1.h" |
@@ -133,12 +133,11 @@ static u_int x11_fake_data_len; | |||
133 | static char *auth_sock_name = NULL; | 133 | static char *auth_sock_name = NULL; |
134 | static char *auth_sock_dir = NULL; | 134 | static char *auth_sock_dir = NULL; |
135 | 135 | ||
136 | |||
137 | /* AF_UNSPEC or AF_INET or AF_INET6 */ | 136 | /* AF_UNSPEC or AF_INET or AF_INET6 */ |
138 | extern int IPv4or6; | 137 | extern int IPv4or6; |
139 | 138 | ||
140 | /* helper */ | 139 | /* helper */ |
141 | void port_open_helper(Channel *c, char *rtype); | 140 | static void port_open_helper(Channel *c, char *rtype); |
142 | 141 | ||
143 | /* -- channel core */ | 142 | /* -- channel core */ |
144 | 143 | ||
@@ -164,7 +163,7 @@ channel_lookup(int id) | |||
164 | * when the channel consumer/producer is ready, e.g. shell exec'd | 163 | * when the channel consumer/producer is ready, e.g. shell exec'd |
165 | */ | 164 | */ |
166 | 165 | ||
167 | void | 166 | static void |
168 | channel_register_fds(Channel *c, int rfd, int wfd, int efd, | 167 | channel_register_fds(Channel *c, int rfd, int wfd, int efd, |
169 | int extusage, int nonblock) | 168 | int extusage, int nonblock) |
170 | { | 169 | { |
@@ -270,7 +269,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, | |||
270 | 269 | ||
271 | /* Close all channel fd/socket. */ | 270 | /* Close all channel fd/socket. */ |
272 | 271 | ||
273 | void | 272 | static void |
274 | channel_close_fds(Channel *c) | 273 | channel_close_fds(Channel *c) |
275 | { | 274 | { |
276 | debug3("channel_close_fds: channel %d: r %d w %d e %d", | 275 | debug3("channel_close_fds: channel %d: r %d w %d e %d", |
@@ -633,20 +632,20 @@ typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset); | |||
633 | chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; | 632 | chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; |
634 | chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; | 633 | chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; |
635 | 634 | ||
636 | void | 635 | static void |
637 | channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) | 636 | channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) |
638 | { | 637 | { |
639 | FD_SET(c->sock, readset); | 638 | FD_SET(c->sock, readset); |
640 | } | 639 | } |
641 | 640 | ||
642 | void | 641 | static void |
643 | channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) | 642 | channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) |
644 | { | 643 | { |
645 | debug3("channel %d: waiting for connection", c->self); | 644 | debug3("channel %d: waiting for connection", c->self); |
646 | FD_SET(c->sock, writeset); | 645 | FD_SET(c->sock, writeset); |
647 | } | 646 | } |
648 | 647 | ||
649 | void | 648 | static void |
650 | channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) | 649 | channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) |
651 | { | 650 | { |
652 | if (buffer_len(&c->input) < packet_get_maxsize()) | 651 | if (buffer_len(&c->input) < packet_get_maxsize()) |
@@ -655,7 +654,7 @@ channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) | |||
655 | FD_SET(c->sock, writeset); | 654 | FD_SET(c->sock, writeset); |
656 | } | 655 | } |
657 | 656 | ||
658 | void | 657 | static void |
659 | channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset) | 658 | channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset) |
660 | { | 659 | { |
661 | /* test whether sockets are 'alive' for read/write */ | 660 | /* test whether sockets are 'alive' for read/write */ |
@@ -672,7 +671,7 @@ channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset) | |||
672 | } | 671 | } |
673 | } | 672 | } |
674 | 673 | ||
675 | void | 674 | static void |
676 | channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset) | 675 | channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset) |
677 | { | 676 | { |
678 | if (c->istate == CHAN_INPUT_OPEN && | 677 | if (c->istate == CHAN_INPUT_OPEN && |
@@ -698,7 +697,7 @@ channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset) | |||
698 | } | 697 | } |
699 | } | 698 | } |
700 | 699 | ||
701 | void | 700 | static void |
702 | channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) | 701 | channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) |
703 | { | 702 | { |
704 | if (buffer_len(&c->input) == 0) { | 703 | if (buffer_len(&c->input) == 0) { |
@@ -710,7 +709,7 @@ channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) | |||
710 | } | 709 | } |
711 | } | 710 | } |
712 | 711 | ||
713 | void | 712 | static void |
714 | channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) | 713 | channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) |
715 | { | 714 | { |
716 | if (buffer_len(&c->output) == 0) | 715 | if (buffer_len(&c->output) == 0) |
@@ -728,7 +727,7 @@ channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) | |||
728 | * XXX All this happens at the client side. | 727 | * XXX All this happens at the client side. |
729 | * Returns: 0 = need more data, -1 = wrong cookie, 1 = ok | 728 | * Returns: 0 = need more data, -1 = wrong cookie, 1 = ok |
730 | */ | 729 | */ |
731 | int | 730 | static int |
732 | x11_open_helper(Buffer *b) | 731 | x11_open_helper(Buffer *b) |
733 | { | 732 | { |
734 | u_char *ucp; | 733 | u_char *ucp; |
@@ -786,7 +785,7 @@ x11_open_helper(Buffer *b) | |||
786 | return 1; | 785 | return 1; |
787 | } | 786 | } |
788 | 787 | ||
789 | void | 788 | static void |
790 | channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) | 789 | channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) |
791 | { | 790 | { |
792 | int ret = x11_open_helper(&c->output); | 791 | int ret = x11_open_helper(&c->output); |
@@ -811,7 +810,7 @@ channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) | |||
811 | } | 810 | } |
812 | } | 811 | } |
813 | 812 | ||
814 | void | 813 | static void |
815 | channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | 814 | channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) |
816 | { | 815 | { |
817 | int ret = x11_open_helper(&c->output); | 816 | int ret = x11_open_helper(&c->output); |
@@ -830,7 +829,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
830 | } | 829 | } |
831 | 830 | ||
832 | /* try to decode a socks4 header */ | 831 | /* try to decode a socks4 header */ |
833 | int | 832 | static int |
834 | channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | 833 | channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) |
835 | { | 834 | { |
836 | u_char *p, *host; | 835 | u_char *p, *host; |
@@ -900,7 +899,7 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) | |||
900 | } | 899 | } |
901 | 900 | ||
902 | /* dynamic port forwarding */ | 901 | /* dynamic port forwarding */ |
903 | void | 902 | static void |
904 | channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) | 903 | channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) |
905 | { | 904 | { |
906 | u_char *p; | 905 | u_char *p; |
@@ -940,7 +939,7 @@ channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) | |||
940 | } | 939 | } |
941 | 940 | ||
942 | /* This is our fake X11 server socket. */ | 941 | /* This is our fake X11 server socket. */ |
943 | void | 942 | static void |
944 | channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | 943 | channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) |
945 | { | 944 | { |
946 | Channel *nc; | 945 | Channel *nc; |
@@ -998,7 +997,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
998 | } | 997 | } |
999 | } | 998 | } |
1000 | 999 | ||
1001 | void | 1000 | static void |
1002 | port_open_helper(Channel *c, char *rtype) | 1001 | port_open_helper(Channel *c, char *rtype) |
1003 | { | 1002 | { |
1004 | int direct; | 1003 | int direct; |
@@ -1052,7 +1051,7 @@ port_open_helper(Channel *c, char *rtype) | |||
1052 | /* | 1051 | /* |
1053 | * This socket is listening for connections to a forwarded TCP/IP port. | 1052 | * This socket is listening for connections to a forwarded TCP/IP port. |
1054 | */ | 1053 | */ |
1055 | void | 1054 | static void |
1056 | channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) | 1055 | channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) |
1057 | { | 1056 | { |
1058 | Channel *nc; | 1057 | Channel *nc; |
@@ -1100,7 +1099,7 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1100 | * This is the authentication agent socket listening for connections from | 1099 | * This is the authentication agent socket listening for connections from |
1101 | * clients. | 1100 | * clients. |
1102 | */ | 1101 | */ |
1103 | void | 1102 | static void |
1104 | channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) | 1103 | channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) |
1105 | { | 1104 | { |
1106 | Channel *nc; | 1105 | Channel *nc; |
@@ -1140,7 +1139,7 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1140 | } | 1139 | } |
1141 | } | 1140 | } |
1142 | 1141 | ||
1143 | void | 1142 | static void |
1144 | channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) | 1143 | channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) |
1145 | { | 1144 | { |
1146 | int err = 0; | 1145 | int err = 0; |
@@ -1187,7 +1186,7 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) | |||
1187 | } | 1186 | } |
1188 | } | 1187 | } |
1189 | 1188 | ||
1190 | int | 1189 | static int |
1191 | channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | 1190 | channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) |
1192 | { | 1191 | { |
1193 | char buf[16*1024]; | 1192 | char buf[16*1024]; |
@@ -1225,7 +1224,7 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1225 | } | 1224 | } |
1226 | return 1; | 1225 | return 1; |
1227 | } | 1226 | } |
1228 | int | 1227 | static int |
1229 | channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | 1228 | channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) |
1230 | { | 1229 | { |
1231 | struct termios tio; | 1230 | struct termios tio; |
@@ -1273,7 +1272,7 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1273 | } | 1272 | } |
1274 | return 1; | 1273 | return 1; |
1275 | } | 1274 | } |
1276 | int | 1275 | static int |
1277 | channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) | 1276 | channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) |
1278 | { | 1277 | { |
1279 | char buf[16*1024]; | 1278 | char buf[16*1024]; |
@@ -1318,7 +1317,7 @@ channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1318 | } | 1317 | } |
1319 | return 1; | 1318 | return 1; |
1320 | } | 1319 | } |
1321 | int | 1320 | static int |
1322 | channel_check_window(Channel *c) | 1321 | channel_check_window(Channel *c) |
1323 | { | 1322 | { |
1324 | if (c->type == SSH_CHANNEL_OPEN && | 1323 | if (c->type == SSH_CHANNEL_OPEN && |
@@ -1338,14 +1337,14 @@ channel_check_window(Channel *c) | |||
1338 | return 1; | 1337 | return 1; |
1339 | } | 1338 | } |
1340 | 1339 | ||
1341 | void | 1340 | static void |
1342 | channel_post_open_1(Channel *c, fd_set * readset, fd_set * writeset) | 1341 | channel_post_open_1(Channel *c, fd_set * readset, fd_set * writeset) |
1343 | { | 1342 | { |
1344 | channel_handle_rfd(c, readset, writeset); | 1343 | channel_handle_rfd(c, readset, writeset); |
1345 | channel_handle_wfd(c, readset, writeset); | 1344 | channel_handle_wfd(c, readset, writeset); |
1346 | } | 1345 | } |
1347 | 1346 | ||
1348 | void | 1347 | static void |
1349 | channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset) | 1348 | channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset) |
1350 | { | 1349 | { |
1351 | channel_handle_rfd(c, readset, writeset); | 1350 | channel_handle_rfd(c, readset, writeset); |
@@ -1355,7 +1354,7 @@ channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset) | |||
1355 | channel_check_window(c); | 1354 | channel_check_window(c); |
1356 | } | 1355 | } |
1357 | 1356 | ||
1358 | void | 1357 | static void |
1359 | channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) | 1358 | channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) |
1360 | { | 1359 | { |
1361 | int len; | 1360 | int len; |
@@ -1370,7 +1369,7 @@ channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) | |||
1370 | } | 1369 | } |
1371 | } | 1370 | } |
1372 | 1371 | ||
1373 | void | 1372 | static void |
1374 | channel_handler_init_20(void) | 1373 | channel_handler_init_20(void) |
1375 | { | 1374 | { |
1376 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_20; | 1375 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_20; |
@@ -1391,7 +1390,7 @@ channel_handler_init_20(void) | |||
1391 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_2; | 1390 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_2; |
1392 | } | 1391 | } |
1393 | 1392 | ||
1394 | void | 1393 | static void |
1395 | channel_handler_init_13(void) | 1394 | channel_handler_init_13(void) |
1396 | { | 1395 | { |
1397 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_13; | 1396 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_13; |
@@ -1413,7 +1412,7 @@ channel_handler_init_13(void) | |||
1413 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; | 1412 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; |
1414 | } | 1413 | } |
1415 | 1414 | ||
1416 | void | 1415 | static void |
1417 | channel_handler_init_15(void) | 1416 | channel_handler_init_15(void) |
1418 | { | 1417 | { |
1419 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_15; | 1418 | channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_15; |
@@ -1432,7 +1431,7 @@ channel_handler_init_15(void) | |||
1432 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; | 1431 | channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; |
1433 | } | 1432 | } |
1434 | 1433 | ||
1435 | void | 1434 | static void |
1436 | channel_handler_init(void) | 1435 | channel_handler_init(void) |
1437 | { | 1436 | { |
1438 | int i; | 1437 | int i; |
@@ -1448,7 +1447,7 @@ channel_handler_init(void) | |||
1448 | channel_handler_init_15(); | 1447 | channel_handler_init_15(); |
1449 | } | 1448 | } |
1450 | 1449 | ||
1451 | void | 1450 | static void |
1452 | channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) | 1451 | channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) |
1453 | { | 1452 | { |
1454 | static int did_init = 0; | 1453 | static int did_init = 0; |
@@ -1828,7 +1827,7 @@ channel_input_open_confirmation(int type, int plen, void *ctxt) | |||
1828 | } | 1827 | } |
1829 | } | 1828 | } |
1830 | 1829 | ||
1831 | char * | 1830 | static char * |
1832 | reason2txt(int reason) | 1831 | reason2txt(int reason) |
1833 | { | 1832 | { |
1834 | switch(reason) { | 1833 | switch(reason) { |
@@ -2220,7 +2219,7 @@ channel_clear_permitted_opens(void) | |||
2220 | 2219 | ||
2221 | 2220 | ||
2222 | /* return socket to remote host, port */ | 2221 | /* return socket to remote host, port */ |
2223 | int | 2222 | static int |
2224 | connect_to(const char *host, u_short port) | 2223 | connect_to(const char *host, u_short port) |
2225 | { | 2224 | { |
2226 | struct addrinfo hints, *ai, *aitop; | 2225 | struct addrinfo hints, *ai, *aitop; |
@@ -2455,8 +2454,7 @@ x11_create_display_inet(int screen_number, int x11_display_offset) | |||
2455 | #define X_UNIX_PATH "/tmp/.X11-unix/X" | 2454 | #define X_UNIX_PATH "/tmp/.X11-unix/X" |
2456 | #endif | 2455 | #endif |
2457 | 2456 | ||
2458 | static | 2457 | static int |
2459 | int | ||
2460 | connect_local_xsocket(u_int dnr) | 2458 | connect_local_xsocket(u_int dnr) |
2461 | { | 2459 | { |
2462 | static const char *const x_sockets[] = { | 2460 | static const char *const x_sockets[] = { |