diff options
author | markus@openbsd.org <markus@openbsd.org> | 2017-05-30 14:23:52 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-05-31 10:50:05 +1000 |
commit | 2ae666a8fc20b3b871b2f1b90ad65cc027336ccd (patch) | |
tree | f13f1c949ae60c16160acebbfb680c3dc7b13fe5 /channels.c | |
parent | 94583beb24a6c5fd19cedb9104ab2d2d5cd052b6 (diff) |
upstream commit
protocol handlers all get struct ssh passed; ok djm@
Upstream-ID: 0ca9ea2a5d01a6d2ded94c5024456a930c5bfb5d
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/channels.c b/channels.c index e7de370d4..d118d8ff7 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.362 2017/05/30 08:49:58 markus Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.363 2017/05/30 14:23:52 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -2394,9 +2394,8 @@ channel_proxy_downstream(Channel *downstream) | |||
2394 | * replaces local (proxy) channel ID with downstream channel ID. | 2394 | * replaces local (proxy) channel ID with downstream channel ID. |
2395 | */ | 2395 | */ |
2396 | int | 2396 | int |
2397 | channel_proxy_upstream(Channel *c, int type, u_int32_t seq, void *ctxt) | 2397 | channel_proxy_upstream(Channel *c, int type, u_int32_t seq, struct ssh *ssh) |
2398 | { | 2398 | { |
2399 | struct ssh *ssh = active_state; | ||
2400 | struct sshbuf *b = NULL; | 2399 | struct sshbuf *b = NULL; |
2401 | Channel *downstream; | 2400 | Channel *downstream; |
2402 | const u_char *cp = NULL; | 2401 | const u_char *cp = NULL; |
@@ -2476,7 +2475,7 @@ channel_proxy_upstream(Channel *c, int type, u_int32_t seq, void *ctxt) | |||
2476 | 2475 | ||
2477 | /* ARGSUSED */ | 2476 | /* ARGSUSED */ |
2478 | int | 2477 | int |
2479 | channel_input_data(int type, u_int32_t seq, void *ctxt) | 2478 | channel_input_data(int type, u_int32_t seq, struct ssh *ssh) |
2480 | { | 2479 | { |
2481 | int id; | 2480 | int id; |
2482 | const u_char *data; | 2481 | const u_char *data; |
@@ -2488,7 +2487,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt) | |||
2488 | c = channel_lookup(id); | 2487 | c = channel_lookup(id); |
2489 | if (c == NULL) | 2488 | if (c == NULL) |
2490 | packet_disconnect("Received data for nonexistent channel %d.", id); | 2489 | packet_disconnect("Received data for nonexistent channel %d.", id); |
2491 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2490 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2492 | return 0; | 2491 | return 0; |
2493 | 2492 | ||
2494 | /* Ignore any data for non-open channels (might happen on close) */ | 2493 | /* Ignore any data for non-open channels (might happen on close) */ |
@@ -2536,7 +2535,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt) | |||
2536 | 2535 | ||
2537 | /* ARGSUSED */ | 2536 | /* ARGSUSED */ |
2538 | int | 2537 | int |
2539 | channel_input_extended_data(int type, u_int32_t seq, void *ctxt) | 2538 | channel_input_extended_data(int type, u_int32_t seq, struct ssh *ssh) |
2540 | { | 2539 | { |
2541 | int id; | 2540 | int id; |
2542 | char *data; | 2541 | char *data; |
@@ -2549,7 +2548,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt) | |||
2549 | 2548 | ||
2550 | if (c == NULL) | 2549 | if (c == NULL) |
2551 | packet_disconnect("Received extended_data for bad channel %d.", id); | 2550 | packet_disconnect("Received extended_data for bad channel %d.", id); |
2552 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2551 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2553 | return 0; | 2552 | return 0; |
2554 | if (c->type != SSH_CHANNEL_OPEN) { | 2553 | if (c->type != SSH_CHANNEL_OPEN) { |
2555 | logit("channel %d: ext data for non open", id); | 2554 | logit("channel %d: ext data for non open", id); |
@@ -2586,7 +2585,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt) | |||
2586 | 2585 | ||
2587 | /* ARGSUSED */ | 2586 | /* ARGSUSED */ |
2588 | int | 2587 | int |
2589 | channel_input_ieof(int type, u_int32_t seq, void *ctxt) | 2588 | channel_input_ieof(int type, u_int32_t seq, struct ssh *ssh) |
2590 | { | 2589 | { |
2591 | int id; | 2590 | int id; |
2592 | Channel *c; | 2591 | Channel *c; |
@@ -2596,7 +2595,7 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt) | |||
2596 | c = channel_lookup(id); | 2595 | c = channel_lookup(id); |
2597 | if (c == NULL) | 2596 | if (c == NULL) |
2598 | packet_disconnect("Received ieof for nonexistent channel %d.", id); | 2597 | packet_disconnect("Received ieof for nonexistent channel %d.", id); |
2599 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2598 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2600 | return 0; | 2599 | return 0; |
2601 | chan_rcvd_ieof(c); | 2600 | chan_rcvd_ieof(c); |
2602 | 2601 | ||
@@ -2612,14 +2611,14 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt) | |||
2612 | 2611 | ||
2613 | /* ARGSUSED */ | 2612 | /* ARGSUSED */ |
2614 | int | 2613 | int |
2615 | channel_input_oclose(int type, u_int32_t seq, void *ctxt) | 2614 | channel_input_oclose(int type, u_int32_t seq, struct ssh *ssh) |
2616 | { | 2615 | { |
2617 | int id = packet_get_int(); | 2616 | int id = packet_get_int(); |
2618 | Channel *c = channel_lookup(id); | 2617 | Channel *c = channel_lookup(id); |
2619 | 2618 | ||
2620 | if (c == NULL) | 2619 | if (c == NULL) |
2621 | packet_disconnect("Received oclose for nonexistent channel %d.", id); | 2620 | packet_disconnect("Received oclose for nonexistent channel %d.", id); |
2622 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2621 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2623 | return 0; | 2622 | return 0; |
2624 | packet_check_eom(); | 2623 | packet_check_eom(); |
2625 | chan_rcvd_oclose(c); | 2624 | chan_rcvd_oclose(c); |
@@ -2628,7 +2627,7 @@ channel_input_oclose(int type, u_int32_t seq, void *ctxt) | |||
2628 | 2627 | ||
2629 | /* ARGSUSED */ | 2628 | /* ARGSUSED */ |
2630 | int | 2629 | int |
2631 | channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt) | 2630 | channel_input_open_confirmation(int type, u_int32_t seq, struct ssh *ssh) |
2632 | { | 2631 | { |
2633 | int id, remote_id; | 2632 | int id, remote_id; |
2634 | Channel *c; | 2633 | Channel *c; |
@@ -2639,7 +2638,7 @@ channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt) | |||
2639 | if (c==NULL) | 2638 | if (c==NULL) |
2640 | packet_disconnect("Received open confirmation for " | 2639 | packet_disconnect("Received open confirmation for " |
2641 | "unknown channel %d.", id); | 2640 | "unknown channel %d.", id); |
2642 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2641 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2643 | return 0; | 2642 | return 0; |
2644 | if (c->type != SSH_CHANNEL_OPENING) | 2643 | if (c->type != SSH_CHANNEL_OPENING) |
2645 | packet_disconnect("Received open confirmation for " | 2644 | packet_disconnect("Received open confirmation for " |
@@ -2680,7 +2679,7 @@ reason2txt(int reason) | |||
2680 | 2679 | ||
2681 | /* ARGSUSED */ | 2680 | /* ARGSUSED */ |
2682 | int | 2681 | int |
2683 | channel_input_open_failure(int type, u_int32_t seq, void *ctxt) | 2682 | channel_input_open_failure(int type, u_int32_t seq, struct ssh *ssh) |
2684 | { | 2683 | { |
2685 | int id, reason; | 2684 | int id, reason; |
2686 | char *msg = NULL, *lang = NULL; | 2685 | char *msg = NULL, *lang = NULL; |
@@ -2692,7 +2691,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt) | |||
2692 | if (c==NULL) | 2691 | if (c==NULL) |
2693 | packet_disconnect("Received open failure for " | 2692 | packet_disconnect("Received open failure for " |
2694 | "unknown channel %d.", id); | 2693 | "unknown channel %d.", id); |
2695 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2694 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2696 | return 0; | 2695 | return 0; |
2697 | if (c->type != SSH_CHANNEL_OPENING) | 2696 | if (c->type != SSH_CHANNEL_OPENING) |
2698 | packet_disconnect("Received open failure for " | 2697 | packet_disconnect("Received open failure for " |
@@ -2719,7 +2718,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt) | |||
2719 | 2718 | ||
2720 | /* ARGSUSED */ | 2719 | /* ARGSUSED */ |
2721 | int | 2720 | int |
2722 | channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) | 2721 | channel_input_window_adjust(int type, u_int32_t seq, struct ssh *ssh) |
2723 | { | 2722 | { |
2724 | Channel *c; | 2723 | Channel *c; |
2725 | int id; | 2724 | int id; |
@@ -2733,7 +2732,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) | |||
2733 | logit("Received window adjust for non-open channel %d.", id); | 2732 | logit("Received window adjust for non-open channel %d.", id); |
2734 | return 0; | 2733 | return 0; |
2735 | } | 2734 | } |
2736 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2735 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2737 | return 0; | 2736 | return 0; |
2738 | adjust = packet_get_int(); | 2737 | adjust = packet_get_int(); |
2739 | packet_check_eom(); | 2738 | packet_check_eom(); |
@@ -2747,7 +2746,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) | |||
2747 | 2746 | ||
2748 | /* ARGSUSED */ | 2747 | /* ARGSUSED */ |
2749 | int | 2748 | int |
2750 | channel_input_status_confirm(int type, u_int32_t seq, void *ctxt) | 2749 | channel_input_status_confirm(int type, u_int32_t seq, struct ssh *ssh) |
2751 | { | 2750 | { |
2752 | Channel *c; | 2751 | Channel *c; |
2753 | struct channel_confirm *cc; | 2752 | struct channel_confirm *cc; |
@@ -2763,7 +2762,7 @@ channel_input_status_confirm(int type, u_int32_t seq, void *ctxt) | |||
2763 | logit("channel_input_status_confirm: %d: unknown", id); | 2762 | logit("channel_input_status_confirm: %d: unknown", id); |
2764 | return 0; | 2763 | return 0; |
2765 | } | 2764 | } |
2766 | if (channel_proxy_upstream(c, type, seq, ctxt)) | 2765 | if (channel_proxy_upstream(c, type, seq, ssh)) |
2767 | return 0; | 2766 | return 0; |
2768 | packet_check_eom(); | 2767 | packet_check_eom(); |
2769 | if ((cc = TAILQ_FIRST(&c->status_confirms)) == NULL) | 2768 | if ((cc = TAILQ_FIRST(&c->status_confirms)) == NULL) |