Skip to content

Commit

Permalink
the buffer length is already checked, Macaddr.of_bytes_exn will never…
Browse files Browse the repository at this point in the history
… raise
  • Loading branch information
hannesm committed Mar 14, 2015
1 parent 1e3e291 commit fd86267
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/wire_structs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ let parse_ethernet_frame frame =
(* minimum payload is 46 + source + destination + type *)
let payload = Cstruct.shift frame sizeof_ethernet
and typ = get_ethernet_ethertype frame
and dst = Macaddr.of_bytes_exn (copy_ethernet_dst frame)
in
match Macaddr.of_bytes (copy_ethernet_dst frame) with
| Some destination_mac -> Some (int_to_ethertype typ, destination_mac, payload)
| None -> None
Some (int_to_ethertype typ, dst, payload)
else
None

Expand Down

0 comments on commit fd86267

Please sign in to comment.