X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=examples%2Fipv4_header.ml;h=e47de03f36acaabd97d9db872d76fbc957f91f67;hb=64bcd448dc8787b82828a49edb709436ec2de93d;hp=40e130f023825a6359bb7fc6c896218820223cd1;hpb=af6d23836ec72aefe4bb765c2af41d89c77677a6;p=ocaml-bitstring.git diff --git a/examples/ipv4_header.ml b/examples/ipv4_header.ml index 40e130f..e47de03 100644 --- a/examples/ipv4_header.ml +++ b/examples/ipv4_header.ml @@ -1,20 +1,20 @@ (* Parse and display an IPv4 header from a file. - * $Id: ipv4_header.ml,v 1.2 2008-04-01 17:31:12 rjones Exp $ + * $Id$ *) open Printf -let header = Bitmatch.bitstring_of_file "ipv4_header.dat" +let header = Bitstring.bitstring_of_file "ipv4_header.dat" let () = bitmatch header with - | version : 4; hdrlen : 4; tos : 8; length : 16; - identification : 16; flags : 3; fragoffset : 13; - ttl : 8; protocol : 8; checksum : 16; - source : 32; - dest : 32; - options : (hdrlen-5)*32 : bitstring; - payload : -1 : bitstring + | { version : 4; hdrlen : 4; tos : 8; length : 16; + identification : 16; flags : 3; fragoffset : 13; + ttl : 8; protocol : 8; checksum : 16; + source : 32; + dest : 32; + options : (hdrlen-5)*32 : bitstring; + payload : -1 : bitstring } when version = 4 -> printf "IPv%d:\n" version; @@ -29,13 +29,13 @@ let () = printf " checksum: %d\n" checksum; printf " source: %lx dest: %lx\n" source dest; printf " header options + padding:\n"; - Bitmatch.hexdump_bitstring stdout options; + Bitstring.hexdump_bitstring stdout options; printf " packet payload:\n"; - Bitmatch.hexdump_bitstring stdout payload + Bitstring.hexdump_bitstring stdout payload - | version : 4 -> + | { version : 4 } -> eprintf "cannot parse IP version %d\n" version - | _ as header -> + | { _ } as header -> eprintf "data is smaller than one nibble:\n"; - Bitmatch.hexdump_bitstring stderr header + Bitstring.hexdump_bitstring stderr header