[ar7] let 802.1q tagged frames go in and out from cpmac (#6730)
[openwrt.git] / package / broadcom-wl / src / driver / proto / bcmtcp.h
1 /*
2 * Copyright 2007, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9 *
10 * Fundamental constants relating to TCP Protocol
11 *
12 */
13
14 #ifndef _bcmtcp_h_
15 #define _bcmtcp_h_
16
17 /* enable structure packing */
18 #if defined(__GNUC__)
19 #define PACKED __attribute__((packed))
20 #else
21 #pragma pack(1)
22 #define PACKED
23 #endif
24
25 #define TCP_SRC_PORT_OFFSET 0 /* TCP source port offset */
26 #define TCP_DEST_PORT_OFFSET 2 /* TCP dest port offset */
27 #define TCP_CHKSUM_OFFSET 16 /* TCP body checksum offset */
28
29 /* These fields are stored in network order */
30 struct bcmtcp_hdr
31 {
32 uint16 src_port; /* Source Port Address */
33 uint16 dst_port; /* Destination Port Address */
34 uint32 seq_num; /* TCP Sequence Number */
35 uint32 ack_num; /* TCP Sequence Number */
36 uint16 hdrlen_rsvd_flags; /* Header length, reserved bits and flags */
37 uint16 tcpwin; /* TCP window */
38 uint16 chksum; /* Segment checksum with pseudoheader */
39 uint16 urg_ptr; /* Points to seq-num of byte following urg data */
40 } PACKED;
41
42 #undef PACKED
43 #if !defined(__GNUC__)
44 #pragma pack()
45 #endif
46
47 /* Byte offset of flags in TCP header */
48 #define TCP_FLAGS_OFFSET 13
49
50 #define TCP_FLAGS_FIN 0x01
51 #define TCP_FLAGS_SYN 0x02
52 #define TCP_FLAGS_RST 0x03
53 #define TCP_FLAGS_PSH 0x04
54 #define TCP_FLAGS_ACK 0x10
55 #define TCP_FLAGS_URG 0x20
56 #define TCP_FLAGS_ECN 0x40
57 #define TCP_FLAGS_CWR 0x80
58
59 #define TCP_FLAGS(tcp_hdr) (((uint8 *)(tcp_hdr))[TCP_FLAGS_OFFSET])
60 #define TCP_IS_ACK(tcp_hdr) (TCP_FLAGS(tcp_hdr) & TCP_FLAGS_ACK)
61
62 #define TCP_SRC_PORT(tcp_hdr) (ntoh16(((struct bcmtcp_hdr*)(tcp_hdr))->src_port))
63 #define TCP_DST_PORT(tcp_hdr) (ntoh16(((struct bcmtcp_hdr*)(tcp_hdr))->dst_port))
64 #define TCP_SEQ_NUM(tcp_hdr) (ntoh32(((struct bcmtcp_hdr*)(tcp_hdr))->seq_num))
65 #define TCP_ACK_NUM(tcp_hdr) (ntoh32(((struct bcmtcp_hdr*)(tcp_hdr))->ack_num))
66
67 #endif /* #ifndef _bcmtcp_h_ */
This page took 0.052332 seconds and 5 git commands to generate.