Skip to content

Instantly share code, notes, and snippets.

@tudang
Last active October 28, 2015 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tudang/ae45cee1f8d59f09c4c6 to your computer and use it in GitHub Desktop.
Save tudang/ae45cee1f8d59f09c4c6 to your computer and use it in GitHub Desktop.
header fields for udp checksum
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