From 58b8f2a31e30a9fe9180f3758acaebf7deffbd91 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 17 Aug 2018 21:33:39 +1000 Subject: ctdb-common: Clean up comments in TCP packet parsing Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Thu Aug 30 07:50:04 CEST 2018 on sn-devel-144 --- ctdb/common/system_socket.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'ctdb/common') diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c index 9336eb50713..668c0454619 100644 --- a/ctdb/common/system_socket.c +++ b/ctdb/common/system_socket.c @@ -752,18 +752,17 @@ static int tcp4_extract(const uint8_t *ip_pkt, return EMSGSIZE; } - /* IP */ ip = (const struct ip *)ip_pkt; - /* We only want IPv4 packets */ + /* IPv4 only */ if (ip->ip_v != 4) { return ENOMSG; } - /* Dont look at fragments */ + /* Don't look at fragments */ if ((ntohs(ip->ip_off)&0x1fff) != 0) { return ENOMSG; } - /* we only want TCP */ + /* TCP only */ if (ip->ip_p != IPPROTO_TCP) { return ENOMSG; } @@ -774,10 +773,8 @@ static int tcp4_extract(const uint8_t *ip_pkt, return EMSGSIZE; } - /* TCP */ tcp = (const struct tcphdr *)(ip_pkt + (ip->ip_hl * sizeof(uint32_t))); - /* tell the caller which one we've found */ src->sin_family = AF_INET; src->sin_addr.s_addr = ip->ip_src.s_addr; src->sin_port = tcp->th_sport; @@ -815,7 +812,6 @@ static int tcp6_extract(const uint8_t *ip_pkt, return EMSGSIZE; } - /* IP6 */ ip6 = (const struct ip6_hdr *)ip_pkt; /* IPv6 only */ @@ -823,15 +819,13 @@ static int tcp6_extract(const uint8_t *ip_pkt, return ENOMSG; } - /* we only want TCP */ + /* TCP only */ if (ip6->ip6_nxt != IPPROTO_TCP) { return ENOMSG; } - /* TCP */ tcp = (const struct tcphdr *)(ip_pkt + sizeof(struct ip6_hdr)); - /* tell the caller which one we've found */ src->sin6_family = AF_INET6; src->sin6_port = tcp->th_sport; src->sin6_addr = ip6->ip6_src; -- cgit v1.2.1