From b4bdefbe9be8d3d502db5e775aa85cd5c38463db Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Mon, 6 Feb 2017 19:27:17 +0100 Subject: prog, sys: add icmp descriptions and checksum --- sys/vnet.txt | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 184 insertions(+), 16 deletions(-) (limited to 'sys/vnet.txt') diff --git a/sys/vnet.txt b/sys/vnet.txt index 794103282..eee1ece19 100644 --- a/sys/vnet.txt +++ b/sys/vnet.txt @@ -247,7 +247,7 @@ ipv4_header { # TODO: frag_off is actually 13 bits, 3 bits are flags ttl int8 protocol flags[ipv4_types, int8] - csum csum[ipv4, int16be] + csum csum[inet, int16be] src_ip ipv4_addr dst_ip ipv4_addr options ipv4_options @@ -381,27 +381,14 @@ ipv6_packet_payload { ip_payload [ tcp tcp_packet udp udp_packet + icmp icmp_packet ] [varlen] -################################################################################ -###################################### UDP ##################################### -################################################################################ - -# https://tools.ietf.org/html/rfc768 -# https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure - -udp_packet { - src_port proc[int16be, 20000, 4] - dst_port proc[int16be, 20000, 4] - length len[parent, int16be] - csum csum[udp, int16be] - data array[int8] -} [packed] - ################################################################################ ###################################### TCP ##################################### ################################################################################ +# https://tools.ietf.org/html/rfc793#section-3.1 # https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure # http://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml @@ -526,3 +513,184 @@ tcp_packet { tcp_payload { payload array[int8] } [packed] + +################################################################################ +###################################### UDP ##################################### +################################################################################ + +# https://tools.ietf.org/html/rfc768 +# https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure + +udp_packet { + src_port proc[int16be, 20000, 4] + dst_port proc[int16be, 20000, 4] + length len[parent, int16be] + csum csum[udp, int16be] + data array[int8] +} [packed] + +################################################################################ +###################################### ICMP #################################### +################################################################################ + +# https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#ICMP_datagram_structure +# https://tools.ietf.org/html/rfc792 + +include + +icmp_ipv4_header { + ihl bytesize4[parent, int8:4] + version const[4, int8:4] + ecn int8:2 + dscp int8:6 + total_len int16be + id int16be + frag_off int16be + ttl int8 + protocol flags[ipv4_types, int8] + csum int16be + src_ip ipv4_addr + dst_ip ipv4_addr + options ipv4_options +} [packed] + +icmp_echo_reply_packet { + type const[ICMP_ECHOREPLY, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be + data array[int8] +} [packed] + +icmp_dest_unreach_codes = ICMP_NET_UNREACH, ICMP_HOST_UNREACH, ICMP_PROT_UNREACH, ICMP_PORT_UNREACH, ICMP_FRAG_NEEDED, ICMP_SR_FAILED, ICMP_NET_UNKNOWN, ICMP_HOST_UNKNOWN, ICMP_HOST_ISOLATED, ICMP_NET_ANO, ICMP_HOST_ANO, ICMP_NET_UNR_TOS, ICMP_HOST_UNR_TOS, ICMP_PKT_FILTERED, ICMP_PREC_VIOLATION, ICMP_PREC_CUTOFF + +icmp_dest_unreach_packet { + type const[ICMP_DEST_UNREACH, int8] + code flags[icmp_dest_unreach_codes, int8] + csum csum[inet, int16be] + unused const[0, int16] + mtu int16be + iph icmp_ipv4_header + data array[int8, 0:8] +} [packed] + +icmp_source_quench_packet { + type const[ICMP_SOURCE_QUENCH, int8] + code const[0, int8] + csum csum[inet, int16be] + unused const[0, int32] + iph icmp_ipv4_header + data array[int8, 0:8] +} [packed] + +icmp_redirect_codes = ICMP_REDIR_NET, ICMP_REDIR_HOST, ICMP_REDIR_NETTOS, ICMP_REDIR_HOSTTOS + +icmp_redirect_packet { + type const[ICMP_REDIRECT, int8] + code flags[icmp_redirect_codes, int8] + csum csum[inet, int16be] + ip ipv4_addr + iph icmp_ipv4_header + data array[int8, 0:8] +} [packed] + +icmp_echo_packet { + type const[ICMP_ECHO, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be + data array[int8] +} [packed] + +icmp_time_exceeded_codes = ICMP_EXC_TTL, ICMP_EXC_FRAGTIME + +icmp_time_exceeded_packet { + type const[ICMP_TIME_EXCEEDED, int8] + code flags[icmp_time_exceeded_codes, int8] + csum csum[inet, int16be] + unsed const[0, int32] + iph icmp_ipv4_header + data array[int8, 0:8] +} [packed] + +icmp_parameter_prob_packet { + type const[ICMP_PARAMETERPROB, int8] + code const[0, int8] + csum csum[inet, int16be] + pointer int8 + unsed array[const[0, int8], 3] + iph icmp_ipv4_header + data array[int8, 0:8] +} [packed] + +icmp_timestamp_packet { + type const[ICMP_TIMESTAMP, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be + orig_ts int32be + recv_ts int32be + trans_ts int32be +} [packed] + +icmp_timestamp_reply_packet { + type const[ICMP_TIMESTAMPREPLY, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be + orig_ts int32be + recv_ts int32be + trans_ts int32be +} [packed] + +icmp_info_request_packet { + type const[ICMP_INFO_REQUEST, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be +} [packed] + +icmp_info_reply_packet { + type const[ICMP_INFO_REPLY, int8] + code const[0, int8] + csum csum[inet, int16be] + id int16be + seq_num int16be +} [packed] + +icmp_address_request_packet { + type const[ICMP_ADDRESS, int8] + code const[0, int8] + csum csum[inet, int16be] + mask int32be +} [packed] + +icmp_address_reply_packet { + type const[ICMP_ADDRESSREPLY, int8] + code const[0, int8] + csum csum[inet, int16be] + mask int32be +} [packed] + +icmp_types = ICMP_ECHOREPLY, ICMP_DEST_UNREACH, ICMP_SOURCE_QUENCH, ICMP_REDIRECT, ICMP_ECHO, ICMP_TIME_EXCEEDED, ICMP_PARAMETERPROB, ICMP_TIMESTAMP, ICMP_TIMESTAMPREPLY, ICMP_INFO_REQUEST, ICMP_INFO_REPLY, ICMP_ADDRESS, ICMP_ADDRESSREPLY + +icmp_packet [ + echo_reply icmp_echo_reply_packet + dest_unreach icmp_dest_unreach_packet + source_quench icmp_source_quench_packet + redirect icmp_redirect_packet + echo icmp_echo_packet + time_exceeded icmp_time_exceeded_packet + parameter_prob icmp_parameter_prob_packet + timestamp icmp_timestamp_packet + timestamp_reply icmp_timestamp_reply_packet + info_request icmp_info_request_packet + info_reply icmp_info_reply_packet + address_request icmp_address_request_packet + address_reply icmp_address_reply_packet +] [varlen] -- cgit mrf-deployment