diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/daemon/common/commonGlobals.ml ./src/daemon/common/commonGlobals.ml
--- ./src/daemon/common/commonGlobals.ml	2006-11-21 23:34:33.000000000 +0100
+++ ./src/daemon/common/commonGlobals.ml	2006-11-26 18:29:34.000000000 +0100
@@ -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
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/daemon/common/commonTypes.ml ./src/daemon/common/commonTypes.ml
--- ./src/daemon/common/commonTypes.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/daemon/common/commonTypes.ml	2006-11-26 18:29:34.000000000 +0100
@@ -260,6 +260,7 @@
 | Field_Completesources (* "completesources" *)
 | Field_Filename (* "filename" *)
 | Field_Size
+| Field_Size_Hi
 | Field_Uid
 | Field_Filerating
 | Field_Lastseencomplete
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/gtk2/gui/guiMisc.ml ./src/gtk2/gui/guiMisc.ml
--- ./src/gtk2/gui/guiMisc.ml	2006-08-16 21:10:34.000000000 +0200
+++ ./src/gtk2/gui/guiMisc.ml	2006-11-26 18:29:34.000000000 +0100
@@ -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"
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyClient.ml ./src/networks/donkey/donkeyClient.ml
--- ./src/networks/donkey/donkeyClient.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyClient.ml	2006-11-26 18:29:34.000000000 +0100
@@ -1560,8 +1560,7 @@
 (*      if file.file_exists then verify_chunks file *)
       end
   
-  
-  | M.EmuleCompressedPart (md4, statpos, newsize, bloc) ->
+  | M.EmuleCompressedPart t ->
       
       set_lifetime sock active_lifetime;      
       if !!reliable_sources && 
@@ -1572,12 +1571,13 @@
           raise Not_found
         end;
       
+      let module Q = M.EmuleCompressedPart in
       let comp = match c.client_comp with
           None ->
             let comp = {
-                comp_md4 = md4;
-                comp_pos = statpos;
-                comp_total = Int64.to_int newsize;
+                comp_md4 = t.Q.md4;
+                comp_pos = t.Q.statpos;
+                comp_total = Int64.to_int t.Q.newsize;
                 comp_len = 0;
                 comp_blocs = [];
               } in
@@ -1585,8 +1585,8 @@
             comp
         | Some comp -> comp
       in
-      comp.comp_blocs <- bloc :: comp.comp_blocs;
-      comp.comp_len <- comp.comp_len + String.length bloc;
+      comp.comp_blocs <- t.Q.bloc :: comp.comp_blocs;
+      comp.comp_len <- comp.comp_len + String.length t.Q.bloc;
 
 (*            lprintf "Comp bloc: %d/%d\n" comp.comp_len comp.comp_total; *)
       if comp.comp_len = comp.comp_total then begin
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyComplexOptions.ml ./src/networks/donkey/donkeyComplexOptions.ml
--- ./src/networks/donkey/donkeyComplexOptions.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyComplexOptions.ml	2006-11-26 19:29:33.000000000 +0100
@@ -557,6 +557,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 = Uint8 v } ->
+          r.result_size <- Int64.logor r.result_size (Int64.shift_left (Int64.of_int v) 32);
       | { tag_name = Field_Format; tag_value = String s } ->
           r.result_tags <- tag :: r.result_tags;
           r.result_format <- s
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyFiles.ml ./src/networks/donkey/donkeyFiles.ml
--- ./src/networks/donkey/donkeyFiles.ml	2006-11-21 23:34:33.000000000 +0100
+++ ./src/networks/donkey/donkeyFiles.ml	2006-11-26 18:29:34.000000000 +0100
@@ -83,12 +83,14 @@
 	    (file_best_name file) (full_client_identifier c)
             (begin_pos) (len_int);
         
+        if file_is_largefile file && c.client_emule_proto.emule_largefiles <> 1 then raise Donkey_large_file;
         let msg =  
           (
             let module M = DonkeyProtoClient in
             let module B = M.Bloc in
             M.BlocReq {  
               B.md4 = file.file_md4;
+              B.largefile = (begin_pos ++ (Int64.of_int len_int)) > old_max_emule_file_size;
               B.start_pos = begin_pos;
               B.end_pos = begin_pos ++ (Int64.of_int len_int);
               B.bloc_str = "";
@@ -114,7 +116,9 @@
         write_string sock upload_buffer;
         check_end_upload c sock
       with
-  End_of_file -> lprintf_nl "Can not send file %s to %s, file removed?"
+      | 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)
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyGlobals.ml ./src/networks/donkey/donkeyGlobals.ml
--- ./src/networks/donkey/donkeyGlobals.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyGlobals.ml	2006-11-26 18:29:34.000000000 +0100
@@ -104,6 +104,7 @@
 let as_file file = as_file file.file_file
 let file_priority file = file.file_file.impl_file_priority
 let file_size file = file.file_file.impl_file_size
+let file_is_largefile f = file_size f > old_max_emule_file_size
 let file_downloaded file = file_downloaded (as_file file)
 let file_age file = file.file_file.impl_file_age
 let file_fd file = file_fd (as_file file)
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyInteractive.ml ./src/networks/donkey/donkeyInteractive.ml
--- ./src/networks/donkey/donkeyInteractive.ml	2006-11-26 18:27:40.000000000 +0100
+++ ./src/networks/donkey/donkeyInteractive.ml	2006-11-26 18:29:34.000000000 +0100
@@ -429,6 +429,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
@@ -559,8 +561,9 @@
   | "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 >= max_emule_file_size then
+	(Printf.sprintf (_b "Files > %s are not allowed")
+	  (Int64ops.int64_to_human_readable max_emule_file_size)), false
       else
         begin
 	  let md4 = if String.length md4 > 32 then
@@ -599,8 +602,9 @@
     	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 >= max_emule_file_size then
+	(Printf.sprintf (_b "Files > %s are not allowed")
+	  (Int64ops.int64_to_human_readable max_emule_file_size)), false
       else
         let md4 = if String.length md4 > 32 then
           String.sub md4 0 32 else md4 in
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyMain.ml ./src/networks/donkey/donkeyMain.ml
--- ./src/networks/donkey/donkeyMain.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyMain.ml	2006-11-26 18:30:28.000000000 +0100
@@ -154,7 +154,7 @@
   extended := !extended lor 0x04; (* support of auxport *)
   extended := !extended lor 0x08; (* newtags *)
 (*extended := !extended lor 0x10; (* unicode *) *)
-(*extended := !extended lor 0x100; (* files > 4GB *) *)
+  extended := !extended lor 0x100; (* files > 4GB *)
 (*extended := !extended lor 0x200; (* support crypt *) *)
 (*extended := !extended lor 0x400; (* request crypt *) *)
 (*extended := !extended lor 0x800; (* require crypt *) *)
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyMftp.ml ./src/networks/donkey/donkeyMftp.ml
--- ./src/networks/donkey/donkeyMftp.ml	2006-02-09 12:45:12.000000000 +0100
+++ ./src/networks/donkey/donkeyMftp.ml	2006-11-26 18:29:36.000000000 +0100
@@ -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;
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyOneFile.ml ./src/networks/donkey/donkeyOneFile.ml
--- ./src/networks/donkey/donkeyOneFile.ml	2006-11-21 23:34:34.000000000 +0100
+++ ./src/networks/donkey/donkeyOneFile.ml	2006-11-26 19:29:48.000000000 +0100
@@ -228,6 +228,16 @@
       c.client_download <- None
 
 let send_get_range_request c file ranges = 
+  let rec check_large (rangelist : (int64 * int64 * range) list) =
+    match rangelist with
+    | [] -> false
+    | (x,y,_ : (int64 * int64 * range))::tail_range ->
+	    (x > old_max_emule_file_size) || (y > old_max_emule_file_size) || (check_large tail_range)
+  in
+  let is_largefile = file_is_largefile file || check_large ranges in
+  if is_largefile && c.client_emule_proto.emule_largefiles <> 1 then
+    lprintf_nl "File %s is too large for %s." (file_best_name file) (full_client_identifier c)
+  else
   match c.client_source.DonkeySources.source_sock with
   | Connection sock ->
       
@@ -239,6 +249,7 @@
           [x1,y1,_] ->
             {
               Q.md4 = file.file_md4;
+              Q.largefile = is_largefile;
               Q.start_pos1 = x1;
               Q.end_pos1 = y1;
               Q.start_pos2 = zero;
@@ -250,6 +261,7 @@
         | [x1,y1,_; x2,y2,_] ->
             {
               Q.md4 = file.file_md4;
+              Q.largefile = is_largefile;
               Q.start_pos1 = x1;
               Q.end_pos1 = y1;
               Q.start_pos2 = x2;
@@ -261,6 +273,7 @@
         | [x1,y1,_; x2,y2,_; x3,y3,_ ] ->
             {
               Q.md4 = file.file_md4;
+              Q.largefile = is_largefile;
               Q.start_pos1 = x1;
               Q.end_pos1 = y1;
               Q.start_pos2 = x2;
@@ -472,8 +485,9 @@
       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_Availability;
-    tag_value = (Uint64 v| Fint64 v) } ->
+      | { tag_name = Field_Size_Hi; tag_value = Uint8 v } ->
+      	  file_size := Int64.logor !file_size (Int64.shift_left (Int64.of_int v) 32)
+      | { tag_name = Field_Availability; tag_value = (Uint64 v| Fint64 v) } ->
           availability := Int64.to_int v;  new_tags := tag :: !new_tags
       | _ -> new_tags := tag :: !new_tags
   ) tags;
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyPandora.ml ./src/networks/donkey/donkeyPandora.ml
--- ./src/networks/donkey/donkeyPandora.ml	2006-04-03 22:50:09.000000000 +0200
+++ ./src/networks/donkey/donkeyPandora.ml	2006-11-26 18:29:36.000000000 +0100
@@ -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,14 +158,14 @@
         | P.UnknownReq (227,_) -> 
             emule.emule_extendedrequest <-  -1
         
-        | P.EmuleCompressedPart (md4, statpos, newsize, bloc) ->
+        | P.EmuleCompressedPart t ->
             
             let comp = match c.client_comp with
                 None ->
                   let comp = {
-                      comp_md4 = md4;
-                      comp_pos = statpos;
-                      comp_total = Int64.to_int newsize;
+                      comp_md4 = t.EmuleCompressedPart.md4;
+                      comp_pos = t.EmuleCompressedPart.statpos;
+                      comp_total = Int64.to_int t.EmuleCompressedPart.newsize;
                       comp_len = 0;
                       comp_blocs = [];
                     } in
@@ -166,8 +173,8 @@
                   comp
               | Some comp -> comp
             in
-            comp.comp_blocs <- bloc :: comp.comp_blocs;
-            comp.comp_len <- comp.comp_len + String.length bloc;
+            comp.comp_blocs <- t.EmuleCompressedPart.bloc :: comp.comp_blocs;
+            comp.comp_len <- comp.comp_len + String.length t.EmuleCompressedPart.bloc;
 
 (*            lprintf "Comp bloc: %d/%d\n" comp.comp_len comp.comp_total; *)
             if comp.comp_len = comp.comp_total then begin
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyProtoClient.ml ./src/networks/donkey/donkeyProtoClient.ml
--- ./src/networks/donkey/donkeyProtoClient.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyProtoClient.ml	2006-11-26 19:33:44.000000000 +0100
@@ -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 *)
@@ -75,13 +76,10 @@
   Int64.of_int o
 
 let emule_miscoptions2 m =
-(*
   let o =
     (m.emule_largefiles lsl 4)
   in
   Int64.of_int o
-*)
-  Int64.zero
 
 let update_emule_proto_from_miscoptions1 m o =
   let o = Int64.to_int o in
@@ -95,11 +93,9 @@
   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 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)
@@ -462,6 +458,7 @@
 module Bloc  = struct
     type t = {
         md4 : Md4.t;
+        largefile : bool;
         start_pos : int64;
         end_pos: int64;
         bloc_str: string;
@@ -469,14 +466,15 @@
         bloc_len : int;
       }
 
-    let parse len s =
+    let parse largefile len s =
       {
         md4 = get_md4 s 1;
-        start_pos = get_uint64_32 s 17;
-        end_pos = get_uint64_32 s 21;
+        largefile = largefile;
+        start_pos = if largefile then get_int64 s 17 else get_uint64_32 s 17;
+        end_pos   = if largefile then get_int64 s 25 else get_uint64_32 s 21;
         bloc_str = s;
-        bloc_begin = 25;
-        bloc_len = len - 25;
+        bloc_begin = if largefile then 33 else 25;
+        bloc_len = if largefile then len - 33 else len - 25;
       }
 
     let print t =
@@ -487,14 +485,15 @@
 
     let write buf t =
       buf_md4 buf t.md4;
-      buf_int64_32 buf t.start_pos;
-      buf_int64_32 buf t.end_pos;
+      if t.largefile then buf_int64 buf t.start_pos else buf_int64_32 buf t.start_pos;
+      if t.largefile then buf_int64 buf t.end_pos else buf_int64_32 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;
+        largefile : bool;
         start_pos1 : int64; (* 180 ko *)
         end_pos1: int64;
         start_pos2 : int64;
@@ -503,15 +502,16 @@
         end_pos3: int64;
       }
 
-    let parse len s =
+    let parse largefile len s =
       {
         md4 = get_md4 s 1;
-        start_pos1 = get_uint64_32 s 17;
-        end_pos1 = get_uint64_32 s 29;
-        start_pos2 = get_uint64_32 s 21;
-        end_pos2 = get_uint64_32 s 33;
-        start_pos3 = get_uint64_32 s 25;
-        end_pos3 = get_uint64_32 s 37;
+        largefile = largefile;
+        start_pos1 = if largefile then get_int64 s 17 else get_uint64_32 s 17;
+        end_pos1   = if largefile then get_int64 s 41 else get_uint64_32 s 29;
+        start_pos2 = if largefile then get_int64 s 25 else get_uint64_32 s 21;
+        end_pos2   = if largefile then get_int64 s 49 else get_uint64_32 s 33;
+        start_pos3 = if largefile then get_int64 s 33 else get_uint64_32 s 25;
+        end_pos3   = if largefile then get_int64 s 57 else get_uint64_32 s 37;
       }
 
     let print t =
@@ -523,12 +523,12 @@
 
     let write buf t =
       buf_md4 buf t.md4;
-      buf_int64_32 buf t.start_pos1;
-      buf_int64_32 buf t.start_pos2;
-      buf_int64_32 buf t.start_pos3;
-      buf_int64_32 buf t.end_pos1;
-      buf_int64_32 buf t.end_pos2;
-      buf_int64_32 buf t.end_pos3
+      if t.largefile then buf_int64 buf t.start_pos1 else buf_int64_32 buf t.start_pos1;
+      if t.largefile then buf_int64 buf t.start_pos2 else buf_int64_32 buf t.start_pos2;
+      if t.largefile then buf_int64 buf t.start_pos3 else buf_int64_32 buf t.start_pos3;
+      if t.largefile then buf_int64 buf t.end_pos1 else buf_int64_32 buf t.end_pos1;
+      if t.largefile then buf_int64 buf t.end_pos2 else buf_int64_32 buf t.end_pos2;
+      if t.largefile then buf_int64 buf t.end_pos3 else buf_int64_32 buf t.end_pos3
   end
 
 let unit = ()
@@ -1090,6 +1090,35 @@
       buf_string buf t.comment
   end
 
+module EmuleCompressedPart = struct
+
+    type t = {
+        md4 : Md4.t;
+        largefile : bool;
+        statpos : int64;
+        newsize : int64;
+        bloc : string;
+      }
+
+    let parse largefile len s =
+      {
+        md4 = get_md4 s 1;
+        largefile = largefile;
+        statpos = if largefile then get_int64 s 17 else get_uint64_32 s 17;
+        newsize = if largefile then get_uint64_32 s 25 else get_uint64_32 s 21;
+    	bloc = if largefile then String.sub s 29 (len-29) else String.sub s 25 (len-25)
+      }
+
+    let print t =
+      lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
+	(Md4.to_string t.md4) t.statpos t.newsize (String.length t.bloc)
+
+    let write buf t =
+      buf_md4 buf t.md4;
+      if t.largefile then buf_int64 buf t.statpos else buf_int64_32 buf t.statpos;
+      buf_int64_32 buf t.newsize;
+      Buffer.add_string buf t.bloc
+  end
 
 module EmulePortTestReq = struct
 
@@ -1147,7 +1176,7 @@
 | EmuleSecIdentStateReq  of EmuleSecIdentStateReq.t
 | EmuleMultiPacketReq of Md4.t * t list
 | EmuleMultiPacketAnswerReq of Md4.t * t list
-| EmuleCompressedPart of Md4.t * int64 * int64 * string
+| EmuleCompressedPart of EmuleCompressedPart.t
 | EmulePortTestReq of EmulePortTestReq.t
 
 let rec print t =
@@ -1216,9 +1245,8 @@
         EmuleSignatureReq.print t
     | EmulePublicKeyReq t ->
         EmulePublicKeyReq.print t
-    | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
-        lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
-          (Md4.to_string md4) statpos newsize (String.length bloc)
+    | EmuleCompressedPart t ->
+        EmuleCompressedPart.print t
     | EmulePortTestReq t ->
         EmulePortTestReq.print t
     | UnknownReq (opcode, s) ->
@@ -1265,11 +1293,7 @@
 
     | 0x40 (* 64 *) ->
 (* OP_COMPRESSEDPART *)
-        let md4 = get_md4 s 1 in
-        let statpos = get_uint64_32 s 17 in
-        let newsize = get_uint64_32 s 21 in
-        let bloc = String.sub s 25 (len-25) in
-        EmuleCompressedPart (md4, statpos, newsize, bloc)
+        EmuleCompressedPart (EmuleCompressedPart.parse false len s)
 
     | 0x85 (* 133 *) ->
         EmulePublicKeyReq(EmulePublicKeyReq.parse len s)
@@ -1352,6 +1376,10 @@
         in
         EmuleMultiPacketAnswerReq (md4, iter s 17 len)
 
+    | 0xa1 (* 161 *) -> (* OP_COMPRESSEDPART_I64 *)
+        EmuleCompressedPart (EmuleCompressedPart.parse true len s)
+    | 0xa2 -> BlocReq (Bloc.parse true len s) (* OP_SENDINGPART_I64 *)
+    | 0xa3 -> QueryBlocReq (QueryBloc.parse true len s) (*OP_REQUESTPARTS_I64 *)
     | 0xfe (* 254 *) ->
         EmulePortTestReq s
 
@@ -1377,8 +1405,8 @@
         begin
           match opcode with
           | 1 -> ConnectReq (Connect.parse false len s)
-          | 70 -> BlocReq (Bloc.parse len s)
-          | 71 -> QueryBlocReq (QueryBloc.parse len s)
+          | 70 -> BlocReq (Bloc.parse false len s)
+          | 71 -> QueryBlocReq (QueryBloc.parse false len s)
           | 72 -> NoSuchFileReq (NoSuchFile.parse len s)
           | 73 -> EndOfDownloadReq (EndOfDownload.parse len s)
           | 74 -> ViewFilesReq (ViewFiles.parse len s)
@@ -1470,6 +1498,8 @@
     | EmuleQueueRankingReq _
     | EmuleCompressedPart _
       -> 0xC5
+    | QueryBlocReq t when t.QueryBloc.largefile -> 0xC5
+    | BlocReq t when t.Bloc.largefile -> 0xC5
     | _
       ->  227
   in
@@ -1491,10 +1521,10 @@
         buf_int8 buf 77;
         OtherLocations.write buf t
     | QueryBlocReq t ->
-        buf_int8 buf 71;
+        buf_int8 buf (if t.QueryBloc.largefile then 0xa3 else 71);
         QueryBloc.write buf t
     | BlocReq t ->
-        buf_int8 buf 70;
+        buf_int8 buf (if t.Bloc.largefile then 0xa2 else 70);
         Bloc.write buf t
     | JoinQueueReq t ->
         buf_int8 buf 84;
@@ -1578,13 +1608,9 @@
     | EmuleFileDescReq t ->
         buf_int8 buf 0x61;
         EmuleFileDesc.write buf t
-    | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
-        buf_int8 buf 0x40;
-        buf_md4 buf md4;
-        buf_int64_32 buf statpos;
-        buf_int64_32 buf newsize;
-        Buffer.add_string buf bloc
-
+    | EmuleCompressedPart t ->
+        buf_int8 buf (if t.EmuleCompressedPart.largefile then 0xa1 else 0x40);
+        EmuleCompressedPart.write buf t
     | EmuleMultiPacketReq (md4, list) ->
         buf_int8 buf 0x92;
         buf_md4 buf md4;
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyProtoCom.ml ./src/networks/donkey/donkeyProtoCom.ml
--- ./src/networks/donkey/donkeyProtoCom.ml	2006-10-08 16:20:22.000000000 +0200
+++ ./src/networks/donkey/donkeyProtoCom.ml	2006-11-26 18:29:36.000000000 +0100
@@ -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
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyProtoServer.ml ./src/networks/donkey/donkeyProtoServer.ml
--- ./src/networks/donkey/donkeyProtoServer.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyProtoServer.ml	2006-11-26 19:07:00.000000000 +0100
@@ -28,31 +28,6 @@
 open DonkeyTypes
 open DonkeyMftp
 
-(*
-let field_of_tagname s =
-  match s with
-  | "size" -> Field_Size
-  | "filename" -> Field_Filename
-  | "Artist" -> Field_Artist
-  | "Album" -> Field_Album
-  | "Title" -> Field_Title
-  | "format" -> Field_Format
-  | "type" -> Field_Type
-  | s -> Field_UNKNOWN s
-
-let tagname_of_field field =
-  match field with
-    Field_Size -> "size"
-  | Field_Filename -> "filename"
-  | Field_Artist -> "Artist"
-  | Field_Album -> "Album"
-  | Field_Title -> "Title"
-  | Field_Format -> "format"
-  | Field_Type -> "type"
-  | Field_Uid -> "uid"
-  | Field_unknown s -> s
-*)
-
 module Connect = struct
     type t = {
         md4 : Md4.t;
@@ -833,7 +808,13 @@
       Printf.bprintf oc "QUERY LOCATION OF %s [%Ld]\n" (Md4.to_string t.md4) t.size
 
     let write buf t =
-      buf_md4 buf t.md4; buf_int64_32 buf t.size 
+      buf_md4 buf t.md4;
+      if t.size > old_max_emule_file_size then
+        begin
+	  buf_int64_32 buf 0L; buf_int64 buf t.size 
+        end
+      else
+        buf_int64_32 buf t.size 
   end
 
 module QueryLocationReply  = struct
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyShare.ml ./src/networks/donkey/donkeyShare.ml
--- ./src/networks/donkey/donkeyShare.ml	2006-10-09 18:17:19.000000000 +0200
+++ ./src/networks/donkey/donkeyShare.ml	2006-11-26 18:29:36.000000000 +0100
@@ -188,13 +188,18 @@
 (* iter through all shared files and check if the file is already published on the current server
    build a list of files_to_send with yet unpublished files *)
       begin
-	let files_to_send = ref [] in
+        let files_to_send = ref [] in
+        let can_publish f = not (file_is_largefile f && not s.server_has_largefiles) in
         List.iter (fun f ->
           match f.file_shared with
 	    Some impl ->
 	      if not (List.mem (CommonServer.as_server s.server_server) impl.impl_shared_servers)
-		&& List.length !files_to_send < !!max_published_files then
-	      files_to_send := f :: !files_to_send
+		&& List.length !files_to_send < !!max_published_files && can_publish f then
+	       files_to_send := f :: !files_to_send
+	      else
+		if not (can_publish f) then
+		  lprintf_nl "Can not publish largefile %s because server %s does not support largefiles"
+		    (file_best_name f) (string_of_server s)
 	    | _ -> () (* this case never happens *)
 	) all_shared;
 
diff -a -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x '*.cmi' -x '*.cma' -x '*.cmo' -x '*.cmx' -x '*.cmxa' -x '*.a' -x '*.o' -x .depend -x Makefile -x mlnet -x ocamlpp.byte -N -r -u ./src/networks/donkey/donkeyTypes.ml ./src/networks/donkey/donkeyTypes.ml
--- ./src/networks/donkey/donkeyTypes.ml	2006-11-26 17:36:29.000000000 +0100
+++ ./src/networks/donkey/donkeyTypes.ml	2006-11-26 19:34:27.000000000 +0100
@@ -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;
@@ -699,6 +702,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 *)
@@ -706,3 +710,9 @@
 
 let emule_proto () =
   { dummy_emule_proto with emule_version = 0 }
+
+let old_max_emule_file_size = 4290048000L
+(* #define OLD_MAX_EMULE_FILE_SIZE 4290048000ui64  // (4294967295/PARTSIZE)*PARTSIZE = ~4GB *)
+
+let max_emule_file_size = 0x4000000000L
+(* #define MAX_EMULE_FILE_SIZE             0x4000000000ui64 // = 2^38 = 256GB *)
