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
17 /* enable structure packing */
19 #define PACKED __attribute__((packed))
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 */
29 /* These fields are stored in network order */
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 */
43 #if !defined(__GNUC__)
47 /* Byte offset of flags in TCP header */
48 #define TCP_FLAGS_OFFSET 13
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
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)
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))
67 #endif /* #ifndef _bcmtcp_h_ */
This page took 0.046267 seconds and 5 git commands to generate.