/[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.18 by spiralvoice, Tue Jun 28 23:25:53 2005 UTC revision 1.19 by spiralvoice, Thu Jul 7 00:25:46 2005 UTC
# Line 144  module Connect  = struct Line 144  module Connect  = struct
144        }        }
145            
146      let print t =      let print t =
147        lprintf "CONNECT:\n";        lprintf_nl "CONNECT:";
148        lprintf "version: %d\n" t.version;        lprintf_nl "version: %d" t.version;
149        lprintf "MD4: %s\n" (Md4.to_string t.md4);        lprintf_nl "MD4: %s" (Md4.to_string t.md4);
150        lprintf "ip: %s\n" (Ip.to_string t.ip);        lprintf_nl "ip: %s" (Ip.to_string t.ip);
151        lprintf "port: %d\n" t.port;        lprintf_nl "port: %d" t.port;
152        lprintf "tags: ";        lprintf "tags: ";
153        print_tags t.tags;        print_tags t.tags;
154        lprint_newline ();        lprintf_nl "";
155        (match t.server_info with        (match t.server_info with
156            None -> ()            None -> ()
157          | Some (ip, port) ->          | Some (ip, port) ->
158              lprintf "ip_server: %s\n" (Ip.to_string ip);              lprintf_nl "ip_server: %s" (Ip.to_string ip);
159              lprintf "port_server: %d\n" port);              lprintf_nl "port_server: %d" port);
160        String.iter (fun c -> lprintf "(%d)" (int_of_char c))        String.iter (fun c -> lprintf "(%d)" (int_of_char c))
161        t.left_bytes;        t.left_bytes;
162        lprintf "\n"        lprintf_nl ""
163            
164      let write buf t =      let write buf t =
165        buf_int8 buf t.version;        buf_int8 buf t.version;
# Line 223  module ConnectReply  = struct Line 223  module ConnectReply  = struct
223        }        }
224            
225      let print t =      let print t =
226        lprintf "CONNECT REPLY:\n";        lprintf_nl "CONNECT REPLY:";
227        lprintf "MD4: %s\n" (Md4.to_string t.md4);        lprintf_nl "MD4: %s" (Md4.to_string t.md4);
228        lprintf "ip: %s\n" (Ip.to_string t.ip);        lprintf_nl "ip: %s" (Ip.to_string t.ip);
229        lprintf "port: %d\n" t.port;        lprintf_nl "port: %d" t.port;
230        lprintf "tags: ";        lprintf "tags: ";
231        print_tags t.tags;        print_tags t.tags;
232        lprint_newline ();        lprintf_nl "";
233        (match t.server_info with        (match t.server_info with
234            None -> ()            None -> ()
235          | Some (ip, port) ->          | Some (ip, port) ->
236              lprintf "ip_server: %s\n" (Ip.to_string ip);              lprintf_nl "ip_server: %s" (Ip.to_string ip);
237              lprintf "port_server: %d\n" port);              lprintf_nl "port_server: %d" port);
238        String.iter (fun c -> lprintf "(%d)" (int_of_char c))        String.iter (fun c -> lprintf "(%d)" (int_of_char c))
239        t.left_bytes;        t.left_bytes;
240        lprintf "\n"        lprintf_nl ""
241                
242      let write buf t =      let write buf t =
243        buf_md4 buf t.md4;        buf_md4 buf t.md4;
# Line 293  module JoinQueue = struct Line 293  module JoinQueue = struct
293        lprintf "JOIN QUEUE";        lprintf "JOIN QUEUE";
294        (match t with None -> () | Some md4 ->        (match t with None -> () | Some md4 ->
295              lprintf " OF %s" (Md4.to_string md4));              lprintf " OF %s" (Md4.to_string md4));
296        lprintf "\n"        lprintf_nl ""
297                        
298      let write emule buf t =      let write emule buf t =
299        if extendedrequest emule > 0 then        if extendedrequest emule > 0 then
# Line 386  module QueryFile  = struct Line 386  module QueryFile  = struct
386          None -> ()          None -> ()
387        | Some (bitmap, ncompletesources) ->        | Some (bitmap, ncompletesources) ->
388            print_bitmap bitmap;            print_bitmap bitmap;
389            lprintf "\n";            lprintf_nl "";
390            if ncompletesources >= 0 then            if ncompletesources >= 0 then
391              lprintf "Complete sources: %d\n" ncompletesources              lprintf_nl "Complete sources: %d" ncompletesources
392            
393      let write emule buf t =      let write emule buf t =
394        buf_md4 buf t.md4;        buf_md4 buf t.md4;
# Line 427  module QueryChunksReply = struct (* Requ Line 427  module QueryChunksReply = struct (* Requ
427        }        }
428                
429      let print t =      let print t =
430        lprintf "CHUNKS for %s\n" (Md4.to_string t.md4);        lprintf_nl "CHUNKS for %s" (Md4.to_string t.md4);
431        lprint_string "   ";        lprint_string "   ";
432        Array.iter (fun b ->        Array.iter (fun b ->
433            if b then lprintf "1" else lprintf "0") t.chunks;            if b then lprintf "1" else lprintf "0") t.chunks;
434        lprint_newline ()        lprintf_nl ""
435            
436      let write buf t =      let write buf t =
437        buf_md4 buf t.md4;        buf_md4 buf t.md4;
# Line 469  module QueryChunkMd4Reply = struct (* Re Line 469  module QueryChunkMd4Reply = struct (* Re
469        }        }
470    
471      let print t =      let print t =
472        lprintf "CHUNKS for %s\n" (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 ()        lprintf_nl ""
478                
479      let write buf t =      let write buf t =
480        buf_md4 buf t.md4;        buf_md4 buf t.md4;
# Line 499  module QueryFileReply  = struct Line 499  module QueryFileReply  = struct
499        }        }
500                
501      let print t =      let print t =
502        lprintf "QUERY FILE REPLY OF %s\n" (Md4.to_string t.md4);        lprintf_nl "QUERY FILE REPLY OF %s" (Md4.to_string t.md4);
503        lprintf "  name = \"%s\"\n" t.name        lprintf_nl "  name = \"%s\"" t.name
504                
505      let write buf t =      let write buf t =
506        buf_md4 buf t.md4;        buf_md4 buf t.md4;
# Line 588  module NoArg = functor(M: sig val m : st Line 588  module NoArg = functor(M: sig val m : st
588          let parse len s = ()          let parse len s = ()
589                    
590          let print t =          let print t =
591            lprintf "%s:\n" M.m            lprintf_nl "%s:" M.m
592                    
593          let write (buf: Buffer.t) (t: t) = unit          let write (buf: Buffer.t) (t: t) = unit
594                        
# Line 643  module ViewFilesReply = struct Line 643  module ViewFilesReply = struct
643        files        files
644            
645      let print t =      let print t =
646        lprintf "VIEW FILES REPLY:\n";        lprintf_nl "VIEW FILES REPLY:";
647        List.iter (fun t ->        List.iter (fun t ->
648            lprintf "FILE:\n";            lprintf_nl "FILE:";
649            lprintf "  MD4: %s\n" (Md4.to_string t.f_md4);            lprintf_nl "  MD4: %s" (Md4.to_string t.f_md4);
650            lprintf "  ip: %s\n" (Ip.to_string t.f_ip);            lprintf_nl "  ip: %s" (Ip.to_string t.f_ip);
651            lprintf "  port: %d\n" t.f_port;            lprintf_nl "  port: %d" t.f_port;
652            lprintf "  tags: ";            lprintf "  tags: ";
653            print_tags t.f_tags;            print_tags t.f_tags;
654            lprint_newline ();) t            lprintf_nl "";) t
655            
656      let rec write_files buf files =      let rec write_files buf files =
657        match files with        match files with
# Line 695  module OtherLocations = struct Line 695  module OtherLocations = struct
695        !list        !list
696            
697      let print t =      let print t =
698        lprintf "OTHER LOCATIONS:\n";        lprintf_nl "OTHER LOCATIONS:\n";
699        List.iter (fun ip ->        List.iter (fun ip ->
700            lprintf "  ip: %s\n" (Ip.to_string ip);            lprintf_nl "  ip: %s" (Ip.to_string ip);) t
           lprint_newline ();) t  
701                    
702      let write buf t =      let write buf t =
703        List.iter (buf_ip buf) t        List.iter (buf_ip buf) t
# Line 712  module NewUserID = struct Line 711  module NewUserID = struct
711        get_ip s 1, get_ip s 5        get_ip s 1, get_ip s 5
712            
713      let print (ip1,ip2) =      let print (ip1,ip2) =
714        lprintf "NEW USER ID: %s -> %s\n" (Ip.to_string ip1)        lprintf_nl "NEW USER ID: %s -> %s" (Ip.to_string ip1)
715        (Ip.to_string ip2)        (Ip.to_string ip2)
716                    
717      let write buf (ip1,ip2) =      let write buf (ip1,ip2) =
# Line 742  module Sources = struct Line 741  module Sources = struct
741        }        }
742            
743      let print t =      let print t =
744        lprintf "SOURCES for %s:\n\n" (Md4.to_string t.md4);        lprintf_nl "SOURCES for %s:" (Md4.to_string t.md4);
745        List.iter (fun (ip1, port, ip2) ->        List.iter (fun (ip1, port, ip2) ->
746            lprintf "  %s:%d:%s\n" (Ip.to_string ip1) port(Ip.to_string ip2);            lprintf_nl "  %s:%d:%s" (Ip.to_string ip1) port(Ip.to_string ip2)) t.sources
           lprint_newline ();) t.sources  
747                    
748      let write buf t =      let write buf t =
749        buf_int16 buf (List.length t.sources);        buf_int16 buf (List.length t.sources);
# Line 821  module EmuleClientInfo = struct Line 819  module EmuleClientInfo = struct
819        }        }
820                
821      let print m t =      let print m t =
822        lprintf "%s:\n" m;        lprintf_nl "%s:" m;
823        lprintf "  version: %d\n" t.version;        lprintf_nl "  version: %d" t.version;
824        lprintf "  protversion: %d\n" t.version;        lprintf_nl "  protversion: %d" t.version;
825        lprintf "  tags: ";        lprintf "  tags: ";
826        print_tags t.tags;        print_tags t.tags;
827            lprint_newline ()        lprintf_nl ""
828                    
829      let write buf t =      let write buf t =
830        buf_int8 buf t.version;        buf_int8 buf t.version;
# Line 841  module EmuleQueueRanking = struct Line 839  module EmuleQueueRanking = struct
839                
840      let parse len s = get_int16 s 1            let parse len s = get_int16 s 1      
841      let print t =      let print t =
842        lprintf "QUEUE RANKING: %d\n" t        lprintf_nl "QUEUE RANKING: %d" t
843    
844      let string_null10 = String.make 10 (char_of_int 0)      let string_null10 = String.make 10 (char_of_int 0)
845                
# Line 857  module QueueRank = struct Line 855  module QueueRank = struct
855                
856      let parse len s = get_int s 1            let parse len s = get_int s 1      
857      let print t =      let print t =
858        lprintf "QUEUE RANK: %d\n" t        lprintf_nl "QUEUE RANK: %d" t
859    
860      let write buf t =      let write buf t =
861        buf_int buf t        buf_int buf t
# Line 872  module EmuleRequestSources = struct Line 870  module EmuleRequestSources = struct
870        get_md4 s 1        get_md4 s 1
871                
872      let print t =      let print t =
873        lprintf "EMULE REQUEST SOURCES: %s\n" (Md4.to_string t)        lprintf_nl "EMULE REQUEST SOURCES: %s" (Md4.to_string t)
874    
875      let write buf t =      let write buf t =
876        buf_md4 buf t        buf_md4 buf t
# Line 943  module EmuleRequestSourcesReply = struct Line 941  module EmuleRequestSourcesReply = struct
941                    
942      let print t =      let print t =
943        let ncount = Array.length t.sources in        let ncount = Array.length t.sources in
944        lprintf "EMULE SOURCES REPLY: %d sources for %s\n"        lprintf_nl "EMULE SOURCES REPLY: %d sources for %s"
945          ncount (Md4.to_string t.md4);          ncount (Md4.to_string t.md4);
946         for i = 0 to ncount - 1 do         for i = 0 to ncount - 1 do
947          let s = t.sources.(i) in          let s = t.sources.(i) in
948            if Ip.valid s.src_ip then            if Ip.valid s.src_ip then
949              lprintf "  %s:%d\n" (Ip.to_string s.src_ip) s.src_port              lprintf_nl "  %s:%d" (Ip.to_string s.src_ip) s.src_port
950            else            else
951              lprintf "  Indirect from %s:%d\n"              lprintf_nl "  Indirect from %s:%d"
952                (Ip.to_string s.src_server_ip) s.src_server_port;                (Ip.to_string s.src_server_ip) s.src_server_port;
953            if s.src_md4 != Md4.null then            if s.src_md4 != Md4.null then
954              lprintf "   Md4: %s\n" (Md4.to_string s.src_md4)              lprintf_nl "   Md4: %s" (Md4.to_string s.src_md4)
955        done        done
956    
957      let write e buf t =      let write e buf t =
# Line 1061  let rec print t = Line 1059  let rec print t =
1059          lprintf "EMULE FILE DESC %s" t          lprintf "EMULE FILE DESC %s" t
1060    
1061      | EmuleMultiPacketReq (md4, list) ->      | EmuleMultiPacketReq (md4, list) ->
1062          lprintf "EmuleMultiPacket for %s:\n" (Md4.to_string md4);          lprintf_nl "EmuleMultiPacket for %s:" (Md4.to_string md4);
1063          List.iter (fun t ->          List.iter (fun t ->
1064              lprintf "  ";              lprintf "  ";
1065              print t              print t
1066          ) list          ) list
1067                    
1068      | EmuleMultiPacketAnswerReq (md4, list) ->      | EmuleMultiPacketAnswerReq (md4, list) ->
1069          lprintf "EmuleMultiPacketAnswer for %s:\n" (Md4.to_string md4);          lprintf_nl "EmuleMultiPacketAnswer for %s:" (Md4.to_string md4);
1070          List.iter (fun t ->          List.iter (fun t ->
1071              lprintf "  ";              lprintf "  ";
1072              print t              print t
1073          ) list          ) list
1074      | EmuleSecIdentStateReq (int, int64) ->      | EmuleSecIdentStateReq (int, int64) ->
1075          lprintf "EmuleSecIdentState for %d, %Ld\n" int int64          lprintf_nl "EmuleSecIdentState for %d, %Ld" int int64
1076      | EmuleSignatureReq s ->      | EmuleSignatureReq s ->
1077          lprintf "EmuleSignature %s\n" (String.escaped s)          lprintf_nl "EmuleSignature %s" (String.escaped s)
1078      | EmulePublicKeyReq s ->      | EmulePublicKeyReq s ->
1079          lprintf "EmulePublicKey %s\n" (String.escaped s)          lprintf_nl "EmulePublicKey %s" (String.escaped s)
1080    
1081      | EmuleCompressedPart (md4, statpos, newsize, bloc) ->      | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
1082          lprintf "EmuleCompressedPart for %s %Ld %Ld len %d\n"          lprintf_nl "EmuleCompressedPart for %s %Ld %Ld len %d"
1083            (Md4.to_string md4) statpos newsize (String.length bloc)            (Md4.to_string md4) statpos newsize (String.length bloc)
1084                    
1085      | UnknownReq (opcode, s) ->        | UnknownReq (opcode, s) ->  
1086          let len = String.length s in          let len = String.length s in
1087          lprintf "UnknownReq: magic %d, opcode %d\n   len %d\n" opcode          lprintf_nl "UnknownReq: magic %d, opcode %d\n   len %d" opcode
1088          (int_of_char s.[0])          (int_of_char s.[0])
1089          (String.length s);          (String.length s);
1090          lprintf "ascii: [";          lprintf "ascii: [";
# Line 1098  let rec print t = Line 1096  let rec print t =
1096            else            else
1097              lprintf "(%d)" n              lprintf "(%d)" n
1098          done;          done;
1099          lprintf "]\n";          lprintf_nl "]";
1100          lprintf "dec: [";          lprintf "dec: [";
1101          for i = 0 to len - 1 do          for i = 0 to len - 1 do
1102            let c = s.[i] in            let c = s.[i] in
1103            let n = int_of_char c in            let n = int_of_char c in
1104            lprintf "(%d)" n                        lprintf "(%d)" n            
1105          done;          done;
1106          lprintf "]\n"          lprintf_nl "]"
1107    end    end
1108    
1109        
# Line 1182  let rec parse_emule_packet emule opcode Line 1180  let rec parse_emule_packet emule opcode
1180              | 0x81 (* 129 *) ->              | 0x81 (* 129 *) ->
1181                  (EmuleRequestSourcesReq md4) :: iter (pos+1)                  (EmuleRequestSourcesReq md4) :: iter (pos+1)
1182              | _ ->              | _ ->
1183                  lprintf "Unknown short emule packet %d\n" opcode;                  lprintf_nl "Unknown short emule packet %d" opcode;
1184                  raise Not_found                  raise Not_found
1185            else            else
1186              []              []
# Line 1215  let rec parse_emule_packet emule opcode Line 1213  let rec parse_emule_packet emule opcode
1213                    } in                    } in
1214                  (QueryChunksReplyReq q) :: (iter s pos len)                  (QueryChunksReplyReq q) :: (iter s pos len)
1215              | _ ->              | _ ->
1216                  lprintf  "Unknown packet in emule multipacket 0x93: %d\n" opcode;                  lprintf_nl "Unknown packet in emule multipacket 0x93: %d" opcode;
1217                  raise Not_found                  raise Not_found
1218            else            else
1219              []              []
# Line 1287  and parse emule_version magic s = Line 1285  and parse emule_version magic s =
1285            with            with
1286            | e ->            | e ->
1287                if !CommonOptions.verbose_unknown_messages then begin                if !CommonOptions.verbose_unknown_messages then begin
1288                    lprintf "Unknown message From client: %s (magic %d)\n"                    lprintf_nl "Unknown message From client: %s (magic %d)"
1289                      (Printexc2.to_string e) magic;                      (Printexc2.to_string e) magic;
1290                    let tmp_file = Filename.temp_file "comp" "pak" in                    let tmp_file = Filename.temp_file "comp" "pak" in
1291                    File.from_string tmp_file s;                    File.from_string tmp_file s;
1292                    lprintf "Saved unknown packet %s\n" tmp_file;                    lprintf_nl "Saved unknown packet %s" tmp_file;
                     
1293                    dump s;                    dump s;
1294                    lprint_newline ();                    lprintf_nl "";
1295                  end;                  end;
1296                UnknownReq (magic,s)                UnknownReq (magic,s)
1297                                
# Line 1310  and parse emule_version magic s = Line 1307  and parse emule_version magic s =
1307          UnknownReq s        *)          UnknownReq s        *)
1308      | _ ->      | _ ->
1309          if !CommonOptions.verbose_unknown_messages then          if !CommonOptions.verbose_unknown_messages then
1310              lprintf "Strange magic: %d\n" magic;              lprintf_nl "Strange magic: %d" magic;
1311          raise Not_found          raise Not_found
1312    with    with
1313    | e ->    | e ->
1314        if !CommonOptions.verbose_unknown_messages then begin        if !CommonOptions.verbose_unknown_messages then begin
1315            lprintf "Unknown message From client: %s (magic %d)\n"            lprintf_nl "Unknown message From client: %s (magic %d)"
1316                (Printexc2.to_string e) magic;                (Printexc2.to_string e) magic;
1317                       let tmp_file = Filename.temp_file "comp" "pak" in                       let tmp_file = Filename.temp_file "comp" "pak" in
1318               File.from_string tmp_file s;               File.from_string tmp_file s;
1319               lprintf "Saved unknown packet %s\n" tmp_file;               lprintf_nl "Saved unknown packet %s" tmp_file;
1320    
1321            dump s;            dump s;
1322            lprint_newline ();            lprintf_nl "";
1323          end;          end;
1324        UnknownReq (magic,s)        UnknownReq (magic,s)
1325        
# Line 1464  let write emule buf t = Line 1461  let write emule buf t =
1461              | EmuleRequestSourcesReq _ ->              | EmuleRequestSourcesReq _ ->
1462                  buf_int8 buf 0x81                  buf_int8 buf 0x81
1463              | _ ->              | _ ->
1464                  lprintf "WARNING: Don't know how to write short packet:\n";                  lprintf_nl "WARNING: Don't know how to write short packet:";
1465                  print t;                  print t;
1466                  print_newline ();                  print_newline ();
1467          ) list          ) list
# Line 1481  let write emule buf t = Line 1478  let write emule buf t =
1478                  buf_int8 buf 80;                  buf_int8 buf 80;
1479                  write_bitmap buf t.QueryChunksReply.chunks                  write_bitmap buf t.QueryChunksReply.chunks
1480              | _ ->              | _ ->
1481                  lprintf "WARNING: Don't know how to write short packet:\n";                  lprintf_nl "WARNING: Don't know how to write short packet:";
1482                  print t;                  print t;
1483                  print_newline ();                  print_newline ();
1484          ) list          ) list

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

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