| 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.4.1.2 (Berkeley) %G% |
| 18 | */ |
| 19 | #ifndef BYTE_ORDER |
| 20 | /* |
| 21 | * Definitions for byte order, |
| 22 | * according to byte significance from low address to high. |
| 23 | */ |
| 24 | #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ |
| 25 | #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ |
| 26 | #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ |
| 27 | |
| 28 | #ifdef vax |
| 29 | #define BYTE_ORDER LITTLE_ENDIAN |
| 30 | #else |
| 31 | #define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */ |
| 32 | #endif |
| 33 | #endif BYTE_ORDER |
| 34 | |
| 35 | typedef u_long tcp_seq; |
| 36 | /* |
| 37 | * TCP header. |
| 38 | * Per RFC 793, September, 1981. |
| 39 | */ |
| 40 | struct tcphdr { |
| 41 | u_short th_sport; /* source port */ |
| 42 | u_short th_dport; /* destination port */ |
| 43 | tcp_seq th_seq; /* sequence number */ |
| 44 | tcp_seq th_ack; /* acknowledgement number */ |
| 45 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 46 | u_char th_x2:4, /* (unused) */ |
| 47 | th_off:4; /* data offset */ |
| 48 | #endif |
| 49 | #if BYTE_ORDER == BIG_ENDIAN |
| 50 | u_char th_off:4, /* data offset */ |
| 51 | th_x2:4; /* (unused) */ |
| 52 | #endif |
| 53 | u_char th_flags; |
| 54 | #define TH_FIN 0x01 |
| 55 | #define TH_SYN 0x02 |
| 56 | #define TH_RST 0x04 |
| 57 | #define TH_PUSH 0x08 |
| 58 | #define TH_ACK 0x10 |
| 59 | #define TH_URG 0x20 |
| 60 | u_short th_win; /* window */ |
| 61 | u_short th_sum; /* checksum */ |
| 62 | u_short th_urp; /* urgent pointer */ |
| 63 | }; |
| 64 | |
| 65 | #define TCPOPT_EOL 0 |
| 66 | #define TCPOPT_NOP 1 |
| 67 | #define TCPOPT_MAXSEG 2 |
| 68 | |
| 69 | /* |
| 70 | * Default maximum segment size for TCP. |
| 71 | * With an IP MSS of 576, this is 536, |
| 72 | * but 512 is probably more convenient. |
| 73 | */ |
| 74 | #ifdef lint |
| 75 | #define TCP_MSS 536 |
| 76 | #else |
| 77 | #ifndef IP_MSS |
| 78 | #define IP_MSS 576 |
| 79 | #endif |
| 80 | #define TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr)) |
| 81 | #endif |
| 82 | |
| 83 | /* |
| 84 | * User-settable options (used with setsockopt). |
| 85 | */ |
| 86 | #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ |
| 87 | #define TCP_MAXSEG 0x02 /* set maximum segment size */ |