Commit 3c652996 authored by Paul Sokolovsky's avatar Paul Sokolovsky Committed by Jukka Rissanen
Browse files

net: tcp: Add NET_TCP_HDR_LEN(hdr) macro for reuse



Calculates full TCP header length (with options). Macro introduced
for reuse, to avoid "magic formula". (E.g., it would be needed to
parse TCP options).

Signed-off-by: default avatarPaul Sokolovsky <paul.sokolovsky@linaro.org>
parent bc88ad75
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1077,10 +1077,9 @@ static int tcp_hdr_len(struct net_pkt *pkt)
{
	struct net_tcp_hdr hdr, *tcp_hdr;

	/* "Offset": 4-bit field in high nibble, units of dwords */
	tcp_hdr = net_tcp_get_hdr(pkt, &hdr);
	if (tcp_hdr) {
		return 4 * (tcp_hdr->offset >> 4);
		return NET_TCP_HDR_LEN(tcp_hdr);
	}

	return 0;
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ enum net_tcp_state {

#define NET_TCP_FLAGS(hdr) (hdr->flags & NET_TCP_CTL)

/* Length of TCP header, including options */
/* "offset": 4-bit field in high nibble, units of dwords */
#define NET_TCP_HDR_LEN(hdr) (4 * ((hdr)->offset >> 4))

/* RFC 1122 4.2.2.6 "If an MSS option is not received at connection
 * setup, TCP MUST assume a default send MSS of 536"
 */