From: Andre Noll Date: Thu, 22 Dec 2011 22:24:54 +0000 (+0100) Subject: Use sideband also for "proceed" handshake. X-Git-Tag: v0.4.11~14^2~7 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=9c2a265397821d91ec628f549516b25757f5c801;p=paraslash.git Use sideband also for "proceed" handshake. This adds sideband-aware code for the next step of the connection handshake. If sideband connections are supported at both ends, the server side sends an empty sideband packet with designator SBD_PROCEED if the client was authenticated successfully. When the client receives this packet, it enters the CL_RECEIVED_PROCEED state, just as with non-sideband connections. --- diff --git a/client_common.c b/client_common.c index eea14fa8..53f7b5a9 100644 --- a/client_common.c +++ b/client_common.c @@ -355,6 +355,18 @@ static void client_post_select(struct sched *s, struct task *t) goto out; case CL_SENT_CH_RESPONSE: /* read server response */ { + if (ct->use_sideband) { + struct sb_buffer sbb; + ret = recv_sb(ct, &s->rfds, &sbb); + if (ret <= 0) + goto out; + free(sbb.iov.iov_base); + if (sbb.band != SBD_PROCEED) + ret = -E_BAD_BAND; + else + ct->status = CL_RECEIVED_PROCEED; + goto out; + } ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n); if (ret < 0 || n == 0) goto out; diff --git a/command.c b/command.c index 5e13df66..8deb69ce 100644 --- a/command.c +++ b/command.c @@ -975,7 +975,10 @@ __noreturn void handle_connect(int fd, const char *peername) /* init stream cipher keys with the second part of the random buffer */ cc->scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, SESSION_KEY_LEN); cc->scc.send = sc_new(rand_buf + CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN); - ret = sc_send_buffer(&cc->scc, PROCEED_MSG); + if (cc->use_sideband) + ret = send_sb(&cc->scc, NULL, 0, SBD_PROCEED, false); + else + ret = sc_send_buffer(&cc->scc, PROCEED_MSG); if (ret < 0) goto net_err; ret = read_command(&cc->scc, &command);