1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | // Copyright (c) 2004 Xilinx, Inc. All rights reserved. |
---|
3 | // |
---|
4 | // Xilinx, Inc. |
---|
5 | // XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A |
---|
6 | // COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS |
---|
7 | // ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR |
---|
8 | // STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION |
---|
9 | // IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE |
---|
10 | // FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. |
---|
11 | // XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO |
---|
12 | // THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO |
---|
13 | // ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
---|
14 | // FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
15 | // AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
16 | // |
---|
17 | // File : tcp.h |
---|
18 | // Date : 2002, March 20. |
---|
19 | // Author : Sathya Thammanur |
---|
20 | // Company: Xilinx |
---|
21 | // Group : Emerging Software Technologies |
---|
22 | // |
---|
23 | // Summary: |
---|
24 | // Header file for TCP |
---|
25 | // |
---|
26 | // $Id: tcp.h,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $ |
---|
27 | // |
---|
28 | //////////////////////////////////////////////////////////////////////////////// |
---|
29 | |
---|
30 | //////////////////////////////////////////////////////////////////////////////// |
---|
31 | // see copyright.txt for Rice University/Mango Communications modifications |
---|
32 | //////////////////////////////////////////////////////////////////////////////// |
---|
33 | |
---|
34 | #ifndef _TCP_H |
---|
35 | #define _TCP_H |
---|
36 | |
---|
37 | #ifdef __cplusplus |
---|
38 | extern "C" { |
---|
39 | #endif |
---|
40 | |
---|
41 | #include <xilnet_ip.h> |
---|
42 | #include <xilnet_config.h> |
---|
43 | |
---|
44 | #define TCP_HDR_LEN 0x05 /* hlen in no.of 32-bit words */ |
---|
45 | #define IP_PROTO_TCP 0x06 /* protocol field in ip header */ |
---|
46 | #define TCP_PORT 8080 /* tcp port for web server */ |
---|
47 | |
---|
48 | struct xilnet_tcp_hdr { |
---|
49 | unsigned short src_port; |
---|
50 | unsigned short dst_port; |
---|
51 | unsigned int seq_no; |
---|
52 | unsigned int ack_no; |
---|
53 | unsigned short hdr_len:4, |
---|
54 | reserved:6, |
---|
55 | urg:1, |
---|
56 | ack:1, |
---|
57 | psh:1, |
---|
58 | rst:1, |
---|
59 | syn:1, |
---|
60 | fin:1; |
---|
61 | unsigned char window_size[2]; |
---|
62 | unsigned short check_sum; |
---|
63 | unsigned short urg_ptr; |
---|
64 | }; |
---|
65 | |
---|
66 | // tcp flags |
---|
67 | #define TCP_FIN 0x01 |
---|
68 | #define TCP_SYN 0x02 |
---|
69 | #define TCP_RST 0x04 |
---|
70 | #define TCP_PSH 0x08 |
---|
71 | #define TCP_ACK 0x10 |
---|
72 | #define TCP_URG 0x20 |
---|
73 | |
---|
74 | // offsets for fields in tcp pkt |
---|
75 | #define TCP_FLAGS_OFF 0x0d |
---|
76 | #define TCP_DEST_OFF 0x02 |
---|
77 | #define TCP_SRC_OFF 0x0 |
---|
78 | #define TCP_SEQ_OFF 0x04 |
---|
79 | #define TCP_ACKSEQ_OFF 0x08 |
---|
80 | #define TCP_HLEN_OFF 0x0c |
---|
81 | #define TCP_CHECK_OFF 0x10 |
---|
82 | #define TCP_WND_OFF 0xe |
---|
83 | #define TCP_URGPTR_OFF 0x12 |
---|
84 | |
---|
85 | // tcp mss max seg size |
---|
86 | #define TCP_MSS (LINK_HDR_LEN - 40) |
---|
87 | #define TCP_WND_HIGH (TCP_MSS >> 8) |
---|
88 | #define TCP_WND_LOW (TCP_MSS & 0xff) |
---|
89 | |
---|
90 | // tcp states |
---|
91 | enum { |
---|
92 | TCP_CLOSED = 1, |
---|
93 | TCP_LISTEN, |
---|
94 | TCP_SYN_RCVD, |
---|
95 | TCP_SYN_SENT, |
---|
96 | TCP_ESTABLISHED, |
---|
97 | TCP_CLOSE_WAIT, |
---|
98 | TCP_LAST_ACK, |
---|
99 | TCP_FIN_WAIT1, |
---|
100 | TCP_FIN_WAIT2, |
---|
101 | TCP_CLOSING, |
---|
102 | TCP_TIME_WAIT, |
---|
103 | }; |
---|
104 | |
---|
105 | // tcp conn management |
---|
106 | |
---|
107 | struct xilnet_tcp_conn { |
---|
108 | unsigned short src_port; |
---|
109 | unsigned short dst_port; |
---|
110 | unsigned char src_ip[IP_VERSION]; |
---|
111 | unsigned char dst_ip[IP_VERSION]; |
---|
112 | unsigned char state; |
---|
113 | int seqno; |
---|
114 | int ack_seqno; |
---|
115 | int exp_acknum; |
---|
116 | int fd; // socket descriptor into xsock_sockets table |
---|
117 | }; |
---|
118 | |
---|
119 | extern struct xilnet_tcp_conn xilnet_tcp_conns[MAX_TCP_CONNS]; |
---|
120 | |
---|
121 | extern void xilnet_tcp_init_conns(); |
---|
122 | |
---|
123 | #ifdef __cplusplus |
---|
124 | } |
---|
125 | #endif |
---|
126 | |
---|
127 | #endif /* _TCP_H */ |
---|