1*2c2f96dcSApple OSS Distributions /* 2*2c2f96dcSApple OSS Distributions * Copyright (c) 2013-2017 Apple Computer, Inc. All Rights Reserved. 3*2c2f96dcSApple OSS Distributions * 4*2c2f96dcSApple OSS Distributions * @APPLE_LICENSE_HEADER_START@ 5*2c2f96dcSApple OSS Distributions * 6*2c2f96dcSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*2c2f96dcSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*2c2f96dcSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*2c2f96dcSApple OSS Distributions * compliance with the License. Please obtain a copy of the License at 10*2c2f96dcSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this 11*2c2f96dcSApple OSS Distributions * file. 12*2c2f96dcSApple OSS Distributions * 13*2c2f96dcSApple OSS Distributions * The Original Code and all software distributed under the License are 14*2c2f96dcSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15*2c2f96dcSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16*2c2f96dcSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17*2c2f96dcSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18*2c2f96dcSApple OSS Distributions * Please see the License for the specific language governing rights and 19*2c2f96dcSApple OSS Distributions * limitations under the License. 20*2c2f96dcSApple OSS Distributions * 21*2c2f96dcSApple OSS Distributions * @APPLE_LICENSE_HEADER_END@ 22*2c2f96dcSApple OSS Distributions */ 23*2c2f96dcSApple OSS Distributions 24*2c2f96dcSApple OSS Distributions #pragma D depends_on library darwin.d 25*2c2f96dcSApple OSS Distributions #pragma D depends_on library socket.d 26*2c2f96dcSApple OSS Distributions #pragma D depends_on module mach_kernel 27*2c2f96dcSApple OSS Distributions #pragma D depends_on provider mptcp 28*2c2f96dcSApple OSS Distributions #pragma D depends_on provider ip 29*2c2f96dcSApple OSS Distributions 30*2c2f96dcSApple OSS Distributions /* 31*2c2f96dcSApple OSS Distributions * MPTCP Protocol Control Block. 32*2c2f96dcSApple OSS Distributions */ 33*2c2f96dcSApple OSS Distributions inline int MPTCPS_CLOSED = 0; 34*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_CLOSED 35*2c2f96dcSApple OSS Distributions inline int MPTCPS_LISTEN = 1; 36*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_LISTEN 37*2c2f96dcSApple OSS Distributions inline int MPTCPS_ESTABLISHED = 2; 38*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_ESTABLISHED 39*2c2f96dcSApple OSS Distributions inline int MPTCPS_CLOSE_WAIT = 3; 40*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_CLOSE_WAIT 41*2c2f96dcSApple OSS Distributions inline int MPTCPS_FIN_WAIT_1 = 4; 42*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_FIN_WAIT_1 43*2c2f96dcSApple OSS Distributions inline int MPTCPS_CLOSING = 5; 44*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_CLOSING 45*2c2f96dcSApple OSS Distributions inline int MPTCPS_LAST_ACK = 6; 46*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_LAST_ACK 47*2c2f96dcSApple OSS Distributions inline int MPTCPS_FIN_WAIT_2 = 7; 48*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_FIN_WAIT_2 49*2c2f96dcSApple OSS Distributions inline int MPTCPS_TIME_WAIT = 8; 50*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_TIME_WAIT 51*2c2f96dcSApple OSS Distributions inline int MPTCPS_TERMINATE = 10; 52*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTCPS_TERMINATE 53*2c2f96dcSApple OSS Distributions 54*2c2f96dcSApple OSS Distributions typedef struct mptsinfo { 55*2c2f96dcSApple OSS Distributions string state; 56*2c2f96dcSApple OSS Distributions uint32_t flags; 57*2c2f96dcSApple OSS Distributions uint32_t vers; 58*2c2f96dcSApple OSS Distributions uint32_t error; 59*2c2f96dcSApple OSS Distributions mptcp_key_t localkey; 60*2c2f96dcSApple OSS Distributions mptcp_key_t remotekey; 61*2c2f96dcSApple OSS Distributions mptcp_token_t localtoken; 62*2c2f96dcSApple OSS Distributions mptcp_token_t remotetoken; 63*2c2f96dcSApple OSS Distributions int rxtshift; 64*2c2f96dcSApple OSS Distributions uint32_t rxtstart; 65*2c2f96dcSApple OSS Distributions uint64_t rtseq; 66*2c2f96dcSApple OSS Distributions uint32_t timervals; 67*2c2f96dcSApple OSS Distributions uint32_t timewait; 68*2c2f96dcSApple OSS Distributions uint64_t snduna; 69*2c2f96dcSApple OSS Distributions uint64_t sndnxt; 70*2c2f96dcSApple OSS Distributions uint64_t sndmax; 71*2c2f96dcSApple OSS Distributions uint64_t local_idsn; 72*2c2f96dcSApple OSS Distributions uint32_t sndwnd; 73*2c2f96dcSApple OSS Distributions uint64_t rcvnxt; 74*2c2f96dcSApple OSS Distributions uint64_t remote_idsn; 75*2c2f96dcSApple OSS Distributions uint32_t rcvwnd; 76*2c2f96dcSApple OSS Distributions struct mptcb *mptcb; 77*2c2f96dcSApple OSS Distributions } mptsinfo_t; 78*2c2f96dcSApple OSS Distributions 79*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" translator 80*2c2f96dcSApple OSS Distributions translator mptsinfo_t < struct mptcb *T > { 81*2c2f96dcSApple OSS Distributions state = T->mpt_state == MPTCPS_CLOSED ? "state-closed" : 82*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_LISTEN ? "state-listen" : 83*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_ESTABLISHED ? 84*2c2f96dcSApple OSS Distributions "state-established" : 85*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_CLOSE_WAIT ? "state-close-wait" : 86*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_FIN_WAIT_1 ? "state-fin-wait-1" : 87*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_CLOSING ? "state-closing" : 88*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_LAST_ACK ? "state-last-ack" : 89*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_FIN_WAIT_2 ? "state-fin-wait-2" : 90*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_TIME_WAIT ? "state-time-wait" : 91*2c2f96dcSApple OSS Distributions T->mpt_state == MPTCPS_TERMINATE ? 92*2c2f96dcSApple OSS Distributions "state-terminate" : 93*2c2f96dcSApple OSS Distributions "<unknown>"; 94*2c2f96dcSApple OSS Distributions flags = T->mpt_flags; 95*2c2f96dcSApple OSS Distributions vers = T->mpt_version; 96*2c2f96dcSApple OSS Distributions error = T->mpt_softerror; 97*2c2f96dcSApple OSS Distributions localkey = T->mpt_localkey; 98*2c2f96dcSApple OSS Distributions remotekey = T->mpt_remotekey; 99*2c2f96dcSApple OSS Distributions localtoken = T->mpt_localtoken; 100*2c2f96dcSApple OSS Distributions remotetoken = T->mpt_remotetoken; 101*2c2f96dcSApple OSS Distributions rxtshift = T->mpt_rxtshift; 102*2c2f96dcSApple OSS Distributions rxtstart = T->mpt_rxtstart; 103*2c2f96dcSApple OSS Distributions rtseq = T->mpt_rtseq; 104*2c2f96dcSApple OSS Distributions timervals = T->mpt_timer_vals; 105*2c2f96dcSApple OSS Distributions timewait = T->mpt_timewait; 106*2c2f96dcSApple OSS Distributions snduna = T->mpt_snduna; 107*2c2f96dcSApple OSS Distributions sndnxt = T->mpt_sndnxt; 108*2c2f96dcSApple OSS Distributions sndmax = T->mpt_sndmax; 109*2c2f96dcSApple OSS Distributions local_idsn = T->mpt_local_idsn; 110*2c2f96dcSApple OSS Distributions sndwnd = T->mpt_sndwnd; 111*2c2f96dcSApple OSS Distributions rcvnxt = T->mpt_rcvnxt; 112*2c2f96dcSApple OSS Distributions remote_idsn = T->mpt_remote_idsn; 113*2c2f96dcSApple OSS Distributions rcvwnd = T->mpt_rcvwnd; 114*2c2f96dcSApple OSS Distributions mptcb = T; 115*2c2f96dcSApple OSS Distributions }; 116*2c2f96dcSApple OSS Distributions 117*2c2f96dcSApple OSS Distributions /* 118*2c2f96dcSApple OSS Distributions * Multipath Control Block. 119*2c2f96dcSApple OSS Distributions */ 120*2c2f96dcSApple OSS Distributions inline int MPPCB_STATE_INUSE = 1; 121*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPPCB_STATE_INUSE 122*2c2f96dcSApple OSS Distributions inline int MPPCB_STATE_DEAD = 2; 123*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPPCB_STATE_DEAD 124*2c2f96dcSApple OSS Distributions 125*2c2f96dcSApple OSS Distributions typedef struct mppsinfo { 126*2c2f96dcSApple OSS Distributions string state; 127*2c2f96dcSApple OSS Distributions uint32_t flags; 128*2c2f96dcSApple OSS Distributions struct mppcb *mppcb; 129*2c2f96dcSApple OSS Distributions } mppsinfo_t; 130*2c2f96dcSApple OSS Distributions 131*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" translator 132*2c2f96dcSApple OSS Distributions translator mppsinfo_t < struct mppcb *T> { 133*2c2f96dcSApple OSS Distributions state = T ? 134*2c2f96dcSApple OSS Distributions T->mpp_state == MPPCB_STATE_INUSE ? "state-inuse" : 135*2c2f96dcSApple OSS Distributions T->mpp_state == MPPCB_STATE_DEAD ? "state-dead" : 136*2c2f96dcSApple OSS Distributions "<unknown>" : "<null>"; 137*2c2f96dcSApple OSS Distributions flags = T->mpp_flags; 138*2c2f96dcSApple OSS Distributions mppcb = T; 139*2c2f96dcSApple OSS Distributions }; 140*2c2f96dcSApple OSS Distributions 141*2c2f96dcSApple OSS Distributions /* 142*2c2f96dcSApple OSS Distributions * MPTCP Session. 143*2c2f96dcSApple OSS Distributions */ 144*2c2f96dcSApple OSS Distributions typedef struct mptsesinfo { 145*2c2f96dcSApple OSS Distributions uint16_t numflows; 146*2c2f96dcSApple OSS Distributions uint16_t nummpcapflows; 147*2c2f96dcSApple OSS Distributions sae_connid_t connid_last; 148*2c2f96dcSApple OSS Distributions uint8_t flags; 149*2c2f96dcSApple OSS Distributions struct mptses *mptses; 150*2c2f96dcSApple OSS Distributions } mptsesinfo_t; 151*2c2f96dcSApple OSS Distributions 152*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" translator 153*2c2f96dcSApple OSS Distributions translator mptsesinfo_t < struct mptses *T > { 154*2c2f96dcSApple OSS Distributions numflows = T->mpte_numflows; 155*2c2f96dcSApple OSS Distributions nummpcapflows = T->mpte_nummpcapflows; 156*2c2f96dcSApple OSS Distributions connid_last = T->mpte_connid_last; 157*2c2f96dcSApple OSS Distributions flags = T->mpte_flags; 158*2c2f96dcSApple OSS Distributions mptses = T; 159*2c2f96dcSApple OSS Distributions }; 160*2c2f96dcSApple OSS Distributions 161*2c2f96dcSApple OSS Distributions /* 162*2c2f96dcSApple OSS Distributions * MPTCP Subflow. 163*2c2f96dcSApple OSS Distributions */ 164*2c2f96dcSApple OSS Distributions inline int MPTSF_CONNECTING = 0x00002; 165*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_CONNECTING 166*2c2f96dcSApple OSS Distributions inline int MPTSF_CONNECT_PENDING= 0x00004; 167*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_CONNECT_PENDING 168*2c2f96dcSApple OSS Distributions inline int MPTSF_CONNECTED = 0x00008; 169*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_CONNECTED 170*2c2f96dcSApple OSS Distributions inline int MPTSF_DISCONNECTING = 0x00010; 171*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_DISCONNECTING 172*2c2f96dcSApple OSS Distributions inline int MPTSF_DISCONNECTED = 0x00020; 173*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_DISCONNECTED 174*2c2f96dcSApple OSS Distributions inline int MPTSF_MP_CAPABLE = 0x00040; 175*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_MP_CAPABLE 176*2c2f96dcSApple OSS Distributions inline int MPTSF_MP_READY = 0x00080; 177*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_MP_READY 178*2c2f96dcSApple OSS Distributions inline int MPTSF_MP_DEGRADED = 0x00100; 179*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_MP_DEGRADED 180*2c2f96dcSApple OSS Distributions inline int MPTSF_SUSPENDED = 0x00200; 181*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_SUSPENDED 182*2c2f96dcSApple OSS Distributions inline int MPTSF_BOUND_IF = 0x00400; 183*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_BOUND_IF 184*2c2f96dcSApple OSS Distributions inline int MPTSF_BOUND_IP = 0x00800; 185*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_BOUND_IP 186*2c2f96dcSApple OSS Distributions inline int MPTSF_BOUND_PORT = 0x01000; 187*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_BOUND_PORT 188*2c2f96dcSApple OSS Distributions inline int MPTSF_PREFERRED = 0x02000; 189*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_PREFERRED 190*2c2f96dcSApple OSS Distributions inline int MPTSF_SOPT_OLDVAL = 0x04000; 191*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_SOPT_OLDVAL 192*2c2f96dcSApple OSS Distributions inline int MPTSF_SOPT_INPROG = 0x08000; 193*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_SOPT_INPROG 194*2c2f96dcSApple OSS Distributions inline int MPTSF_DELETEOK = 0x10000; 195*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_DELETEOK 196*2c2f96dcSApple OSS Distributions inline int MPTSF_FAILINGOVER = 0x20000; 197*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_FAILINGOVER 198*2c2f96dcSApple OSS Distributions inline int MPTSF_ACTIVE = 0x40000; 199*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_ACTIVE 200*2c2f96dcSApple OSS Distributions inline int MPTSF_MPCAP_CTRSET = 0x80000; 201*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" MPTSF_MPCAP_CTRSET 202*2c2f96dcSApple OSS Distributions 203*2c2f96dcSApple OSS Distributions typedef struct mptsubinfo { 204*2c2f96dcSApple OSS Distributions uint32_t flags; 205*2c2f96dcSApple OSS Distributions uint32_t evctl; 206*2c2f96dcSApple OSS Distributions sae_connid_t connid; 207*2c2f96dcSApple OSS Distributions uint32_t rank; 208*2c2f96dcSApple OSS Distributions struct mptsub *mptsub; 209*2c2f96dcSApple OSS Distributions } mptsubinfo_t; 210*2c2f96dcSApple OSS Distributions 211*2c2f96dcSApple OSS Distributions #pragma D binding "1.0" translator 212*2c2f96dcSApple OSS Distributions translator mptsubinfo_t < struct mptsub *T > { 213*2c2f96dcSApple OSS Distributions flags = T->mpts_flags; 214*2c2f96dcSApple OSS Distributions evctl = T->mpts_evctl; 215*2c2f96dcSApple OSS Distributions connid = T->mpts_connid; 216*2c2f96dcSApple OSS Distributions mptsub = T; 217*2c2f96dcSApple OSS Distributions }; 218