RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / cfe / cfe / net / net_http.h
blob249caacdb094b2ce9d11483d0fe3dbbeb97eb1d4
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * TCP and HTTP Protocol Definitions File: net_http.h
5 *
6 * This file contains TCP and HTTP protocol-specific definitions
7 *
8 * Author:
9 *
10 *********************************************************************
12 * Copyright 2000~2008
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 ********************************************************************* */
47 #ifndef _NET_HTTP_H
48 #define _NET_HTTP_H
50 /* *********************************************************************
51 * TCP Constants
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 /* *********************************************************************
62 * TCP Protocol
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 /* *********************************************************************
79 * TCP State machine
80 ********************************************************************* */
82 /*
83 * TCB states, see RFC
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 /* *********************************************************************
99 * TCP Control Block
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 */
112 uint32_t txlen;
113 char *tcb_rxbuf; /* Receive buffer */
114 uint32_t rxlen;
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
132 uint32_t wait_ack;
134 } tcb_t;
136 #ifdef _TCP_DEBUG_
137 #define _tcp_setstate(tcb,state) (tcb)->tcb_state = (state); \
138 printf("tcp state = " #state "\n");
139 #define DEBUGMSG(x) printf x
140 #else
141 #define _tcp_setstate(tcb,state) (tcb)->tcb_state = (state);
142 #define DEBUGMSG(x)
143 #endif /* _TCP_DEBUG_ */
145 /* *********************************************************************
146 * HTTP API
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 */