Skip to content

Commit

Permalink
Update the Unix code (including tests) to the new Cstruct interface
Browse files Browse the repository at this point in the history
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
  • Loading branch information
David Scott committed Jul 25, 2013
1 parent 711d398 commit 1abfb8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib_test/test.ml
Expand Up @@ -24,7 +24,8 @@ let example_file = "lib_test/dhcp.pcap"

let open_file filename =
let fd = Unix.(openfile filename [O_RDONLY] 0) in
Bigarray.(Array1.map_file fd Bigarray.char c_layout false (-1))
let ba = Bigarray.(Array1.map_file fd Bigarray.char c_layout false (-1)) in
Cstruct.of_bigarray ba

let read_header filename =
let buf = open_file filename in
Expand Down
1 change: 1 addition & 0 deletions print/print.ml
Expand Up @@ -119,6 +119,7 @@ let parse filename =
printf "filename: %s\n" filename;
let fd = Unix.(openfile filename [O_RDONLY] 0) in
let buf = Bigarray.(Array1.map_file fd Bigarray.char c_layout false (-1)) in
let buf = Cstruct.of_bigarray buf in
printf "total pcap file length %d\n" (Cstruct.len buf);

let header, body = Cstruct.split buf sizeof_pcap_header in
Expand Down

0 comments on commit 1abfb8a

Please sign in to comment.