1 #pragma once 2 3 #include <features.h> 4 #include <stdint.h> 5 #include <sys/types.h> 6 7 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 8 9 struct tcphdr { 10 #ifdef _GNU_SOURCE 11 #ifdef __GNUC__ 12 __extension__ 13 #endif 14 union { struct { 15 16 uint16_t source; 17 uint16_t dest; 18 uint32_t seq; 19 uint32_t ack_seq; 20 #if __BYTE_ORDER == __LITTLE_ENDIAN 21 uint16_t res1:4; 22 uint16_t doff:4; 23 uint16_t fin:1; 24 uint16_t syn:1; 25 uint16_t rst:1; 26 uint16_t psh:1; 27 uint16_t ack:1; 28 uint16_t urg:1; 29 uint16_t res2:2; 30 #else 31 uint16_t doff:4; 32 uint16_t res1:4; 33 uint16_t res2:2; 34 uint16_t urg:1; 35 uint16_t ack:1; 36 uint16_t psh:1; 37 uint16_t rst:1; 38 uint16_t syn:1; 39 uint16_t fin:1; 40 #endif 41 uint16_t window; 42 uint16_t check; 43 uint16_t urg_ptr; 44 45 }; struct { 46 #endif 47 48 uint16_t th_sport; 49 uint16_t th_dport; 50 uint32_t th_seq; 51 uint32_t th_ack; 52 #if __BYTE_ORDER == __LITTLE_ENDIAN 53 uint8_t th_x2:4; 54 uint8_t th_off:4; 55 #else 56 uint8_t th_off:4; 57 uint8_t th_x2:4; 58 #endif 59 uint8_t th_flags; 60 uint16_t th_win; 61 uint16_t th_sum; 62 uint16_t th_urp; 63 64 #ifdef _GNU_SOURCE 65 }; }; 66 #endif 67 }; 68 69 #endif 70