&ssh->cfg);
&ssh->cfg, realpf->pfrec->addressfamily);
static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin){    char *type;    int typelen;    char *peeraddr;    int peeraddrlen;    int peerport;    char *error = NULL;    struct ssh_channel *c;    unsigned remid, winsize, pktsize;    struct Packet *pktout;    ssh_pkt_getstring(pktin, &type, &typelen);    c = snew(struct ssh_channel);    c->ssh = ssh;    remid = ssh_pkt_getuint32(pktin);    winsize = ssh_pkt_getuint32(pktin);    pktsize = ssh_pkt_getuint32(pktin);    if (typelen == 3 && !memcmp(type, "x11", 3)) {	char *addrstr;	ssh_pkt_getstring(pktin, &peeraddr, &peeraddrlen);	addrstr = snewn(peeraddrlen+1, char);	memcpy(addrstr, peeraddr, peeraddrlen);	addrstr[peeraddrlen] = '\0';	peerport = ssh_pkt_getuint32(pktin);	logeventf(ssh, "Received X11 connect request from %s:%d",		  addrstr, peerport);	if (!ssh->X11_fwd_enabled)	    error = "X11 forwarding is not enabled";	else if (x11_init(&c->u.x11.s, ssh->cfg.x11_display, c,			  ssh->x11auth, addrstr, peerport,			  &ssh->cfg) != NULL) {	    error = "Unable to open an X11 connection";	} else {	    logevent("Opening X11 forward connection succeeded");	    c->type = CHAN_X11;	}	sfree(addrstr);    } else if (typelen == 15 &&	       !memcmp(type, "forwarded-tcpip", 15)) {	struct ssh_rportfwd pf, *realpf;	char *dummy;	int dummylen;	ssh_pkt_getstring(pktin, &dummy, &dummylen);/* skip address */	pf.sport = ssh_pkt_getuint32(pktin);	ssh_pkt_getstring(pktin, &peeraddr, &peeraddrlen);	peerport = ssh_pkt_getuint32(pktin);	realpf = find234(ssh->rportfwds, &pf, NULL);	logeventf(ssh, "Received remote port %d open request "		  "from %s:%d", pf.sport, peeraddr, peerport);	if (realpf == NULL) {	    error = "Remote port is not recognised";	} else {	    const char *e = pfd_newconnect(&c->u.pfd.s,					   realpf->dhost,					   realpf->dport, c,					   &ssh->cfg);	    logeventf(ssh, "Attempting to forward remote port to "		      "%s:%d", realpf->dhost, realpf->dport);	    if (e != NULL) {		logeventf(ssh, "Port open failed: %s", e);		error = "Port open failed";	    } else {		logevent("Forwarded port opened successfully");		c->type = CHAN_SOCKDATA;	    }	}    } else if (typelen == 22 &&	       !memcmp(type, "auth-agent@openssh.com", 3)) {	if (!ssh->agentfwd_enabled)	    error = "Agent forwarding is not enabled";	else {	    c->type = CHAN_AGENT;	/* identify channel type */	    c->u.a.lensofar = 0;	}    } else {	error = "Unsupported channel type requested";    }    c->remoteid = remid;    if (error) {	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN_FAILURE);	ssh2_pkt_adduint32(pktout, c->remoteid);	ssh2_pkt_adduint32(pktout, SSH2_OPEN_CONNECT_FAILED);	ssh2_pkt_addstring(pktout, error);	ssh2_pkt_addstring(pktout, "en");	/* language tag */	ssh2_pkt_send(ssh, pktout);	logeventf(ssh, "Rejected channel open: %s", error);	sfree(c);    } else {	c->localid = alloc_channel_id(ssh);	c->closes = 0;	c->v.v2.locwindow = OUR_V2_WINSIZE;	c->v.v2.remwindow = winsize;	c->v.v2.remmaxpkt = pktsize;	bufchain_init(&c->v.v2.outbuffer);	add234(ssh->channels, c);	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION);	ssh2_pkt_adduint32(pktout, c->remoteid);	ssh2_pkt_adduint32(pktout, c->localid);	ssh2_pkt_adduint32(pktout, c->v.v2.locwindow);	ssh2_pkt_adduint32(pktout, 0x4000UL);	/* our max pkt size */	ssh2_pkt_send(ssh, pktout);    }}