Skip to content
Snippets Groups Projects
Commit 76411965 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

update embeded decision

parent 51ba2345
No related branches found
No related tags found
No related merge requests found
......@@ -268,16 +268,21 @@ module Main
| true ->
let options = ipv4_hdr.options in
let custom_opt = Custom_option.init in
Custom_option.add_entry custom_opt (Int32.of_int 0) 255 255;
Custom_option.add_entry custom_opt (Int32.of_int 0) 255 0;
let custom_opt_cs = Custom_option.of_cstruct custom_opt in
let len_option_cs = Cstruct.length custom_opt_cs in
match Cstruct.length options with
| 0 -> (
let new_ipv4_hdr = {ipv4_hdr with options= Custom_option.of_cstruct custom_opt} in
let new_packet = Ipv4_packet.Marshal.make_cstruct ~payload_len:10 new_ipv4_hdr in
let new_ipv4_hdr = {ipv4_hdr with options= custom_opt_cs} in
let len_new_ipv4_hdr = 20 + len_option_cs in
let new_packet = Ipv4_packet.Marshal.make_cstruct ~payload_len:len_new_ipv4_hdr new_ipv4_hdr in
output_ether_private4 header.Ethernet.Packet.source header.Ethernet.Packet.destination new_packet)
| _ -> (
let len_old_option_cs = Cstruct.length ipv4_hdr.options in
let len_new_ipv4_hdr = 20 + len_option_cs +len_old_option_cs in
let new_ipv4_hdr = {ipv4_hdr with options= Cstruct.append ipv4_hdr.options (Custom_option.of_cstruct custom_opt)} in
let new_packet = Ipv4_packet.Marshal.make_cstruct ~payload_len:10 new_ipv4_hdr in
let new_packet = Ipv4_packet.Marshal.make_cstruct ~payload_len:len_new_ipv4_hdr new_ipv4_hdr in
output_ether_private4 header.Ethernet.Packet.source header.Ethernet.Packet.destination new_packet)
in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment