2 * Copyright 2007, Broadcom Corporation
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.
10 * Fundamental constants relating to TCP Protocol
12 * $Id: bcmtcp.h,v 1.1.1.1 2007/05/31 08:00:41 michael Exp $
18 /* enable structure packing */
20 #define PACKED __attribute__((packed))
26 #define TCP_SRC_PORT_OFFSET 0 /* TCP source port offset */
27 #define TCP_DEST_PORT_OFFSET 2 /* TCP dest port offset */
28 #define TCP_CHKSUM_OFFSET 16 /* TCP body checksum offset */
30 /* These fields are stored in network order */
33 uint16 src_port
; /* Source Port Address */
34 uint16 dst_port
; /* Destination Port Address */
35 uint32 seq_num
; /* TCP Sequence Number */
36 uint32 ack_num
; /* TCP Sequence Number */
37 uint16 hdrlen_rsvd_flags
; /* Header length, reserved bits and flags */
38 uint16 tcpwin
; /* TCP window */
39 uint16 chksum
; /* Segment checksum with pseudoheader */
40 uint16 urg_ptr
; /* Points to seq-num of byte following urg data */
44 #if !defined(__GNUC__)
48 /* Byte offset of flags in TCP header */
49 #define TCP_FLAGS_OFFSET 13
51 #define TCP_FLAGS_FIN 0x01
52 #define TCP_FLAGS_SYN 0x02
53 #define TCP_FLAGS_RST 0x03
54 #define TCP_FLAGS_PSH 0x04
55 #define TCP_FLAGS_ACK 0x10
56 #define TCP_FLAGS_URG 0x20
57 #define TCP_FLAGS_ECN 0x40
58 #define TCP_FLAGS_CWR 0x80
60 #define TCP_FLAGS(tcp_hdr) (((uint8 *)(tcp_hdr))[TCP_FLAGS_OFFSET])
61 #define TCP_IS_ACK(tcp_hdr) (TCP_FLAGS(tcp_hdr) & TCP_FLAGS_ACK)
63 #define TCP_SRC_PORT(tcp_hdr) (ntoh16(((struct bcmtcp_hdr*)(tcp_hdr))->src_port))
64 #define TCP_DST_PORT(tcp_hdr) (ntoh16(((struct bcmtcp_hdr*)(tcp_hdr))->dst_port))
65 #define TCP_SEQ_NUM(tcp_hdr) (ntoh32(((struct bcmtcp_hdr*)(tcp_hdr))->seq_num))
66 #define TCP_ACK_NUM(tcp_hdr) (ntoh32(((struct bcmtcp_hdr*)(tcp_hdr))->ack_num))
68 #endif /* #ifndef _bcmtcp_h_ */
This page took 0.048427 seconds and 5 git commands to generate.