* If the channel's remoteid is -1, we have sent
* If halfopen is true, we have sent
void sshfwd_close(struct ssh_channel *c){    Ssh ssh = c->ssh;    if (ssh->state != SSH_STATE_SESSION) {	assert(ssh->state == SSH_STATE_CLOSED);	return;    }    if (c && !c->closes) {	/*	 * If the channel's remoteid is -1, we have sent	 * CHANNEL_OPEN for this channel, but it hasn't even been	 * acknowledged by the server. So we must set a close flag	 * on it now, and then when the server acks the channel	 * open, we can close it then.	 */	if (((int)c->remoteid) != -1) {	    if (ssh->version == 1) {		send_packet(ssh, SSH1_MSG_CHANNEL_CLOSE, PKT_INT, c->remoteid,			    PKT_END);	    } else {		struct Packet *pktout;		pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_CLOSE);		ssh2_pkt_adduint32(pktout, c->remoteid);		ssh2_pkt_send(ssh, pktout);	    }	}	c->closes = 1;		       /* sent MSG_CLOSE */	if (c->type == CHAN_X11) {	    c->u.x11.s = NULL;	    logevent("Forwarded X11 connection terminated");	} else if (c->type == CHAN_SOCKDATA ||		   c->type == CHAN_SOCKDATA_DORMANT) {	    c->u.pfd.s = NULL;	    logevent("Forwarded port closed");	}    }}