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