/[mldonkey]/mldonkey/src/networks/donkey/donkeyProtoClient.ml
ViewVC logotype

Diff of /mldonkey/src/networks/donkey/donkeyProtoClient.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by spiralvoice, Sun Sep 18 19:00:52 2005 UTC revision 1.26 by spiralvoice, Thu Oct 6 10:21:09 2005 UTC
# Line 24  open Md4 Line 24  open Md4
24  open CommonTypes  open CommonTypes
25  open LittleEndian  open LittleEndian
26  open CommonGlobals  open CommonGlobals
27      
28  open DonkeyTypes  open DonkeyTypes
29  open DonkeyMftp  open DonkeyMftp
30      
31  let emule_version b1 b2 b3 b4 b5 =  let emule_version b1 b2 b3 b4 b5 =
32    let s = Printf.sprintf "%s"    let s = Printf.sprintf "%s"
33      (string_of_int(int_of_string("0b" ^      (string_of_int(int_of_string("0b" ^
# Line 50  let mldonkey_emule_proto = { Line 50  let mldonkey_emule_proto = {
50      emule_secident = 3; (* Emule uses v1 if advertising both, v2 if only advertising 2 *)      emule_secident = 3; (* Emule uses v1 if advertising both, v2 if only advertising 2 *)
51      emule_noviewshared = 0;      emule_noviewshared = 0;
52      emule_supportpreview = 0;      emule_supportpreview = 0;
53      emule_compression = if Autoconf.has_zlib then 1 else 0; (* 1 *)      emule_compression = 1; (* 1 *)
54      emule_sourceexchange = 2; (* 2 : +client_md4 3 : +IdHybrid (emule Kademlia?)*)      emule_sourceexchange = 2; (* 2 : +client_md4 3 : +IdHybrid (emule Kademlia?)*)
55      emule_multipacket = 0; (* 1 *)      emule_multipacket = 0; (* 1 *)
56      emule_extendedrequest = 1; (* 1: +file_status 2: +ncomplete_sources*)      emule_extendedrequest = 1; (* 1: +file_status 2: +ncomplete_sources*)
57      emule_features = 0; (* 3 *)      emule_features = 0; (* 3 *)
58      emule_udpver = 0; (* 4 *)      emule_udpver = 0; (* 4 *)
59    }    }
60      
61  let emule_miscoptions1 m =  let emule_miscoptions1 m =
62    let o =    let o =
63      (m.emule_udpver lsl 24) lor      (m.emule_udpver lsl 24) lor
64      (m.emule_compression lsl 20) lor      (m.emule_compression lsl 20) lor
65      (m.emule_secident lsl 16) lor      (m.emule_secident lsl 16) lor
# Line 71  let emule_miscoptions1 m = Line 71  let emule_miscoptions1 m =
71      (m.emule_supportpreview lsl 0)      (m.emule_supportpreview lsl 0)
72    in    in
73    Int64.of_int o    Int64.of_int o
74      
75  let update_emule_proto_from_miscoptions1 m o =  let update_emule_proto_from_miscoptions1 m o =
76    let o = Int64.to_int o in    let o = Int64.to_int o in
77    m.emule_udpver <- (o lsr 24) land 0xf;    m.emule_udpver <- (o lsr 24) land 0xf;
# Line 83  let update_emule_proto_from_miscoptions1 Line 83  let update_emule_proto_from_miscoptions1
83    m.emule_noviewshared <- (o lsr 2) land 0x1;    m.emule_noviewshared <- (o lsr 2) land 0x1;
84    m.emule_udpver <- (o lsr 1) land 0x1;    m.emule_udpver <- (o lsr 1) land 0x1;
85    m.emule_udpver <- (o lsr 0) land 0x1    m.emule_udpver <- (o lsr 0) land 0x1
86      
87  let extendedrequest e =  let extendedrequest e =
88    min e.emule_extendedrequest mldonkey_emule_proto.emule_extendedrequest    min e.emule_extendedrequest mldonkey_emule_proto.emule_extendedrequest
89      
90  let sourceexchange e =  let sourceexchange e =
91    min e.emule_sourceexchange mldonkey_emule_proto.emule_sourceexchange    min e.emule_sourceexchange mldonkey_emule_proto.emule_sourceexchange
92    
93  (*  (*
# Line 103  dec: [ Line 103  dec: [
103  (0)(0)(0)(0)  (0)(0)(0)(0)
104  (0)(0)(0)(0)(0)(0)  (0)(0)(0)(0)(0)(0)
105  ]  ]
   
   
   
106    *)    *)
107      
108  module Connect  = struct  module Connect  = struct
109      type t = {      type t = {
110          md4 : Md4.t;          md4 : Md4.t;
# Line 118  module Connect  = struct Line 115  module Connect  = struct
115          server_info : (Ip.t * int) option;          server_info : (Ip.t * int) option;
116          left_bytes: string;          left_bytes: string;
117        }        }
118        
119      let names_of_tag =      let names_of_tag =
120        [        [
121          "\001", Field_UNKNOWN "name";          "\001", Field_UNKNOWN "name";
# Line 132  module Connect  = struct Line 129  module Connect  = struct
129          "\250", Field_UNKNOWN "emule_miscoptions1";          "\250", Field_UNKNOWN "emule_miscoptions1";
130          "\251", Field_UNKNOWN "emule_version";          "\251", Field_UNKNOWN "emule_version";
131        ]        ]
132          
133      let parse len s =      let parse len s =
134        let version = get_uint8 s 1 in        let version = get_uint8 s 1 in
135        let md4 = get_md4 s 2 in        let md4 = get_md4 s 2 in
# Line 141  module Connect  = struct Line 138  module Connect  = struct
138  (*      lprintf "port: %d" port; lprint_newline (); *)  (*      lprintf "port: %d" port; lprint_newline (); *)
139        let tags, pos = get_tags s 24 names_of_tag in        let tags, pos = get_tags s 24 names_of_tag in
140        let len = String.length s in        let len = String.length s in
141        let server_info =        let server_info =
142          Some (get_ip s pos, get_port s (pos+4))          Some (get_ip s pos, get_port s (pos+4))
143        in        in
144        let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in        let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in
145        {        {
# Line 154  module Connect  = struct Line 151  module Connect  = struct
151          server_info = server_info;          server_info = server_info;
152          left_bytes = left_bytes;          left_bytes = left_bytes;
153        }        }
154        
155      let print t =      let print t =
156        lprintf "Connect (version %d) from [%s:%d] MD4: %s"        lprintf "Connect (version %d) from [%s:%d] MD4: %s"
157          t.version          t.version
158          (Ip.to_string t.ip)          (Ip.to_string t.ip)
# Line 180  module Connect  = struct Line 177  module Connect  = struct
177        buf_tags buf t.tags names_of_tag;        buf_tags buf t.tags names_of_tag;
178        begin        begin
179          match t.server_info with          match t.server_info with
180            None ->            None ->
181              buf_ip buf Ip.null;              buf_ip buf Ip.null;
182              buf_port buf 0              buf_port buf 0
183          | Some (ip, port) ->          | Some (ip, port) ->
# Line 194  module Connect  = struct Line 191  module Connect  = struct
191  module ConnectReply  = struct  module ConnectReply  = struct
192      open Connect      open Connect
193      type t = Connect.t      type t = Connect.t
194          
195      let parse len s =      let parse len s =
196        let version = get_uint8 s 1 in        let version = get_uint8 s 1 in
197        let md4 = get_md4 s 2 in        let md4 = get_md4 s 2 in
# Line 202  module ConnectReply  = struct Line 199  module ConnectReply  = struct
199        let port = get_port s 22 in        let port = get_port s 22 in
200        let tags, pos = get_tags s 24 names_of_tag in        let tags, pos = get_tags s 24 names_of_tag in
201        let len = String.length s in        let len = String.length s in
202        let server_info =        let server_info =
203          Some (get_ip s pos, get_port s (pos+4))          Some (get_ip s pos, get_port s (pos+4))
204        in        in
205        let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in        let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in
206        {        {
# Line 215  module ConnectReply  = struct Line 212  module ConnectReply  = struct
212          server_info = server_info;          server_info = server_info;
213          left_bytes = left_bytes;          left_bytes = left_bytes;
214        }        }
215        
216      let parse len s =      let parse len s =
217        let md4 = get_md4 s 1 in        let md4 = get_md4 s 1 in
218        let ip = get_ip s 17 in        let ip = get_ip s 17 in
# Line 232  module ConnectReply  = struct Line 229  module ConnectReply  = struct
229          left_bytes = left_bytes;          left_bytes = left_bytes;
230          version = -1;          version = -1;
231        }        }
232        
233      let print t =      let print t =
234        lprintf "Connect reply from [%s:%d] MD4: %s"        lprintf "Connect reply from [%s:%d] MD4: %s"
235          (Ip.to_string t.ip)          (Ip.to_string t.ip)
236          t.port          t.port
# Line 248  module ConnectReply  = struct Line 245  module ConnectReply  = struct
245          lprintf "  left bytes = ";          lprintf "  left bytes = ";
246          String.iter (fun c -> lprintf "(%d)" (int_of_char c))          String.iter (fun c -> lprintf "(%d)" (int_of_char c))
247          t.left_bytes  end          t.left_bytes  end
248          
249      let write buf t =      let write buf t =
250        buf_md4 buf t.md4;        buf_md4 buf t.md4;
251        buf_ip buf t.ip;        buf_ip buf t.ip;
# Line 266  module ConnectReply  = struct Line 263  module ConnectReply  = struct
263    
264  module Say = struct  module Say = struct
265      type t = string      type t = string
266          
267      let parse len s =      let parse len s =
268        let (s, p) = get_string s 1 in        let (s, p) = get_string s 1 in
269        s        s
270          
271      let print t =      let print t =
272        lprintf "SAY %s" t        lprintf "SAY %s" t
273          
274      let write buf t =      let write buf t =
275        buf_string buf t        buf_string buf t
276    end    end
277      
278  module OneMd4 = functor(M: sig val m : string end) -> (struct  module OneMd4 = functor(M: sig val m : string end) -> (struct
279      type t = Md4.t      type t = Md4.t
280          
281      let parse len s =      let parse len s =
282        get_md4 s 1        get_md4 s 1
283          
284      let print t =      let print t =
285            lprintf "%s OF %s" M.m (Md4.to_string t)            lprintf "%s OF %s" M.m (Md4.to_string t)
286              
287      let write buf t =      let write buf t =
288        buf_md4 buf t        buf_md4 buf t
289        end)        end)
290      
291  module JoinQueue = struct  module JoinQueue = struct
292      type t = Md4.t option      type t = Md4.t option
293          
294      let parse len s =      let parse len s =
295        if len >= 17 then        if len >= 17 then
296          Some (get_md4 s 1)          Some (get_md4 s 1)
297        else None        else None
298          
299      let print t =      let print t =
300        lprintf "JOIN QUEUE";        lprintf "JOIN QUEUE";
301        (match t with None -> () | Some md4 ->        (match t with None -> () | Some md4 ->
302              lprintf " OF %s" (Md4.to_string md4));              lprintf " OF %s" (Md4.to_string md4));
303        lprint_newline ()        lprint_newline ()
304              
305      let write emule buf t =      let write emule buf t =
306        if extendedrequest emule > 0 then        if extendedrequest emule > 0 then
307          match t with          match t with
308            None -> ()            None -> ()
# Line 318  module JoinQueue = struct Line 315  module JoinQueue = struct
315            val parse : int -> string  -> t            val parse : int -> string  -> t
316            val print : t -> unit            val print : t -> unit
317            val write : Buffer.t -> t  -> unit            val write : Buffer.t -> t  -> unit
318            val t :t            val t :t
319            end            end
320        )        )
321  *)  *)
322        
323  (* In Emule, this message contains much more information, and will probably  (* In Emule, this message contains much more information, and will probably
324  remove the need for QueryChunks. *)  remove the need for QueryChunks. *)
325    
326  let get_bitmap s pos =  let get_bitmap s pos =
327    let nchunks = get_int16 s pos in    let nchunks = get_int16 s pos in
328    let chunks, pos =    let chunks, pos =
329      if nchunks = 0 then [||], pos+2 else      if nchunks = 0 then [||], pos+2 else
330      let pos = pos + 2 in      let pos = pos + 2 in
331      let chunks = Array.create nchunks false  in      let chunks = Array.create nchunks false  in
# Line 347  let get_bitmap s pos = Line 344  let get_bitmap s pos =
344    
345  let print_bitmap chunks =  let print_bitmap chunks =
346    lprint_string "\n   ";    lprint_string "\n   ";
347    Array.iter (fun b ->    Array.iter (fun b ->
348        if b then lprintf "1" else lprintf "0") chunks        if b then lprintf "1" else lprintf "0") chunks
349    
350  let write_bitmap buf chunks =  let write_bitmap buf chunks =
351    let nchunks = Array.length chunks in    let nchunks = Array.length chunks in
352    buf_int16 buf nchunks;    buf_int16 buf nchunks;
353    if nchunks > 0 then    if nchunks > 0 then
354    for i = 0 to (nchunks-1) / 8 do    for i = 0 to (nchunks-1) / 8 do
355      let m = ref 0 in      let m = ref 0 in
356      for j = 0 to 7 do      for j = 0 to 7 do
# Line 364  let write_bitmap buf chunks = Line 361  let write_bitmap buf chunks =
361      done;      done;
362      buf_int8 buf !m      buf_int8 buf !m
363    done    done
364      
365  module QueryFile  = struct  module QueryFile  = struct
366      type t = {      type t = {
367          md4 : Md4.t;          md4 : Md4.t;
368          emule_extension : (bool array * int) option;          emule_extension : (bool array * int) option;
369        }        }
370        
371      let parse emule len s =      let parse emule len s =
372  (*      Printf.printf "Query File: emule version %d len %d"  (*      Printf.printf "Query File: emule version %d len %d"
373        (extendedrequest emule) len;        (extendedrequest emule) len;
374        print_newline (); *)        print_newline (); *)
375        let md4 = get_md4 s 1 in        let md4 = get_md4 s 1 in
376        let emule_extension =        let emule_extension =
377          try          try
378            if len < 18 || extendedrequest emule = 0 then None else            if len < 18 || extendedrequest emule = 0 then None else
379            let chunks, pos = get_bitmap s 17 in            let chunks, pos = get_bitmap s 17 in
380            let ncompletesources =            let ncompletesources =
381              if extendedrequest emule > 1 && len > pos+1 then get_int16 s pos              if extendedrequest emule > 1 && len > pos+1 then get_int16 s pos
382              else -1 in              else -1 in
383            Some (chunks, ncompletesources)            Some (chunks, ncompletesources)
384          with _ -> None          with _ -> None
385        in        in
386        { md4 = md4;        { md4 = md4;
387          emule_extension = emule_extension }          emule_extension = emule_extension }
388        
389            let print t =
     let print t =  
390        lprintf "QUERY FILE OF %s" (Md4.to_string t.md4);        lprintf "QUERY FILE OF %s" (Md4.to_string t.md4);
391        match t.emule_extension with        match t.emule_extension with
392          None -> ()          None -> ()
393        | Some (bitmap, ncompletesources) ->        | Some (bitmap, ncompletesources) ->
394            print_bitmap bitmap;            print_bitmap bitmap;
395            lprint_newline ();            lprint_newline ();
396            if ncompletesources >= 0 then            if ncompletesources >= 0 then
397              lprintf_nl "Complete sources: %d" ncompletesources              lprintf_nl "Complete sources: %d" ncompletesources
398        
399      let write emule buf t =      let write emule buf t =
400        buf_md4 buf t.md4;        buf_md4 buf t.md4;
401        match t.emule_extension with        match t.emule_extension with
402          None -> ()          None -> ()
# Line 410  module QueryFile  = struct Line 406  module QueryFile  = struct
406                if extendedrequest emule > 1 && ncompletesources >= 0 then                if extendedrequest emule > 1 && ncompletesources >= 0 then
407                  buf_int16 buf ncompletesources                  buf_int16 buf ncompletesources
408              end              end
               
409    end    end
410      
     
411  module QueryChunks  = OneMd4(struct let m = "QUERY CHUNKS" end)  module QueryChunks  = OneMd4(struct let m = "QUERY CHUNKS" end)
412    (* Request 79 *)    (* Request 79 *)
413        
414  module QueryChunkMd4  = OneMd4(struct let m = "QUERY CHUNKS MD4" end)  module QueryChunkMd4  = OneMd4(struct let m = "QUERY CHUNKS MD4" end)
415  module EndOfDownload  = OneMd4(struct let m = "END OF DOWNLOAD MD4" end)  module EndOfDownload  = OneMd4(struct let m = "END OF DOWNLOAD MD4" end)
416  module NoSuchFile  = OneMd4(struct let m = "NO SUCH FILE" end)  module NoSuchFile  = OneMd4(struct let m = "NO SUCH FILE" end)
417    
418  module QueryChunksReply = struct (* Request 80 *)  module QueryChunksReply = struct (* Request 80 *)
419        
420      type t = {      type t = {
421          md4 : Md4.t;          md4 : Md4.t;
422          chunks: bool array;          chunks: bool array;
423        }        }
424        
425      let parse len s =      let parse len s =
426        let md4 = get_md4 s 1 in        let md4 = get_md4 s 1 in
427        let chunks, pos = get_bitmap s 17 in        let chunks, pos = get_bitmap s 17 in
428        {        {
429          md4 = md4;          md4 = md4;
430          chunks = chunks;          chunks = chunks;
431        }        }
432          
433      let print t =      let print t =
434        lprintf_nl "CHUNKS for %s" (Md4.to_string t.md4);        lprintf_nl "CHUNKS for %s" (Md4.to_string t.md4);
435        lprint_string "   ";        lprint_string "   ";
436        Array.iter (fun b ->        Array.iter (fun b ->
437            if b then lprintf "1" else lprintf "0") t.chunks;            if b then lprintf "1" else lprintf "0") t.chunks;
438        lprint_newline ()        lprint_newline ()
439        
440      let write buf t =      let write buf t =
441        buf_md4 buf t.md4;        buf_md4 buf t.md4;
442        write_bitmap buf t.chunks;        write_bitmap buf t.chunks;
443        if t.chunks = [||] then buf_int8 buf 0        if t.chunks = [||] then buf_int8 buf 0
                   
444    end    end
445  (*  (*
446  dec: [(96)(215)(1)(0)(0)(0)(0)(0)(0)(0)(0)(0)(0)]  dec: [(96)(215)(1)(0)(0)(0)(0)(0)(0)(0)(0)(0)(0)]
447    
448  OP_QUEUERANKING: int16  OP_QUEUERANKING: int16
     
     
449  *)  *)
450    
   
451  module QueryChunkMd4Reply = struct (* Request 80 *)  module QueryChunkMd4Reply = struct (* Request 80 *)
452        
453      type t = {      type t = {
454          md4 : Md4.t;          md4 : Md4.t;
455          chunks: Md4.t array;          chunks: Md4.t array;
456        }        }
457          
458      let parse len s =      let parse len s =
459        let md4 = get_md4 s 1 in        let md4 = get_md4 s 1 in
460        let nchunks = get_int16 s 17 in        let nchunks = get_int16 s 17 in
461  (*      lprintf "nchunks : %d" nchunks; lprint_newline (); *)  (*      lprintf "nchunks : %d" nchunks; lprint_newline (); *)
462        let chunks = Array.create nchunks md4  in        let chunks = Array.create nchunks md4  in
463        for i = 0 to nchunks - 1 do        for i = 0 to nchunks - 1 do
464          chunks.(i) <- get_md4 s (19 + i * 16)                  chunks.(i) <- get_md4 s (19 + i * 16)
465        done;        done;
466        {        {
467          md4 = md4;          md4 = md4;
# Line 481  module QueryChunkMd4Reply = struct (* Re Line 471  module QueryChunkMd4Reply = struct (* Re
471      let print t =      let print t =
472        lprintf_nl "CHUNKS for %s" (Md4.to_string t.md4);        lprintf_nl "CHUNKS for %s" (Md4.to_string t.md4);
473        lprint_string "   ";        lprint_string "   ";
474        Array.iter (fun b ->        Array.iter (fun b ->
475            lprintf "  %s" (Md4.to_string b))            lprintf "  %s" (Md4.to_string b))
476        t.chunks;        t.chunks;
477        lprint_newline ()        lprint_newline ()
478          
479      let write buf t =      let write buf t =
480        buf_md4 buf t.md4;        buf_md4 buf t.md4;
481        let nchunks = Array.length t.chunks in        let nchunks = Array.length t.chunks in
# Line 493  module QueryChunkMd4Reply = struct (* Re Line 483  module QueryChunkMd4Reply = struct (* Re
483        for i = 0 to nchunks - 1 do        for i = 0 to nchunks - 1 do
484          buf_md4 buf t.chunks.(i)          buf_md4 buf t.chunks.(i)
485        done        done
         
486    end    end
487      
488  module QueryFileReply  = struct  module QueryFileReply  = struct
489      type t = {      type t = {
490          md4 : Md4.t;          md4 : Md4.t;
491          name : string;          name : string;
492        }        }
493          
494      let parse len s =      let parse len s =
495        let name, _ = get_string s 17 in        let name, _ = get_string s 17 in
496        { md4 = get_md4 s 1;        { md4 = get_md4 s 1;
497          name =  name;          name =  name;
498        }        }
499          
500      let print t =      let print t =
501        lprintf_nl "QUERY FILE REPLY OF %s" (Md4.to_string t.md4);        lprintf_nl "QUERY FILE REPLY OF %s" (Md4.to_string t.md4);
502        lprintf_nl "  name = \"%s\"" t.name        lprintf_nl "  name = \"%s\"" t.name
503          
504      let write buf t =      let write buf t =
505        buf_md4 buf t.md4;        buf_md4 buf t.md4;
506        buf_string buf t.name        buf_string buf t.name
507    end    end
508        
509  module Bloc  = struct  module Bloc  = struct
510      type t = {      type t = {
511          md4 : Md4.t;          md4 : Md4.t;
512          start_pos : int64;          start_pos : int64;
# Line 526  module Bloc  = struct Line 515  module Bloc  = struct
515          bloc_begin : int;          bloc_begin : int;
516          bloc_len : int;          bloc_len : int;
517        }        }
518          
519      let parse len s =      let parse len s =
520        {        {
521          md4 = get_md4 s 1;          md4 = get_md4 s 1;
522          start_pos = get_uint64_32 s 17;          start_pos = get_uint64_32 s 17;
# Line 536  module Bloc  = struct Line 525  module Bloc  = struct
525          bloc_begin = 25;          bloc_begin = 25;
526          bloc_len = len - 25;          bloc_len = len - 25;
527        }        }
528          
529      let print t =      let print t =
530        lprintf "BLOC OF %s len %Ld [%Ld - %Ld] " (Md4.to_string t.md4)        lprintf "BLOC OF %s len %Ld [%Ld - %Ld] " (Md4.to_string t.md4)
531        (t.end_pos -- t.start_pos)        (t.end_pos -- t.start_pos)
532        t.start_pos        t.start_pos
533          t.end_pos          t.end_pos
534          
535      let write buf t =      let write buf t =
536        buf_md4 buf t.md4;        buf_md4 buf t.md4;
537        buf_int64_32 buf t.start_pos;        buf_int64_32 buf t.start_pos;
538        buf_int64_32 buf t.end_pos;        buf_int64_32 buf t.end_pos;
539        Buffer.add_substring buf t.bloc_str t.bloc_begin t.bloc_len        Buffer.add_substring buf t.bloc_str t.bloc_begin t.bloc_len
540    end    end
541        
542  module QueryBloc  = struct  module QueryBloc  = struct
543      type t = {      type t = {
544          md4 : Md4.t;          md4 : Md4.t;
545          start_pos1 : int64; (* 180 ko *)          start_pos1 : int64; (* 180 ko *)
# Line 560  module QueryBloc  = struct Line 549  module QueryBloc  = struct
549          start_pos3 : int64;          start_pos3 : int64;
550          end_pos3: int64;          end_pos3: int64;
551        }        }
552          
553      let parse len s =      let parse len s =
554        {        {
555          md4 = get_md4 s 1;          md4 = get_md4 s 1;
556          start_pos1 = get_uint64_32 s 17;          start_pos1 = get_uint64_32 s 17;
# Line 571  module QueryBloc  = struct Line 560  module QueryBloc  = struct
560          start_pos3 = get_uint64_32 s 25;          start_pos3 = get_uint64_32 s 25;
561          end_pos3 = get_uint64_32 s 37;          end_pos3 = get_uint64_32 s 37;
562        }        }
563          
564      let print t =      let print t =
565        lprintf "QUERY BLOCS OF %s [%s - %s] [%s - %s] [%s - %s]"        lprintf "QUERY BLOCS OF %s [%s - %s] [%s - %s] [%s - %s]"
566        (Md4.to_string t.md4)        (Md4.to_string t.md4)
567        (Int64.to_string t.start_pos1) (Int64.to_string t.end_pos1)        (Int64.to_string t.start_pos1) (Int64.to_string t.end_pos1)
568        (Int64.to_string t.start_pos2) (Int64.to_string t.end_pos2)        (Int64.to_string t.start_pos2) (Int64.to_string t.end_pos2)
569        (Int64.to_string t.start_pos3) (Int64.to_string t.end_pos3)        (Int64.to_string t.start_pos3) (Int64.to_string t.end_pos3)
570          
571      let write buf t =      let write buf t =
572        buf_md4 buf t.md4;        buf_md4 buf t.md4;
573        buf_int64_32 buf t.start_pos1;        buf_int64_32 buf t.start_pos1;
574        buf_int64_32 buf t.start_pos2;        buf_int64_32 buf t.start_pos2;
# Line 587  module QueryBloc  = struct Line 576  module QueryBloc  = struct
576        buf_int64_32 buf t.end_pos1;        buf_int64_32 buf t.end_pos1;
577        buf_int64_32 buf t.end_pos2;        buf_int64_32 buf t.end_pos2;
578        buf_int64_32 buf t.end_pos3        buf_int64_32 buf t.end_pos3
         
579    end    end
580    
     
581  let unit = ()  let unit = ()
582  module NoArg = functor(M: sig val m : string end) -> (struct  module NoArg = functor(M: sig val m : string end) -> (struct
583          type t = unit          type t = unit
584            
585          let parse len s = ()          let parse len s = ()
586            
587          let print t =          let print t =
588            lprintf_nl "%s:" M.m            lprintf_nl "%s:" M.m
589            
590          let write (buf: Buffer.t) (t: t) = unit          let write (buf: Buffer.t) (t: t) = unit
591              
592          let t = (() : t)          let t = (() : t)
593        end : sig        end : sig
594          type t          type t
595            val parse : int -> string  -> t            val parse : int -> string  -> t
596            val print : t -> unit            val print : t -> unit
597            val write : Buffer.t -> t  -> unit            val write : Buffer.t -> t  -> unit
598            val t :t            val t :t
599            end            end
600        )        )
601        
602  module AvailableSlot = NoArg(struct let m = "AvailableSlot" end)  module AvailableSlot = NoArg(struct let m = "AvailableSlot" end)
603  module ReleaseSlot = NoArg(struct let m = "ReleaseSlot" end)  module ReleaseSlot = NoArg(struct let m = "ReleaseSlot" end)
604  module CloseSlot = NoArg(struct let m = "CloseSlot" end)  module CloseSlot = NoArg(struct let m = "CloseSlot" end)
605  module ViewFiles = NoArg(struct let m = "VIEW FILES" end)  module ViewFiles = NoArg(struct let m = "VIEW FILES" end)
606    
607      module ViewFilesReply = struct
608  module ViewFilesReply = struct  
       
609      type file = {      type file = {
610          md4: Md4.t;          md4: Md4.t;
611          ip: Ip.t;          ip: Ip.t;
612          port: int;          port: int;
613          tags:  tag list;          tags:  tag list;
614        }        }
615        
616      type t = tagged_file list      type t = tagged_file list
617        
618      let names_of_tag = file_common_tags      let names_of_tag = file_common_tags
619        
620      let rec get_files  s pos n =      let rec get_files  s pos n =
621        if n = 0 then [], pos else        if n = 0 then [], pos else
622        let md4 = get_md4 s pos in        let md4 = get_md4 s pos in
# Line 645  module ViewFilesReply = struct Line 631  module ViewFilesReply = struct
631          } in          } in
632        let files, pos =  get_files s pos (n-1) in        let files, pos =  get_files s pos (n-1) in
633        file :: files, pos        file :: files, pos
634        
       
635      let parse len s =      let parse len s =
636        let n = get_int s 1 in        let n = get_int s 1 in
637        let files, pos = get_files s 5 n in        let files, pos = get_files s 5 n in
638        files        files
639        
640      let print t =      let print t =
641        lprintf_nl "VIEW FILES REPLY:";        lprintf_nl "VIEW FILES REPLY:";
642        List.iter (fun t ->        List.iter (fun t ->
643            lprintf_nl "FILE:";            lprintf_nl "FILE:";
# Line 662  module ViewFilesReply = struct Line 647  module ViewFilesReply = struct
647            lprintf "  tags: ";            lprintf "  tags: ";
648            print_tags t.f_tags;            print_tags t.f_tags;
649            lprint_newline ();) t            lprint_newline ();) t
650        
651      let rec write_files buf files =      let rec write_files buf files =
652        match files with        match files with
653          [] -> ()          [] -> ()
# Line 672  module ViewFilesReply = struct Line 657  module ViewFilesReply = struct
657            buf_port buf file.f_port;            buf_port buf file.f_port;
658            buf_tags buf file.f_tags names_of_tag;            buf_tags buf file.f_tags names_of_tag;
659            write_files buf files            write_files buf files
660        
661      let write buf t =      let write buf t =
662        buf_int buf (List.length t);        buf_int buf (List.length t);
663        write_files buf t        write_files buf t
664            
665      let rec write_files_max buf files nfiles max_len =      let rec write_files_max buf files nfiles max_len =
666        let prev_len = Buffer.length buf in        let prev_len = Buffer.length buf in
667        match files with        match files with
# Line 690  module ViewFilesReply = struct Line 675  module ViewFilesReply = struct
675              write_files_max buf files (nfiles+1) max_len              write_files_max buf files (nfiles+1) max_len
676            else            else
677              nfiles, prev_len              nfiles, prev_len
   
678    end    end
679      
680  module OtherLocations = struct  module OtherLocations = struct
681    
682      type t = Ip.t list      type t = Ip.t list
683          
684      let parse len s =      let parse len s =
685        let list = ref [] in        let list = ref [] in
686        for i = 0 to len / 4 - 1 do        for i = 0 to len / 4 - 1 do
687          list := (get_ip s (i*4+1)) :: !list;          list := (get_ip s (i*4+1)) :: !list;
688        done;        done;
689        !list        !list
690        
691      let print t =      let print t =
692        lprintf_nl "OTHER LOCATIONS:\n";        lprintf_nl "OTHER LOCATIONS:\n";
693        List.iter (fun ip ->        List.iter (fun ip ->
694            lprintf_nl "  ip: %s" (Ip.to_string ip);) t            lprintf_nl "  ip: %s" (Ip.to_string ip);) t
695            
696      let write buf t =      let write buf t =
697        List.iter (buf_ip buf) t        List.iter (buf_ip buf) t
698    end    end
699      
700  module NewUserID = struct  module NewUserID = struct
701    
702      type t = Ip.t * Ip.t      type t = Ip.t * Ip.t
703          
704      let parse len s =      let parse len s =
705        get_ip s 1, get_ip s 5        get_ip s 1, get_ip s 5
706        
707      let print (ip1,ip2) =      let print (ip1,ip2) =
708        lprintf_nl "NEW USER ID: %s -> %s" (Ip.to_string ip1)        lprintf_nl "NEW USER ID: %s -> %s" (Ip.to_string ip1)
709        (Ip.to_string ip2)        (Ip.to_string ip2)
710            
711      let write buf (ip1,ip2) =      let write buf (ip1,ip2) =
712        buf_ip buf ip1;        buf_ip buf ip1;
713        buf_ip buf ip2        buf_ip buf ip2
714    end    end
715    
716    
717  module Sources = struct  module Sources = struct
718    
719      type t = {      type t = {
720          md4: Md4.t;          md4: Md4.t;
721          sources : (Ip.t * int * Ip.t) list;          sources : (Ip.t * int * Ip.t) list;
722        }        }
723          
724      let parse len s =      let parse len s =
725        let len = get_int16 s 1 in        let len = get_int16 s 1 in
726        let md4 = get_md4 s 3 in        let md4 = get_md4 s 3 in
# Line 749  module Sources = struct Line 733  module Sources = struct
733        { md4 = md4;        { md4 = md4;
734          sources = !list;          sources = !list;
735        }        }
736        
737      let print t =      let print t =
738        lprintf_nl "SOURCES for %s:" (Md4.to_string t.md4);        lprintf_nl "SOURCES for %s:" (Md4.to_string t.md4);
739        List.iter (fun (ip1, port, ip2) ->        List.iter (fun (ip1, port, ip2) ->
740            lprintf_nl "  %s:%d:%s" (Ip.to_string ip1) port(Ip.to_string ip2)) t.sources            lprintf_nl "  %s:%d:%s" (Ip.to_string ip1) port(Ip.to_string ip2)) t.sources
741            
742      let write buf t =      let write buf t =
743        buf_int16 buf (List.length t.sources);        buf_int16 buf (List.length t.sources);
744        buf_md4 buf t.md4;        buf_md4 buf t.md4;
745        List.iter (fun (ip1, port, ip2) ->        List.iter (fun (ip1, port, ip2) ->
746            buf_ip buf ip1;            buf_ip buf ip1;
747            buf_port buf port;            buf_port buf port;
748            buf_ip buf ip2) t.sources            buf_ip buf ip2) t.sources
749    end    end
     
750    
751          module EmuleClientInfo = struct
 module EmuleClientInfo = struct  
752    
753      type t = {      type t = {
754          version : int; (* CURRENT_VERSION_SHORT = !!emule_protocol_version *)          version : int; (* CURRENT_VERSION_SHORT = !!emule_protocol_version *)
755          protversion : int; (* EMULE_PROTOCOL_VERSION = 0x1 *)          protversion : int; (* EMULE_PROTOCOL_VERSION = 0x1 *)
756          mutable tags : tag list;          mutable tags : tag list;
757        }        }
758          
759      let names_of_tag =      let names_of_tag =
760        [        [
761          "\032", "compression";          "\032", "compression";
# Line 815  module EmuleClientInfo = struct Line 797  module EmuleClientInfo = struct
797          "\161", "dev_wombat";          "\161", "dev_wombat";
798        ]        ]
799    
800      let names_of_tag =      let names_of_tag =
801        List.map (fun (v, name) -> (v, Field_UNKNOWN name)) names_of_tag        List.map (fun (v, name) -> (v, Field_UNKNOWN name)) names_of_tag
802          
803      let parse len s =      let parse len s =
804        let version = get_uint8 s 1 in        let version = get_uint8 s 1 in
805        let protversion = get_uint8 s 2 in        let protversion = get_uint8 s 2 in
806        let tags,_ = get_tags s 3 names_of_tag in        let tags,_ = get_tags s 3 names_of_tag in
807        {        {
808          version = version;          version = version;
809          protversion = protversion;          protversion = protversion;
810          tags = tags;          tags = tags;
811        }        }
812          
813      let print m t =      let print m t =
814        lprintf_nl "%s:" m;        lprintf_nl "%s:" m;
815        lprintf_nl "  version: %d" t.version;        lprintf_nl "  version: %d" t.version;
816        lprintf_nl "  protversion: %d" t.version;        lprintf_nl "  protversion: %d" t.version;
817        lprintf "  tags: ";        lprintf "  tags: ";
818        print_tags t.tags;        print_tags t.tags;
819        lprint_newline ()        lprint_newline ()
820            
821      let write buf t =      let write buf t =
822        buf_int8 buf t.version;        buf_int8 buf t.version;
823        buf_int8 buf t.protversion;        buf_int8 buf t.protversion;
824        buf_tags buf t.tags names_of_tag;        buf_tags buf t.tags names_of_tag;
825          
826    end    end
827          
828  module EmuleQueueRanking = struct  module EmuleQueueRanking = struct
829    
830      type t = int      type t = int
831          
832      let parse len s = get_int16 s 1            let parse len s = get_int16 s 1
833      let print t =      let print t =
834        lprintf_nl "QUEUE RANKING: %d" t        lprintf_nl "QUEUE RANKING: %d" t
835    
836      let string_null10 = String.make 10 (char_of_int 0)      let string_null10 = String.make 10 (char_of_int 0)
837          
838      let write buf t =      let write buf t =
839        buf_int16 buf t;        buf_int16 buf t;
840        Buffer.add_string buf string_null10        Buffer.add_string buf string_null10
841                
842    end    end
843    
844  module QueueRank = struct  module QueueRank = struct
845    
846      type t = int      type t = int
847          
848      let parse len s = get_int s 1            let parse len s = get_int s 1
849      let print t =      let print t =
850        lprintf_nl "QUEUE RANK: %d" t        lprintf_nl "QUEUE RANK: %d" t
851    
852      let write buf t =      let write buf t =
853        buf_int buf t        buf_int buf t
854                
855    end    end
856          
857  module EmuleRequestSources = struct  module EmuleRequestSources = struct
858    
859      type t =  Md4.t      type t =  Md4.t
860          
861      let parse len s =      let parse len s =
862        get_md4 s 1        get_md4 s 1
863          
864      let print t =      let print t =
865        lprintf_nl "EMULE REQUEST SOURCES: %s" (Md4.to_string t)        lprintf_nl "EMULE REQUEST SOURCES: %s" (Md4.to_string t)
866    
867      let write buf t =      let write buf t =
868        buf_md4 buf t        buf_md4 buf t
869                
870    end    end
871          
872    
873  let buf_estring buf s =  let buf_estring buf s =
874    let len = String.length s in    let len = String.length s in
# Line 896  let buf_estring buf s = Line 878  let buf_estring buf s =
878  module EmuleSignatureReq = struct  module EmuleSignatureReq = struct
879    
880      type t = {      type t = {
881          signature : string;          signature : string;
882          ip_type : int;          ip_type : int;
883        }        }
884        
885      let print t =      let print t =
886        lprintf_nl "EmuleSignatureReq [type %d] [sig(%d): %s]" t.ip_type (String.length t.signature) (String.escaped t.signature)        lprintf_nl "EmuleSignatureReq [type %d] [sig(%d): %s]" t.ip_type (String.length t.signature) (String.escaped t.signature)
887    
# Line 915  module EmuleSignatureReq = struct Line 897  module EmuleSignatureReq = struct
897    
898      let write buf t =      let write buf t =
899        buf_estring buf t.signature;        buf_estring buf t.signature;
900        if (t.ip_type <> 0) then        if (t.ip_type <> 0) then
901             buf_int8 buf t.ip_type;             buf_int8 buf t.ip_type;
902    
903    end    end
# Line 930  module EmulePublicKeyReq = struct Line 912  module EmulePublicKeyReq = struct
912    
913      let parse len s =      let parse len s =
914        let len = get_uint8 s 1 in        let len = get_uint8 s 1 in
915        String.sub s 2 len        String.sub s 2 len
916        
917      let write buf t =      let write buf t =
918        buf_estring buf t        buf_estring buf t
919    
# Line 940  module EmulePublicKeyReq = struct Line 922  module EmulePublicKeyReq = struct
922  module EmuleSecIdentStateReq = struct  module EmuleSecIdentStateReq = struct
923    
924      type t = {      type t = {
925          state : int;          state : int;
926          challenge : int64;          challenge : int64;
927        }        }
928    
929      let print t =      let print t =
930        lprintf_nl "EmuleSecIdentStateReq [state: %d] [challenge: %Ld]" t.state t.challenge        lprintf_nl "EmuleSecIdentStateReq [state: %d] [challenge: %Ld]" t.state t.challenge
931    
932      let parse len s =      let parse len s =
933        let state = get_uint8 s 1 in        let state = get_uint8 s 1 in
934        let challenge = get_uint64_32 s 2 in        let challenge = get_uint64_32 s 2 in
935        {        {
# Line 955  module EmuleSecIdentStateReq = struct Line 937  module EmuleSecIdentStateReq = struct
937          challenge = challenge;          challenge = challenge;
938        }        }
939    
940      let write buf t =      let write buf t =
941        buf_int8 buf t.state;        buf_int8 buf t.state;
942        buf_int64_32 buf t.challenge        buf_int64_32 buf t.challenge
943                
944    end    end
945          
946  module EmuleRequestSourcesReply = struct  module EmuleRequestSourcesReply = struct
947        
948      type source = {      type source = {
949          src_ip : Ip.t;          src_ip : Ip.t;
950          src_port : int;          src_port : int;
# Line 970  module EmuleRequestSourcesReply = struct Line 952  module EmuleRequestSourcesReply = struct
952          mutable src_server_port : int;          mutable src_server_port : int;
953          mutable src_md4 : Md4.t;          mutable src_md4 : Md4.t;
954        }        }
955        
956      type t = {      type t = {
957          md4 : Md4.t;          md4 : Md4.t;
958          sources : source array;                  sources : source array;
959        }        }
960        
961      let dummy_source = {      let dummy_source = {
962          src_ip = Ip.null;          src_ip = Ip.null;
963          src_port = 0;          src_port = 0;
# Line 983  module EmuleRequestSourcesReply = struct Line 965  module EmuleRequestSourcesReply = struct
965          src_server_port = 0;          src_server_port = 0;
966          src_md4 = Md4.null;          src_md4 = Md4.null;
967        }        }
968        
969      let parse e len s =      let parse e len s =
970        let md4 = get_md4 s 1 in        let md4 = get_md4 s 1 in
971        let ncount = get_int16 s 17 in        let ncount = get_int16 s 17 in
972          
973        let sources =        let sources =
974          if ncount = 0 then [||] else          if ncount = 0 then [||] else
975          let slen = (len - 19) / ncount in          let slen = (len - 19) / ncount in
976  (*        lprintf "PER SOURCES LEN: %d\n" slen; *)  (*        lprintf "PER SOURCES LEN: %d\n" slen; *)
977          let sources = Array.create ncount dummy_source in          let sources = Array.create ncount dummy_source in
978          let rec iter pos i =          let rec iter pos i =
979            if i < ncount then            if i < ncount then
980              let ss = {              let ss = {
981                  dummy_source with                  dummy_source with
982                  src_ip = get_ip s pos;                  src_ip = get_ip s pos;
# Line 1010  module EmuleRequestSourcesReply = struct Line 992  module EmuleRequestSourcesReply = struct
992                      end else                      end else
993                      pos + 12                      pos + 12
994                  end                  end
995                else pos + 6                else pos + 6
996              in              in
997              sources.(i) <- ss;              sources.(i) <- ss;
998              iter pos (i+1)              iter pos (i+1)
# Line 1022  module EmuleRequestSourcesReply = struct Line 1004  module EmuleRequestSourcesReply = struct
1004          md4 = md4;          md4 = md4;
1005          sources = sources;          sources = sources;
1006        }        }
1007            
1008      let print t =      let print t =
1009        let ncount = Array.length t.sources in        let ncount = Array.length t.sources in
1010        lprintf_nl "EMULE SOURCES REPLY: %d sources for %s"        lprintf_nl "EMULE SOURCES REPLY: %d sources for %s"
1011          ncount (Md4.to_string t.md4);          ncount (Md4.to_string t.md4);
1012         for i = 0 to ncount - 1 do         for i = 0 to ncount - 1 do
1013          let s = t.sources.(i) in          let s = t.sources.(i) in
1014            if Ip.valid s.src_ip then            if Ip.valid s.src_ip then
1015              lprintf_nl "  %s:%d" (Ip.to_string s.src_ip) s.src_port              lprintf_nl "  %s:%d" (Ip.to_string s.src_ip) s.src_port
1016            else            else
1017              lprintf_nl "  Indirect from %s:%d"              lprintf_nl "  Indirect from %s:%d"
1018                (Ip.to_string s.src_server_ip) s.src_server_port;                (Ip.to_string s.src_server_ip) s.src_server_port;
1019            if s.src_md4 != Md4.null then            if s.src_md4 != Md4.null then
1020              lprintf_nl "   Md4: %s" (Md4.to_string s.src_md4)              lprintf_nl "   Md4: %s" (Md4.to_string s.src_md4)
1021        done        done
1022    
1023      let write e buf t =      let write e buf t =
1024        buf_md4 buf t.md4;        buf_md4 buf t.md4;
1025        let ncount = Array.length t.sources in        let ncount = Array.length t.sources in
1026        buf_int16 buf ncount;        buf_int16 buf ncount;
1027          
1028        for i = 0 to ncount - 1 do        for i = 0 to ncount - 1 do
1029          let s = t.sources.(i) in          let s = t.sources.(i) in
1030            buf_ip buf s.src_ip;            buf_ip buf s.src_ip;
1031            buf_port buf s.src_port;            buf_port buf s.src_port;
1032            if sourceexchange e > 0 then begin            if sourceexchange e > 0 then begin
1033                buf_ip buf s.src_server_ip;                buf_ip buf s.src_server_ip;
1034                buf_port buf s.src_server_port;                buf_port buf s.src_server_port;
1035                if sourceexchange e > 1 then                if sourceexchange e > 1 then
1036                  buf_md4 buf s.src_md4                  buf_md4 buf s.src_md4
1037              end              end
1038        done        done
1039                
1040    end    end
1041    
1042      type t =
 type t =  
1043  | ConnectReq of Connect.t  | ConnectReq of Connect.t
1044  | ConnectReplyReq of ConnectReply.t  | ConnectReplyReq of ConnectReply.t
1045  | QueryFileReq of QueryFile.t  | QueryFileReq of QueryFile.t
# Line 1082  type t = Line 1063  type t =
1063  | SourcesReq of Sources.t  | SourcesReq of Sources.t
1064  | EndOfDownloadReq of EndOfDownload.t  | EndOfDownloadReq of EndOfDownload.t
1065  | NewUserIDReq of NewUserID.t  | NewUserIDReq of NewUserID.t
1066  | NoSuchFileReq of NoSuchFile.t    | NoSuchFileReq of NoSuchFile.t
1067  | QueueRankReq of QueueRank.t  | QueueRankReq of QueueRank.t
1068      
     
1069  | EmuleClientInfoReq of EmuleClientInfo.t  | EmuleClientInfoReq of EmuleClientInfo.t
1070  | EmuleClientInfoReplyReq of EmuleClientInfo.t  | EmuleClientInfoReplyReq of EmuleClientInfo.t
1071  | EmuleQueueRankingReq of EmuleQueueRanking.t  | EmuleQueueRankingReq of EmuleQueueRanking.t
# Line 1093  type t = Line 1073  type t =
1073  | EmuleRequestSourcesReplyReq of EmuleRequestSourcesReply.t  | EmuleRequestSourcesReplyReq of EmuleRequestSourcesReply.t
1074  | EmuleFileDescReq of string  | EmuleFileDescReq of string
1075  | EmulePublicKeyReq of EmulePublicKeyReq.t  | EmulePublicKeyReq of EmulePublicKeyReq.t
1076  | EmuleSignatureReq of EmuleSignatureReq.t  | EmuleSignatureReq of EmuleSignatureReq.t
1077  | EmuleSecIdentStateReq  of EmuleSecIdentStateReq.t  | EmuleSecIdentStateReq  of EmuleSecIdentStateReq.t
1078  | EmuleMultiPacketReq of Md4.t * t list  | EmuleMultiPacketReq of Md4.t * t list
1079  | EmuleMultiPacketAnswerReq of Md4.t * t list  | EmuleMultiPacketAnswerReq of Md4.t * t list
1080  | EmuleCompressedPart of Md4.t * int64 * int64 * string  | EmuleCompressedPart of Md4.t * int64 * int64 * string
1081      
1082  let rec print t =  let rec print t =
1083    begin    begin
1084      match t with      match t with
# Line 1111  let rec print t = Line 1091  let rec print t =
1091      | JoinQueueReq t -> JoinQueue.print t      | JoinQueueReq t -> JoinQueue.print t
1092      | AvailableSlotReq t -> AvailableSlot.print t      | AvailableSlotReq t -> AvailableSlot.print t
1093      | ReleaseSlotReq t -> ReleaseSlot.print t      | ReleaseSlotReq t -> ReleaseSlot.print t
1094      | CloseSlotReq t -> CloseSlot.print t          | CloseSlotReq t -> CloseSlot.print t
1095      | QueryChunksReq t -> QueryChunks.print t          | QueryChunksReq t -> QueryChunks.print t
1096      | QueryChunksReplyReq t -> QueryChunksReply.print t          | QueryChunksReplyReq t -> QueryChunksReply.print t
1097      | QueryChunkMd4Req t -> QueryChunkMd4.print t          | QueryChunkMd4Req t -> QueryChunkMd4.print t
1098      | QueryChunkMd4ReplyReq t -> QueryChunkMd4Reply.print t          | QueryChunkMd4ReplyReq t -> QueryChunkMd4Reply.print t
1099      | ViewFilesReplyReq t -> ViewFilesReply.print t      | ViewFilesReplyReq t -> ViewFilesReply.print t
1100      | ViewFilesReq t -> ViewFiles.print t          | ViewFilesReq t -> ViewFiles.print t
1101      | QueueReq t -> OtherLocations.print t          | QueueReq t -> OtherLocations.print t
1102      | OtherLocationsReq t  -> OtherLocations.print t      | OtherLocationsReq t  -> OtherLocations.print t
1103      | SayReq t -> Say.print t      | SayReq t -> Say.print t
1104      | SourcesReq t -> Sources.print t      | SourcesReq t -> Sources.print t
1105      | EndOfDownloadReq t -> EndOfDownload.print t      | EndOfDownloadReq t -> EndOfDownload.print t
1106      | NewUserIDReq t -> NewUserID.print t      | NewUserIDReq t -> NewUserID.print t
1107      | NoSuchFileReq t -> NoSuchFile.print t      | NoSuchFileReq t -> NoSuchFile.print t
1108      | QueueRankReq t ->      | QueueRankReq t ->
1109          QueueRank.print t          QueueRank.print t
1110        
1111      | EmuleClientInfoReq t ->      | EmuleClientInfoReq t ->
1112          EmuleClientInfo.print "EMULE CLIENT INFO"  t          EmuleClientInfo.print "EMULE CLIENT INFO"  t
1113      | EmuleClientInfoReplyReq t ->      | EmuleClientInfoReplyReq t ->
1114          EmuleClientInfo.print "EMULE CLIENT INFO REPLY" t          EmuleClientInfo.print "EMULE CLIENT INFO REPLY" t
1115      | EmuleQueueRankingReq t ->      | EmuleQueueRankingReq t ->
1116          EmuleQueueRanking.print t          EmuleQueueRanking.print t
1117      | EmuleRequestSourcesReq t ->      | EmuleRequestSourcesReq t ->
1118          EmuleRequestSources.print  t          EmuleRequestSources.print  t
1119      | EmuleRequestSourcesReplyReq t ->      | EmuleRequestSourcesReplyReq t ->
1120          EmuleRequestSourcesReply.print t          EmuleRequestSourcesReply.print t
1121    
1122      | EmuleFileDescReq t ->      | EmuleFileDescReq t ->
1123          lprintf "EMULE FILE DESC %s" t          lprintf "EMULE FILE DESC %s" t
1124    
1125      | EmuleMultiPacketReq (md4, list) ->      | EmuleMultiPacketReq (md4, list) ->
# Line 1148  let rec print t = Line 1128  let rec print t =
1128              lprintf "  ";              lprintf "  ";
1129              print t              print t
1130          ) list          ) list
1131            
1132      | EmuleMultiPacketAnswerReq (md4, list) ->      | EmuleMultiPacketAnswerReq (md4, list) ->
1133          lprintf_nl "EmuleMultiPacketAnswer for %s:" (Md4.to_string md4);          lprintf_nl "EmuleMultiPacketAnswer for %s:" (Md4.to_string md4);
1134          List.iter (fun t ->          List.iter (fun t ->
# Line 1157  let rec print t = Line 1137  let rec print t =
1137          ) list          ) list
1138      | EmuleSecIdentStateReq t ->      | EmuleSecIdentStateReq t ->
1139          EmuleSecIdentStateReq.print t          EmuleSecIdentStateReq.print t
1140      | EmuleSignatureReq t ->      | EmuleSignatureReq t ->
1141          EmuleSignatureReq.print t          EmuleSignatureReq.print t
1142      | EmulePublicKeyReq t ->      | EmulePublicKeyReq t ->
1143          EmulePublicKeyReq.print t          EmulePublicKeyReq.print t
1144    
1145      | EmuleCompressedPart (md4, statpos, newsize, bloc) ->      | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
1146          lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"          lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
1147            (Md4.to_string md4) statpos newsize (String.length bloc)            (Md4.to_string md4) statpos newsize (String.length bloc)
1148            
1149      | UnknownReq (opcode, s) ->        | UnknownReq (opcode, s) ->
1150          let len = String.length s in          let len = String.length s in
1151          lprintf_nl "UnknownReq: magic %d, opcode %d\n   len %d" opcode          lprintf_nl "UnknownReq: magic %d, opcode %d\n   len %d" opcode
1152          (int_of_char s.[0])          (int_of_char s.[0])
1153          (String.length s);          (String.length s);
1154          lprintf "ascii: [";          lprintf "ascii: [";
# Line 1185  let rec print t = Line 1165  let rec print t =
1165          for i = 0 to len - 1 do          for i = 0 to len - 1 do
1166            let c = s.[i] in            let c = s.[i] in
1167            let n = int_of_char c in            let n = int_of_char c in
1168            lprintf "(%d)" n                        lprintf "(%d)" n
1169          done;          done;
1170          lprintf_nl "]"          lprintf_nl "]"
1171    end    end
1172    
     
1173  let rec parse_emule_packet emule opcode len s =  let rec parse_emule_packet emule opcode len s =
1174  (*  (*
1175    lprintf "Emule magic: %d opcode %d:" magic opcode; lprint_newline ();    lprintf "Emule magic: %d opcode %d:" magic opcode; lprint_newline ();
1176            dump s; lprint_newline ();            dump s; lprint_newline ();
1177    *)            *)
1178    let t = match opcode with    let t = match opcode with
1179      | 1 -> EmuleClientInfoReq (EmuleClientInfo.parse len s)      | 1 -> EmuleClientInfoReq (EmuleClientInfo.parse len s)
1180      | 2 -> EmuleClientInfoReplyReq (EmuleClientInfo.parse len s)      | 2 -> EmuleClientInfoReplyReq (EmuleClientInfo.parse len s)
1181        
       
       
1182      | 0x60 (* 96 *) -> EmuleQueueRankingReq (EmuleQueueRanking.parse len s)      | 0x60 (* 96 *) -> EmuleQueueRankingReq (EmuleQueueRanking.parse len s)
1183        
1184      | 0x61 (* 97 *) ->      | 0x61 (* 97 *) ->
1185          let (comment,_) = get_string s 1 in          let (comment,_) = get_string s 1 in
1186          EmuleFileDescReq comment          EmuleFileDescReq comment
1187        
1188      | 0x81 (* 129 *) -> EmuleRequestSourcesReq (EmuleRequestSources.parse len s)      | 0x81 (* 129 *) -> EmuleRequestSourcesReq (EmuleRequestSources.parse len s)
1189      | 0x82 (* 130 *) ->      | 0x82 (* 130 *) ->
1190          EmuleRequestSourcesReplyReq (          EmuleRequestSourcesReplyReq (
1191            EmuleRequestSourcesReply.parse emule len s)            EmuleRequestSourcesReply.parse emule len s)
1192        
1193      | 0x40 (* 64 *) ->      | 0x40 (* 64 *) ->
1194  (* OP_COMPRESSEDPART *)  (* OP_COMPRESSEDPART *)
1195          let md4 = get_md4 s 1 in          let md4 = get_md4 s 1 in
# Line 1220  let rec parse_emule_packet emule opcode Line 1197  let rec parse_emule_packet emule opcode
1197          let newsize = get_uint64_32 s 21 in          let newsize = get_uint64_32 s 21 in
1198          let bloc = String.sub s 25 (len-25) in          let bloc = String.sub s 25 (len-25) in
1199          EmuleCompressedPart (md4, statpos, newsize, bloc)          EmuleCompressedPart (md4, statpos, newsize, bloc)
1200        
1201      | 0x85 (* 133 *) ->      | 0x85 (* 133 *) ->
1202          EmulePublicKeyReq(EmulePublicKeyReq.parse len s)          EmulePublicKeyReq(EmulePublicKeyReq.parse len s)
1203        
1204      | 0x86 (* 134 *) ->      | 0x86 (* 134 *) ->
1205          EmuleSignatureReq(EmuleSignatureReq.parse len s)          EmuleSignatureReq(EmuleSignatureReq.parse len s)
1206        
1207      | 0x87 (* 135 *) ->      | 0x87 (* 135 *) ->
1208          EmuleSecIdentStateReq (EmuleSecIdentStateReq.parse len s)          EmuleSecIdentStateReq (EmuleSecIdentStateReq.parse len s)
1209    
1210  (*     | 0x90 (* 144 *) -> RequestPreview *)  (*     | 0x90 (* 144 *) -> RequestPreview *)
1211  (*    | 0x91 (* 145 *) -> PreviewAnswer *)  (*    | 0x91 (* 145 *) -> PreviewAnswer *)
1212      | 0x92 (* 146 *) ->      | 0x92 (* 146 *) ->
1213          let md4 = get_md4 s 1 in          let md4 = get_md4 s 1 in
1214            
1215  (*        Printf.printf "MULTI EMULE VERSION %d"  (*        Printf.printf "MULTI EMULE VERSION %d"
1216            (extendedrequest emule); print_newline (); *)            (extendedrequest emule); print_newline (); *)
1217          let pos = 17 in          let pos = 17 in
1218          let rec iter pos =          let rec iter pos =
1219            if pos < len then            if pos < len then
1220              let opcode = get_uint8 s pos in              let opcode = get_uint8 s pos in
1221              match opcode with              match opcode with
1222                0x58 (* 88 *) ->                0x58 (* 88 *) ->
1223                  let bitmap, pos = get_bitmap s (pos+1) in                  let bitmap, pos = get_bitmap s (pos+1) in
1224                  let ncompletesources, pos =                  let ncompletesources, pos =
1225                    if extendedrequest emule > 1 then                    if extendedrequest emule > 1 then
1226                      get_int16 s pos, pos+2                      get_int16 s pos, pos+2
1227                    else -1, pos                    else -1, pos
1228                  in                  in
# Line 1253  let rec parse_emule_packet emule opcode Line 1230  let rec parse_emule_packet emule opcode
1230                      QueryFile.md4 = md4;                      QueryFile.md4 = md4;
1231                      QueryFile.emule_extension = Some (bitmap, ncompletesources);                      QueryFile.emule_extension = Some (bitmap, ncompletesources);
1232                    }) :: (iter pos)                    }) :: (iter pos)
1233              | 0x4F (* 79 *) ->              | 0x4F (* 79 *) ->
1234                  (QueryChunksReq md4) :: iter (pos+1)                  (QueryChunksReq md4) :: iter (pos+1)
1235              | 0x81 (* 129 *) ->              | 0x81 (* 129 *) ->
1236                  (EmuleRequestSourcesReq md4) :: iter (pos+1)                  (EmuleRequestSourcesReq md4) :: iter (pos+1)
1237              | _ ->              | _ ->
1238                  lprintf_nl "Unknown short emule packet %d" opcode;                  lprintf_nl "Unknown short emule packet %d" opcode;
# Line 1264  let rec parse_emule_packet emule opcode Line 1241  let rec parse_emule_packet emule opcode
1241              []              []
1242          in          in
1243          EmuleMultiPacketReq (md4, iter 17)          EmuleMultiPacketReq (md4, iter 17)
1244        
1245      | 0x93 (* 147 *) ->      | 0x93 (* 147 *) ->
1246          let md4 = get_md4 s 1 in          let md4 = get_md4 s 1 in
1247            
1248  (*        Printf.printf "MULTI EMULE VERSION %d"  (*        Printf.printf "MULTI EMULE VERSION %d"
1249            (extendedrequest emule); print_newline (); *)            (extendedrequest emule); print_newline (); *)
1250          let rec iter s pos len =          let rec iter s pos len =
1251            if pos < len then            if pos < len then
1252              let opcode = get_uint8 s pos in              let opcode = get_uint8 s pos in
1253              match opcode with              match opcode with
1254              | 89 ->              | 89 ->
1255                  let module Q = QueryFileReply in                  let module Q = QueryFileReply in
1256                  let name, pos = get_string s (pos+1) in                  let name, pos = get_string s (pos+1) in
1257                  let q = {                  let q = {
1258                      Q.md4 = md4;                      Q.md4 = md4;
1259                      Q.name =  name;                      Q.name =  name;
1260                    } in                    } in
# Line 1297  let rec parse_emule_packet emule opcode Line 1274  let rec parse_emule_packet emule opcode
1274              []              []
1275          in          in
1276          EmuleMultiPacketAnswerReq (md4, iter s 17 len)          EmuleMultiPacketAnswerReq (md4, iter s 17 len)
1277        
1278      | code ->      | code ->
1279          if !CommonOptions.verbose_unknown_messages then          if !CommonOptions.verbose_unknown_messages then
1280            lprintf_nl "EDK: unknown eMule message %d" code;            lprintf_nl "EDK: unknown eMule message %d" code;
# Line 1310  let rec parse_emule_packet emule opcode Line 1287  let rec parse_emule_packet emule opcode
1287    t    t
1288    
1289  and parse emule_version magic s =  and parse emule_version magic s =
1290    try    try
1291      let len = String.length s in      let len = String.length s in
1292      if len = 0 then raise Not_found;      if len = 0 then raise Not_found;
1293      let opcode = int_of_char (s.[0]) in      let opcode = int_of_char (s.[0]) in
# Line 1318  and parse emule_version magic s = Line 1295  and parse emule_version magic s =
1295      match magic with      match magic with
1296        227 ->        227 ->
1297          begin          begin
1298            match opcode with            match opcode with
1299            | 1 -> ConnectReq (Connect.parse len s)            | 1 -> ConnectReq (Connect.parse len s)
1300            | 70 -> BlocReq (Bloc.parse len s)            | 70 -> BlocReq (Bloc.parse len s)
1301            | 71 -> QueryBlocReq (QueryBloc.parse len s)            | 71 -> QueryBlocReq (QueryBloc.parse len s)
# Line 1334  and parse emule_version magic s = Line 1311  and parse emule_version magic s =
1311            | 81 -> QueryChunkMd4Req (QueryChunkMd4.parse len s)            | 81 -> QueryChunkMd4Req (QueryChunkMd4.parse len s)
1312            | 82 -> QueryChunkMd4ReplyReq (QueryChunkMd4Reply.parse len s)            | 82 -> QueryChunkMd4ReplyReq (QueryChunkMd4Reply.parse len s)
1313  (* JoinQueue: the sender wants to join the upload queue *)  (* JoinQueue: the sender wants to join the upload queue *)
1314            | 84 -> JoinQueueReq (JoinQueue.parse len s)            | 84 -> JoinQueueReq (JoinQueue.parse len s)
1315  (* AvailableSlot: there is an available slot in upload queue *)  (* AvailableSlot: there is an available slot in upload queue *)
1316            | 85 -> AvailableSlotReq (AvailableSlot.parse len s)            | 85 -> AvailableSlotReq (AvailableSlot.parse len s)
1317  (* ReleaseSlot: the upload is finished *)  (* ReleaseSlot: the upload is finished *)
# Line 1344  and parse emule_version magic s = Line 1321  and parse emule_version magic s =
1321            | 88 -> QueryFileReq (QueryFile.parse emule_version len s)            | 88 -> QueryFileReq (QueryFile.parse emule_version len s)
1322            | 89 -> QueryFileReplyReq (QueryFileReply.parse len s)            | 89 -> QueryFileReplyReq (QueryFileReply.parse len s)
1323            | 92 -> QueueRankReq (QueueRank.parse len s)            | 92 -> QueueRankReq (QueueRank.parse len s)
1324            | 250 -> SourcesReq (Sources.parse len s)                    | 250 -> SourcesReq (Sources.parse len s)
1325              
1326            | _ -> raise Not_found            | _ -> raise Not_found
1327          end          end
1328        
1329      | 0xc5  -> (* 197: emule extended protocol *)      | 0xc5  -> (* 197: emule extended protocol *)
1330          parse_emule_packet emule_version opcode len s          parse_emule_packet emule_version opcode len s
1331    
1332  (* Compressed packet, probably sent by cDonkey ? *)  (* Compressed packet, probably sent by cDonkey ? *)
1333        
1334      | 0xD4 -> (* 212 *)      | 0xD4 -> (* 212 *)
1335            
         if Autoconf.has_zlib then  
1336            let s = Autoconf.zlib__uncompress_string2 (String.sub s 1 (len-1)) in            let s = Autoconf.zlib__uncompress_string2 (String.sub s 1 (len-1)) in
1337            let s = Printf.sprintf "%c%s" (char_of_int opcode) s in            let s = Printf.sprintf "%c%s" (char_of_int opcode) s in
1338            try            begin try
1339              parse_emule_packet emule_version opcode (String.length s) s              parse_emule_packet emule_version opcode (String.length s) s
1340            with            with
1341            | e ->            | e ->
1342                if !CommonOptions.verbose_unknown_messages then begin                if !CommonOptions.verbose_unknown_messages then begin
1343                    lprintf_nl "Unknown message From client: %s (magic %d)"                    lprintf_nl "Unknown message From client: %s (magic %d)"
1344                      (Printexc2.to_string e) magic;                      (Printexc2.to_string e) magic;
# Line 1373  and parse emule_version magic s = Line 1349  and parse emule_version magic s =
1349                    lprint_newline ();                    lprint_newline ();
1350                  end;                  end;
1351                UnknownReq (magic,s)                UnknownReq (magic,s)
1352                            end
1353          else  
1354            failwith "No Zlib to uncompress packet"      | _ ->
         (*  
         lprintf "Compressed message decompressed with opcode %d" opcode; lprint_newline ();  
         if !CommonOptions.verbose_unknown_messages then begin        
             let tmp_file = Filename.temp_file "comp" "unpak" in  
             File.from_string tmp_file s;  
             lprintf "Saved compressed packet %s" tmp_file; lprint_newline ();  
           end;      
         UnknownReq s        *)  
     | _ ->  
1355          if !CommonOptions.verbose_unknown_messages then          if !CommonOptions.verbose_unknown_messages then
1356              lprintf_nl "Strange magic: %d" magic;              lprintf_nl "Strange magic: %d" magic;
1357          raise Not_found          raise Not_found
1358    with    with
1359    | e ->    | e ->
1360        if !CommonOptions.verbose_unknown_messages then begin        if !CommonOptions.verbose_unknown_messages then begin
1361            lprintf_nl "Unknown message From client: %s (magic %d)"            lprintf_nl "Unknown message From client: %s (magic %d)"
1362                (Printexc2.to_string e) magic;                (Printexc2.to_string e) magic;
# Line 1401  and parse emule_version magic s = Line 1368  and parse emule_version magic s =
1368            lprint_newline ();            lprint_newline ();
1369          end;          end;
1370        UnknownReq (magic,s)        UnknownReq (magic,s)
1371      
1372  let write emule buf t =  let write emule buf t =
1373    let magic = match t with    let magic = match t with
1374        EmuleMultiPacketAnswerReq _        EmuleMultiPacketAnswerReq _
1375      | EmuleMultiPacketReq _      | EmuleMultiPacketReq _
1376      | EmuleSecIdentStateReq _      | EmuleSecIdentStateReq _
1377      | EmuleSignatureReq _      | EmuleSignatureReq _
1378      | EmulePublicKeyReq _      | EmulePublicKeyReq _
1379      | EmuleRequestSourcesReplyReq _      | EmuleRequestSourcesReplyReq _
1380      | EmuleRequestSourcesReq _      | EmuleRequestSourcesReq _
1381      | EmuleClientInfoReplyReq _      | EmuleClientInfoReplyReq _
1382      | EmuleClientInfoReq _      | EmuleClientInfoReq _
1383      | EmuleFileDescReq _      | EmuleFileDescReq _
1384      | EmuleQueueRankingReq _      | EmuleQueueRankingReq _
1385      | EmuleCompressedPart _      | EmuleCompressedPart _
1386        -> 0xC5        -> 0xC5
1387      | _      | _
1388        ->  227        ->  227
1389    in    in
1390    begin    begin
1391      match t with      match t with
1392      | ConnectReq t ->      | ConnectReq t ->
1393          buf_int8 buf 1;          buf_int8 buf 1;
1394          Connect.write buf t          Connect.write buf t
1395      | ConnectReplyReq t ->      | ConnectReplyReq t ->
1396          buf_int8 buf 76;          buf_int8 buf 76;
1397          ConnectReply.write buf t          ConnectReply.write buf t
1398      | QueryFileReq t ->      | QueryFileReq t ->
1399          buf_int8 buf 88;          buf_int8 buf 88;
1400          QueryFile.write emule buf t          QueryFile.write emule buf t
1401      | QueryFileReplyReq t ->      | QueryFileReplyReq t ->
1402          buf_int8 buf 89;          buf_int8 buf 89;
1403          QueryFileReply.write buf t          QueryFileReply.write buf t
1404      | QueueReq t ->      | QueueReq t ->
# Line 1440  let write emule buf t = Line 1407  let write emule buf t =
1407      | QueryBlocReq t ->      | QueryBlocReq t ->
1408          buf_int8 buf 71;          buf_int8 buf 71;
1409          QueryBloc.write buf t          QueryBloc.write buf t
1410      | BlocReq t ->      | BlocReq t ->
1411          buf_int8 buf 70;          buf_int8 buf 70;
1412          Bloc.write buf t          Bloc.write buf t
1413      | JoinQueueReq t ->      | JoinQueueReq t ->
1414          buf_int8 buf 84;          buf_int8 buf 84;
1415          JoinQueue.write emule buf t          JoinQueue.write emule buf t
1416      | QueryChunksReq t ->      | QueryChunksReq t ->
1417          buf_int8 buf 79;          buf_int8 buf 79;
1418          QueryChunks.write buf t          QueryChunks.write buf t
1419      | QueryChunksReplyReq t ->      | QueryChunksReplyReq t ->
1420          buf_int8 buf 80;          buf_int8 buf 80;
1421          QueryChunksReply.write buf t          QueryChunksReply.write buf t
1422      | QueryChunkMd4Req t ->      | QueryChunkMd4Req t ->
1423          buf_int8 buf 81;          buf_int8 buf 81;
1424          QueryChunkMd4.write buf t          QueryChunkMd4.write buf t
1425      | QueryChunkMd4ReplyReq t ->      | QueryChunkMd4ReplyReq t ->
1426          buf_int8 buf 82;          buf_int8 buf 82;
1427          QueryChunkMd4Reply.write buf t          QueryChunkMd4Reply.write buf t
1428      | AvailableSlotReq t ->      | AvailableSlotReq t ->
1429          buf_int8 buf 85;          buf_int8 buf 85;
1430          AvailableSlot.write buf t          AvailableSlot.write buf t
1431      | ReleaseSlotReq t ->      | ReleaseSlotReq t ->
1432          buf_int8 buf 86;          buf_int8 buf 86;
1433          ReleaseSlot.write buf t          ReleaseSlot.write buf t
1434      | CloseSlotReq t ->      | CloseSlotReq t ->
1435          buf_int8 buf 87;          buf_int8 buf 87;
1436          CloseSlot.write buf t          CloseSlot.write buf t
1437      | ViewFilesReq t ->      | ViewFilesReq t ->
1438          buf_int8 buf 74;          buf_int8 buf 74;
1439          ViewFiles.write buf t          ViewFiles.write buf t
1440      | ViewFilesReplyReq t ->      | ViewFilesReplyReq t ->
1441          buf_int8 buf 75;          buf_int8 buf 75;
1442          ViewFilesReply.write buf t          ViewFilesReply.write buf t
1443      | OtherLocationsReq t ->      | OtherLocationsReq t ->
# Line 1494  let write emule buf t = Line 1461  let write emule buf t =
1461      | QueueRankReq t ->      | QueueRankReq t ->
1462          buf_int8 buf 92;          buf_int8 buf 92;
1463          QueueRank.write buf t          QueueRank.write buf t
1464        
1465      | EmuleClientInfoReq t ->      | EmuleClientInfoReq t ->
1466          buf_int8 buf 1;          buf_int8 buf 1;
1467          EmuleClientInfo.write buf t          EmuleClientInfo.write buf t
# Line 1521  let write emule buf t = Line 1488  let write emule buf t =
1488          buf_int64_32 buf statpos;          buf_int64_32 buf statpos;
1489          buf_int64_32 buf newsize;          buf_int64_32 buf newsize;
1490          Buffer.add_string buf bloc          Buffer.add_string buf bloc
1491            
1492      | EmuleMultiPacketReq (md4, list) ->      | EmuleMultiPacketReq (md4, list) ->
1493          buf_int8 buf 0x92;          buf_int8 buf 0x92;
1494          buf_md4 buf md4;          buf_md4 buf md4;
# Line 1539  let write emule buf t = Line 1506  let write emule buf t =
1506                  buf_int8 buf 0x4F                  buf_int8 buf 0x4F
1507              | EmuleRequestSourcesReq _ ->              | EmuleRequestSourcesReq _ ->
1508                  buf_int8 buf 0x81                  buf_int8 buf 0x81
1509              | _ ->              | _ ->
1510                  lprintf_nl "WARNING: Don't know how to write short packet:";                  lprintf_nl "WARNING: Don't know how to write short packet:";
1511                  print t;                  print t;
1512                  print_newline ();                  print_newline ();
1513          ) list          ) list
1514        
1515      | EmuleMultiPacketAnswerReq (md4, list) ->      | EmuleMultiPacketAnswerReq (md4, list) ->
1516          buf_int8 buf 0x93;          buf_int8 buf 0x93;
1517          buf_md4 buf md4;          buf_md4 buf md4;
# Line 1556  let write emule buf t = Line 1523  let write emule buf t =
1523              | QueryChunksReplyReq t ->              | QueryChunksReplyReq t ->
1524                  buf_int8 buf 80;                  buf_int8 buf 80;
1525                  write_bitmap buf t.QueryChunksReply.chunks                  write_bitmap buf t.QueryChunksReply.chunks
1526              | _ ->              | _ ->
1527                  lprintf_nl "WARNING: Don't know how to write short packet:";                  lprintf_nl "WARNING: Don't know how to write short packet:";
1528                  print t;                  print t;
1529                  print_newline ();                  print_newline ();
1530          ) list          ) list
1531            
           
1532      | EmuleSecIdentStateReq t ->      | EmuleSecIdentStateReq t ->
1533          buf_int8 buf 0x87;          buf_int8 buf 0x87;
1534          EmuleSecIdentStateReq.write buf t          EmuleSecIdentStateReq.write buf t
1535            
1536      | EmuleSignatureReq t ->        | EmuleSignatureReq t ->
1537          buf_int8 buf 0x86;          buf_int8 buf 0x86;
1538          EmuleSignatureReq.write buf t          EmuleSignatureReq.write buf t
1539          
1540      | EmulePublicKeyReq t ->      | EmulePublicKeyReq t ->
1541          buf_int8 buf 0x85;          buf_int8 buf 0x85;
1542          EmulePublicKeyReq.write buf t          EmulePublicKeyReq.write buf t
1543            
1544      | UnknownReq (opcode, s) ->      | UnknownReq (opcode, s) ->
1545          Buffer.add_string buf s          Buffer.add_string buf s
       
   end;  
   magic  
     
 (*  
1546    
1547      end;
1548      magic
1549    
1550    (*
1551  ------------------------------------------------------  ------------------------------------------------------
1552  1044008574.297 192.168.0.3:37522 -> 80.26.114.12:13842 of len 6  1044008574.297 192.168.0.3:37522 -> 80.26.114.12:13842 of len 6
1553  ? Become Friend ? ping ?  ? Become Friend ? ping ?
1554    
1555  (227)(1)(0)(0)(0)  (227)(1)(0)(0)(0)
1556  (98)  (98)
1557    
1558  ------------------------------------------------------  ------------------------------------------------------
1559  1044008576.274 80.26.114.12:13842 -> 192.168.0.3:37522 of len 6  1044008576.274 80.26.114.12:13842 -> 192.168.0.3:37522 of len 6
# Line 1600  let write emule buf t = Line 1564  let write emule buf t =
1564  ------------------------------------------------------  ------------------------------------------------------
1565  1044008687.977 192.168.0.3:37522 -> 80.26.114.12:13842 of len 6  1044008687.977 192.168.0.3:37522 -> 80.26.114.12:13842 of len 6
1566  Browse Main Dir  Browse Main Dir
1567      
1568  (227)(1)(0)(0)(0)  (227)(1)(0)(0)(0)
1569  (93)  (93)
1570    
# Line 1617  Browse Main Dir Reply Line 1581  Browse Main Dir Reply
1581  ------------------------------------------------------  ------------------------------------------------------
1582  1044008766.137 192.168.0.3:37522 -> 80.26.114.12:13842 of len 20  1044008766.137 192.168.0.3:37522 -> 80.26.114.12:13842 of len 20
1583  Browse directory  Browse directory
1584      
1585  (227)(15)(0)(0)(0)  (227)(15)(0)(0)(0)
1586  (94)  (94)
1587  (12)(0) C : \ D o w n l o a d s  (12)(0) C : \ D o w n l o a d s
# Line 1626  Browse directory Line 1590  Browse directory
1590  1044008769.045 80.26.114.12:13842 -> 192.168.0.3:37522 of len 300  1044008769.045 80.26.114.12:13842 -> 192.168.0.3:37522 of len 300
1591  (227) p(8)(0)(0) `(12)(0) C : \ D o w n l o a d s(21)(0)(0)(0)(152) 2(229)(158)(218)(141)(217)(138) n(181) 6 ( ) h V(179)(0)(0)(0)(0)(0)(0)(3)(0)(0)(0)(2)(1)(0)(1)(11)(0) d e s k t o p . i n i(3)(1)(0)(2)(180)(0)(0)(0)(3)(1)(0)(19)(0)(0)(0)(0) y(16)(15) 9 O Z(219) i e(200)(10) |(29)(27) F(128)(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(15)(0) u t b o n u s p a c k . z i p(3)(1)(0)(2) J(16)(221)(0)(2)(1)(0)(3)(3)(0) P r o(2)(1)(0)(4)(3)(0) z i p(3)(1)(0)(19)(0)(0)(0)(0)(178)(145)(161)(146) P(199)(228)(249) K a :(9)(237)(246)(233) v(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(11)(0) c t f m a p s . z i p(3)(1)(0)(2)(236)(239)(23)(0)(2)(1)(0)(3)(3)(0) P r o(2)(1)(0)(4)(3)(0) z i p(3)(1)(0)(19)(0)(0)(0)(0) a n(251)(225) ^ g(205)(133)(25)(12) # ' J A(221) `(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(23)(0) u t i n o x x p a c k - n o - u m o d . z i p(3)(1)(0)(2)]  (227) p(8)(0)(0) `(12)(0) C : \ D o w n l o a d s(21)(0)(0)(0)(152) 2(229)(158)(218)(141)(217)(138) n(181) 6 ( ) h V(179)(0)(0)(0)(0)(0)(0)(3)(0)(0)(0)(2)(1)(0)(1)(11)(0) d e s k t o p . i n i(3)(1)(0)(2)(180)(0)(0)(0)(3)(1)(0)(19)(0)(0)(0)(0) y(16)(15) 9 O Z(219) i e(200)(10) |(29)(27) F(128)(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(15)(0) u t b o n u s p a c k . z i p(3)(1)(0)(2) J(16)(221)(0)(2)(1)(0)(3)(3)(0) P r o(2)(1)(0)(4)(3)(0) z i p(3)(1)(0)(19)(0)(0)(0)(0)(178)(145)(161)(146) P(199)(228)(249) K a :(9)(237)(246)(233) v(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(11)(0) c t f m a p s . z i p(3)(1)(0)(2)(236)(239)(23)(0)(2)(1)(0)(3)(3)(0) P r o(2)(1)(0)(4)(3)(0) z i p(3)(1)(0)(19)(0)(0)(0)(0) a n(251)(225) ^ g(205)(133)(25)(12) # ' J A(221) `(0)(0)(0)(0)(0)(0)(5)(0)(0)(0)(2)(1)(0)(1)(23)(0) u t i n o x x p a c k - n o - u m o d . z i p(3)(1)(0)(2)]
1592  (227)(112)(8)(0)(0)  (227)(112)(8)(0)(0)
1593      
1594  (96)  (96)
1595  (12)(0) C : \ D o w n l o a d s  (12)(0) C : \ D o w n l o a d s
1596  (21)(0)(0)(0) 21 files  (21)(0)(0)(0) 21 files
# Line 1665  Browse directory Line 1629  Browse directory
1629  (1)(0)(19)  (1)(0)(19)
1630  (0)(0)(0)(0)  (0)(0)(0)(0)
1631  ....  ....
1632      
1633  *)  *)
1634          
1635  (* 92: Queue Rank *)  (* 92: Queue Rank *)

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26