/[mldonkey]/mldonkey/src/utils/net/ip.ml
ViewVC logotype

Diff of /mldonkey/src/utils/net/ip.ml

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

revision 1.17 by spiralvoice, Mon Sep 19 10:09:06 2005 UTC revision 1.18 by spiralvoice, Sun Oct 16 20:42:55 2005 UTC
# Line 17  Line 17 
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *)  *)
19    
20    open Int64ops
21  open Printf2  open Printf2
22  type t =  int * int * int * int  type t =  int * int * int * int
23    
# Line 49  let to_fixed_string ((a4, a3, a2, a1) as Line 50  let to_fixed_string ((a4, a3, a2, a1) as
50        Printf.sprintf "%03d.%03d.%03d.%03d" a4 a3 a2 a1        Printf.sprintf "%03d.%03d.%03d.%03d" a4 a3 a2 a1
51    
52  let to_int64  ((a4, a3, a2, a1) as t) =  let to_int64  ((a4, a3, a2, a1) as t) =
53    let small = a1 + 256 * (a2 + 256 * a3) in    let small = a1 lor (a2 lsl 8) lor (a3 lsl 16) in
54    Int64.add (Int64.of_int small) (Int64.shift_left (Int64.of_int a4) 24)    (Int64.of_int small) ++ (Int64.shift_left (Int64.of_int a4) 24)
   
 let const_int32_255 = Int64.of_int 255  
55    
56  let of_int64 i =  let of_int64 i =
57    let a4 = Int64.to_int (Int64.logand (Int64.shift_right i 24) const_int32_255)    let a4 = Int64.to_int (Int64.logand (Int64.shift_right i 24) 0xffL)
58    in    in
59    let a3 = Int64.to_int (Int64.logand (Int64.shift_right i 16) const_int32_255)    let a3 = Int64.to_int (Int64.logand (Int64.shift_right i 16) 0xffL)
60    in    in
61    let a2 = Int64.to_int (Int64.logand (Int64.shift_right i 8) const_int32_255)    let a2 = Int64.to_int (Int64.logand (Int64.shift_right i 8) 0xffL)
62    in    in
63    let a1 = Int64.to_int (Int64.logand i const_int32_255)    let a1 = Int64.to_int (Int64.logand i 0xffL)
64    in    in
65    (a4, a3, a2, a1)    (a4, a3, a2, a1)
66    

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

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