github.com/cilium/cilium@v1.16.2/bpf/include/linux/tcp.h (about)

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