Last active
October 28, 2015 07:41
-
-
Save tudang/ae45cee1f8d59f09c4c6 to your computer and use it in GitHub Desktop.
header fields for udp checksum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header_type udp_t { | |
fields { | |
srcPort : 16; | |
dstPort : 16; | |
length_ : 16; | |
checksum : 16; | |
} | |
} | |
header udp_t udp; | |
field_list udp_checksum_list { | |
ipv4.srcAddr; | |
ipv4.dstAddr; | |
8'0; | |
ipv4.protocol; | |
udp.length_; | |
udp.srcPort; | |
udp.dstPort; | |
payload; | |
} | |
field_list_calculation udp_checksum { | |
input { | |
udp_checksum_list; | |
} | |
algorithm : csum16; | |
output_width : 16; | |
} | |
calculated_field udp.checksum { | |
update udp_checksum if (valid(udp)); | |
} | |
header_type custom_head_t { | |
fields { | |
round : 2; | |
} | |
} | |
header custom_head_t custom_header; | |
action mod_payload() { | |
add_to_field(custom_header.round, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment