Index: src/daemon/common/commonGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonGlobals.ml,v
retrieving revision 1.75
diff -u -w -r1.75 commonGlobals.ml
--- src/daemon/common/commonGlobals.ml	14 Nov 2006 11:23:11 -0000	1.75
+++ src/daemon/common/commonGlobals.ml	15 Nov 2006 21:05:57 -0000
@@ -398,6 +398,7 @@
   | Field_Completesources -> "completesources"
   | Field_Filename -> "filename"
   | Field_Size -> "size"
+  | Field_Size_Hi -> "size_hi"
   | Field_Uid -> "uid"
   | Field_Bitrate -> "bitrate"
   | Field_Codec -> "codec"
@@ -419,6 +420,7 @@
   | "completesources" -> Field_Completesources
   | "filename" -> Field_Filename
   | "size" -> Field_Size
+  | "size_hi" -> Field_Size_Hi
   | "uid" -> Field_Uid
   | "bitrate" -> Field_Bitrate
   | "codec" -> Field_Codec
Index: src/daemon/common/commonTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonTypes.ml,v
retrieving revision 1.62
diff -u -w -r1.62 commonTypes.ml
--- src/daemon/common/commonTypes.ml	13 Nov 2006 13:10:17 -0000	1.62
+++ src/daemon/common/commonTypes.ml	15 Nov 2006 21:05:58 -0000
@@ -260,6 +260,7 @@
 | Field_Completesources (* "completesources" *)
 | Field_Filename (* "filename" *)
 | Field_Size
+| Field_Size_Hi
 | Field_Uid
 | Field_Filerating
 | Field_Lastseencomplete
Index: src/gtk2/gui/guiMisc.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/gtk2/gui/guiMisc.ml,v
retrieving revision 1.19
diff -u -w -r1.19 guiMisc.ml
--- src/gtk2/gui/guiMisc.ml	16 Aug 2006 19:10:34 -0000	1.19
+++ src/gtk2/gui/guiMisc.ml	15 Nov 2006 21:05:58 -0000
@@ -1046,6 +1046,7 @@
     | Field_Completesources -> "completesources"
     | Field_Filename -> "filename"
     | Field_Size -> "size"
+    | Field_Size_Hi -> "size_hi"
     | Field_Uid -> "uid"
     | Field_Medialength -> "length"
     | Field_Mediacodec -> "codec"
Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.107
diff -u -w -r1.107 donkeyClient.ml
--- src/networks/donkey/donkeyClient.ml	14 Nov 2006 16:35:52 -0000	1.107
+++ src/networks/donkey/donkeyClient.ml	15 Nov 2006 21:05:59 -0000
@@ -677,11 +677,16 @@
             DonkeyProtoClient.update_emule_proto_from_miscoptions1
             c.client_emule_proto i
           )
+      | Field_UNKNOWN "emule_miscoptions2" ->
+          for_int64_tag tag (fun i ->
+            DonkeyProtoClient.update_emule_proto_from_miscoptions2
+            c.client_emule_proto i
+          )
       | Field_UNKNOWN "emule_compatoptions" ->
           for_int_tag tag (fun i ->
             DonkeyProtoClient.update_emule_proto_from_compatoptions
             c.client_emule_proto i
-          );
+          )
       | Field_UNKNOWN "emule_version" ->
           for_int_tag tag (fun i ->
             c.client_emule_proto.emule_version <- i;
@@ -1555,8 +1560,8 @@
 (*      if file.file_exists then verify_chunks file *)
       end
   
-  
-  | M.EmuleCompressedPart (md4, statpos, newsize, bloc) ->
+  | M.EmuleCompressedPart (md4, statpos, newsize, bloc)
+  | M.EmuleCompressedPart64 (md4, statpos, newsize, bloc) ->
       
       set_lifetime sock active_lifetime;      
       if !!reliable_sources && 
@@ -1641,6 +1646,31 @@
       DonkeyOneFile.block_received c t.Q.md4
         t.Q.start_pos t.Q.bloc_str t.Q.bloc_begin t.Q.bloc_len
 
+  | M.BlocReq64 t ->
+      
+      set_lifetime sock active_lifetime;      
+      if !!reliable_sources && 
+        client_reliability c = Reliability_suspicious 0 then begin
+          lprintf_nl "Receiving data from unreliable client, disconnect";
+          corruption_warning c;
+          disconnect_client c (Closed_for_error "Unreliable Source");
+          raise Not_found
+        end;
+      
+      let module M = DonkeyProtoClient in  
+      let module Q = M.Bloc64 in
+      
+      let begin_pos = t.Q.start_pos in
+      let end_pos = t.Q.end_pos in
+      let len = end_pos -- begin_pos in
+      if Int64.to_int len <> t.Q.bloc_len then begin
+          lprintf_nl "%d: inconsistent packet sizes" (client_num c);
+          raise Not_found
+        end;
+      
+      DonkeyOneFile.block_received c t.Q.md4
+        t.Q.start_pos t.Q.bloc_str t.Q.bloc_begin t.Q.bloc_len
+
 (* Upload requests *)
   | M.ViewFilesReq t when !CommonUploads.has_upload = 0 && 
     (match !!allow_browse_share with
@@ -2066,6 +2096,70 @@
       end;
       if !verbose_upload then lprintf_nl "QueryBloc treated"
       
+  | M.QueryBlocReq64 t when !CommonUploads.has_upload = 0 &&
+    client_has_a_slot (as_client c) ->
+      
+      if !verbose_upload then
+          lprintf_nl "donkeyClient: uploader %s ask for block" (full_client_identifier c);
+      
+      let module Q = M.QueryBloc64 in
+      let file = find_file  t.Q.md4 in
+      let prio = (file_priority file) in
+      let client_upload_lifetime = ref ((maxi 0 !!upload_lifetime) * 60) in
+      begin
+        
+        if !!dynamic_upload_lifetime
+            && c.client_uploaded > c.client_downloaded
+            && c.client_uploaded > Int64.of_int !!dynamic_upload_threshold ** zone_size
+        then
+          client_upload_lifetime :=
+          Int64.to_int 
+            (Int64.of_int !client_upload_lifetime 
+              ** c.client_downloaded // c.client_uploaded);
+        if last_time() > c.client_connect_time + 
+            !client_upload_lifetime + 5 * prio then
+          begin
+
+(* And what happens if we were downloading from this client also ? *)
+            
+            disconnect_client c (Closed_for_error "Upload lifetime expired");
+            raise Not_found
+          end;
+        
+        set_lifetime sock active_lifetime;
+        set_rtimeout sock !!upload_timeout;
+        
+        let up, waiting = match c.client_upload with
+            Some ({ up_file = f } as up) when f == file ->  up, up.up_waiting
+          | Some old_up ->
+              {
+                up_file = file;
+                up_pos = Int64.zero;
+                up_end_chunk = Int64.zero;
+                up_chunks = [];
+                up_waiting = old_up.up_waiting;
+              }, old_up.up_waiting
+          | _ ->
+              {
+                up_file = file;
+                up_pos = Int64.zero;
+                up_end_chunk = Int64.zero;
+                up_chunks = [];
+                up_waiting = false;
+              }, false
+        in
+        new_chunk up t.Q.start_pos1 t.Q.end_pos1;
+        new_chunk up t.Q.start_pos2 t.Q.end_pos2;
+        new_chunk up t.Q.start_pos3 t.Q.end_pos3;
+        c.client_upload <- Some up;
+        set_client_upload (as_client c) (as_file file);
+        if not waiting && !CommonUploads.has_upload = 0 then begin
+            CommonUploads.ready_for_upload (as_client c);
+            up.up_waiting <- true
+          end
+      end;
+      if !verbose_upload then lprintf_nl "QueryBloc treated"
+      
   | M.NoSuchFileReq t ->
       begin
         try
Index: src/networks/donkey/donkeyComplexOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyComplexOptions.ml,v
retrieving revision 1.58
diff -u -w -r1.58 donkeyComplexOptions.ml
--- src/networks/donkey/donkeyComplexOptions.ml	19 Sep 2006 17:07:43 -0000	1.58
+++ src/networks/donkey/donkeyComplexOptions.ml	15 Nov 2006 21:06:01 -0000
@@ -565,6 +565,8 @@
           r.result_names <- s :: r.result_names
       | { tag_name = Field_Size; tag_value = Uint64 v } ->
           r.result_size <- v;
+      | { tag_name = Field_Size_Hi; tag_value = Uint64 v } ->
+          r.result_size <- Int64.logor r.result_size (Int64.shift_left v 32);
       | { tag_name = Field_Format; tag_value = String s } ->
           r.result_tags <- tag :: r.result_tags;
           r.result_format <- s
Index: src/networks/donkey/donkeyFiles.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyFiles.ml,v
retrieving revision 1.21
diff -u -w -r1.21 donkeyFiles.ml
--- src/networks/donkey/donkeyFiles.ml	25 Oct 2006 11:12:38 -0000	1.21
+++ src/networks/donkey/donkeyFiles.ml	15 Nov 2006 21:06:01 -0000
@@ -83,6 +83,41 @@
 	    (file_best_name file) (full_client_identifier c)
             (begin_pos) (len_int);
         
+        if ((file.file_file.impl_file_size > 0xffffffffL) && (c.client_emule_proto.emule_largefiles <> 1)) then raise Donkey_large_file;
+        if ((begin_pos ++ (Int64.of_int len_int)) > 0xffffffffL) then
+        begin
+          let msg =  
+            (
+              let module M = DonkeyProtoClient in
+                let module B = M.Bloc64 in
+                M.BlocReq64 {  
+                  B.md4 = file.file_md4;
+                  B.start_pos = begin_pos;
+                  B.end_pos = begin_pos ++ (Int64.of_int len_int);
+                  B.bloc_str = "";
+                  B.bloc_begin = 0;
+                  B.bloc_len = 0; 
+                }
+            ) in
+          let s = client_msg_to_string c.client_emule_proto msg in
+          let slen = String.length s in
+          let upload_buffer = String.create (slen + len_int) in
+          String.blit s 0 upload_buffer 0 slen;
+          DonkeyProtoCom.new_string msg upload_buffer;
+          Unix32.read (file_fd file) begin_pos upload_buffer slen len_int;
+          let uploaded = Int64.of_int len_int in
+          count_upload c uploaded;
+        	CommonUploads.consume_bandwidth len_int;
+          (match file.file_shared with None -> ()
+            | Some impl ->
+                shared_must_update_downloaded (as_shared impl);
+                impl.impl_shared_uploaded <- 
+                  impl.impl_shared_uploaded ++ uploaded);
+        
+          write_string sock upload_buffer;
+          check_end_upload c sock
+        end else 
+        begin
         let msg =  
           (
             let module M = DonkeyProtoClient in
@@ -113,9 +148,12 @@
         
         write_string sock upload_buffer;
         check_end_upload c sock
+        end
       with
   End_of_file -> lprintf_nl "Can not send file %s to %s, file removed?"
 			 (file_best_name file) (full_client_identifier c)
+			| Donkey_large_file -> lprintf_nl "File %s is too large for %s."
+			 (file_best_name file) (full_client_identifier c)
       | e -> if !verbose then lprintf_nl
 	       "Exception %s in send_small_block" (Printexc2.to_string e)
     
Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.137
diff -u -w -r1.137 donkeyInteractive.ml
--- src/networks/donkey/donkeyInteractive.ml	15 Nov 2006 12:34:30 -0000	1.137
+++ src/networks/donkey/donkeyInteractive.ml	15 Nov 2006 21:06:01 -0000
@@ -431,6 +431,8 @@
                     filename_met := Some s;
                 | { tag_name = Field_Size; tag_value = Uint64 v } ->
                     size := v
+                | { tag_name = Field_Size_Hi; tag_value = Uint64 v } ->
+                    size := Int64.logor !size (Int64.shift_left v 32)
                 | _ -> ()
             ) f.P.tags;
             ignore (really_query_download
@@ -561,8 +563,8 @@
   | "ed2k://" :: "file" :: name :: size :: md4 :: "/" :: "sources" :: sources :: _
   | "file" :: name :: size :: md4 :: "/" :: "sources" :: sources :: _ ->
 (*  ed2k://|file|Wikipedia_3.3_noimages.iso|2666311680|747735CD46B61DA92973E9A8840A9C99|/|sources,62.143.4.124:4662|/  *)
-      if Int64.of_string size >= 4294967295L then
-	(Printf.sprintf (_b "Files > 4GB are not allowed")), false
+      if Int64.of_string size >= 256L ** 1024L ** 1024L ** 1024L then
+	(Printf.sprintf (_b "Files > 256GB are not allowed")), false
       else
         begin
 	  let md4 = if String.length md4 > 32 then
@@ -601,8 +603,8 @@
     	end
   | "ed2k://" :: "file" :: name :: size :: md4 :: _
   | "file" :: name :: size :: md4 :: _ ->
-      if Int64.of_string size >= 4294967295L then
-	(Printf.sprintf (_b "Files > 4GB are not allowed")), false
+      if Int64.of_string size >= 256L ** 1024L ** 1024L ** 1024L then
+	(Printf.sprintf (_b "Files > 256GB are not allowed")), false
       else
         let md4 = if String.length md4 > 32 then
           String.sub md4 0 32 else md4 in
Index: src/networks/donkey/donkeyMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyMain.ml,v
retrieving revision 1.60
diff -u -w -r1.60 donkeyMain.ml
--- src/networks/donkey/donkeyMain.ml	31 Oct 2006 15:40:06 -0000	1.60
+++ src/networks/donkey/donkeyMain.ml	15 Nov 2006 21:06:01 -0000
@@ -133,6 +133,7 @@
     m.emule_features <- secident;
 
   let emule_miscoptions1 = D.emule_miscoptions1 m in
+  let emule_miscoptions2 = D.emule_miscoptions2 m in
   let emule_compatoptions = D.emule_compatoptions m in
   client_to_client_tags :=
   [
@@ -142,11 +143,14 @@
     int_tag (Field_UNKNOWN "emule_udpports") (!!donkey_port+4);
     int_tag (Field_UNKNOWN "emule_version") m.emule_version;
     int64_tag (Field_UNKNOWN "emule_miscoptions1") emule_miscoptions1;
+    int64_tag (Field_UNKNOWN "emule_miscoptions2") emule_miscoptions2;
     int_tag (Field_UNKNOWN "emule_compatoptions") emule_compatoptions;
   ];
 
-  let extended = ref 0x04 in (* support of auxport *)
+  let extended = ref 0x0 in
     extended := !extended lor 0x01; (* support of compression *)
+  extended := !extended lor 0x04; (* support of auxport *)
+  extended := !extended lor 0x100; (* files > 4GB *)
 
   client_to_server_tags :=
   [
Index: src/networks/donkey/donkeyMftp.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyMftp.ml,v
retrieving revision 1.13
diff -u -w -r1.13 donkeyMftp.ml
--- src/networks/donkey/donkeyMftp.ml	9 Feb 2006 11:45:12 -0000	1.13
+++ src/networks/donkey/donkeyMftp.ml	15 Nov 2006 21:06:01 -0000
@@ -211,6 +211,7 @@
     "\005", Field_Lastseencomplete;
     "\021", Field_Availability;
     "\048", Field_Completesources;
+    "\058", Field_Size_Hi;
     "\208", Field_Artist;
     "\209", Field_Album;
     "\210", Field_Title;
Index: src/networks/donkey/donkeyOneFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOneFile.ml,v
retrieving revision 1.45
diff -u -w -r1.45 donkeyOneFile.ml
--- src/networks/donkey/donkeyOneFile.ml	25 Oct 2006 11:12:38 -0000	1.45
+++ src/networks/donkey/donkeyOneFile.ml	15 Nov 2006 21:06:01 -0000
@@ -228,6 +228,68 @@
       c.client_download <- None
 
 let send_get_range_request c file ranges = 
+  try
+    if ((file.file_file.impl_file_size > 0xffffffffL) && (c.client_emule_proto.emule_largefiles <> 1)) then raise Donkey_large_file;
+    let rec check_large (rangelist : (int64 * int64 * range) list) = match rangelist with
+       [] -> false
+       | (x,y,_ : (int64 * int64 * range))::tail_range ->
+         (x > 0xffffffffL) || (y > 0xffffffffL) || (check_large tail_range)
+    in
+    if (check_large ranges) && (c.client_emule_proto.emule_largefiles <> 1) then raise Donkey_large_file;
+    if (check_large ranges) then 
+    begin 
+    match c.client_source.DonkeySources.source_sock with
+    | Connection sock ->
+      
+        set_rtimeout sock !queue_timeout;
+        let module M = DonkeyProtoClient in
+        let module Q = M.QueryBloc64 in
+        let msg, len =
+          match ranges with
+            [x1,y1,_] ->
+              {
+                Q.md4 = file.file_md4;
+                Q.start_pos1 = x1;
+                Q.end_pos1 = y1;
+                Q.start_pos2 = zero;
+                Q.end_pos2 = zero;
+                Q.start_pos3 = zero;
+                Q.end_pos3 = zero;
+              }, y1 -- x1
+        
+          | [x1,y1,_; x2,y2,_] ->
+              {
+                Q.md4 = file.file_md4;
+                Q.start_pos1 = x1;
+                Q.end_pos1 = y1;
+                Q.start_pos2 = x2;
+                Q.end_pos2 = y2;
+                Q.start_pos3 = zero;
+                Q.end_pos3 = zero;
+              }, y1 -- x1
+        
+          | [x1,y1,_; x2,y2,_; x3,y3,_ ] ->
+              {
+                Q.md4 = file.file_md4;
+                Q.start_pos1 = x1;
+                Q.end_pos1 = y1;
+                Q.start_pos2 = x2;
+                Q.end_pos2 = y2;
+                Q.start_pos3 = x3;
+                Q.end_pos3 = y3;
+              }, y1 -- x1
+        
+          | _ -> assert false
+        in
+        let msg = M.QueryBlocReq64 msg in
+        set_read_power sock (!!upload_power + maxi 0 (file_priority file));
+(*      lprintf "QUEUE DOWNLOAD REQUEST\n"; *)
+(*      CommonUploads.queue_download_request (fun _ ->  *)
+            client_send c msg 
+(*          ) (Int64.to_int len) *)
+    | _ -> assert false
+  end else
+  begin
   match c.client_source.DonkeySources.source_sock with
   | Connection sock ->
       
@@ -278,6 +340,10 @@
           client_send c msg 
 (*          ) (Int64.to_int len) *)
   | _ -> assert false
+  end
+  with
+  Donkey_large_file -> lprintf_nl "File %s is too large for %s."
+			 (file_best_name file) (full_client_identifier c)
       
 let rec get_from_client c =
   match c.client_download with
@@ -472,6 +538,8 @@
       match tag with
         { tag_name = Field_Filename; tag_value = String s } -> file_name := s
       | { tag_name = Field_Size; tag_value = Uint64 v } -> file_size := v
+      | { tag_name = Field_Size_Hi; tag_value = Uint64 v } ->
+      	  file_size := Int64.logor !file_size (Int64.shift_left v 32)
       | { tag_name = Field_Availability;
     tag_value = (Uint64 v| Fint64 v) } ->
           availability := Int64.to_int v;  new_tags := tag :: !new_tags
Index: src/networks/donkey/donkeyPandora.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyPandora.ml,v
retrieving revision 1.7
diff -u -w -r1.7 donkeyPandora.ml
--- src/networks/donkey/donkeyPandora.ml	3 Apr 2006 20:50:09 -0000	1.7
+++ src/networks/donkey/donkeyPandora.ml	15 Nov 2006 21:06:01 -0000
@@ -138,12 +138,19 @@
             
             begin
               try
-                let options = find_tag (Field_UNKNOWN "emule_miscoptions1") tags in
-                match options with
-                  Uint64 v | Fint64 v ->
+                let options1 = find_tag (Field_UNKNOWN "emule_miscoptions1") tags in
+                (match options1 with
+                | Uint64 v | Fint64 v ->
                     update_emule_proto_from_miscoptions1 emule v
                 | _ -> 
-                    lprintf "CANNOT INTERPRETE EMULE OPTIONS\n"
+                    lprintf "CANNOT INTERPRETE EMULE OPTIONS\n");
+
+                let options2 = find_tag (Field_UNKNOWN "emule_miscoptions2") tags in
+                (match options2 with
+                | Uint64 v | Fint64 v ->
+                    update_emule_proto_from_miscoptions2 emule v
+                | _ -> 
+                    lprintf "CANNOT INTERPRETE EMULE OPTIONS 2\n");
               
               with _ -> ()
             end;
@@ -151,7 +158,8 @@
         | P.UnknownReq (227,_) -> 
             emule.emule_extendedrequest <-  -1
         
-        | P.EmuleCompressedPart (md4, statpos, newsize, bloc) ->
+        | P.EmuleCompressedPart (md4, statpos, newsize, bloc)
+        | P.EmuleCompressedPart64 (md4, statpos, newsize, bloc) ->
             
             let comp = match c.client_comp with
                 None ->
Index: src/networks/donkey/donkeyProtoClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoClient.ml,v
retrieving revision 1.39
diff -u -w -r1.39 donkeyProtoClient.ml
--- src/networks/donkey/donkeyProtoClient.ml	31 Oct 2006 15:40:06 -0000	1.39
+++ src/networks/donkey/donkeyProtoClient.ml	15 Nov 2006 21:06:02 -0000
@@ -55,6 +55,7 @@
     emule_compression = 1; (* 1 *)
     emule_sourceexchange = 2; (* 2 : +client_md4 3 : +IdHybrid (emule Kademlia?)*)
     emule_multipacket = 0; (* 1 *)
+    emule_largefiles = 1; (* 1 *)
     emule_extendedrequest = 1; (* 1: +file_status 2: +ncomplete_sources*)
     emule_features = 3; (* 3 *)
     emule_udpver = 0; (* 4 *)
@@ -74,6 +75,12 @@
   in
   Int64.of_int o
 
+let emule_miscoptions2 m =
+  let o =
+    (m.emule_largefiles lsl 4)
+  in
+  Int64.of_int o
+
 let update_emule_proto_from_miscoptions1 m o =
   let o = Int64.to_int o in
   m.emule_udpver <- (o lsr 24) land 0xf;
@@ -86,6 +93,10 @@
   m.emule_multipacket <- (o lsr 1) land 0x1;
   m.emule_supportpreview <- (o lsr 0) land 0x1
 
+let update_emule_proto_from_miscoptions2 m o =
+  let o = Int64.to_int o in
+  m.emule_largefiles <- (o lsr 4) land 0x1
+
 let emule_compatoptions m =
   (m.emule_osinfosupport lsl 0)
 
@@ -477,6 +488,39 @@
       Buffer.add_substring buf t.bloc_str t.bloc_begin t.bloc_len
   end
 
+module Bloc64  = struct
+    type t = {
+        md4 : Md4.t;
+        start_pos : int64;
+        end_pos: int64;
+        bloc_str: string;
+        bloc_begin : int;
+        bloc_len : int;
+      }
+
+    let parse len s =
+      {
+        md4 = get_md4 s 1;
+        start_pos = get_int64 s 17;
+        end_pos = get_int64 s 25;
+        bloc_str = s;
+        bloc_begin = 33;
+        bloc_len = len - 33;
+      }
+
+    let print t =
+      lprintf_nl "BLOC OF %s len %Ld [%Ld - %Ld] " (Md4.to_string t.md4)
+      (t.end_pos -- t.start_pos)
+      t.start_pos
+        t.end_pos
+
+    let write buf t =
+      buf_md4 buf t.md4;
+      buf_int64 buf t.start_pos;
+      buf_int64 buf t.end_pos;
+      Buffer.add_substring buf t.bloc_str t.bloc_begin t.bloc_len
+  end
+
 module QueryBloc  = struct
     type t = {
         md4 : Md4.t;
@@ -516,6 +560,45 @@
       buf_int64_32 buf t.end_pos3
   end
 
+module QueryBloc64  = struct
+    type t = {
+        md4 : Md4.t;
+        start_pos1 : int64; (* 180 ko *)
+        end_pos1: int64;
+        start_pos2 : int64;
+        end_pos2: int64;
+        start_pos3 : int64;
+        end_pos3: int64;
+      }
+
+    let parse len s =
+      {
+        md4 = get_md4 s 1;
+        start_pos1 = get_int64 s 17;
+        end_pos1 = get_int64 s 41;
+        start_pos2 = get_int64 s 25;
+        end_pos2 = get_int64 s 49;
+        start_pos3 = get_int64 s 33;
+        end_pos3 = get_int64 s 57;
+      }
+
+    let print t =
+      lprintf_nl "QUERY BLOCS OF %s [%s - %s] [%s - %s] [%s - %s]"
+      (Md4.to_string t.md4)
+      (Int64.to_string t.start_pos1) (Int64.to_string t.end_pos1)
+      (Int64.to_string t.start_pos2) (Int64.to_string t.end_pos2)
+      (Int64.to_string t.start_pos3) (Int64.to_string t.end_pos3)
+
+    let write buf t =
+      buf_md4 buf t.md4;
+      buf_int64 buf t.start_pos1;
+      buf_int64 buf t.start_pos2;
+      buf_int64 buf t.start_pos3;
+      buf_int64 buf t.end_pos1;
+      buf_int64 buf t.end_pos2;
+      buf_int64 buf t.end_pos3
+  end
+
 let unit = ()
 module NoArg = functor(M: sig val m : string end) -> (struct
         type t = unit
@@ -1096,7 +1179,9 @@
 | QueryFileReq of QueryFile.t
 | QueryFileReplyReq of QueryFileReply.t
 | BlocReq of Bloc.t
+| BlocReq64 of Bloc64.t
 | QueryBlocReq of QueryBloc.t
+| QueryBlocReq64 of QueryBloc64.t
 | JoinQueueReq of JoinQueue.t (* sent before queryBloc *)
 | AvailableSlotReq of AvailableSlot.t
 | ReleaseSlotReq of ReleaseSlot.t
@@ -1133,6 +1218,7 @@
 | EmuleMultiPacketReq of Md4.t * t list
 | EmuleMultiPacketAnswerReq of Md4.t * t list
 | EmuleCompressedPart of Md4.t * int64 * int64 * string
+| EmuleCompressedPart64 of Md4.t * int64 * int64 * string
 | EmulePortTestReq of EmulePortTestReq.t
 
 let rec print t =
@@ -1143,7 +1229,9 @@
     | QueryFileReq t -> QueryFile.print t
     | QueryFileReplyReq t -> QueryFileReply.print t
     | BlocReq t -> Bloc.print t
+    | BlocReq64 t -> Bloc64.print t
     | QueryBlocReq t -> QueryBloc.print t
+    | QueryBlocReq64 t -> QueryBloc64.print t
     | JoinQueueReq t -> JoinQueue.print t
     | AvailableSlotReq t -> AvailableSlot.print t
     | ReleaseSlotReq t -> ReleaseSlot.print t
@@ -1204,6 +1292,9 @@
     | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
         lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
           (Md4.to_string md4) statpos newsize (String.length bloc)
+    | EmuleCompressedPart64 (md4, statpos, newsize, bloc) ->
+        lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
+          (Md4.to_string md4) statpos newsize (String.length bloc)
     | EmulePortTestReq t ->
         EmulePortTestReq.print t
     | UnknownReq (opcode, s) ->
@@ -1337,6 +1428,18 @@
         in
         EmuleMultiPacketAnswerReq (md4, iter s 17 len)
 
+    | 0xa1 (* 161 *) ->
+(* OP_COMPRESSEDPART_I64 *)
+        let md4 = get_md4 s 1 in
+        let statpos = get_int64 s 17 in
+        let newsize = get_uint64_32 s 25 in
+        let bloc = String.sub s 29 (len-29) in
+        EmuleCompressedPart64 (md4, statpos, newsize, bloc)
+
+    | 0xa2 -> BlocReq64 (Bloc64.parse len s) (* OP_SENDINGPART_I64 *)
+
+    | 0xa3 -> QueryBlocReq64 (QueryBloc64.parse len s) (*OP_REQUESTPARTS_I64 *)
+
     | 0xfe (* 254 *) ->
         EmulePortTestReq s
 
@@ -1454,6 +1557,9 @@
     | EmuleFileDescReq _
     | EmuleQueueRankingReq _
     | EmuleCompressedPart _
+    | BlocReq64 _
+    | QueryBlocReq64 _
+    | EmuleCompressedPart64 _
       -> 0xC5
     | _
       ->  227
@@ -1622,6 +1728,19 @@
         buf_int8 buf 0x85;
         EmulePublicKeyReq.write buf t
 
+    | QueryBlocReq64 t ->
+        buf_int8 buf 0xa3;
+        QueryBloc64.write buf t
+    | BlocReq64 t ->
+        buf_int8 buf 0xa2;
+        Bloc64.write buf t
+    | EmuleCompressedPart64 (md4, statpos, newsize, bloc) ->
+        buf_int8 buf 0xa1;
+        buf_md4 buf md4;
+        buf_int64 buf statpos;
+        buf_int64_32 buf newsize;
+        Buffer.add_string buf bloc
+
     | EmulePortTestReq t ->
         buf_int8 buf 0xfe;
         EmulePortTestReq.write buf;
Index: src/networks/donkey/donkeyProtoCom.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoCom.ml,v
retrieving revision 1.33
diff -u -w -r1.33 donkeyProtoCom.ml
--- src/networks/donkey/donkeyProtoCom.ml	8 Oct 2006 14:20:22 -0000	1.33
+++ src/networks/donkey/donkeyProtoCom.ml	15 Nov 2006 21:06:02 -0000
@@ -234,7 +234,8 @@
       if !verbose_share then lprintf_nl "tag_file: Sharing %s" name;
       name
     ))::
-  (int64_tag Field_Size file.file_file.impl_file_size) ::
+    (int64_tag Field_Size_Hi (Int64.shift_right_logical file.file_file.impl_file_size 32)) ::
+    (int64_tag Field_Size (Int64.logand file.file_file.impl_file_size 0xffffffffL)) ::
   (
     (match file.file_format with
         FormatNotComputed next_time when
Index: src/networks/donkey/donkeyTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyTypes.ml,v
retrieving revision 1.51
diff -u -w -r1.51 donkeyTypes.ml
--- src/networks/donkey/donkeyTypes.ml	14 Nov 2006 18:42:59 -0000	1.51
+++ src/networks/donkey/donkeyTypes.ml	15 Nov 2006 21:06:02 -0000
@@ -32,6 +32,8 @@
 let lprintf_n fmt =
   lprintf2 log_prefix fmt
 
+exception Donkey_large_file
+
 type emule_proto = {
     mutable emule_comments : int;
     mutable emule_version : int;
@@ -44,6 +46,7 @@
     mutable emule_compression : int;
     mutable emule_sourceexchange : int;
     mutable emule_multipacket : int;
+    mutable emule_largefiles : int;
     mutable emule_extendedrequest : int;
     mutable emule_features : int;
     mutable emule_udpver : int;
@@ -697,6 +700,7 @@
     emule_compression = 0; (* 1 *)
     emule_sourceexchange = 0; (* 3 *)
     emule_multipacket = 0; (* 1 *)
+    emule_largefiles = 0; (* 1 *)
     emule_extendedrequest = 0; (* 2 *)
     emule_features = 0; (* 3 *)
     emule_udpver = 0; (* 4 *)
