2013-02-26 00:00:02 +08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2012
|
|
|
|
*
|
|
|
|
* Gregory Detal <gregory.detal@uclouvain.be>
|
|
|
|
* Christoph Paasch <christoph.paasch@uclouvain.be>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 3. Neither the name of the University nor of the Laboratory may be used
|
|
|
|
* to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <tcpdump-stdinc.h>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "extract.h"
|
|
|
|
#include "addrtoname.h"
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
#include "tcp.h"
|
2013-02-26 00:00:02 +08:00
|
|
|
|
2013-12-31 14:52:15 +08:00
|
|
|
#define MPTCP_SUB_CAPABLE 0x0
|
|
|
|
#define MPTCP_SUB_JOIN 0x1
|
|
|
|
#define MPTCP_SUB_DSS 0x2
|
|
|
|
#define MPTCP_SUB_ADD_ADDR 0x3
|
|
|
|
#define MPTCP_SUB_REMOVE_ADDR 0x4
|
|
|
|
#define MPTCP_SUB_PRIO 0x5
|
|
|
|
#define MPTCP_SUB_FAIL 0x6
|
|
|
|
#define MPTCP_SUB_FCLOSE 0x7
|
|
|
|
|
|
|
|
struct mptcp_option {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub_etc; /* subtype upper 4 bits, other stuff lower 4 bits */
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MPTCP_OPT_SUBTYPE(sub_etc) (((sub_etc) >> 4) & 0xF)
|
|
|
|
|
|
|
|
struct mp_capable {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub_ver;
|
|
|
|
uint8_t flags;
|
|
|
|
uint8_t sender_key[8];
|
|
|
|
uint8_t receiver_key[8];
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_CAPABLE_OPT_VERSION(sub_ver) (((sub_ver) >> 0) & 0xF)
|
|
|
|
#define MP_CAPABLE_C 0x80
|
|
|
|
#define MP_CAPABLE_S 0x01
|
|
|
|
|
|
|
|
struct mp_join {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub_b;
|
|
|
|
uint8_t addr_id;
|
2013-12-31 14:52:15 +08:00
|
|
|
union {
|
|
|
|
struct {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t token[4];
|
|
|
|
uint8_t nonce[4];
|
2013-12-31 14:52:15 +08:00
|
|
|
} syn;
|
|
|
|
struct {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t mac[8];
|
|
|
|
uint8_t nonce[4];
|
2013-12-31 14:52:15 +08:00
|
|
|
} synack;
|
|
|
|
struct {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t mac[20];
|
2013-12-31 14:52:15 +08:00
|
|
|
} ack;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_JOIN_B 0x01
|
|
|
|
|
|
|
|
struct mp_dss {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub;
|
|
|
|
uint8_t flags;
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_DSS_F 0x10
|
|
|
|
#define MP_DSS_m 0x08
|
|
|
|
#define MP_DSS_M 0x04
|
|
|
|
#define MP_DSS_a 0x02
|
|
|
|
#define MP_DSS_A 0x01
|
|
|
|
|
|
|
|
struct mp_add_addr {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub_ipver;
|
|
|
|
uint8_t addr_id;
|
2013-12-31 14:52:15 +08:00
|
|
|
union {
|
|
|
|
struct {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t addr[4];
|
|
|
|
uint8_t port[2];
|
2013-12-31 14:52:15 +08:00
|
|
|
} v4;
|
|
|
|
struct {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t addr[16];
|
|
|
|
uint8_t port[2];
|
2013-12-31 14:52:15 +08:00
|
|
|
} v6;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_ADD_ADDR_IPVER(sub_ipver) (((sub_ipver) >> 0) & 0xF)
|
|
|
|
|
|
|
|
struct mp_remove_addr {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub;
|
2013-12-31 14:52:15 +08:00
|
|
|
/* list of addr_id */
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t addrs_id;
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_fail {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub;
|
|
|
|
uint8_t resv;
|
|
|
|
uint8_t data_seq[8];
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_close {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub;
|
|
|
|
uint8_t rsv;
|
|
|
|
uint8_t key[8];
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_prio {
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t kind;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t sub_b;
|
|
|
|
uint8_t addr_id;
|
2013-12-31 14:52:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_PRIO_B 0x01
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
dummy_print(netdissect_options *ndo _U_,
|
|
|
|
const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_capable_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
struct mp_capable *mpc = (struct mp_capable *) opt;
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if (!(opt_len == 12 && flags & TH_SYN) &&
|
|
|
|
!(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))
|
|
|
|
return 0;
|
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));
|
2013-04-17 22:05:21 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mpc->flags & MP_CAPABLE_C)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " csum"));
|
|
|
|
ND_PRINT((ndo, " {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key)));
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len == 20) /* ACK */
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, ",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));
|
|
|
|
ND_PRINT((ndo, "}"));
|
2013-02-26 00:00:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_join_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
struct mp_join *mpj = (struct mp_join *) opt;
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if (!(opt_len == 12 && flags & TH_SYN) &&
|
|
|
|
!(opt_len == 16 && (flags & (TH_SYN | TH_ACK)) == (TH_SYN | TH_ACK)) &&
|
|
|
|
!(opt_len == 24 && flags & TH_ACK))
|
|
|
|
return 0;
|
2013-02-26 00:00:02 +08:00
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len != 24) {
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mpj->sub_b & MP_JOIN_B)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " backup"));
|
|
|
|
ND_PRINT((ndo, " id %u", mpj->addr_id));
|
2013-04-17 22:05:21 +08:00
|
|
|
}
|
2013-02-26 00:00:02 +08:00
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
switch (opt_len) {
|
|
|
|
case 12: /* SYN */
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " token 0x%x" " nonce 0x%x",
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
EXTRACT_32BITS(mpj->u.syn.token),
|
2014-03-20 18:39:44 +08:00
|
|
|
EXTRACT_32BITS(mpj->u.syn.nonce)));
|
2013-04-17 22:05:21 +08:00
|
|
|
break;
|
|
|
|
case 16: /* SYN/ACK */
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " hmac 0x%" PRIx64 " nonce 0x%x",
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
EXTRACT_64BITS(mpj->u.synack.mac),
|
2014-03-20 18:39:44 +08:00
|
|
|
EXTRACT_32BITS(mpj->u.synack.nonce)));
|
2013-04-17 22:05:21 +08:00
|
|
|
break;
|
|
|
|
case 24: {/* ACK */
|
2013-05-06 09:31:48 +08:00
|
|
|
size_t i;
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " hmac 0x"));
|
2013-04-17 22:05:21 +08:00
|
|
|
for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, "%02x", mpj->u.ack.mac[i]));
|
2013-04-17 22:05:21 +08:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-02-26 00:00:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
static u_int mp_dss_len(struct mp_dss *m, int csum)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
u_int len;
|
|
|
|
|
|
|
|
len = 4;
|
|
|
|
if (m->flags & MP_DSS_A) {
|
|
|
|
/* Ack present - 4 or 8 octets */
|
|
|
|
len += (m->flags & MP_DSS_a) ? 8 : 4;
|
|
|
|
}
|
|
|
|
if (m->flags & MP_DSS_M) {
|
|
|
|
/*
|
|
|
|
* Data Sequence Number (DSN), Subflow Sequence Number (SSN),
|
|
|
|
* Data-Level Length present, and Checksum possibly present.
|
|
|
|
* All but the Checksum are 10 bytes if the m flag is
|
|
|
|
* clear (4-byte DSN) and 14 bytes if the m flag is set
|
|
|
|
* (8-byte DSN).
|
|
|
|
*/
|
|
|
|
len += (m->flags & MP_DSS_m) ? 14 : 10;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Checksum is present only if negotiated.
|
|
|
|
*/
|
|
|
|
if (csum)
|
|
|
|
len += 2;
|
|
|
|
}
|
|
|
|
return len;
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_dss_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
struct mp_dss *mdss = (struct mp_dss *) opt;
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if ((opt_len != mp_dss_len(mdss, 1) &&
|
|
|
|
opt_len != mp_dss_len(mdss, 0)) || flags & TH_SYN)
|
|
|
|
return 0;
|
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mdss->flags & MP_DSS_F)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " fin"));
|
2013-02-26 00:00:02 +08:00
|
|
|
|
|
|
|
opt += 4;
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mdss->flags & MP_DSS_A) {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " ack "));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mdss->flags & MP_DSS_a) {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
opt += 8;
|
|
|
|
} else {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
opt += 4;
|
|
|
|
}
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mdss->flags & MP_DSS_M) {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " seq "));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mdss->flags & MP_DSS_m) {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
opt += 8;
|
|
|
|
} else {
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
opt += 4;
|
|
|
|
}
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " subseq %u", EXTRACT_32BITS(opt)));
|
2013-02-26 00:00:02 +08:00
|
|
|
opt += 4;
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " len %u", EXTRACT_16BITS(opt)));
|
2013-02-26 00:00:02 +08:00
|
|
|
opt += 2;
|
|
|
|
|
|
|
|
if (opt_len == mp_dss_len(mdss, 1))
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " csum 0x%x", EXTRACT_16BITS(opt)));
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
add_addr_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
struct mp_add_addr *add_addr = (struct mp_add_addr *) opt;
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
u_int ipver = MP_ADD_ADDR_IPVER(add_addr->sub_ipver);
|
2013-02-26 00:00:02 +08:00
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (!((opt_len == 8 || opt_len == 10) && ipver == 4) &&
|
|
|
|
!((opt_len == 20 || opt_len == 22) && ipver == 6))
|
2013-04-17 22:05:21 +08:00
|
|
|
return 0;
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " id %u", add_addr->addr_id));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
switch (ipver) {
|
2013-02-26 00:00:02 +08:00
|
|
|
case 4:
|
2014-04-04 15:43:46 +08:00
|
|
|
ND_PRINT((ndo, " %s", ipaddr_string(ndo, add_addr->u.v4.addr)));
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (opt_len == 10)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
|
2013-02-26 00:00:02 +08:00
|
|
|
break;
|
|
|
|
case 6:
|
2013-04-17 22:05:21 +08:00
|
|
|
#ifdef INET6
|
2014-04-04 15:43:46 +08:00
|
|
|
ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
|
2013-02-26 00:00:02 +08:00
|
|
|
#endif
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (opt_len == 22)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
|
2013-04-17 22:05:21 +08:00
|
|
|
break;
|
2013-02-26 00:00:02 +08:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-17 22:05:21 +08:00
|
|
|
|
2013-02-26 00:00:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
remove_addr_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
2013-05-06 10:52:14 +08:00
|
|
|
struct mp_remove_addr *remove_addr = (struct mp_remove_addr *) opt;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t *addr_id = &remove_addr->addrs_id;
|
2013-02-26 00:00:02 +08:00
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len < 4)
|
|
|
|
return 0;
|
|
|
|
|
2013-02-26 00:00:02 +08:00
|
|
|
opt_len -= 3;
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " id"));
|
2013-02-26 00:00:02 +08:00
|
|
|
while (opt_len--)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " %u", *addr_id++));
|
2013-02-26 00:00:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_prio_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
|
|
|
struct mp_prio *mpp = (struct mp_prio *) opt;
|
|
|
|
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len != 3 && opt_len != 4)
|
|
|
|
return 0;
|
|
|
|
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
if (mpp->sub_b & MP_PRIO_B)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " backup"));
|
2013-02-26 00:00:02 +08:00
|
|
|
else
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " non-backup"));
|
2013-02-26 00:00:02 +08:00
|
|
|
if (opt_len == 4)
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " id %u", mpp->addr_id));
|
2013-02-26 00:00:02 +08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_fail_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len != 12)
|
|
|
|
return 0;
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " seq %" PRIu64, EXTRACT_64BITS(opt + 4)));
|
2013-04-15 08:21:19 +08:00
|
|
|
return 1;
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
static int
|
|
|
|
mp_fast_close_print(netdissect_options *ndo,
|
|
|
|
const u_char *opt, u_int opt_len, u_char flags _U_)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
2013-04-17 22:05:21 +08:00
|
|
|
if (opt_len != 12)
|
|
|
|
return 0;
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " key 0x%" PRIx64, EXTRACT_64BITS(opt + 4)));
|
2013-04-15 08:21:19 +08:00
|
|
|
return 1;
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct {
|
2013-02-26 00:00:02 +08:00
|
|
|
const char *name;
|
2014-03-20 18:39:44 +08:00
|
|
|
int (*print)(netdissect_options *, const u_char *, u_int, u_char);
|
2013-02-26 00:00:02 +08:00
|
|
|
} mptcp_options[] = {
|
2013-04-17 22:05:21 +08:00
|
|
|
{ "capable", mp_capable_print},
|
|
|
|
{ "join", mp_join_print },
|
2013-02-26 00:00:02 +08:00
|
|
|
{ "dss", mp_dss_print },
|
2013-04-17 22:05:21 +08:00
|
|
|
{ "add-addr", add_addr_print },
|
|
|
|
{ "rem-addr", remove_addr_print },
|
|
|
|
{ "prio", mp_prio_print },
|
|
|
|
{ "fail", mp_fail_print },
|
|
|
|
{ "fast-close", mp_fast_close_print },
|
|
|
|
{ "unknown", dummy_print },
|
2013-02-26 00:00:02 +08:00
|
|
|
};
|
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
int
|
|
|
|
mptcp_print(netdissect_options *ndo,
|
|
|
|
const u_char *cp, u_int len, u_char flags)
|
2013-02-26 00:00:02 +08:00
|
|
|
{
|
2013-04-17 22:05:21 +08:00
|
|
|
struct mptcp_option *opt;
|
|
|
|
u_int subtype;
|
|
|
|
|
|
|
|
if (len < 3)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
opt = (struct mptcp_option *) cp;
|
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
Bitfields are not one of C's shining points. There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware). In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned. Don't use them.
Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned. Use the EXTRACT_nBITS() macros.
__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled. Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).
Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
2013-05-06 09:52:54 +08:00
|
|
|
subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
|
2013-02-26 00:00:02 +08:00
|
|
|
|
2014-03-20 18:39:44 +08:00
|
|
|
ND_PRINT((ndo, " %s", mptcp_options[subtype].name));
|
|
|
|
return mptcp_options[subtype].print(ndo, cp, len, flags);
|
2013-02-26 00:00:02 +08:00
|
|
|
}
|