version 1.86, 2001/01/31 19:26:19 |
version 1.87, 2001/01/31 20:37:22 |
|
|
* Initiate forwarding of connections to local port "port" through the secure |
* Initiate forwarding of connections to local port "port" through the secure |
* channel to host:port from remote side. |
* channel to host:port from remote side. |
*/ |
*/ |
void |
int |
channel_request_local_forwarding(u_short listen_port, const char *host_to_connect, |
channel_request_local_forwarding(u_short listen_port, const char *host_to_connect, |
u_short port_to_connect, int gateway_ports) |
u_short port_to_connect, int gateway_ports) |
{ |
{ |
channel_request_forwarding( |
return channel_request_forwarding( |
NULL, listen_port, |
NULL, listen_port, |
host_to_connect, port_to_connect, |
host_to_connect, port_to_connect, |
gateway_ports, /*remote_fwd*/ 0); |
gateway_ports, /*remote_fwd*/ 0); |
|
|
* If 'remote_fwd' is true we have a '-R style' listener for protocol 2 |
* If 'remote_fwd' is true we have a '-R style' listener for protocol 2 |
* (SSH_CHANNEL_RPORT_LISTENER). |
* (SSH_CHANNEL_RPORT_LISTENER). |
*/ |
*/ |
void |
int |
channel_request_forwarding( |
channel_request_forwarding( |
const char *listen_address, u_short listen_port, |
const char *listen_address, u_short listen_port, |
const char *host_to_connect, u_short port_to_connect, |
const char *host_to_connect, u_short port_to_connect, |
|
|
const char *host; |
const char *host; |
struct linger linger; |
struct linger linger; |
|
|
|
success = 0; |
|
|
if (remote_fwd) { |
if (remote_fwd) { |
host = listen_address; |
host = listen_address; |
ctype = SSH_CHANNEL_RPORT_LISTENER; |
ctype = SSH_CHANNEL_RPORT_LISTENER; |
|
|
ctype =SSH_CHANNEL_PORT_LISTENER; |
ctype =SSH_CHANNEL_PORT_LISTENER; |
} |
} |
|
|
if (strlen(host) > sizeof(channels[0].path) - 1) |
if (strlen(host) > sizeof(channels[0].path) - 1) { |
packet_disconnect("Forward host name too long."); |
error("Forward host name too long."); |
|
return success; |
|
} |
|
|
/* XXX listen_address is currently ignored */ |
/* XXX listen_address is currently ignored */ |
/* |
/* |
|
|
if (getaddrinfo(NULL, strport, &hints, &aitop) != 0) |
if (getaddrinfo(NULL, strport, &hints, &aitop) != 0) |
packet_disconnect("getaddrinfo: fatal error"); |
packet_disconnect("getaddrinfo: fatal error"); |
|
|
success = 0; |
|
for (ai = aitop; ai; ai = ai->ai_next) { |
for (ai = aitop; ai; ai = ai->ai_next) { |
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) |
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) |
continue; |
continue; |
|
|
success = 1; |
success = 1; |
} |
} |
if (success == 0) |
if (success == 0) |
packet_disconnect("cannot listen port: %d", listen_port); /*XXX ?disconnect? */ |
error("channel_request_forwarding: cannot listen to port: %d", |
|
listen_port); |
freeaddrinfo(aitop); |
freeaddrinfo(aitop); |
|
return success; |
} |
} |
|
|
/* |
/* |