github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/freebsd/vnet.txt (about) 1 # Copyright 2017 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 include <sys/types.h> 5 include <sys/param.h> 6 include <sys/socket.h> 7 include <net/ethernet.h> 8 include <net/if_arp.h> 9 include <netinet/in.h> 10 include <netinet/ip.h> 11 include <netinet/ip_icmp.h> 12 include <netinet/ip6.h> 13 include <netinet/icmp6.h> 14 include <netinet/tcp.h> 15 16 syz_emit_ethernet(len len[packet], packet ptr[in, eth_packet]) 17 18 hop_limits = 0, 1, 255 19 20 resource tcp_seq_num[int32]: 0x41424344 21 22 tcp_resources { 23 seq tcp_seq_num 24 ack tcp_seq_num 25 } 26 27 # These pseudo syscalls read a packet from tap device and extract tcp sequence and acknowledgement numbers from it. 28 # They also adds the inc arguments to the returned values, this way sequence numbers get incremented. 29 syz_extract_tcp_res(res ptr[out, tcp_resources], seq_inc int32, ack_inc int32) 30 syz_extract_tcp_res$synack(res ptr[out, tcp_resources], seq_inc const[1], ack_inc const[0]) 31 32 ################################################################################ 33 ################################### Ethernet ################################### 34 ################################################################################ 35 36 # https://en.wikipedia.org/wiki/Ethernet_frame#Structure 37 # https://en.wikipedia.org/wiki/IEEE_802.1Q 38 39 type mac_addr_t[LAST] { 40 a0 array[const[0xaa, int8], 5] 41 a1 LAST 42 } [packed] 43 44 mac_addr [ 45 empty array[const[0x0, int8], 6] 46 local mac_addr_t[const[0xaa, int8]] 47 remote mac_addr_t[const[0xbb, int8]] 48 broadcast array[const[0xff, int8], 6] 49 random array[int8, 6] 50 ] 51 52 vlan_tag_ad { 53 tpid const[ETHERTYPE_QINQ, int16be] 54 pcp int16:3 55 dei int16:1 56 vid int16:12[0:4] 57 } [packed] 58 59 vlan_tag_q { 60 tpid const[ETHERTYPE_VLAN, int16be] 61 pcp int16:3 62 dei int16:1 63 vid int16:12[0:4] 64 } [packed] 65 66 vlan_tag { 67 tag_ad array[vlan_tag_ad, 0:1] 68 tag_q vlan_tag_q 69 } [packed] 70 71 eth_packet { 72 dst_mac mac_addr 73 src_mac mac_addr 74 vtag array[vlan_tag, 0:1] 75 payload eth_payload 76 } [packed] 77 78 eth_payload { 79 eth2 eth2_packet 80 } [packed] 81 82 ################################################################################ 83 ################################## Ethernet 2 ################################## 84 ################################################################################ 85 86 # https://en.wikipedia.org/wiki/Ethernet_frame#Ethernet_II 87 88 ether_types = ETHERTYPE_8023, ETHERTYPE_PUP, ETHERTYPE_PUPAT, ETHERTYPE_SPRITE, ETHERTYPE_NS, ETHERTYPE_NSAT, ETHERTYPE_DLOG1, ETHERTYPE_DLOG2, ETHERTYPE_IP, ETHERTYPE_X75, ETHERTYPE_NBS, ETHERTYPE_ECMA, ETHERTYPE_CHAOS, ETHERTYPE_X25, ETHERTYPE_ARP, ETHERTYPE_NSCOMPAT, ETHERTYPE_FRARP, ETHERTYPE_UBDEBUG, ETHERTYPE_IEEEPUP, ETHERTYPE_IEEEPUPAT, ETHERTYPE_VINES, ETHERTYPE_VINESLOOP, ETHERTYPE_VINESECHO, ETHERTYPE_DCA, ETHERTYPE_VALID, ETHERTYPE_DOGFIGHT, ETHERTYPE_RCL, ETHERTYPE_NBPVCD, ETHERTYPE_NBPSCD, ETHERTYPE_NBPCREQ, ETHERTYPE_NBPCRSP, ETHERTYPE_NBPCC, ETHERTYPE_NBPCLREQ, ETHERTYPE_NBPCLRSP, ETHERTYPE_NBPDG, ETHERTYPE_NBPDGB, ETHERTYPE_NBPCLAIM, ETHERTYPE_NBPDLTE, ETHERTYPE_NBPRAS, ETHERTYPE_NBPRAR, ETHERTYPE_NBPRST, ETHERTYPE_PCS, ETHERTYPE_IMLBLDIAG, ETHERTYPE_DIDDLE, ETHERTYPE_IMLBL, ETHERTYPE_SIMNET, ETHERTYPE_DECEXPER, ETHERTYPE_MOPDL, ETHERTYPE_MOPRC, ETHERTYPE_DECnet, ETHERTYPE_LAT, ETHERTYPE_DECDIAG, ETHERTYPE_DECCUST, ETHERTYPE_SCA, ETHERTYPE_AMBER, ETHERTYPE_DECMUMPS, ETHERTYPE_TRANSETHER, ETHERTYPE_RAWFR, ETHERTYPE_UBDL, ETHERTYPE_UBNIU, ETHERTYPE_UBDIAGLOOP, ETHERTYPE_UBNMC, ETHERTYPE_UBBST, ETHERTYPE_OS9, ETHERTYPE_OS9NET, ETHERTYPE_RACAL, ETHERTYPE_PRIMENTS, ETHERTYPE_CABLETRON, ETHERTYPE_CRONUSVLN, ETHERTYPE_CRONUS, ETHERTYPE_HP, ETHERTYPE_NESTAR, ETHERTYPE_ATTSTANFORD, ETHERTYPE_EXCELAN, ETHERTYPE_SG_DIAG, ETHERTYPE_SG_NETGAMES, ETHERTYPE_SG_RESV, ETHERTYPE_SG_BOUNCE, ETHERTYPE_APOLLODOMAIN, ETHERTYPE_TYMSHARE, ETHERTYPE_TIGAN, ETHERTYPE_REVARP, ETHERTYPE_AEONIC, ETHERTYPE_IPXNEW, ETHERTYPE_LANBRIDGE, ETHERTYPE_DSMD, ETHERTYPE_ARGONAUT, ETHERTYPE_VAXELN, ETHERTYPE_DECDNS, ETHERTYPE_ENCRYPT, ETHERTYPE_DECDTS, ETHERTYPE_DECLTM, ETHERTYPE_DECNETBIOS, ETHERTYPE_DECLAST, ETHERTYPE_PLANNING, ETHERTYPE_DECAM, ETHERTYPE_EXPERDATA, ETHERTYPE_VEXP, ETHERTYPE_VPROD, ETHERTYPE_ES, ETHERTYPE_LITTLE, ETHERTYPE_COUNTERPOINT, ETHERTYPE_VEECO, ETHERTYPE_GENDYN, ETHERTYPE_ATT, ETHERTYPE_AUTOPHON, ETHERTYPE_COMDESIGN, ETHERTYPE_COMPUGRAPHIC, ETHERTYPE_MATRA, ETHERTYPE_DDE, ETHERTYPE_MERIT, ETHERTYPE_VLTLMAN, ETHERTYPE_ATALK, ETHERTYPE_SPIDER, ETHERTYPE_PACER, ETHERTYPE_APPLITEK, ETHERTYPE_SNA, ETHERTYPE_VARIAN, ETHERTYPE_RETIX, ETHERTYPE_AARP, ETHERTYPE_APOLLO, ETHERTYPE_VLAN, ETHERTYPE_BOFL, ETHERTYPE_WELLFLEET, ETHERTYPE_TALARIS, ETHERTYPE_WATERLOO, ETHERTYPE_HAYES, ETHERTYPE_VGLAB, ETHERTYPE_IPX, ETHERTYPE_NOVELL, ETHERTYPE_MUMPS, ETHERTYPE_AMOEBA, ETHERTYPE_FLIP, ETHERTYPE_VURESERVED, ETHERTYPE_LOGICRAFT, ETHERTYPE_NCD, ETHERTYPE_ALPHA, ETHERTYPE_SNMP, ETHERTYPE_TEC, ETHERTYPE_RATIONAL, ETHERTYPE_XTP, ETHERTYPE_SGITW, ETHERTYPE_HIPPI_FP, ETHERTYPE_STP, ETHERTYPE_MOTOROLA, ETHERTYPE_NETBEUI, ETHERTYPE_ACCTON, ETHERTYPE_TALARISMC, ETHERTYPE_KALPANA, ETHERTYPE_SECTRA, ETHERTYPE_IPV6, ETHERTYPE_DELTACON, ETHERTYPE_ATOMIC, ETHERTYPE_RDP, ETHERTYPE_MICP, ETHERTYPE_TCPCOMP, ETHERTYPE_IPAS, ETHERTYPE_SECUREDATA, ETHERTYPE_FLOWCONTROL, ETHERTYPE_SLOW, ETHERTYPE_PPP, ETHERTYPE_HITACHI, ETHERTYPE_TEST, ETHERTYPE_MPLS, ETHERTYPE_MPLS_MCAST, ETHERTYPE_AXIS, ETHERTYPE_PPPOEDISC, ETHERTYPE_PPPOE, ETHERTYPE_LANPROBE, ETHERTYPE_PAE, ETHERTYPE_QINQ, ETHERTYPE_LOOPBACK, ETHERTYPE_XNSSM, ETHERTYPE_TCPSM, ETHERTYPE_BCLOOP, ETHERTYPE_DEBNI, ETHERTYPE_SONIX, ETHERTYPE_VITAL 89 90 eth2_packet [ 91 generic eth2_packet_generic 92 arp eth2_packet_t[ETHERTYPE_ARP, arp_packet] 93 ipv4 eth2_packet_t[ETHERTYPE_IP, ipv4_packet] 94 ipv6 eth2_packet_t[ETHERTYPE_IPV6, ipv6_packet_t] 95 ] [varlen] 96 97 eth2_packet_generic { 98 etype flags[ether_types, int16be] 99 payload array[int8] 100 } [packed] 101 102 type eth2_packet_t[TYPE, PAYLOAD] { 103 etype const[TYPE, int16be] 104 payload PAYLOAD 105 } [packed] 106 107 ################################################################################ 108 ###################################### ARP ##################################### 109 ################################################################################ 110 111 # https://en.wikipedia.org/wiki/Address_Resolution_Protocol#Packet_structure 112 # https://tools.ietf.org/html/rfc826 113 114 arp_hrds = ARPHRD_ETHER, ARPHRD_IEEE802, ARPHRD_FRELAY, ARPHRD_IEEE1394, ARPHRD_INFINIBAND 115 116 arp_ops = ARPOP_REQUEST, ARPOP_REPLY, ARPOP_REVREQUEST, ARPOP_REVREPLY, ARPOP_INVREQUEST, ARPOP_INVREPLY 117 118 arp_generic_packet { 119 ar_hrd flags[arp_hrds, int16be] 120 ar_pro flags[ether_types, int16be] 121 ar_hln const[6, int8] 122 ar_pln len[ar_spa, int8] 123 ar_op flags[arp_ops, int16be] 124 ar_sha mac_addr 125 ar_spa array[int8, 0:16] 126 ar_tha mac_addr 127 ar_tpa array[int8, 16] 128 } [packed] 129 130 arp_ether_ipv4_packet { 131 ar_hrd const[ARPHRD_ETHER, int16be] 132 ar_pro const[ETHERTYPE_IP, int16be] 133 ar_hln const[6, int8] 134 ar_pln const[4, int8] 135 ar_op flags[arp_ops, int16be] 136 ar_sha mac_addr 137 ar_spa ipv4_addr 138 ar_tha mac_addr 139 ar_tpa ipv4_addr 140 } [packed] 141 142 arp_packet [ 143 generic arp_generic_packet 144 ether_ipv4 arp_ether_ipv4_packet 145 ] [varlen] 146 147 ################################################################################ 148 ##################################### IPv4 ##################################### 149 ################################################################################ 150 151 # https://tools.ietf.org/html/rfc791#section-3.1 152 # https://en.wikipedia.org/wiki/IPv4#Header 153 154 # This corresponds to LOCAL_IPV4 ("172.20.%d.170" % pid) in executor/common_bsd.h 155 ipv4_addr_local { 156 a0 const[0xac, int8] 157 a1 const[0x14, int8] 158 a2 proc[0, 1, int8] 159 a3 const[0xaa, int8] 160 } [packed] 161 162 # This corresponds to LOCAL_IPV4 ("172.20.%d.187" % pid) in executor/common_bsd.h 163 ipv4_addr_remote { 164 a0 const[0xac, int8] 165 a1 const[0x14, int8] 166 a2 proc[0, 1, int8] 167 a3 const[0xbb, int8] 168 } [packed] 169 170 ipv4_addr [ 171 # 0.0.0.0 172 empty const[0x0, int32be] 173 # 172.20.%d.170 174 local ipv4_addr_local 175 # 172.20.%d.187 176 remote ipv4_addr_remote 177 # 127.0.0.1 178 loopback const[0x7f000001, int32be] 179 # 224.0.0.1 180 multicast1 const[0xe0000001, int32be] 181 # 224.0.0.2 182 multicast2 const[0xe0000002, int32be] 183 # 255.255.255.255 184 broadcast const[0xffffffff, int32be] 185 # random 186 rand_addr int32be 187 ] 188 189 # http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-1 190 ipv4_option [ 191 generic ipv4_option_generic 192 end ipv4_option_end 193 noop ipv4_option_noop 194 lsrr ipv4_option_lsrr 195 ssrr ipv4_option_ssrr 196 rr ipv4_option_rr 197 timestamp ipv4_option_timestamp 198 ra ipv4_option_ra 199 ] [varlen] 200 201 ipv4_option_types = IPOPT_EOL, IPOPT_NOP, IPOPT_RR, IPOPT_TS, IPOPT_SECURITY, IPOPT_LSRR, IPOPT_ESO, IPOPT_CIPSO, IPOPT_SATID, IPOPT_SSRR, IPOPT_RA 202 203 ipv4_option_generic { 204 type flags[ipv4_option_types, int8] 205 length len[parent, int8] 206 data array[int8, 0:16] 207 } [packed] 208 209 # https://tools.ietf.org/html/rfc791#section-3.1 210 ipv4_option_end { 211 type const[IPOPT_EOL, int8] 212 } [packed] 213 214 # https://tools.ietf.org/html/rfc791#section-3.1 215 ipv4_option_noop { 216 type const[IPOPT_NOP, int8] 217 } [packed] 218 219 # https://tools.ietf.org/html/rfc791#section-3.1 220 ipv4_option_lsrr { 221 type const[IPOPT_LSRR, int8] 222 length len[parent, int8] 223 pointer int8 224 data array[ipv4_addr] 225 } [packed] 226 227 # https://tools.ietf.org/html/rfc791#section-3.1 228 ipv4_option_ssrr { 229 type const[IPOPT_SSRR, int8] 230 length len[parent, int8] 231 pointer int8 232 data array[ipv4_addr] 233 } [packed] 234 235 # https://tools.ietf.org/html/rfc791#section-3.1 236 ipv4_option_rr { 237 type const[IPOPT_RR, int8] 238 length len[parent, int8] 239 pointer int8 240 data array[ipv4_addr] 241 } [packed] 242 243 ipv4_option_timestamp_flags = IPOPT_TS_TSONLY, IPOPT_TS_TSANDADDR, IPOPT_TS_PRESPEC 244 245 ipv4_option_timestamp_timestamp { 246 addr array[ipv4_addr, 0:1] 247 timestamp int32be 248 } [packed] 249 250 # https://tools.ietf.org/html/rfc791#section-3.1 251 # http://www.networksorcery.com/enp/protocol/ip/option004.htm 252 ipv4_option_timestamp { 253 type const[IPOPT_TS, int8] 254 length len[parent, int8] 255 pointer int8 256 flg flags[ipv4_option_timestamp_flags, int8:4] 257 oflw int8:4 258 timestamps array[ipv4_option_timestamp_timestamp] 259 } [packed] 260 261 # https://tools.ietf.org/html/rfc2113 262 ipv4_option_ra { 263 type const[IPOPT_RA, int8] 264 length len[parent, int8] 265 value int32be 266 } [packed] 267 268 ipv4_options { 269 options array[ipv4_option] 270 } [packed, align[4]] 271 272 ipv4_types = IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_IPV4, IPPROTO_TCP, IPPROTO_ST, IPPROTO_EGP, IPPROTO_PIGP, IPPROTO_RCCMON, IPPROTO_NVPII, IPPROTO_PUP, IPPROTO_ARGUS, IPPROTO_EMCON, IPPROTO_XNET, IPPROTO_CHAOS, IPPROTO_UDP, IPPROTO_MUX, IPPROTO_MEAS, IPPROTO_HMP, IPPROTO_PRM, IPPROTO_IDP, IPPROTO_TRUNK1, IPPROTO_TRUNK2, IPPROTO_LEAF1, IPPROTO_LEAF2, IPPROTO_RDP, IPPROTO_IRTP, IPPROTO_TP, IPPROTO_BLT, IPPROTO_NSP, IPPROTO_INP, IPPROTO_DCCP, IPPROTO_3PC, IPPROTO_IDPR, IPPROTO_XTP, IPPROTO_DDP, IPPROTO_CMTP, IPPROTO_TPXX, IPPROTO_IL, IPPROTO_SDRP, IPPROTO_IDRP, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_MHRP, IPPROTO_BHA, IPPROTO_ESP, IPPROTO_AH, IPPROTO_INLSP, IPPROTO_SWIPE, IPPROTO_NHRP, IPPROTO_MOBILE, IPPROTO_TLSP, IPPROTO_SKIP, IPPROTO_AHIP, IPPROTO_CFTP, IPPROTO_HELLO, IPPROTO_SATEXPAK, IPPROTO_KRYPTOLAN, IPPROTO_RVD, IPPROTO_IPPC, IPPROTO_ADFS, IPPROTO_SATMON, IPPROTO_VISA, IPPROTO_IPCV, IPPROTO_CPNX, IPPROTO_CPHB, IPPROTO_WSN, IPPROTO_PVP, IPPROTO_BRSATMON, IPPROTO_ND, IPPROTO_WBMON, IPPROTO_WBEXPAK, IPPROTO_EON, IPPROTO_VMTP, IPPROTO_SVMTP, IPPROTO_VINES, IPPROTO_TTP, IPPROTO_IGP, IPPROTO_DGP, IPPROTO_TCF, IPPROTO_IGRP, IPPROTO_OSPFIGP, IPPROTO_SRPC, IPPROTO_LARP, IPPROTO_MTP, IPPROTO_AX25, IPPROTO_IPEIP, IPPROTO_MICP, IPPROTO_SCCSP, IPPROTO_ETHERIP, IPPROTO_ENCAP, IPPROTO_APES, IPPROTO_GMTP, IPPROTO_IPCOMP, IPPROTO_IPCOMP, IPPROTO_MH, IPPROTO_UDPLITE, IPPROTO_HIP, IPPROTO_SHIM6, IPPROTO_PIM, IPPROTO_CARP, IPPROTO_PGM, IPPROTO_MPLS, IPPROTO_PFSYNC 273 274 ipv4_header { 275 ihl bytesize4[parent, int8:4] 276 version const[4, int8:4] 277 ecn int8:2 278 dscp int8:6 279 total_len len[ipv4_packet, int16be] 280 id int16be[100:104] 281 frag_off int16be 282 # TODO: frag_off is actually 13 bits, 3 bits are flags 283 ttl int8 284 protocol flags[ipv4_types, int8] 285 csum csum[parent, inet, int16be] 286 src_ip ipv4_addr 287 dst_ip ipv4_addr 288 options ipv4_options 289 } [packed] 290 291 ipv4_packet { 292 header ipv4_header 293 payload ipv4_payload 294 } [packed] 295 296 ipv4_payload [ 297 generic array[int8] 298 tcp tcp_packet 299 udp udp_packet 300 icmp icmp_packet 301 ] [varlen] 302 303 ################################################################################ 304 ###################################### ICMP #################################### 305 ################################################################################ 306 307 # https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#ICMP_datagram_structure 308 # https://tools.ietf.org/html/rfc792 309 # https://tools.ietf.org/html/rfc4884#section-4.1 310 # http://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml 311 312 icmp_ipv4_header { 313 ihl bytesize4[parent, int8:4] 314 version const[4, int8:4] 315 ecn int8:2 316 dscp int8:6 317 total_len int16be 318 id icmp_id 319 frag_off int16be 320 ttl int8 321 protocol flags[ipv4_types, int8] 322 csum int16be 323 src_ip ipv4_addr 324 dst_ip ipv4_addr 325 options ipv4_options 326 } [packed] 327 328 icmp_types = ICMP_ECHOREPLY, ICMP_UNREACH, ICMP_SOURCEQUENCH, ICMP_REDIRECT, ICMP_ALTHOSTADDR, ICMP_ECHO, ICMP_ROUTERADVERT, ICMP_ROUTERSOLICIT, ICMP_TIMXCEED, ICMP_PARAMPROB, ICMP_TSTAMP, ICMP_TSTAMPREPLY, ICMP_IREQ, ICMP_IREQREPLY, ICMP_MASKREQ, ICMP_MASKREPLY, ICMP_TRACEROUTE, ICMP_DATACONVERR, ICMP_MOBILE_REDIRECT, ICMP_IPV6_WHEREAREYOU, ICMP_IPV6_IAMHERE, ICMP_MOBILE_REGREQUEST, ICMP_MOBILE_REGREPLY, ICMP_SKIP, ICMP_PHOTURIS 329 330 icmp_generic_packet { 331 type flags[icmp_types, int8] 332 code int8 333 csum csum[parent, inet, int16be] 334 data array[int8] 335 } [packed] 336 337 icmp_echo_reply_packet { 338 type const[ICMP_ECHOREPLY, int8] 339 code const[0, int8] 340 csum csum[parent, inet, int16be] 341 id icmp_id 342 seq_num int16be 343 data array[int8] 344 } [packed] 345 346 type icmp_id int16be[100:104] 347 348 icmp_dest_unreach_codes = ICMP_UNREACH_NET, ICMP_UNREACH_HOST, ICMP_UNREACH_PROTOCOL, ICMP_UNREACH_PORT, ICMP_UNREACH_NEEDFRAG, ICMP_UNREACH_SRCFAIL, ICMP_UNREACH_NET_UNKNOWN, ICMP_UNREACH_HOST_UNKNOWN, ICMP_UNREACH_ISOLATED, ICMP_UNREACH_NET_PROHIB, ICMP_UNREACH_HOST_PROHIB, ICMP_UNREACH_TOSNET, ICMP_UNREACH_TOSHOST, ICMP_UNREACH_FILTER_PROHIB, ICMP_UNREACH_HOST_PRECEDENCE, ICMP_UNREACH_PRECEDENCE_CUTOFF 349 350 icmp_dest_unreach_packet { 351 type const[ICMP_UNREACH, int8] 352 code flags[icmp_dest_unreach_codes, int8] 353 csum csum[parent, inet, int16be] 354 unused const[0, int8] 355 length int8 356 mtu int16be 357 iph icmp_ipv4_header 358 data array[int8, 0:8] 359 } [packed] 360 361 icmp_source_quench_packet { 362 type const[ICMP_SOURCEQUENCH, int8] 363 code const[0, int8] 364 csum csum[parent, inet, int16be] 365 unused const[0, int32] 366 iph icmp_ipv4_header 367 data array[int8, 0:8] 368 } [packed] 369 370 icmp_redirect_codes = ICMP_REDIRECT_NET, ICMP_REDIRECT_HOST, ICMP_REDIRECT_TOSNET, ICMP_REDIRECT_TOSHOST 371 372 icmp_redirect_packet { 373 type const[ICMP_REDIRECT, int8] 374 code flags[icmp_redirect_codes, int8] 375 csum csum[parent, inet, int16be] 376 ip ipv4_addr 377 iph icmp_ipv4_header 378 data array[int8, 0:8] 379 } [packed] 380 381 icmp_echo_packet { 382 type const[ICMP_ECHO, int8] 383 code const[0, int8] 384 csum csum[parent, inet, int16be] 385 id int16be 386 seq_num int16be 387 data array[int8] 388 } [packed] 389 390 icmp_time_exceeded_codes = ICMP_TIMXCEED_INTRANS, ICMP_TIMXCEED_REASS 391 392 icmp_time_exceeded_packet { 393 type const[ICMP_TIMXCEED, int8] 394 code flags[icmp_time_exceeded_codes, int8] 395 csum csum[parent, inet, int16be] 396 unused1 const[0, int8] 397 length int8 398 unused2 const[0, int16] 399 iph icmp_ipv4_header 400 data array[int8, 0:8] 401 } [packed] 402 403 icmp_parameter_prob_codes = ICMP_PARAMPROB_ERRATPTR, ICMP_PARAMPROB_OPTABSENT, ICMP_PARAMPROB_LENGTH 404 405 icmp_parameter_prob_packet { 406 type const[ICMP_PARAMPROB, int8] 407 code flags[icmp_parameter_prob_codes, int8] 408 csum csum[parent, inet, int16be] 409 pointer int8 410 length int8 411 unused const[0, int16] 412 iph icmp_ipv4_header 413 data array[int8, 0:8] 414 } [packed] 415 416 icmp_timestamp_packet { 417 type const[ICMP_TSTAMP, int8] 418 code const[0, int8] 419 csum csum[parent, inet, int16be] 420 id int16be 421 seq_num int16be 422 orig_ts int32be 423 recv_ts int32be 424 trans_ts int32be 425 } [packed] 426 427 icmp_timestamp_reply_packet { 428 type const[ICMP_TSTAMPREPLY, int8] 429 code const[0, int8] 430 csum csum[parent, inet, int16be] 431 id int16be 432 seq_num int16be 433 orig_ts int32be 434 recv_ts int32be 435 trans_ts int32be 436 } [packed] 437 438 icmp_info_request_packet { 439 type const[ICMP_IREQ, int8] 440 code const[0, int8] 441 csum csum[parent, inet, int16be] 442 id int16be 443 seq_num int16be 444 } [packed] 445 446 icmp_info_reply_packet { 447 type const[ICMP_IREQREPLY, int8] 448 code const[0, int8] 449 csum csum[parent, inet, int16be] 450 id int16be 451 seq_num int16be 452 } [packed] 453 454 icmp_mask_request_packet { 455 type const[ICMP_MASKREQ, int8] 456 code const[0, int8] 457 csum csum[parent, inet, int16be] 458 mask int32be 459 } [packed] 460 461 icmp_mask_reply_packet { 462 type const[ICMP_MASKREPLY, int8] 463 code const[0, int8] 464 csum csum[parent, inet, int16be] 465 mask int32be 466 } [packed] 467 468 icmp_packet [ 469 generic icmp_generic_packet 470 echo_reply icmp_echo_reply_packet 471 dest_unreach icmp_dest_unreach_packet 472 source_quench icmp_source_quench_packet 473 redirect icmp_redirect_packet 474 echo icmp_echo_packet 475 time_exceeded icmp_time_exceeded_packet 476 parameter_prob icmp_parameter_prob_packet 477 timestamp icmp_timestamp_packet 478 timestamp_reply icmp_timestamp_reply_packet 479 info_request icmp_info_request_packet 480 info_reply icmp_info_reply_packet 481 mask_request icmp_mask_request_packet 482 mask_reply icmp_mask_reply_packet 483 ] [varlen] 484 485 ################################################################################ 486 ##################################### IPv6 ##################################### 487 ################################################################################ 488 489 ipv6_types = IPPROTO_IPV4, IPPROTO_TCP, IPPROTO_ST, IPPROTO_EGP, IPPROTO_PIGP, IPPROTO_RCCMON, IPPROTO_NVPII, IPPROTO_PUP, IPPROTO_ARGUS, IPPROTO_EMCON, IPPROTO_XNET, IPPROTO_CHAOS, IPPROTO_UDP, IPPROTO_MUX, IPPROTO_MEAS, IPPROTO_HMP, IPPROTO_PRM, IPPROTO_IDP, IPPROTO_TRUNK1, IPPROTO_TRUNK2, IPPROTO_LEAF1, IPPROTO_LEAF2, IPPROTO_RDP, IPPROTO_IRTP, IPPROTO_TP, IPPROTO_BLT, IPPROTO_NSP, IPPROTO_INP, IPPROTO_DCCP, IPPROTO_3PC, IPPROTO_IDPR, IPPROTO_XTP, IPPROTO_DDP, IPPROTO_CMTP, IPPROTO_TPXX, IPPROTO_IL, IPPROTO_SDRP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_IDRP, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_MHRP, IPPROTO_BHA, IPPROTO_ESP, IPPROTO_AH, IPPROTO_INLSP, IPPROTO_SWIPE, IPPROTO_NHRP, IPPROTO_MOBILE, IPPROTO_TLSP, IPPROTO_SKIP, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_AHIP, IPPROTO_CFTP, IPPROTO_HELLO, IPPROTO_SATEXPAK, IPPROTO_KRYPTOLAN, IPPROTO_RVD, IPPROTO_IPPC, IPPROTO_ADFS, IPPROTO_SATMON, IPPROTO_VISA, IPPROTO_IPCV, IPPROTO_CPNX, IPPROTO_CPHB, IPPROTO_WSN, IPPROTO_PVP, IPPROTO_BRSATMON, IPPROTO_ND, IPPROTO_WBMON, IPPROTO_WBEXPAK, IPPROTO_EON, IPPROTO_VMTP, IPPROTO_SVMTP, IPPROTO_VINES, IPPROTO_TTP, IPPROTO_IGP, IPPROTO_DGP, IPPROTO_TCF, IPPROTO_IGRP, IPPROTO_OSPFIGP, IPPROTO_SRPC, IPPROTO_LARP, IPPROTO_MTP, IPPROTO_AX25, IPPROTO_IPEIP, IPPROTO_MICP, IPPROTO_SCCSP, IPPROTO_ETHERIP, IPPROTO_ENCAP, IPPROTO_APES, IPPROTO_GMTP, IPPROTO_IPCOMP, IPPROTO_IPCOMP, IPPROTO_MH, IPPROTO_UDPLITE, IPPROTO_HIP, IPPROTO_SHIM6, IPPROTO_PIM, IPPROTO_CARP, IPPROTO_PGM, IPPROTO_MPLS, IPPROTO_PFSYNC 490 491 ipv6_addr_empty { 492 a0 array[const[0x0, int8], 16] 493 } 494 495 # This corresponds to LOCAL_IPV6 ("fe80::%02hxaa" % pid) in executor/common_bsd.h 496 ipv6_addr_local { 497 a0 const[0xfe, int8] 498 a1 const[0x80, int8] 499 a2 array[const[0x0, int8], 12] 500 a3 proc[0, 1, int8] 501 a4 const[0xaa, int8] 502 } [packed] 503 504 # This corresponds to REMOTE_IPV6 ("fe80::%02hxbb" % pid) in executor/common_bsd.h 505 ipv6_addr_remote { 506 a0 const[0xfe, int8] 507 a1 const[0x80, int8] 508 a2 array[const[0x0, int8], 12] 509 a3 proc[0, 1, int8] 510 a4 const[0xbb, int8] 511 } [packed] 512 513 ipv6_addr_loopback { 514 a0 const[0, int64be] 515 a1 const[1, int64be] 516 } [packed] 517 518 ipv6_addr_ipv4 { 519 a0 array[const[0x0, int8], 10] 520 a1 array[const[0xff, int8], 2] 521 a3 ipv4_addr 522 } [packed] 523 524 ipv6_addr_multicast1 { 525 a0 const[0xff, int8] 526 a1 const[0x1, int8] 527 a2 array[const[0x0, int8], 13] 528 a3 const[0x1, int8] 529 } [packed] 530 531 ipv6_addr_multicast2 { 532 a0 const[0xff, int8] 533 a1 const[0x2, int8] 534 a2 array[const[0x0, int8], 13] 535 a3 const[0x1, int8] 536 } [packed] 537 538 ipv6_addr [ 539 rand_addr array[int8, 16] 540 empty ipv6_addr_empty 541 local ipv6_addr_local 542 remote ipv6_addr_remote 543 loopback ipv6_addr_loopback 544 ipv4 ipv6_addr_ipv4 545 mcast1 ipv6_addr_multicast1 546 mcast2 ipv6_addr_multicast2 547 ] [size[16]] 548 549 # https://tools.ietf.org/html/rfc2402 550 # https://tools.ietf.org/html/rfc2406 551 # https://tools.ietf.org/html/rfc3775 552 553 # https://tools.ietf.org/html/rfc2460#section-4 554 # The length field in each of the extension headers specifies the 555 # length of the header in 8-octet units not including the first 8 octets. 556 557 ipv6_ext_header [ 558 hopopts ipv6_hopopts_ext_header 559 routing ipv6_rt_hdr 560 fragment ipv6_fragment_ext_header 561 dstopts ipv6_dstopts_ext_header 562 ] [varlen] 563 564 ipv6_hopopts_ext_header { 565 next_header flags[ipv6_types, int8] 566 length bytesize8[options, int8] 567 pad array[const[0, int8], 6] 568 options array[ipv6_tlv_option] 569 } [packed, align[8]] 570 571 ipv6_routing_types = IPV6_RTHDR_LOOSE, IPV6_RTHDR_STRICT, IPV6_RTHDR_TYPE_0 572 573 ipv6_rt_hdr { 574 next_header flags[ipv6_types, int8] 575 length bytesize8[data, int8] 576 routing_type flags[ipv6_routing_types, int8] 577 segments_left int8 578 reserved const[0, int32] 579 data array[ipv6_addr] 580 } [packed, align[8]] 581 582 ipv6_fragment_ext_header { 583 next_header flags[ipv6_types, int8] 584 reserved1 const[0, int8] 585 fragment_off_hi int8 586 m_flag int8:1 587 reserved2 const[0, int8:2] 588 fragment_off_lo int8:5 589 identification int32[100:104] 590 } [packed, align[8]] 591 592 ipv6_dstopts_ext_header { 593 next_header flags[ipv6_types, int8] 594 length bytesize8[options, int8] 595 pad array[const[0, int8], 6] 596 options array[ipv6_tlv_option] 597 } [packed, align[8]] 598 599 ipv6_tlv_option [ 600 generic ipv6_tlv_generic 601 pad1 ipv6_tlv_pad1 602 padn ipv6_tlv_padn 603 jumbo ipv6_tlv_jumbo 604 enc_lim ipv6_tlv_tun_lim 605 ra ipv6_tlv_ra 606 ] [varlen] 607 608 ipv6_tlv_generic { 609 type int8 610 length len[data, int8] 611 data array[int8] 612 } [packed] 613 614 ipv6_tlv_pad1 { 615 type const[IP6OPT_PAD1, int8] 616 len const[1, int8] 617 pad const[0, int8] 618 } [packed] 619 620 ipv6_tlv_padn { 621 type const[IP6OPT_PADN, int8] 622 len len[pad, int8] 623 pad array[const[0, int8]] 624 } [packed] 625 626 ipv6_tlv_jumbo { 627 type const[IP6OPT_JUMBO, int8] 628 len const[4, int8] 629 pkt_len int32be 630 } [packed] 631 632 ipv6_tlv_tun_lim { 633 type const[IP6OPT_TUNNEL_LIMIT, int8] 634 len const[1, int8] 635 encap_limit int8 636 } [packed] 637 638 ipv6_tlv_ra { 639 type const[IP6OPT_ROUTER_ALERT, int8] 640 len const[2, int8] 641 ra int16be 642 } [packed] 643 644 ipv6_packet_t { 645 priority int8:4 646 version const[6, int8:4] 647 flow_label array[int8, 3] 648 # TODO: flow_label is actually 20 bits, 4 bits are part of priority 649 length len[payload, int16be] 650 next_header flags[ipv6_types, int8] 651 hop_limit flags[hop_limits, int8] 652 src_ip ipv6_addr 653 dst_ip ipv6_addr 654 payload ipv6_packet_payload 655 } [packed] 656 657 ipv6_packet_payload { 658 ext_headers array[ipv6_ext_header] 659 payload ipv6_payload 660 } [packed] 661 662 ipv6_payload [ 663 generic array[int8] 664 tcp tcp_packet 665 udp udp_packet 666 icmpv6 icmpv6_packet 667 ] [varlen] 668 669 ################################################################################ 670 ##################################### ICMPv6 ################################### 671 ################################################################################ 672 673 # https://tools.ietf.org/html/rfc4443 674 # http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml 675 676 icmpv6_ipv6_packet { 677 priority int8:4 678 version const[6, int8:4] 679 flow_label array[int8, 3] 680 length int16be 681 next_header flags[ipv6_types, int8] 682 hop_limit flags[hop_limits, int8] 683 src_ip ipv6_addr 684 dst_ip ipv6_addr 685 ext_headers array[ipv6_ext_header] 686 data array[int8] 687 } [packed] 688 689 icmpv6_dest_unreach_codes = ICMP6_DST_UNREACH_NOROUTE, ICMP6_DST_UNREACH_ADMIN, ICMP6_DST_UNREACH_NOTNEIGHBOR, ICMP6_DST_UNREACH_BEYONDSCOPE, ICMP6_DST_UNREACH_ADDR, ICMP6_DST_UNREACH_NOPORT, ICMP6_DST_UNREACH_POLICY, ICMP6_DST_UNREACH_REJECT, ICMP6_DST_UNREACH_SRCROUTE 690 691 icmpv6_dest_unreach_packet { 692 type const[ICMP6_DST_UNREACH, int8] 693 code flags[icmpv6_dest_unreach_codes, int8] 694 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 695 length int8 696 unused array[const[0, int8], 3] 697 packet icmpv6_ipv6_packet 698 } [packed] 699 700 icmpv6_pkt_toobig_packet { 701 type const[ICMP6_PACKET_TOO_BIG, int8] 702 code const[0, int8] 703 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 704 mtu int32be 705 packet icmpv6_ipv6_packet 706 } [packed] 707 708 icmpv6_time_exceed_codes = ICMP6_TIME_EXCEED_TRANSIT, ICMP6_TIME_EXCEED_REASSEMBLY 709 710 icmpv6_time_exceed_packet { 711 type const[ICMP6_TIME_EXCEEDED, int8] 712 code flags[icmpv6_time_exceed_codes, int8] 713 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 714 length int8 715 unused array[const[0, int8], 3] 716 packet icmpv6_ipv6_packet 717 } [packed] 718 719 icmpv6_param_prob_codes = ICMP6_PARAMPROB_HEADER, ICMP6_PARAMPROB_NEXTHEADER, ICMP6_PARAMPROB_OPTION 720 721 icmpv6_param_prob_packet { 722 type const[ICMP6_PARAM_PROB, int8] 723 code flags[icmpv6_param_prob_codes, int8] 724 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 725 pointer int32be 726 packet icmpv6_ipv6_packet 727 } [packed] 728 729 icmpv6_echo_request_packet { 730 type const[ICMP6_ECHO_REQUEST, int8] 731 code const[0, int8] 732 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 733 id int16be 734 seq_num int16be 735 data array[int8] 736 } [packed] 737 738 icmpv6_echo_reply_packet { 739 type const[ICMP6_ECHO_REPLY, int8] 740 code const[0, int8] 741 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 742 id int16be 743 seq_num int16be 744 data array[int8] 745 } [packed] 746 747 icmpv6_mld_types = MLD_LISTENER_QUERY, MLD_LISTENER_REPORT, MLD_LISTENER_REDUCTION 748 749 # https://tools.ietf.org/html/rfc2710#section-3 750 icmpv6_mld_packet { 751 type flags[icmpv6_mld_types, int8] 752 code const[0, int8] 753 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 754 mrd int16be 755 unused int16be 756 addr ipv6_addr 757 } [packed] 758 759 # https://tools.ietf.org/html/rfc3810#section-5.1 760 icmpv6_mldv2_listener_query_packet { 761 type const[MLD_LISTENER_QUERY, int8] 762 code const[0, int8] 763 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 764 mrd int16be 765 unused int16be 766 mca ipv6_addr 767 qrv int8:3 768 suppress int8:1 769 resv2 int8:4 770 qqic int8 771 nsrcs len[srcs, int16be] 772 srcs array[ipv6_addr] 773 } [packed] 774 775 icmpv6_mldv2_grec { 776 type int8 777 auxwords len[aux, int8] 778 nsrcs len[srcs, int16be] 779 mca ipv6_addr 780 srcs array[ipv6_addr] 781 aux array[int32] 782 } [packed] 783 784 # https://tools.ietf.org/html/rfc3810#section-5.2 785 icmpv6_mldv2_listener_report_packet { 786 type const[MLDV2_LISTENER_REPORT, int8] 787 code const[0, int8] 788 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 789 unused int16 790 ngrec len[grec, int16be] 791 grec array[icmpv6_mldv2_grec] 792 } [packed] 793 794 icmpv6_ni_types = ICMP6_NI_QUERY, ICMP6_NI_REPLY 795 796 # https://tools.ietf.org/html/rfc4620#section-4 797 icmpv6_ni_packet { 798 type flags[icmpv6_ni_types, int8] 799 code const[0, int8] 800 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 801 qtype int16be 802 flags int16be 803 nonce int64be 804 data array[int8] 805 } [packed] 806 807 icmpv6_ndisc_option_types = ND_OPT_SOURCE_LINKADDR, ND_OPT_TARGET_LINKADDR, ND_OPT_PREFIX_INFORMATION, ND_OPT_REDIRECTED_HEADER, ND_OPT_MTU, ND_OPT_NONCE, ND_OPT_ROUTE_INFO, ND_OPT_RDNSS, ND_OPT_DNSSL 808 809 # https://tools.ietf.org/html/rfc4861#section-4.6 810 icmpv6_ndisc_option { 811 option_type flags[icmpv6_ndisc_option_types, int8] 812 length bytesize8[parent, int8] 813 # TODO: define the option formats 814 data array[int8] 815 } [packed] 816 817 # https://tools.ietf.org/html/rfc4861#section-4.1 818 icmpv6_ndisc_router_solicit_packet { 819 type const[ND_ROUTER_SOLICIT, int8] 820 code const[0, int8] 821 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 822 unused array[const[0, int8], 4] 823 options array[icmpv6_ndisc_option] 824 } [packed] 825 826 # https://tools.ietf.org/html/rfc4861#section-4.2 827 icmpv6_ndisc_router_advert_packet { 828 type const[ND_ROUTER_ADVERT, int8] 829 code const[0, int8] 830 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 831 cur_hop_limit flags[hop_limits, int8] 832 # TODO: Implement bitflags for the router advert flags 833 router_flags int8 834 router_lifetime int16be 835 reachable_time int32be 836 retrans_time int32be 837 options array[icmpv6_ndisc_option] 838 } [packed] 839 840 # https://tools.ietf.org/html/rfc4861#section-4.3 841 icmpv6_ndisc_neigh_solicit_packet { 842 type const[ND_NEIGHBOR_SOLICIT, int8] 843 code const[0, int8] 844 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 845 target_addr ipv6_addr 846 options array[icmpv6_ndisc_option] 847 } [packed] 848 849 # https://tools.ietf.org/html/rfc4861#section-4.4 850 icmpv6_ndisc_neigh_advert_packet { 851 type const[ND_NEIGHBOR_ADVERT, int8] 852 code const[0, int8] 853 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 854 # TODO: Implement bitflags for the neighbor advert flags 855 neighbor_flags int8 856 unused array[const[0, int8], 3] 857 target_addr ipv6_addr 858 options array[icmpv6_ndisc_option] 859 } [packed] 860 861 # https://tools.ietf.org/html/rfc4861#section-4.5 862 icmpv6_ndisc_redir_packet { 863 type const[ND_REDIRECT, int8] 864 code const[0, int8] 865 csum csum[parent, pseudo, IPPROTO_ICMPV6, int16be] 866 unused array[const[0, int8], 4] 867 target_addr ipv6_addr 868 dst_addr ipv6_addr 869 options array[icmpv6_ndisc_option] 870 } [packed] 871 872 icmpv6_packet [ 873 dest_unreach icmpv6_dest_unreach_packet 874 pkt_toobig icmpv6_pkt_toobig_packet 875 time_exceed icmpv6_time_exceed_packet 876 param_prob icmpv6_param_prob_packet 877 echo_request icmpv6_echo_request_packet 878 echo_reply icmpv6_echo_reply_packet 879 mld icmpv6_mld_packet 880 mlv2_query icmpv6_mldv2_listener_query_packet 881 mlv2_report icmpv6_mldv2_listener_report_packet 882 ni icmpv6_ni_packet 883 ndisc_rs icmpv6_ndisc_router_solicit_packet 884 ndisc_ra icmpv6_ndisc_router_advert_packet 885 ndisc_na icmpv6_ndisc_neigh_advert_packet 886 ndisc_ns icmpv6_ndisc_neigh_solicit_packet 887 ndisc_redir icmpv6_ndisc_redir_packet 888 ] [varlen] 889 890 ################################################################################ 891 ###################################### TCP ##################################### 892 ################################################################################ 893 894 # https://tools.ietf.org/html/rfc793#section-3.1 895 # https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure 896 # http://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml 897 898 tcp_option [ 899 generic tcp_generic_option 900 nop tcp_nop_option 901 eol tcp_eol_option 902 mss tcp_mss_option 903 window tcp_window_option 904 sack_perm tcp_sack_perm_option 905 sack tcp_sack_option 906 timestamp tcp_timestamp_option 907 md5sig tcp_md5sig_option 908 fastopen tcp_fastopen_option 909 ] [varlen] 910 911 tcp_option_types = TCPOPT_EOL, TCPOPT_NOP, TCPOPT_MAXSEG, TCPOPT_WINDOW, TCPOPT_SACK_PERMITTED, TCPOPT_SACK, TCPOPT_TIMESTAMP, TCPOPT_SIGNATURE, TCPOPT_FAST_OPEN 912 913 tcp_generic_option { 914 type flags[tcp_option_types, int8] 915 length len[parent, int8] 916 data array[int8, 0:16] 917 } [packed] 918 919 # https://tools.ietf.org/html/rfc793#section-3.1 920 tcp_eol_option { 921 type const[TCPOPT_EOL, int8] 922 } [packed] 923 924 # https://tools.ietf.org/html/rfc793#section-3.1 925 tcp_nop_option { 926 type const[TCPOPT_NOP, int8] 927 } [packed] 928 929 # https://tools.ietf.org/html/rfc793#section-3.1 930 tcp_mss_option { 931 type const[TCPOPT_MAXSEG, int8] 932 length len[parent, int8] 933 seg_size int16be 934 } [packed] 935 936 # https://tools.ietf.org/html/rfc7323#section-2 937 tcp_window_option { 938 type const[TCPOPT_WINDOW, int8] 939 length len[parent, int8] 940 shift int8 941 } [packed] 942 943 # https://tools.ietf.org/html/rfc2018#section-2 944 tcp_sack_perm_option { 945 type const[TCPOPT_SACK_PERMITTED, int8] 946 length len[parent, int8] 947 } [packed] 948 949 # https://tools.ietf.org/html/rfc2018#section-3 950 tcp_sack_option { 951 type const[TCPOPT_SACK, int8] 952 length len[parent, int8] 953 data array[int32be] 954 } [packed] 955 956 # https://tools.ietf.org/html/rfc7323#section-3 957 tcp_timestamp_option { 958 type const[TCPOPT_TIMESTAMP, int8] 959 length len[parent, int8] 960 tsval int32be 961 tsecr int32be 962 } [packed] 963 964 # https://tools.ietf.org/html/rfc2385#section-3.0 965 tcp_md5sig_option { 966 type const[TCPOPT_SIGNATURE, int8] 967 length len[parent, int8] 968 md5 array[int8, 16] 969 } [packed] 970 971 # https://tools.ietf.org/html/rfc7413#section-4.1.1 972 tcp_fastopen_option { 973 type const[TCPOPT_FAST_OPEN, int8] 974 length len[parent, int8] 975 data array[int8, 0:16] 976 } [packed] 977 978 tcp_options { 979 options array[tcp_option] 980 } [packed, align[4]] 981 982 tcp_flags = 0, TH_FIN, TH_SYN, TH_RST, TH_PUSH, TH_ACK, TH_URG, TH_ECE, TH_CWR 983 984 tcp_header { 985 src_port sock_port 986 dst_port sock_port 987 seq_num tcp_seq_num 988 ack_num tcp_seq_num 989 ns int8:1 990 reserved const[0, int8:3] 991 data_off bytesize4[parent, int8:4] 992 flags flags[tcp_flags, int8] 993 window_size int16be 994 csum csum[tcp_packet, pseudo, IPPROTO_TCP, int16be] 995 urg_ptr int16be 996 options tcp_options 997 } [packed] 998 999 tcp_packet { 1000 header tcp_header 1001 payload tcp_payload 1002 } [packed] 1003 1004 tcp_payload { 1005 payload array[int8] 1006 } [packed] 1007 1008 ################################################################################ 1009 ###################################### UDP ##################################### 1010 ################################################################################ 1011 1012 # https://tools.ietf.org/html/rfc768 1013 # https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure 1014 1015 udp_header { 1016 src_port sock_port 1017 dst_port sock_port 1018 length len[parent, int16be] 1019 csum csum[parent, pseudo, IPPROTO_UDP, int16be] 1020 } [packed] 1021 1022 udp_packet { 1023 header udp_header 1024 payload udp_payload 1025 } [packed] 1026 1027 udp_payload { 1028 payload array[int8] 1029 } [packed]