| 3501 |
msg = buffer_init(); |
msg = buffer_init(); |
| 3502 |
if (msg == NULL) { |
if (msg == NULL) { |
| 3503 |
// TODO: error check |
// TODO: error check |
| 3504 |
|
logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL"); |
| 3505 |
return; |
return; |
| 3506 |
} |
} |
| 3507 |
buffer_put_int(msg, c->remote_id); // remote ID |
buffer_put_int(msg, c->remote_id); // remote ID |
| 3542 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |
| 3543 |
int host_len = strlen(to_local_host); |
int host_len = strlen(to_local_host); |
| 3544 |
unsigned char *outmsg = |
unsigned char *outmsg = |
| 3545 |
begin_send_packet(pvar, SSH_CMSG_PORT_FORWARD_REQUEST, |
begin_send_packet(pvar, SSH_CMSG_PORT_FORWARD_REQUEST, 12 + host_len); |
| 3546 |
12 + host_len); |
|
| 3547 |
|
logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": Forwarding request (SSH1 RtoL): " |
| 3548 |
|
"remote_port=%d, to_host=%s, to_port=%d", |
| 3549 |
|
from_server_port, to_local_host, to_local_port); |
| 3550 |
|
|
| 3551 |
set_uint32(outmsg, from_server_port); |
set_uint32(outmsg, from_server_port); |
| 3552 |
set_uint32(outmsg + 4, host_len); |
set_uint32(outmsg + 4, host_len); |
| 3556 |
|
|
| 3557 |
enque_forwarding_request_handlers(pvar); |
enque_forwarding_request_handlers(pvar); |
| 3558 |
|
|
| 3559 |
|
logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH_CMSG_PORT_FORWARD_REQUEST." |
| 3560 |
|
"remote_port=%d, to_host=%s, to_port=%d", |
| 3561 |
|
from_server_port, to_local_host, to_local_port); |
| 3562 |
|
|
| 3563 |
} else { |
} else { |
| 3564 |
// SSH2 port-forwading remote to local (2005.6.21 yutaka) |
// SSH2 port-forwading remote to local (2005.6.21 yutaka) |
| 3565 |
buffer_t *msg; |
buffer_t *msg; |
| 3566 |
char *s; |
char *req; |
| 3567 |
unsigned char *outmsg; |
unsigned char *outmsg; |
| 3568 |
int len; |
int len; |
| 3569 |
|
|
| 3570 |
|
logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": Forwarding request (SSH2 RtoL): " |
| 3571 |
|
"bind_addr=%s, remote_port=%d, to_host=%s, to_port=%d", |
| 3572 |
|
bind_address, from_server_port, to_local_host, to_local_port); |
| 3573 |
|
|
| 3574 |
msg = buffer_init(); |
msg = buffer_init(); |
| 3575 |
if (msg == NULL) { |
if (msg == NULL) { |
| 3576 |
// TODO: error check |
// TODO: error check |
| 3577 |
|
logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL"); |
| 3578 |
return; |
return; |
| 3579 |
} |
} |
| 3580 |
s = "tcpip-forward"; |
req = "tcpip-forward"; |
| 3581 |
buffer_put_string(msg, s, strlen(s)); // ctype |
buffer_put_string(msg, req, strlen(req)); // ctype |
| 3582 |
buffer_put_char(msg, 1); // want reply |
buffer_put_char(msg, 1); // want reply |
| 3583 |
buffer_put_string(msg, bind_address, strlen(bind_address)); |
buffer_put_string(msg, bind_address, strlen(bind_address)); |
| 3584 |
|
|
| 3590 |
finish_send_packet(pvar); |
finish_send_packet(pvar); |
| 3591 |
buffer_free(msg); |
buffer_free(msg); |
| 3592 |
|
|
| 3593 |
logputs(LOG_LEVEL_VERBOSE, "SSH2_MSG_GLOBAL_REQUEST was sent at SSH_request_forwarding()."); |
logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_GLOBAL_REQUEST. " |
| 3594 |
|
"request=%s, want_reply=%d, bind_address=%s, remote_port=%d", |
| 3595 |
|
req, 1, bind_address, from_server_port); |
| 3596 |
} |
} |
| 3597 |
} |
} |
| 3598 |
|
|