Fix examples to use the new syntax.
authorRichard W.M. Jones <rich@annexia.org>
Sun, 18 May 2008 18:30:08 +0000 (18:30 +0000)
committerRichard W.M. Jones <rich@annexia.org>
Sun, 18 May 2008 18:30:08 +0000 (18:30 +0000)
examples/ipv4_header.ml
examples/make_ipv4_header.ml

index 40e130f..b3cf27e 100644 (file)
@@ -8,13 +8,13 @@ let header = Bitmatch.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;
@@ -33,9 +33,9 @@ let () =
     printf "  packet payload:\n";
     Bitmatch.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
index 9605647..329ccd3 100644 (file)
@@ -21,7 +21,7 @@ let payload_length = (length - hdrlen*4) * 8
 let payload = Bitmatch.create_bitstring payload_length
 
 let header =
-  BITSTRING
+  BITSTRING {
     version : 4; hdrlen : 4; tos : 8; length : 16;
     identification : 16; flags : 3; fragoffset : 13;
     ttl : 8; protocol : 8; checksum : 16;
@@ -29,5 +29,6 @@ let header =
     dest : 32;
     options : -1, bitstring;
     payload : payload_length, bitstring
+  }
 
 let () = Bitmatch.file_of_bitstring header "ipv4_header_out.dat"