summaryrefslogtreecommitdiff
path: root/print-mptcp.c
diff options
context:
space:
mode:
authorDavide Caratti <dcaratti@redhat.com>2020-01-13 15:07:30 +0100
committerfxlb <devel.fx.lebail@orange.fr>2020-02-28 14:34:47 +0100
commit4738c1fa73227fcc0fc4de757572807cadec2b01 (patch)
tree2f1e0772aa817991cf46ea0e9bfe62e262246b94 /print-mptcp.c
parent3520ce005723144706aebc747d4714ccd503331d (diff)
downloadtcpdump-4738c1fa73227fcc0fc4de757572807cadec2b01.tar.gz
MPTCP: parse MP_CAPABLE v1 options
A new version of MPTCP protocol (RFC8684) has been published, with some changes to the MP_CAPABLE options handling. Let tcpdump print the protocol version, and adjust parsing of MP_CAPABLE options according to RFC8684. Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Diffstat (limited to 'print-mptcp.c')
-rw-r--r--print-mptcp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/print-mptcp.c b/print-mptcp.c
index e3a82fe6..43258e50 100644
--- a/print-mptcp.c
+++ b/print-mptcp.c
@@ -178,21 +178,30 @@ mp_capable_print(netdissect_options *ndo,
{
const struct mp_capable *mpc = (const struct mp_capable *) opt;
- if (!(opt_len == 12 && (flags & TH_SYN)) &&
- !(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))
+ if (!((opt_len == 12 || opt_len == 4) && flags & TH_SYN) &&
+ !((opt_len == 20 || opt_len == 22) && (flags & (TH_SYN | TH_ACK)) ==
+ TH_ACK))
return 0;
- if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
- ND_PRINT(" Unknown Version (%u)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver));
- return 1;
+ switch (MP_CAPABLE_OPT_VERSION(mpc->sub_ver)) {
+ case 0: /* fall through */
+ case 1:
+ ND_PRINT(" v%d", MP_CAPABLE_OPT_VERSION(mpc->sub_ver));
+ break;
+ default:
+ ND_PRINT(" Unknown Version (%d)",
+ MP_CAPABLE_OPT_VERSION(mpc->sub_ver));
+ return 1;
}
if (GET_U_1(mpc->flags) & MP_CAPABLE_C)
ND_PRINT(" csum");
- ND_PRINT(" {0x%" PRIx64, GET_BE_U_8(mpc->sender_key));
- if (opt_len == 20) /* ACK */
- ND_PRINT(",0x%" PRIx64, GET_BE_U_8(mpc->receiver_key));
- ND_PRINT("}");
+ if (opt_len == 12 || opt_len >= 20) {
+ ND_PRINT(" {0x%" PRIx64, GET_BE_U_8(mpc->sender_key));
+ if (opt_len >= 20)
+ ND_PRINT(",0x%" PRIx64, GET_BE_U_8(mpc->receiver_key));
+ ND_PRINT("}");
+ }
return 1;
}