mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Factor out some common code for constructing SSH2_CHANNEL_OPEN.
[originally from svn r9649]
This commit is contained in:
parent
de6d59b500
commit
33c58dd91b
33
ssh.c
33
ssh.c
@ -6571,6 +6571,21 @@ static void ssh2_channel_init(struct ssh_channel *c)
|
|||||||
bufchain_init(&c->v.v2.outbuffer);
|
bufchain_init(&c->v.v2.outbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct the common parts of a CHANNEL_OPEN.
|
||||||
|
*/
|
||||||
|
static struct Packet *ssh2_chanopen_init(struct ssh_channel *c, char *type)
|
||||||
|
{
|
||||||
|
struct Packet *pktout;
|
||||||
|
|
||||||
|
pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN);
|
||||||
|
ssh2_pkt_addstring(pktout, type);
|
||||||
|
ssh2_pkt_adduint32(pktout, c->localid);
|
||||||
|
ssh2_pkt_adduint32(pktout, c->v.v2.locwindow);/* our window size */
|
||||||
|
ssh2_pkt_adduint32(pktout, OUR_V2_MAXPKT); /* our max pkt size */
|
||||||
|
return pktout;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CHANNEL_FAILURE doesn't come with any indication of what message
|
* CHANNEL_FAILURE doesn't come with any indication of what message
|
||||||
* caused it, so we have to keep track of the outstanding
|
* caused it, so we have to keep track of the outstanding
|
||||||
@ -9113,11 +9128,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
|
|||||||
"Opening direct-tcpip channel to %s:%d in place of session",
|
"Opening direct-tcpip channel to %s:%d in place of session",
|
||||||
conf_get_str(ssh->conf, CONF_ssh_nc_host),
|
conf_get_str(ssh->conf, CONF_ssh_nc_host),
|
||||||
conf_get_int(ssh->conf, CONF_ssh_nc_port));
|
conf_get_int(ssh->conf, CONF_ssh_nc_port));
|
||||||
s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN);
|
s->pktout = ssh2_chanopen_init(ssh->mainchan, "direct-tcpip");
|
||||||
ssh2_pkt_addstring(s->pktout, "direct-tcpip");
|
|
||||||
ssh2_pkt_adduint32(s->pktout, ssh->mainchan->localid);
|
|
||||||
ssh2_pkt_adduint32(s->pktout, ssh->mainchan->v.v2.locwindow);/* our window size */
|
|
||||||
ssh2_pkt_adduint32(s->pktout, OUR_V2_MAXPKT); /* our max pkt size */
|
|
||||||
ssh2_pkt_addstring(s->pktout, conf_get_str(ssh->conf, CONF_ssh_nc_host));
|
ssh2_pkt_addstring(s->pktout, conf_get_str(ssh->conf, CONF_ssh_nc_host));
|
||||||
ssh2_pkt_adduint32(s->pktout, conf_get_int(ssh->conf, CONF_ssh_nc_port));
|
ssh2_pkt_adduint32(s->pktout, conf_get_int(ssh->conf, CONF_ssh_nc_port));
|
||||||
/*
|
/*
|
||||||
@ -9152,11 +9163,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
|
|||||||
ssh->mainchan = snew(struct ssh_channel);
|
ssh->mainchan = snew(struct ssh_channel);
|
||||||
ssh->mainchan->ssh = ssh;
|
ssh->mainchan->ssh = ssh;
|
||||||
ssh2_channel_init(ssh->mainchan);
|
ssh2_channel_init(ssh->mainchan);
|
||||||
s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN);
|
s->pktout = ssh2_chanopen_init(ssh->mainchan, "session");
|
||||||
ssh2_pkt_addstring(s->pktout, "session");
|
|
||||||
ssh2_pkt_adduint32(s->pktout, ssh->mainchan->localid);
|
|
||||||
ssh2_pkt_adduint32(s->pktout, ssh->mainchan->v.v2.locwindow);/* our window size */
|
|
||||||
ssh2_pkt_adduint32(s->pktout, OUR_V2_MAXPKT); /* our max pkt size */
|
|
||||||
ssh2_pkt_send(ssh, s->pktout);
|
ssh2_pkt_send(ssh, s->pktout);
|
||||||
crWaitUntilV(pktin);
|
crWaitUntilV(pktin);
|
||||||
if (pktin->type != SSH2_MSG_CHANNEL_OPEN_CONFIRMATION) {
|
if (pktin->type != SSH2_MSG_CHANNEL_OPEN_CONFIRMATION) {
|
||||||
@ -10147,11 +10154,7 @@ void ssh_send_port_open(void *channel, char *hostname, int port, char *org)
|
|||||||
/* PKT_STR, <org:orgport>, */
|
/* PKT_STR, <org:orgport>, */
|
||||||
PKT_END);
|
PKT_END);
|
||||||
} else {
|
} else {
|
||||||
pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN);
|
pktout = ssh2_chanopen_init(c, "direct-tcpip");
|
||||||
ssh2_pkt_addstring(pktout, "direct-tcpip");
|
|
||||||
ssh2_pkt_adduint32(pktout, c->localid);
|
|
||||||
ssh2_pkt_adduint32(pktout, c->v.v2.locwindow);/* our window size */
|
|
||||||
ssh2_pkt_adduint32(pktout, OUR_V2_MAXPKT); /* our max pkt size */
|
|
||||||
ssh2_pkt_addstring(pktout, hostname);
|
ssh2_pkt_addstring(pktout, hostname);
|
||||||
ssh2_pkt_adduint32(pktout, port);
|
ssh2_pkt_adduint32(pktout, port);
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user