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