newch = channel_allocate(SSH_CHANNEL_CONNECTING, sock, originator_string); channels[newch].remote_id = remote_channel;
c = channel_new("connected socket", SSH_CHANNEL_CONNECTING, sock, sock, -1, 0, 0, 0, originator_string, 1); if (c == NULL) { error("channel_input_port_open: channel_new failed"); close(sock); } else { c->remote_id = remote_id; } } if (c == NULL) { packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE); packet_put_int(remote_id); } else {
channel_input_port_open(int type, int plen, void *ctxt){	u_short host_port;	char *host, *originator_string;	int remote_channel, sock = -1, newch;	remote_channel = packet_get_int();	host = packet_get_string(NULL);	host_port = packet_get_int();	if (have_hostname_in_open) {		originator_string = packet_get_string(NULL);	} else {		originator_string = xstrdup("unknown (remote did not supply name)");	}	packet_done();	sock = channel_connect_to(host, host_port);	if (sock != -1) {		newch = channel_allocate(SSH_CHANNEL_CONNECTING,		    sock, originator_string);		channels[newch].remote_id = remote_channel;		/*XXX delay answer? */		packet_start(SSH_MSG_CHANNEL_OPEN_CONFIRMATION);		packet_put_int(remote_channel);		packet_put_int(newch);		packet_send();	} else {		packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE);		packet_put_int(remote_channel);		packet_send();	}	xfree(host);}