PageRenderTime 61ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/arm-unknown-linux-gnueabi-linaro/arm-unknown-linux-gnueabi-linaro_4.7.4-2013.12/arm-unknown-linux-gnueabi/sysroot/usr/include/netinet/tcp.h

https://gitlab.com/mrimp/linaro-toolchains
C Header | 301 lines | 213 code | 35 blank | 53 comment | 8 complexity | e5f2d20e4785e7323a8e7d3f3cc24266 MD5 | raw file
  1. /*
  2. * Copyright (c) 1982, 1986, 1993
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 4. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * @(#)tcp.h 8.1 (Berkeley) 6/10/93
  30. */
  31. #ifndef _NETINET_TCP_H
  32. #define _NETINET_TCP_H 1
  33. #include <features.h>
  34. /*
  35. * User-settable options (used with setsockopt).
  36. */
  37. #define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
  38. #define TCP_MAXSEG 2 /* Set maximum segment size */
  39. #define TCP_CORK 3 /* Control sending of partial frames */
  40. #define TCP_KEEPIDLE 4 /* Start keeplives after this period */
  41. #define TCP_KEEPINTVL 5 /* Interval between keepalives */
  42. #define TCP_KEEPCNT 6 /* Number of keepalives before death */
  43. #define TCP_SYNCNT 7 /* Number of SYN retransmits */
  44. #define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
  45. #define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
  46. #define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
  47. #define TCP_INFO 11 /* Information about this connection. */
  48. #define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
  49. #define TCP_CONGESTION 13 /* Congestion control algorithm. */
  50. #define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
  51. #define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
  52. #define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
  53. #define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
  54. #define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
  55. #define TCP_REPAIR 19 /* TCP sock is under repair right now */
  56. #define TCP_REPAIR_QUEUE 20 /* Set TCP queue to repair */
  57. #define TCP_QUEUE_SEQ 21 /* Set sequence number of repaired queue. */
  58. #define TCP_REPAIR_OPTIONS 22 /* Repair TCP connection options */
  59. #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
  60. #define TCP_TIMESTAMP 24 /* TCP time stamp */
  61. #ifdef __USE_MISC
  62. # include <sys/types.h>
  63. # include <sys/socket.h>
  64. # ifdef __FAVOR_BSD
  65. typedef u_int32_t tcp_seq;
  66. /*
  67. * TCP header.
  68. * Per RFC 793, September, 1981.
  69. */
  70. struct tcphdr
  71. {
  72. u_int16_t th_sport; /* source port */
  73. u_int16_t th_dport; /* destination port */
  74. tcp_seq th_seq; /* sequence number */
  75. tcp_seq th_ack; /* acknowledgement number */
  76. # if __BYTE_ORDER == __LITTLE_ENDIAN
  77. u_int8_t th_x2:4; /* (unused) */
  78. u_int8_t th_off:4; /* data offset */
  79. # endif
  80. # if __BYTE_ORDER == __BIG_ENDIAN
  81. u_int8_t th_off:4; /* data offset */
  82. u_int8_t th_x2:4; /* (unused) */
  83. # endif
  84. u_int8_t th_flags;
  85. # define TH_FIN 0x01
  86. # define TH_SYN 0x02
  87. # define TH_RST 0x04
  88. # define TH_PUSH 0x08
  89. # define TH_ACK 0x10
  90. # define TH_URG 0x20
  91. u_int16_t th_win; /* window */
  92. u_int16_t th_sum; /* checksum */
  93. u_int16_t th_urp; /* urgent pointer */
  94. };
  95. # else /* !__FAVOR_BSD */
  96. struct tcphdr
  97. {
  98. u_int16_t source;
  99. u_int16_t dest;
  100. u_int32_t seq;
  101. u_int32_t ack_seq;
  102. # if __BYTE_ORDER == __LITTLE_ENDIAN
  103. u_int16_t res1:4;
  104. u_int16_t doff:4;
  105. u_int16_t fin:1;
  106. u_int16_t syn:1;
  107. u_int16_t rst:1;
  108. u_int16_t psh:1;
  109. u_int16_t ack:1;
  110. u_int16_t urg:1;
  111. u_int16_t res2:2;
  112. # elif __BYTE_ORDER == __BIG_ENDIAN
  113. u_int16_t doff:4;
  114. u_int16_t res1:4;
  115. u_int16_t res2:2;
  116. u_int16_t urg:1;
  117. u_int16_t ack:1;
  118. u_int16_t psh:1;
  119. u_int16_t rst:1;
  120. u_int16_t syn:1;
  121. u_int16_t fin:1;
  122. # else
  123. # error "Adjust your <bits/endian.h> defines"
  124. # endif
  125. u_int16_t window;
  126. u_int16_t check;
  127. u_int16_t urg_ptr;
  128. };
  129. # endif /* __FAVOR_BSD */
  130. enum
  131. {
  132. TCP_ESTABLISHED = 1,
  133. TCP_SYN_SENT,
  134. TCP_SYN_RECV,
  135. TCP_FIN_WAIT1,
  136. TCP_FIN_WAIT2,
  137. TCP_TIME_WAIT,
  138. TCP_CLOSE,
  139. TCP_CLOSE_WAIT,
  140. TCP_LAST_ACK,
  141. TCP_LISTEN,
  142. TCP_CLOSING /* now a valid state */
  143. };
  144. # define TCPOPT_EOL 0
  145. # define TCPOPT_NOP 1
  146. # define TCPOPT_MAXSEG 2
  147. # define TCPOLEN_MAXSEG 4
  148. # define TCPOPT_WINDOW 3
  149. # define TCPOLEN_WINDOW 3
  150. # define TCPOPT_SACK_PERMITTED 4 /* Experimental */
  151. # define TCPOLEN_SACK_PERMITTED 2
  152. # define TCPOPT_SACK 5 /* Experimental */
  153. # define TCPOPT_TIMESTAMP 8
  154. # define TCPOLEN_TIMESTAMP 10
  155. # define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
  156. # define TCPOPT_TSTAMP_HDR \
  157. (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
  158. /*
  159. * Default maximum segment size for TCP.
  160. * With an IP MSS of 576, this is 536,
  161. * but 512 is probably more convenient.
  162. * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
  163. */
  164. # define TCP_MSS 512
  165. # define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
  166. # define TCP_MAX_WINSHIFT 14 /* maximum window shift */
  167. # define SOL_TCP 6 /* TCP level */
  168. # define TCPI_OPT_TIMESTAMPS 1
  169. # define TCPI_OPT_SACK 2
  170. # define TCPI_OPT_WSCALE 4
  171. # define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */
  172. # define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */
  173. # define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */
  174. /* Values for tcpi_state. */
  175. enum tcp_ca_state
  176. {
  177. TCP_CA_Open = 0,
  178. TCP_CA_Disorder = 1,
  179. TCP_CA_CWR = 2,
  180. TCP_CA_Recovery = 3,
  181. TCP_CA_Loss = 4
  182. };
  183. struct tcp_info
  184. {
  185. u_int8_t tcpi_state;
  186. u_int8_t tcpi_ca_state;
  187. u_int8_t tcpi_retransmits;
  188. u_int8_t tcpi_probes;
  189. u_int8_t tcpi_backoff;
  190. u_int8_t tcpi_options;
  191. u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
  192. u_int32_t tcpi_rto;
  193. u_int32_t tcpi_ato;
  194. u_int32_t tcpi_snd_mss;
  195. u_int32_t tcpi_rcv_mss;
  196. u_int32_t tcpi_unacked;
  197. u_int32_t tcpi_sacked;
  198. u_int32_t tcpi_lost;
  199. u_int32_t tcpi_retrans;
  200. u_int32_t tcpi_fackets;
  201. /* Times. */
  202. u_int32_t tcpi_last_data_sent;
  203. u_int32_t tcpi_last_ack_sent; /* Not remembered, sorry. */
  204. u_int32_t tcpi_last_data_recv;
  205. u_int32_t tcpi_last_ack_recv;
  206. /* Metrics. */
  207. u_int32_t tcpi_pmtu;
  208. u_int32_t tcpi_rcv_ssthresh;
  209. u_int32_t tcpi_rtt;
  210. u_int32_t tcpi_rttvar;
  211. u_int32_t tcpi_snd_ssthresh;
  212. u_int32_t tcpi_snd_cwnd;
  213. u_int32_t tcpi_advmss;
  214. u_int32_t tcpi_reordering;
  215. u_int32_t tcpi_rcv_rtt;
  216. u_int32_t tcpi_rcv_space;
  217. u_int32_t tcpi_total_retrans;
  218. };
  219. /* For TCP_MD5SIG socket option. */
  220. #define TCP_MD5SIG_MAXKEYLEN 80
  221. struct tcp_md5sig
  222. {
  223. struct sockaddr_storage tcpm_addr; /* Address associated. */
  224. u_int16_t __tcpm_pad1; /* Zero. */
  225. u_int16_t tcpm_keylen; /* Key length. */
  226. u_int32_t __tcpm_pad2; /* Zero. */
  227. u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */
  228. };
  229. /* For socket repair options. */
  230. struct tcp_repair_opt
  231. {
  232. u_int32_t opt_code;
  233. u_int32_t opt_val;
  234. };
  235. /* Queue to repair, for TCP_REPAIR_QUEUE. */
  236. enum
  237. {
  238. TCP_NO_QUEUE,
  239. TCP_RECV_QUEUE,
  240. TCP_SEND_QUEUE,
  241. TCP_QUEUES_NR,
  242. };
  243. /* For cookie transactions socket options. */
  244. #define TCP_COOKIE_MIN 8 /* 64-bits */
  245. #define TCP_COOKIE_MAX 16 /* 128-bits */
  246. #define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX)
  247. /* Flags for both getsockopt and setsockopt */
  248. #define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */
  249. #define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies,
  250. * supercedes everything. */
  251. /* Flags for getsockopt */
  252. #define TCP_S_DATA_IN (1 << 2) /* Was data received? */
  253. #define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */
  254. #define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */
  255. #define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */
  256. struct tcp_cookie_transactions
  257. {
  258. u_int16_t tcpct_flags;
  259. u_int8_t __tcpct_pad1;
  260. u_int8_t tcpct_cookie_desired;
  261. u_int16_t tcpct_s_data_desired;
  262. u_int16_t tcpct_used;
  263. u_int8_t tcpct_value[TCP_MSS_DEFAULT];
  264. };
  265. #endif /* Misc. */
  266. #endif /* netinet/tcp.h */