github.com/looshlee/beatles@v0.0.0-20220727174639-742810ab631c/bpf/include/linux/tcp.h (about) 1 /* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Definitions for the TCP protocol. 7 * 8 * Version: @(#)tcp.h 1.0.2 04/28/93 9 * 10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 15 * 2 of the License, or (at your option) any later version. 16 */ 17 #ifndef _LINUX_TCP_H 18 #define _LINUX_TCP_H 19 20 #include <linux/type_mapper.h> 21 22 struct tcphdr { 23 __be16 source; 24 __be16 dest; 25 __be32 seq; 26 __be32 ack_seq; 27 #if defined(__LITTLE_ENDIAN_BITFIELD) 28 __u16 res1:4, 29 doff:4, 30 fin:1, 31 syn:1, 32 rst:1, 33 psh:1, 34 ack:1, 35 urg:1, 36 ece:1, 37 cwr:1; 38 #elif defined(__BIG_ENDIAN_BITFIELD) 39 __u16 doff:4, 40 res1:4, 41 cwr:1, 42 ece:1, 43 urg:1, 44 ack:1, 45 psh:1, 46 rst:1, 47 syn:1, 48 fin:1; 49 #else 50 #error "Adjust your <asm/byteorder.h> defines" 51 #endif 52 __be16 window; 53 __sum16 check; 54 __be16 urg_ptr; 55 }; 56 57 /* 58 * The union cast uses a gcc extension to avoid aliasing problems 59 * (union is compatible to any of its members) 60 * This means this part of the code is -fstrict-aliasing safe now. 61 */ 62 union tcp_word_hdr { 63 struct tcphdr hdr; 64 __be32 words[5]; 65 }; 66 67 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) 68 69 enum { 70 TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), 71 TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), 72 TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), 73 TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000), 74 TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), 75 TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), 76 TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), 77 TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), 78 TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), 79 TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) 80 }; 81 82 /* 83 * TCP general constants 84 */ 85 #define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */ 86 #define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */ 87 88 89 #endif /* _LINUX_TCP_H */