#ifndef _NETINET_MPTCP_H_
#define _NETINET_MPTCP_H_
#ifdef BSD_KERNEL_PRIVATE
#include <machine/endian.h>
#if BYTE_ORDER == BIG_ENDIAN
#define mptcp_hton64(x) (x)
#define mptcp_ntoh64(x) (x)
#else
#define mptcp_hton64(x) __DARWIN_OSSwapInt64(x)
#define mptcp_ntoh64(x) __DARWIN_OSSwapInt64(x)
#endif
#define MPO_CAPABLE 0x0
#define MPO_JOIN 0x1
#define MPO_DSS 0x2
#define MPO_ADD_ADDR 0x3
#define MPO_REMOVE_ADDR 0x4
#define MPO_PRIO 0x5
#define MPO_FAIL 0x6
#define MPO_FASTCLOSE 0x7
#define MPTCP_STD_VERSION_0 0x0
struct mptcp_mpcapable_opt_common {
u_int8_t mmco_kind;
u_int8_t mmco_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mmco_version:4,
mmco_subtype:4;
#else
u_int8_t mmco_subtype:4,
mmco_version:4;
#endif
#define MPCAP_PROPOSAL_SBIT 0x01
#define MPCAP_HBIT 0x01
#define MPCAP_GBIT 0x02
#define MPCAP_FBIT 0x04
#define MPCAP_EBIT 0x08
#define MPCAP_DBIT 0x10
#define MPCAP_CBIT 0x20
#define MPCAP_BBIT 0x40
#define MPCAP_ABIT 0x80
#define MPCAP_CHECKSUM_CBIT 0x80
u_int8_t mmco_flags;
} __attribute__((__packed__));
struct mptcp_mpcapable_opt_rsp {
struct mptcp_mpcapable_opt_common mmc_common;
mptcp_key_t mmc_localkey;
} __attribute__((__packed__));
struct mptcp_mpcapable_opt_rsp1 {
struct mptcp_mpcapable_opt_common mmc_common;
mptcp_key_t mmc_localkey;
mptcp_key_t mmc_remotekey;
} __attribute__((__packed__));
struct mptcp_mpjoin_opt_req {
u_int8_t mmjo_kind;
u_int8_t mmjo_len;
#define MPTCP_BACKUP 0x1
u_int8_t mmjo_subtype_bkp;
u_int8_t mmjo_addr_id;
u_int32_t mmjo_peer_token;
u_int32_t mmjo_rand;
} __attribute__((__packed__));
struct mptcp_mpjoin_opt_rsp {
u_int8_t mmjo_kind;
u_int8_t mmjo_len;
#define MPTCP_BACKUP 0x1
u_int8_t mmjo_subtype_bkp;
u_int8_t mmjo_addr_id;
u_int64_t mmjo_mac;
u_int32_t mmjo_rand;
} __attribute__((__packed__));
struct mptcp_mpjoin_opt_rsp2 {
u_int8_t mmjo_kind;
u_int8_t mmjo_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mmjo_reserved1:4,
mmjo_subtype:4;
#else
u_int8_t mmjo_subtype:4,
mmjo_reserved1:4;
#endif
u_int8_t mmjo_reserved2;
u_int8_t mmjo_mac[20];
} __attribute__((__packed__));
struct mptcp_addaddr_opt {
u_int8_t ma_kind;
u_int8_t ma_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t ma_ipver:4,
ma_subtype:4;
#else
u_int8_t ma_subtype:4,
ma_ipver:4;
#endif
#define MA_IPVer_V4 4
#define MA_IPVer_V6 6
u_int8_t ma_addr_id;
} __attribute__((__packed__));
struct mptcp_addr_family_val {
union {
struct in_addr ma_v4_addr;
struct in6_addr ma_v6_addr;
} ma_addr;
} __attribute__((__packed__));
struct mptcp_remaddr_opt {
u_int8_t mr_kind;
u_int8_t mr_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mr_rest:4,
mr_subtype:4;
#else
u_int8_t mr_subtype:4,
mr_rest:4;
#endif
u_int8_t mr_addr_id;
} __attribute__((__packed__));
#define MDSS_A 0x01
#define MDSS_a 0x02
#define MDSS_M 0x04
#define MDSS_m 0x08
#define MDSS_F 0x10
struct mptcp_dss_copt {
u_int8_t mdss_kind;
u_int8_t mdss_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mdss_reserved1:4,
mdss_subtype:4;
#else
u_int8_t mdss_subtype:4,
mdss_reserved1:4;
#endif
u_int8_t mdss_flags;
}__attribute__((__packed__));
struct mptcp_dsn_opt {
struct mptcp_dss_copt mdss_copt;
u_int32_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_dsn64_opt {
struct mptcp_dss_copt mdss_copt;
u_int64_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_data_ack_opt {
struct mptcp_dss_copt mdss_copt;
u_int32_t mdss_ack;
}__attribute__((__packed__));
struct mptcp_data_ack64_opt {
struct mptcp_dss_copt mdss_copt;
u_int64_t mdss_ack;
}__attribute__((__packed__));
struct mptcp_dss_ack_opt {
struct mptcp_dss_copt mdss_copt;
u_int32_t mdss_ack;
u_int32_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_dss64_ack64_opt {
struct mptcp_dss_copt mdss_copt;
u_int64_t mdss_ack;
u_int64_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_dss32_ack64_opt {
struct mptcp_dss_copt mdss_copt;
u_int64_t mdss_ack;
u_int32_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_dss64_ack32_opt {
struct mptcp_dss_copt mdss_copt;
u_int32_t mdss_ack;
u_int64_t mdss_dsn;
u_int32_t mdss_subflow_seqn;
u_int16_t mdss_data_len;
}__attribute__((__packed__));
struct mptcp_fastclose_opt {
u_int8_t mfast_kind;
u_int8_t mfast_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mfast_reserved:4,
mfast_subtype:4;
#else
u_int8_t mfast_subtype:4,
mfast_reserved:4;
#endif
u_int8_t mfast_reserved1;
u_int64_t mfast_key;
}__attribute__((__packed__));
struct mptcp_mpfail_opt {
u_int8_t mfail_kind;
u_int8_t mfail_len;
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mfail_reserved:4,
mfail_subtype:4;
#else
u_int8_t mfail_subtype:4,
mfail_reserved:4;
#endif
u_int8_t mfail_reserved1:8;
u_int64_t mfail_dsn;
}__attribute__((__packed__));
struct mptcp_mpprio_opt {
u_int8_t mpprio_kind;
u_int8_t mpprio_len;
#define MPTCP_MPPRIO_BKP 0x1
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mpprio_flags:4,
mpprio_subtype:4;
#else
u_int8_t mpprio_subtype:4,
mpprio_flags:4;
#endif
}__attribute__((__packed__));
struct mptcp_mpprio_addr_opt {
u_int8_t mpprio_kind;
u_int8_t mpprio_len;
#define MPTCP_MPPRIO_BKP 0x1
#if BYTE_ORDER == LITTLE_ENDIAN
u_int8_t mpprio_flags:4,
mpprio_subtype:4;
#else
u_int8_t mpprio_subtype:4,
mpprio_flags:4;
#endif
u_int8_t mpprio_addrid;
}__attribute__((__packed__));
struct mptcp_pseudohdr {
u_int64_t mphdr_dsn;
u_int32_t mphdr_ssn;
u_int16_t mphdr_len;
u_int16_t mphdr_xsum;
}__attribute__((__packed__));
#endif
#endif