1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * TCP and HTTP Protocol Definitions File: net_http.h
6 * This file contains TCP and HTTP protocol-specific definitions
10 *********************************************************************
13 * Broadcom Corporation. All rights reserved.
15 * This software is furnished under license and may be used and
16 * copied only in accordance with the following terms and
17 * conditions. Subject to these conditions, you may download,
18 * copy, install, use, modify and distribute modified or unmodified
19 * copies of this software in source and/or binary form. No title
20 * or ownership is transferred hereby.
22 * 1) Any source code used, modified or distributed must reproduce
23 * and retain this copyright notice and list of conditions
24 * as they appear in the source file.
26 * 2) No right is granted to use any trade name, trademark, or
27 * logo of Broadcom Corporation. The "Broadcom Corporation"
28 * name may not be used to endorse or promote products derived
29 * from this software without the prior written permission of
30 * Broadcom Corporation.
32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
44 * THE POSSIBILITY OF SUCH DAMAGE.
45 ********************************************************************* */
50 /* *********************************************************************
52 ********************************************************************* */
55 #define TCP_MAX_PORTS 1
56 #define TCP_MAX_TCBS 16
57 #define TCP_BUF_SIZE 65536
59 #define TCP_MAX_SEG_SIZE 1400
61 /* *********************************************************************
63 ********************************************************************* */
65 #define TCPFLG_FIN 0x0001
66 #define TCPFLG_SYN 0x0002
67 #define TCPFLG_RST 0x0004
68 #define TCPFLG_PSH 0x0008
69 #define TCPFLG_ACK 0x0010
70 #define TCPFLG_URG 0x0020
71 #define TCPHDRSIZE(flg) (((flg) >> 12)*4)
72 #define TCPHDRFLG(size) (((size)/4)<<12)
74 #define TCP_HDR_LENGTH 20
76 #define TCP_MAX_SEG_OPT 0x0204
78 /* *********************************************************************
80 ********************************************************************* */
86 #define TCPSTATE_CLOSED 0
87 #define TCPSTATE_LISTEN 1
88 #define TCPSTATE_SYN_SENT 2
89 #define TCPSTATE_SYN_RECEIVED 3
90 #define TCPSTATE_ESTABLISHED 4
91 #define TCPSTATE_CLOSE_WAIT 5
92 #define TCPSTATE_FINWAIT_1 6
93 #define TCPSTATE_FINWAIT_2 7
94 #define TCPSTATE_CLOSING 8
95 #define TCPSTATE_LAST_ACK 9
96 #define TCPSTATE_TIME_WAIT 10
98 /* *********************************************************************
100 ********************************************************************* */
102 typedef struct tcb_s
{
103 int tcb_state
; /* current connection state */
105 uint8_t tcb_peeraddr
[IP_ADDR_LEN
]; /* Peer's IP Address */
106 uint16_t tcb_peerport
; /* Peer's port address */
107 uint16_t tcb_lclport
; /* My port address */
109 uint16_t tcb_txflags
; /* packet flags for next tx packet */
110 uint16_t rxflag
; /* packet flags for receive packet */
111 char *tcb_txbuf
; /* Transmit buffer */
113 char *tcb_rxbuf
; /* Receive buffer */
116 unsigned int tcb_flags
; /* Misc protocol flags */
119 * Send sequence variables
121 uint32_t tcb_sendnext
; /* Next seqnum to send */
122 uint32_t tcb_sendwindow
; /* Last advertised send window */
125 * Receive sequence variables
127 uint32_t tcb_rcvnext
; /* next in-order receive seq num */
130 * Window management variables
137 #define _tcp_setstate(tcb,state) (tcb)->tcb_state = (state); \
138 printf("tcp state = " #state "\n");
139 #define DEBUGMSG(x) printf x
141 #define _tcp_setstate(tcb,state) (tcb)->tcb_state = (state);
143 #endif /* _TCP_DEBUG_ */
145 /* *********************************************************************
147 ********************************************************************* */
149 typedef struct http_info_s http_info_t
;
151 http_info_t
*_tcphttp_init(ip_info_t
*ipi
,void *ref
);
152 void _tcphttp_uninit(http_info_t
*info
);
154 #endif /* _NET_HTTP_H */