X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/dc5ddbccace1f4f37d57ce5d961117effc28a356..3fac9b6e93b595f91108c0f9c6b6f40d14a58618:/compat.c diff --git a/compat.c b/compat.c index 04913c2e..1c28c253 100644 --- a/compat.c +++ b/compat.c @@ -21,6 +21,8 @@ #include "rsync.h" +extern int am_server; + extern int csum_length; extern int preserve_links; @@ -30,6 +32,7 @@ extern int preserve_uid; extern int preserve_gid; extern int preserve_times; extern int always_checksum; +extern int checksum_seed; extern int remote_version; @@ -180,8 +183,24 @@ void receive_file_entry_v10(struct file_struct *file, -void setup_protocol(void) +void setup_protocol(int f_out,int f_in) { + if (am_server) { + remote_version = read_int(f_in); + write_int(f_out,PROTOCOL_VERSION); + write_flush(f_out); + } else { + write_int(f_out,PROTOCOL_VERSION); + write_flush(f_out); + remote_version = read_int(f_in); + } + + if (remote_version < MIN_PROTOCOL_VERSION || + remote_version > MAX_PROTOCOL_VERSION) { + fprintf(FERROR,"protocol version mismatch - is your shell clean?\n"); + exit_cleanup(1); + } + if (remote_version == 10) { send_file_entry = send_file_entry_v10; receive_file_entry = receive_file_entry_v10; @@ -189,5 +208,16 @@ void setup_protocol(void) send_file_entry = send_file_entry_v11; receive_file_entry = receive_file_entry_v11; } + + if (remote_version >= 12) { + if (am_server) { + checksum_seed = time(NULL); + write_int(f_out,checksum_seed); + } else { + checksum_seed = read_int(f_in); + } + } + + checksum_init(); }