if (compat20) packet_set_ssh2_format();
sshd_exchange_identification(int sock_in, int sock_out){	int i, mismatch;	int remote_major, remote_minor;	int major, minor;	char *s;	char buf[256];			/* Must not be larger than remote_version. */	char remote_version[256];	/* Must be at least as big as buf. */	if ((options.protocol & SSH_PROTO_1) &&	    (options.protocol & SSH_PROTO_2)) {		major = PROTOCOL_MAJOR_1;		minor = 99;	} else if (options.protocol & SSH_PROTO_2) {		major = PROTOCOL_MAJOR_2;		minor = PROTOCOL_MINOR_2;	} else {		major = PROTOCOL_MAJOR_1;		minor = PROTOCOL_MINOR_1;	}	snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n", major, minor, SSH_VERSION);	server_version_string = xstrdup(buf);	if (client_version_string == NULL) {		/* Send our protocol version identification. */		if (atomicio(write, sock_out, server_version_string, strlen(server_version_string))		    != strlen(server_version_string)) {			log("Could not write ident string to %s.", get_remote_ipaddr());			fatal_cleanup();		}		/* Read other side\'s version identification. */		for (i = 0; i < sizeof(buf) - 1; i++) {			if (read(sock_in, &buf[i], 1) != 1) {				log("Did not receive ident string from %s.", get_remote_ipaddr());				fatal_cleanup();			}			if (buf[i] == '\r') {				buf[i] = '\n';				buf[i + 1] = 0;				continue;			}			if (buf[i] == '\n') {				/* buf[i] == '\n' */				buf[i + 1] = 0;				break;			}		}		buf[sizeof(buf) - 1] = 0;		client_version_string = xstrdup(buf);	}	/*	 * Check that the versions match.  In future this might accept	 * several versions and set appropriate flags to handle them.	 */	if (sscanf(client_version_string, "SSH-%d.%d-%[^\n]\n",	    &remote_major, &remote_minor, remote_version) != 3) {		s = "Protocol mismatch.\n";		(void) atomicio(write, sock_out, s, strlen(s));		close(sock_in);		close(sock_out);		log("Bad protocol version identification '%.100s' from %s",		    client_version_string, get_remote_ipaddr());		fatal_cleanup();	}	debug("Client protocol version %d.%d; client software version %.100s",	      remote_major, remote_minor, remote_version);	compat_datafellows(remote_version);	mismatch = 0;	switch(remote_major) {	case 1:		if (!(options.protocol & SSH_PROTO_1)) {			mismatch = 1;			break;		}		if (remote_minor < 3) {			packet_disconnect("Your ssh version is too old and"			    "is no longer supported.  Please install a newer version.");		} else if (remote_minor == 3) {			/* note that this disables agent-forwarding */			enable_compat13();		}		if (remote_minor == 99) {			if (options.protocol & SSH_PROTO_2)				enable_compat20();			else				mismatch = 1;		}		break;	case 2:		if (options.protocol & SSH_PROTO_2) {			enable_compat20();			break;		}		/* FALLTHROUGH */	default:		mismatch = 1;		break;	}	chop(server_version_string);	chop(client_version_string);	debug("Local version string %.200s", server_version_string);	if (mismatch) {		s = "Protocol major versions differ.\n";		(void) atomicio(write, sock_out, s, strlen(s));		close(sock_in);		close(sock_out);		log("Protocol major versions differ for %s: %.200s vs. %.200s",		    get_remote_ipaddr(),		    server_version_string, client_version_string);		fatal_cleanup();	}}