channels.c (226046) | channels.c (231584) |
---|---|
1/* $OpenBSD: channels.c,v 1.311 2011/06/22 22:08:42 djm Exp $ */ | 1/* $OpenBSD: channels.c,v 1.311 2011/06/22 22:08:42 djm Exp $ */ |
2/* $FreeBSD: head/crypto/openssh/channels.c 226046 2011-10-05 22:08:17Z des $ */ | 2/* $FreeBSD: head/crypto/openssh/channels.c 231584 2012-02-13 11:59:59Z ed $ */ |
3/* 4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 6 * All rights reserved 7 * This file contains functions for generic socket connection forwarding. 8 * There is also code for initiating connection forwarding for X11 connections, 9 * arbitrary tcp/ip connections, and the authentication agent connection. 10 * --- 808 unchanged lines hidden (view full) --- 819channel_tcpwinsz(void) 820{ 821 u_int32_t tcpwinsz; 822 socklen_t optsz; 823 int ret, sd; 824 u_int maxlen; 825 826 /* If we are not on a socket return 128KB. */ | 3/* 4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 6 * All rights reserved 7 * This file contains functions for generic socket connection forwarding. 8 * There is also code for initiating connection forwarding for X11 connections, 9 * arbitrary tcp/ip connections, and the authentication agent connection. 10 * --- 808 unchanged lines hidden (view full) --- 819channel_tcpwinsz(void) 820{ 821 u_int32_t tcpwinsz; 822 socklen_t optsz; 823 int ret, sd; 824 u_int maxlen; 825 826 /* If we are not on a socket return 128KB. */ |
827 if (!packet_connection_is_on_socket()) | 827 if (!packet_connection_is_on_socket()) |
828 return (128 * 1024); 829 830 tcpwinsz = 0; 831 optsz = sizeof(tcpwinsz); 832 sd = packet_get_connection_in(); 833 ret = getsockopt(sd, SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz); 834 835 /* Return no more than the maximum buffer size. */ --- 13 unchanged lines hidden (view full) --- 849 u_int limit; 850 851 /* Check buffer limits. */ 852 if (!c->tcpwinsz || c->dynamic_window > 0) 853 c->tcpwinsz = channel_tcpwinsz(); 854 855 limit = MIN(compat20 ? c->remote_window : packet_get_maxsize(), 856 2 * c->tcpwinsz); | 828 return (128 * 1024); 829 830 tcpwinsz = 0; 831 optsz = sizeof(tcpwinsz); 832 sd = packet_get_connection_in(); 833 ret = getsockopt(sd, SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz); 834 835 /* Return no more than the maximum buffer size. */ --- 13 unchanged lines hidden (view full) --- 849 u_int limit; 850 851 /* Check buffer limits. */ 852 if (!c->tcpwinsz || c->dynamic_window > 0) 853 c->tcpwinsz = channel_tcpwinsz(); 854 855 limit = MIN(compat20 ? c->remote_window : packet_get_maxsize(), 856 2 * c->tcpwinsz); |
857 | 857 |
858 if (c->istate == CHAN_INPUT_OPEN && 859 limit > 0 && 860 buffer_len(&c->input) < limit && 861 buffer_check_alloc(&c->input, CHAN_RBUF)) 862 FD_SET(c->rfd, readset); 863 if (c->ostate == CHAN_OUTPUT_OPEN || 864 c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { 865 if (buffer_len(&c->output) > 0) { --- 1816 unchanged lines hidden (view full) --- 2682/* -- tcp forwarding */ 2683 2684void 2685channel_set_af(int af) 2686{ 2687 IPv4or6 = af; 2688} 2689 | 858 if (c->istate == CHAN_INPUT_OPEN && 859 limit > 0 && 860 buffer_len(&c->input) < limit && 861 buffer_check_alloc(&c->input, CHAN_RBUF)) 862 FD_SET(c->rfd, readset); 863 if (c->ostate == CHAN_OUTPUT_OPEN || 864 c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { 865 if (buffer_len(&c->output) > 0) { --- 1816 unchanged lines hidden (view full) --- 2682/* -- tcp forwarding */ 2683 2684void 2685channel_set_af(int af) 2686{ 2687 IPv4or6 = af; 2688} 2689 |
2690void | 2690void |
2691channel_set_hpn(int disabled, u_int buf_size) 2692{ | 2691channel_set_hpn(int disabled, u_int buf_size) 2692{ |
2693 hpn_disabled = disabled; | 2693 hpn_disabled = disabled; |
2694 buffer_size = buf_size; 2695 debug("HPN Disabled: %d, HPN Buffer Size: %d", 2696 hpn_disabled, buffer_size); 2697} 2698 2699static int 2700channel_setup_fwd_listener(int type, const char *listen_addr, 2701 u_short listen_port, int *allocated_listen_port, --- 149 unchanged lines hidden (view full) --- 2851 /* 2852 * Allocate a channel number for the socket. Explicitly test 2853 * for hpn disabled option. If true use smaller window size. 2854 */ 2855 if (hpn_disabled) 2856 c = channel_new("port listener", type, sock, sock, -1, 2857 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 2858 0, "port listener", 1); | 2694 buffer_size = buf_size; 2695 debug("HPN Disabled: %d, HPN Buffer Size: %d", 2696 hpn_disabled, buffer_size); 2697} 2698 2699static int 2700channel_setup_fwd_listener(int type, const char *listen_addr, 2701 u_short listen_port, int *allocated_listen_port, --- 149 unchanged lines hidden (view full) --- 2851 /* 2852 * Allocate a channel number for the socket. Explicitly test 2853 * for hpn disabled option. If true use smaller window size. 2854 */ 2855 if (hpn_disabled) 2856 c = channel_new("port listener", type, sock, sock, -1, 2857 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 2858 0, "port listener", 1); |
2859 else 2860 c = channel_new("port listener", type, sock, sock, -1, 2861 buffer_size, CHAN_TCP_PACKET_DEFAULT, 2862 0, "port listener", 1); | 2859 else 2860 c = channel_new("port listener", type, sock, sock, -1, 2861 buffer_size, CHAN_TCP_PACKET_DEFAULT, 2862 0, "port listener", 1); |
2863 c->path = xstrdup(host); 2864 c->host_port = port_to_connect; 2865 c->listening_port = listen_port; 2866 success = 1; 2867 } 2868 if (success == 0) 2869 error("channel_setup_fwd_listener: cannot listen to port: %d", 2870 listen_port); --- 848 unchanged lines hidden --- | 2863 c->path = xstrdup(host); 2864 c->host_port = port_to_connect; 2865 c->listening_port = listen_port; 2866 success = 1; 2867 } 2868 if (success == 0) 2869 error("channel_setup_fwd_listener: cannot listen to port: %d", 2870 listen_port); --- 848 unchanged lines hidden --- |