]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | /* |
5ba3f43e | 2 | * Copyright (c) 2013-2017 Apple Computer, Inc. All Rights Reserved. |
39236c6e A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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 | |
11 | * file. | |
12 | * | |
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. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
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 | |
29 | ||
30 | /* | |
31 | * MPTCP Protocol Control Block. | |
32 | */ | |
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 | |
fe8ab488 A |
51 | inline int MPTCPS_TERMINATE = 10; |
52 | #pragma D binding "1.0" MPTCPS_TERMINATE | |
39236c6e | 53 | |
39236c6e A |
54 | typedef struct mptsinfo { |
55 | string state; | |
56 | uint32_t flags; | |
57 | uint32_t vers; | |
58 | uint32_t error; | |
59 | mptcp_key_t localkey; | |
60 | mptcp_key_t remotekey; | |
61 | mptcp_token_t localtoken; | |
62 | mptcp_token_t remotetoken; | |
63 | int rxtshift; | |
64 | uint32_t rxtstart; | |
65 | uint64_t rtseq; | |
66 | uint32_t timervals; | |
67 | uint32_t timewait; | |
68 | uint64_t snduna; | |
69 | uint64_t sndnxt; | |
70 | uint64_t sndmax; | |
71 | uint64_t local_idsn; | |
72 | uint32_t sndwnd; | |
73 | uint64_t rcvnxt; | |
39236c6e A |
74 | uint64_t remote_idsn; |
75 | uint32_t rcvwnd; | |
76 | struct mptcb *mptcb; | |
77 | } mptsinfo_t; | |
78 | ||
79 | #pragma D binding "1.0" translator | |
80 | translator mptsinfo_t < struct mptcb *T > { | |
81 | state = T->mpt_state == MPTCPS_CLOSED ? "state-closed" : | |
82 | T->mpt_state == MPTCPS_LISTEN ? "state-listen" : | |
83 | T->mpt_state == MPTCPS_ESTABLISHED ? | |
84 | "state-established" : | |
85 | T->mpt_state == MPTCPS_CLOSE_WAIT ? "state-close-wait" : | |
86 | T->mpt_state == MPTCPS_FIN_WAIT_1 ? "state-fin-wait-1" : | |
87 | T->mpt_state == MPTCPS_CLOSING ? "state-closing" : | |
88 | T->mpt_state == MPTCPS_LAST_ACK ? "state-last-ack" : | |
89 | T->mpt_state == MPTCPS_FIN_WAIT_2 ? "state-fin-wait-2" : | |
90 | T->mpt_state == MPTCPS_TIME_WAIT ? "state-time-wait" : | |
fe8ab488 A |
91 | T->mpt_state == MPTCPS_TERMINATE ? |
92 | "state-terminate" : | |
39236c6e A |
93 | "<unknown>"; |
94 | flags = T->mpt_flags; | |
95 | vers = T->mpt_version; | |
96 | error = T->mpt_softerror; | |
5ba3f43e | 97 | localkey = T->mpt_localkey; |
39236c6e A |
98 | remotekey = T->mpt_remotekey; |
99 | localtoken = T->mpt_localtoken; | |
100 | remotetoken = T->mpt_remotetoken; | |
101 | rxtshift = T->mpt_rxtshift; | |
102 | rxtstart = T->mpt_rxtstart; | |
103 | rtseq = T->mpt_rtseq; | |
104 | timervals = T->mpt_timer_vals; | |
105 | timewait = T->mpt_timewait; | |
106 | snduna = T->mpt_snduna; | |
107 | sndnxt = T->mpt_sndnxt; | |
108 | sndmax = T->mpt_sndmax; | |
109 | local_idsn = T->mpt_local_idsn; | |
110 | sndwnd = T->mpt_sndwnd; | |
111 | rcvnxt = T->mpt_rcvnxt; | |
39236c6e A |
112 | remote_idsn = T->mpt_remote_idsn; |
113 | rcvwnd = T->mpt_rcvwnd; | |
114 | mptcb = T; | |
115 | }; | |
116 | ||
117 | /* | |
118 | * Multipath Control Block. | |
119 | */ | |
120 | inline int MPPCB_STATE_INUSE = 1; | |
121 | #pragma D binding "1.0" MPPCB_STATE_INUSE | |
122 | inline int MPPCB_STATE_DEAD = 2; | |
123 | #pragma D binding "1.0" MPPCB_STATE_DEAD | |
124 | ||
125 | typedef struct mppsinfo { | |
126 | string state; | |
127 | uint32_t flags; | |
128 | struct mppcb *mppcb; | |
129 | } mppsinfo_t; | |
130 | ||
131 | #pragma D binding "1.0" translator | |
132 | translator mppsinfo_t < struct mppcb *T> { | |
133 | state = T ? | |
134 | T->mpp_state == MPPCB_STATE_INUSE ? "state-inuse" : | |
135 | T->mpp_state == MPPCB_STATE_DEAD ? "state-dead" : | |
136 | "<unknown>" : "<null>"; | |
137 | flags = T->mpp_flags; | |
138 | mppcb = T; | |
139 | }; | |
140 | ||
141 | /* | |
142 | * MPTCP Session. | |
143 | */ | |
144 | typedef struct mptsesinfo { | |
145 | uint16_t numflows; | |
146 | uint16_t nummpcapflows; | |
3e170ce0 | 147 | sae_connid_t connid_last; |
39236c6e A |
148 | uint8_t flags; |
149 | struct mptses *mptses; | |
150 | } mptsesinfo_t; | |
151 | ||
152 | #pragma D binding "1.0" translator | |
153 | translator mptsesinfo_t < struct mptses *T > { | |
154 | numflows = T->mpte_numflows; | |
155 | nummpcapflows = T->mpte_nummpcapflows; | |
156 | connid_last = T->mpte_connid_last; | |
157 | flags = T->mpte_flags; | |
158 | mptses = T; | |
159 | }; | |
160 | ||
161 | /* | |
162 | * MPTCP Subflow. | |
163 | */ | |
164 | inline int MPTSF_ATTACHED = 0x00001; | |
165 | #pragma D binding "1.0" MPTSF_ATTACHED | |
166 | inline int MPTSF_CONNECTING = 0x00002; | |
167 | #pragma D binding "1.0" MPTSF_CONNECTING | |
168 | inline int MPTSF_CONNECT_PENDING= 0x00004; | |
169 | #pragma D binding "1.0" MPTSF_CONNECT_PENDING | |
170 | inline int MPTSF_CONNECTED = 0x00008; | |
171 | #pragma D binding "1.0" MPTSF_CONNECTED | |
172 | inline int MPTSF_DISCONNECTING = 0x00010; | |
173 | #pragma D binding "1.0" MPTSF_DISCONNECTING | |
174 | inline int MPTSF_DISCONNECTED = 0x00020; | |
175 | #pragma D binding "1.0" MPTSF_DISCONNECTED | |
176 | inline int MPTSF_MP_CAPABLE = 0x00040; | |
177 | #pragma D binding "1.0" MPTSF_MP_CAPABLE | |
178 | inline int MPTSF_MP_READY = 0x00080; | |
179 | #pragma D binding "1.0" MPTSF_MP_READY | |
180 | inline int MPTSF_MP_DEGRADED = 0x00100; | |
181 | #pragma D binding "1.0" MPTSF_MP_DEGRADED | |
182 | inline int MPTSF_SUSPENDED = 0x00200; | |
183 | #pragma D binding "1.0" MPTSF_SUSPENDED | |
184 | inline int MPTSF_BOUND_IF = 0x00400; | |
185 | #pragma D binding "1.0" MPTSF_BOUND_IF | |
186 | inline int MPTSF_BOUND_IP = 0x00800; | |
187 | #pragma D binding "1.0" MPTSF_BOUND_IP | |
188 | inline int MPTSF_BOUND_PORT = 0x01000; | |
189 | #pragma D binding "1.0" MPTSF_BOUND_PORT | |
190 | inline int MPTSF_PREFERRED = 0x02000; | |
191 | #pragma D binding "1.0" MPTSF_PREFERRED | |
192 | inline int MPTSF_SOPT_OLDVAL = 0x04000; | |
193 | #pragma D binding "1.0" MPTSF_SOPT_OLDVAL | |
194 | inline int MPTSF_SOPT_INPROG = 0x08000; | |
195 | #pragma D binding "1.0" MPTSF_SOPT_INPROG | |
196 | inline int MPTSF_DELETEOK = 0x10000; | |
197 | #pragma D binding "1.0" MPTSF_DELETEOK | |
198 | inline int MPTSF_FAILINGOVER = 0x20000; | |
199 | #pragma D binding "1.0" MPTSF_FAILINGOVER | |
200 | inline int MPTSF_ACTIVE = 0x40000; | |
201 | #pragma D binding "1.0" MPTSF_ACTIVE | |
202 | inline int MPTSF_MPCAP_CTRSET = 0x80000; | |
203 | #pragma D binding "1.0" MPTSF_MPCAP_CTRSET | |
204 | ||
205 | typedef struct mptsubinfo { | |
206 | uint32_t flags; | |
207 | uint32_t evctl; | |
3e170ce0 | 208 | sae_connid_t connid; |
39236c6e | 209 | uint32_t rank; |
39236c6e A |
210 | struct mptsub *mptsub; |
211 | } mptsubinfo_t; | |
212 | ||
213 | #pragma D binding "1.0" translator | |
214 | translator mptsubinfo_t < struct mptsub *T > { | |
215 | flags = T->mpts_flags; | |
216 | evctl = T->mpts_evctl; | |
39236c6e | 217 | connid = T->mpts_connid; |
39236c6e A |
218 | mptsub = T; |
219 | }; |