added checksum seed
[rsync/rsync.git] / compat.c
index 04913c2..293bbc6 100644 (file)
--- 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,14 @@ 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);
+    }
+  }
 }