ip_tcp.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 1982, 1986 Regents of the University of California.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms are permitted
  6. * provided that the above copyright notice and this paragraph are
  7. * duplicated in all such forms and that any documentation,
  8. * advertising materials, and other materials related to such
  9. * distribution and use acknowledge that the software was developed
  10. * by the University of California, Berkeley. The name of the
  11. * University may not be used to endorse or promote products derived
  12. * from this software without specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * @(#)tcp.h 7.5 (Berkeley) 6/29/88
  18. */
  19. #ifndef _NETINET_IP_TCP_H
  20. #define _NETINET_IP_TCP_H
  21. #include <endian.h>
  22. #include <linux/socket.h>
  23. #include <sys/types.h>
  24. typedef u_int32_t tcp_seq;
  25. /*
  26. * TCP header.
  27. * Per RFC 793, September, 1981.
  28. */
  29. struct tcphdr {
  30. u_short th_sport; /* source port */
  31. u_short th_dport; /* destination port */
  32. tcp_seq th_seq; /* sequence number */
  33. tcp_seq th_ack; /* acknowledgement number */
  34. #if __BYTE_ORDER == __LITTLE_ENDIAN
  35. u_char th_x2:4, /* (unused) */
  36. th_off:4; /* data offset */
  37. #endif
  38. #if __BYTE_ORDER == __BIG_ENDIAN
  39. u_char th_off:4, /* data offset */
  40. th_x2:4; /* (unused) */
  41. #endif
  42. u_char th_flags;
  43. #define TH_FIN 0x01
  44. #define TH_SYN 0x02
  45. #define TH_RST 0x04
  46. #define TH_PUSH 0x08
  47. #define TH_ACK 0x10
  48. #define TH_URG 0x20
  49. u_short th_win; /* window */
  50. u_short th_sum; /* checksum */
  51. u_short th_urp; /* urgent pointer */
  52. };
  53. #define TCPOPT_EOL 0
  54. #define TCPOPT_NOP 1
  55. #define TCPOPT_MAXSEG 2
  56. /*
  57. * Default maximum segment size for TCP.
  58. * With an IP MSS of 576, this is 536,
  59. * but 512 is probably more convenient.
  60. */
  61. #ifdef lint
  62. #define TCP_MSS 536
  63. #else
  64. #define TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr))
  65. #endif
  66. #endif /* _NETINET_TCP_H */