[279] | 1 | #ifndef _NETINET_TCP_H
|
---|
| 2 | #define _NETINET_TCP_H
|
---|
| 3 |
|
---|
| 4 | #include <features.h>
|
---|
| 5 |
|
---|
| 6 | #define TCP_NODELAY 1
|
---|
| 7 | #define TCP_MAXSEG 2
|
---|
| 8 | #define TCP_CORK 3
|
---|
| 9 | #define TCP_KEEPIDLE 4
|
---|
| 10 | #define TCP_KEEPINTVL 5
|
---|
| 11 | #define TCP_KEEPCNT 6
|
---|
| 12 | #define TCP_SYNCNT 7
|
---|
| 13 | #define TCP_LINGER2 8
|
---|
| 14 | #define TCP_DEFER_ACCEPT 9
|
---|
| 15 | #define TCP_WINDOW_CLAMP 10
|
---|
| 16 | #define TCP_INFO 11
|
---|
| 17 | #define TCP_QUICKACK 12
|
---|
| 18 | #define TCP_CONGESTION 13
|
---|
| 19 | #define TCP_MD5SIG 14
|
---|
| 20 | #define TCP_THIN_LINEAR_TIMEOUTS 16
|
---|
| 21 | #define TCP_THIN_DUPACK 17
|
---|
| 22 | #define TCP_USER_TIMEOUT 18
|
---|
| 23 | #define TCP_REPAIR 19
|
---|
| 24 | #define TCP_REPAIR_QUEUE 20
|
---|
| 25 | #define TCP_QUEUE_SEQ 21
|
---|
| 26 | #define TCP_REPAIR_OPTIONS 22
|
---|
| 27 | #define TCP_FASTOPEN 23
|
---|
| 28 | #define TCP_TIMESTAMP 24
|
---|
| 29 | #define TCP_NOTSENT_LOWAT 25
|
---|
| 30 |
|
---|
| 31 | #define TCP_ESTABLISHED 1
|
---|
| 32 | #define TCP_SYN_SENT 2
|
---|
| 33 | #define TCP_SYN_RECV 3
|
---|
| 34 | #define TCP_FIN_WAIT1 4
|
---|
| 35 | #define TCP_FIN_WAIT2 5
|
---|
| 36 | #define TCP_TIME_WAIT 6
|
---|
| 37 | #define TCP_CLOSE 7
|
---|
| 38 | #define TCP_CLOSE_WAIT 8
|
---|
| 39 | #define TCP_LAST_ACK 9
|
---|
| 40 | #define TCP_LISTEN 10
|
---|
| 41 | #define TCP_CLOSING 11
|
---|
| 42 |
|
---|
| 43 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
---|
| 44 | #define SOL_TCP 6
|
---|
| 45 | #include <sys/types.h>
|
---|
| 46 | #include <sys/socket.h>
|
---|
| 47 | #include <stdint.h>
|
---|
| 48 | #include <endian.h>
|
---|
| 49 |
|
---|
| 50 | typedef uint32_t tcp_seq;
|
---|
| 51 |
|
---|
| 52 | #define TH_FIN 0x01
|
---|
| 53 | #define TH_SYN 0x02
|
---|
| 54 | #define TH_RST 0x04
|
---|
| 55 | #define TH_PUSH 0x08
|
---|
| 56 | #define TH_ACK 0x10
|
---|
| 57 | #define TH_URG 0x20
|
---|
| 58 |
|
---|
| 59 | struct tcphdr {
|
---|
| 60 | #ifdef _GNU_SOURCE
|
---|
| 61 | #ifdef __GNUC__
|
---|
| 62 | __extension__
|
---|
| 63 | #endif
|
---|
| 64 | union { struct {
|
---|
| 65 |
|
---|
| 66 | uint16_t source;
|
---|
| 67 | uint16_t dest;
|
---|
| 68 | uint32_t seq;
|
---|
| 69 | uint32_t ack_seq;
|
---|
| 70 | #if __BYTE_ORDER == __LITTLE_ENDIAN
|
---|
| 71 | uint16_t res1:4;
|
---|
| 72 | uint16_t doff:4;
|
---|
| 73 | uint16_t fin:1;
|
---|
| 74 | uint16_t syn:1;
|
---|
| 75 | uint16_t rst:1;
|
---|
| 76 | uint16_t psh:1;
|
---|
| 77 | uint16_t ack:1;
|
---|
| 78 | uint16_t urg:1;
|
---|
| 79 | uint16_t res2:2;
|
---|
| 80 | #else
|
---|
| 81 | uint16_t doff:4;
|
---|
| 82 | uint16_t res1:4;
|
---|
| 83 | uint16_t res2:2;
|
---|
| 84 | uint16_t urg:1;
|
---|
| 85 | uint16_t ack:1;
|
---|
| 86 | uint16_t psh:1;
|
---|
| 87 | uint16_t rst:1;
|
---|
| 88 | uint16_t syn:1;
|
---|
| 89 | uint16_t fin:1;
|
---|
| 90 | #endif
|
---|
| 91 | uint16_t window;
|
---|
| 92 | uint16_t check;
|
---|
| 93 | uint16_t urg_ptr;
|
---|
| 94 |
|
---|
| 95 | }; struct {
|
---|
| 96 | #endif
|
---|
| 97 |
|
---|
| 98 | uint16_t th_sport;
|
---|
| 99 | uint16_t th_dport;
|
---|
| 100 | uint32_t th_seq;
|
---|
| 101 | uint32_t th_ack;
|
---|
| 102 | #if __BYTE_ORDER == __LITTLE_ENDIAN
|
---|
| 103 | uint8_t th_x2:4;
|
---|
| 104 | uint8_t th_off:4;
|
---|
| 105 | #else
|
---|
| 106 | uint8_t th_off:4;
|
---|
| 107 | uint8_t th_x2:4;
|
---|
| 108 | #endif
|
---|
| 109 | uint8_t th_flags;
|
---|
| 110 | uint16_t th_win;
|
---|
| 111 | uint16_t th_sum;
|
---|
| 112 | uint16_t th_urp;
|
---|
| 113 |
|
---|
| 114 | #ifdef _GNU_SOURCE
|
---|
| 115 | }; };
|
---|
| 116 | #endif
|
---|
| 117 | };
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
| 120 | #ifdef _GNU_SOURCE
|
---|
| 121 | #define TCPI_OPT_TIMESTAMPS 1
|
---|
| 122 | #define TCPI_OPT_SACK 2
|
---|
| 123 | #define TCPI_OPT_WSCALE 4
|
---|
| 124 | #define TCPI_OPT_ECN 8
|
---|
| 125 |
|
---|
| 126 | #define TCP_CA_Open 0
|
---|
| 127 | #define TCP_CA_Disorder 1
|
---|
| 128 | #define TCP_CA_CWR 2
|
---|
| 129 | #define TCP_CA_Recovery 3
|
---|
| 130 | #define TCP_CA_Loss 4
|
---|
| 131 |
|
---|
| 132 | struct tcp_info
|
---|
| 133 | {
|
---|
| 134 | uint8_t tcpi_state;
|
---|
| 135 | uint8_t tcpi_ca_state;
|
---|
| 136 | uint8_t tcpi_retransmits;
|
---|
| 137 | uint8_t tcpi_probes;
|
---|
| 138 | uint8_t tcpi_backoff;
|
---|
| 139 | uint8_t tcpi_options;
|
---|
| 140 | uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
|
---|
| 141 | uint32_t tcpi_rto;
|
---|
| 142 | uint32_t tcpi_ato;
|
---|
| 143 | uint32_t tcpi_snd_mss;
|
---|
| 144 | uint32_t tcpi_rcv_mss;
|
---|
| 145 | uint32_t tcpi_unacked;
|
---|
| 146 | uint32_t tcpi_sacked;
|
---|
| 147 | uint32_t tcpi_lost;
|
---|
| 148 | uint32_t tcpi_retrans;
|
---|
| 149 | uint32_t tcpi_fackets;
|
---|
| 150 | uint32_t tcpi_last_data_sent;
|
---|
| 151 | uint32_t tcpi_last_ack_sent;
|
---|
| 152 | uint32_t tcpi_last_data_recv;
|
---|
| 153 | uint32_t tcpi_last_ack_recv;
|
---|
| 154 | uint32_t tcpi_pmtu;
|
---|
| 155 | uint32_t tcpi_rcv_ssthresh;
|
---|
| 156 | uint32_t tcpi_rtt;
|
---|
| 157 | uint32_t tcpi_rttvar;
|
---|
| 158 | uint32_t tcpi_snd_ssthresh;
|
---|
| 159 | uint32_t tcpi_snd_cwnd;
|
---|
| 160 | uint32_t tcpi_advmss;
|
---|
| 161 | uint32_t tcpi_reordering;
|
---|
| 162 | uint32_t tcpi_rcv_rtt;
|
---|
| 163 | uint32_t tcpi_rcv_space;
|
---|
| 164 | uint32_t tcpi_total_retrans;
|
---|
| 165 | uint64_t tcpi_pacing_rate;
|
---|
| 166 | uint64_t tcpi_max_pacing_rate;
|
---|
| 167 | };
|
---|
| 168 |
|
---|
| 169 | #define TCP_MD5SIG_MAXKEYLEN 80
|
---|
| 170 |
|
---|
| 171 | struct tcp_md5sig
|
---|
| 172 | {
|
---|
| 173 | struct sockaddr_storage tcpm_addr;
|
---|
| 174 | uint16_t __tcpm_pad1;
|
---|
| 175 | uint16_t tcpm_keylen;
|
---|
| 176 | uint32_t __tcpm_pad2;
|
---|
| 177 | uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
|
---|
| 178 | };
|
---|
| 179 |
|
---|
| 180 | #endif
|
---|
| 181 |
|
---|
| 182 | #endif
|
---|