1 | /* |
2 | * Copyright (c) 2019 Apple Inc. All rights reserved. |
3 | * |
4 | * @APPLE_OSREFERENCE_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. The rights granted to you under the License |
10 | * may not be used to create, or enable the creation or redistribution of, |
11 | * unlawful or unlicensed copies of an Apple operating system, or to |
12 | * circumvent, violate, or enable the circumvention or violation of, any |
13 | * terms of an Apple operating system software license agreement. |
14 | * |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. |
17 | * |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and |
24 | * limitations under the License. |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ |
28 | |
29 | #ifndef _NET_MULTI_LAYER_PKT_LOG_H_ |
30 | #define _NET_MULTI_LAYER_PKT_LOG_H_ |
31 | |
32 | #include <os/log.h> |
33 | |
34 | /* |
35 | * Bump this version whenever the format of a log is modified |
36 | */ |
37 | #define MPKL_VERSION 1 |
38 | |
39 | /* |
40 | * Protocol ID, use to track inter-layer transitions and direction of data flow. |
41 | * Watch transport physical layer has lowest numeric value, increases to the highest layer in the system. |
42 | * Direction is to physical layer, or away from physical layer. |
43 | * |
44 | */ |
45 | |
46 | #define MPKL_PROTOCOL_PHYSICAL ((uint8_t)0) /* (OTA/serial-port/etc..) */ |
47 | |
48 | #define MPKL_PROTOCOL_BT ((uint8_t)20) |
49 | #define MPKL_PROTOCOL_WIFI ((uint8_t)30) |
50 | #define MPKL_PROTOCOL_CELLULAR ((uint8_t)40) |
51 | #define MPKL_PROTOCOL_TERMINUS ((uint8_t)60) |
52 | #define MPKL_PROTOCOL_IPSEC ((uint8_t)80) |
53 | #define MPKL_PROTOCOL_TCP ((uint8_t)100) |
54 | #define MPKL_PROTOCOL_IDS ((uint8_t)120) |
55 | #define MPKL_PROTOCOL_LIBNETCORE ((uint8_t)140) |
56 | #define MPKL_PROTOCOL_CFNETWORK ((uint8_t)160) |
57 | #define MPKL_PROTOCOL_REMOTE_CONNECTION ((uint8_t)200) |
58 | |
59 | #define MPKL_TOPMOST_LAYER ((uint8_t)255) /* Top-most layer */ |
60 | |
61 | |
62 | /*! |
63 | * @macro MPKL_CREATE_LOGOBJECT |
64 | * @discussion Creates a log object with input category name for the transportpacketlog subsystem |
65 | * |
66 | * @param Name string name of os_log_t category |
67 | * |
68 | * @return os_log_t object |
69 | * |
70 | */ |
71 | #define MPKL_CREATE_LOGOBJECT(Name) os_log_create("com.apple.magnetpacketlog", Name) |
72 | |
73 | /* |
74 | * Cross-layer association APIs |
75 | * |
76 | */ |
77 | |
78 | /*! |
79 | * @macro MPKL_UUID_UUID_ASSOCIATE_PREV |
80 | * @discussion Associate current layer's packet UUID to previous layer's packet UUID, data is flowing into the current layer |
81 | * |
82 | * @param LOGOBJECT os_log_t object to write data into |
83 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
84 | * @param PREV_PROTOCOL_ID uint8_t ID of previous layer being associated |
85 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet |
86 | * @param PREV_UUID uuid_t Previous layer 16-byte UUID of packet |
87 | * @param CUR_LEN uint16_t Current layer packet length |
88 | * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages |
89 | */ |
90 | |
91 | #define MPKL_UUID_UUID_ASSOCIATE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_UUID, PREV_UUID, CUR_LEN, LOG_SEQN) \ |
92 | os_log(LOGOBJECT, "1 {curProtocol: %hhu, prevProtocol: %hhu, curUUID: %{public,uuid_t}.16P, prevUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_UUID, PREV_UUID, CUR_LEN, LOG_SEQN) |
93 | |
94 | /*! |
95 | * @macro MPKL_UUID_UUID_ASSOCIATE_NEXT |
96 | * @discussion Associate current layer's packet UUID to next layer's packet UUID, data is flowing out of the current layer |
97 | * |
98 | * @param LOGOBJECT os_log_t object to write data into |
99 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
100 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
101 | * @param NEXT_PROTOCOL_ID uint8_t ID of next layer being associated |
102 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet |
103 | * @param NEXT_UUID uuid_t Next layer 16-byte UUID of packet |
104 | * @param CUR_LEN uint16_t Current layer packet length |
105 | * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages |
106 | */ |
107 | |
108 | #define MPKL_UUID_UUID_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, CUR_LEN, LOG_SEQN) \ |
109 | os_log(LOGOBJECT, "2 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, nextUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, CUR_LEN, LOG_SEQN) |
110 | |
111 | /*! |
112 | * @macro MPKL_SEQRANGE_UUID_ASSOCIATE |
113 | * @discussion Associate previous layer's byte sequence range (start/end) to current layer's packet UUID |
114 | * |
115 | * @param LOGOBJECT os_log_t object to write data into |
116 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
117 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
118 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
119 | * @param PREV_RANGE_START uint32_t Previous layer byte sequence range start |
120 | * @param PREV_RANGE_END uint32_t Previous layer byte sequence range end |
121 | * @param CUR_UUID uuid_t Other layer 16-byte UUID of packet |
122 | * @param CUR_LEN uint16_t Current layer packet length |
123 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
124 | */ |
125 | |
126 | #define MPKL_SEQRANGE_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CUR_LEN, LOG_SEQN) \ |
127 | os_log(LOGOBJECT, "3 {curProtocol: %hhu, prevProtocol: %hhu, prevStart: %u, prevEnd: %u, curUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CUR_LEN, LOG_SEQN) |
128 | |
129 | /*! |
130 | * @macro MPKL_UUID_SEQRANGE_ASSOCIATE |
131 | * @discussion Associate previous layer's packet UUID to current layer's byte sequence range (start/end) |
132 | * |
133 | * @param LOGOBJECT os_log_t object to write data into |
134 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
135 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
136 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
137 | * @param PREV_UUID uuid_t Previous layer 16-byte UUID of packet |
138 | * @param CUR_RANGE_START uint16_t Current layer byte sequence range start |
139 | * @param CUR_RANGE_END uint16_t Current layer byte sequence range end |
140 | * @param PREV_LEN uint16_t PRevious layer message length |
141 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
142 | */ |
143 | |
144 | #define MPKL_UUID_SEQRANGE_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, CUR_RANGE_START, CUR_RANGE_END, PREV_LEN, LOG_SEQN) \ |
145 | os_log(LOGOBJECT, "4 {curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, curStart: %u, curEnd: %u, prevPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, CUR_RANGE_START, CUR_RANGE_END, PREV_LEN, LOG_SEQN) |
146 | |
147 | |
148 | /*! |
149 | * @macro MPKL_BUNDLEID_UUID_ASSOCIATE |
150 | * @discussion Associate previous layer's packet BUNDLEID to current layer's UUID |
151 | * |
152 | * @param LOGOBJECT os_log_t object to write data into |
153 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
154 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
155 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
156 | * @param PREV_BUNDLE_ID NSString BundleID of previous layer |
157 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet |
158 | * @param CUR_LEN uint32_t Current layer packet length |
159 | * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages |
160 | */ |
161 | |
162 | #define MPKL_BUNDLEID_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_BUNDLE_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ |
163 | os_log(LOGOBJECT, "5 {curProtocol: %hhu, prevProtocol: %hhu, prevBundleID: %@, curUUID: %{public,uuid_t}.16P, curPktLen: %u, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_BUNDLE_ID, CUR_UUID, CUR_LEN, LOG_SEQN) |
164 | |
165 | |
166 | /*! |
167 | * @macro MPKL_SEQRANGE_UUID_ASSOCIATE_W_BUNDLEID |
168 | * @discussion Associate previous layer's packet byte sequence range to to current layer's UUID and client's bundle id |
169 | * |
170 | * @param LOGOBJECT os_log_t object to write data into |
171 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
172 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
173 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
174 | * @param PREV_RANGE_START uint32_t Previous layer byte sequence range start |
175 | * @param PREV_RANGE_END uint32_t Previous layer byte sequence range end |
176 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet |
177 | * @param PREV_BUNDLE_ID NSString BundleID of previous layer |
178 | * @param CUR_LEN uint16_t Current layer packet length |
179 | * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages |
180 | */ |
181 | |
182 | #define MPKL_SEQRANGE_UUID_ASSOCIATE_W_BUNDLEID(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CLIENT_BUNDLE_ID, CUR_LEN, LOG_SEQN) \ |
183 | os_log(LOGOBJECT, "6 {curProtocol: %hhu, prevProtocol: %hhu, prevStart: %u, prevEnd: %u, curUUID: %{public,uuid_t}.16P, curBundleID: %@, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CLIENT_BUNDLE_ID, CUR_LEN, LOG_SEQN) |
184 | |
185 | |
186 | /*! |
187 | * @macro MPKL_SEQN_UUID_ASSOCIATE_PREV |
188 | * @discussion Associate current layer's packet unique protocol sequenceNumber to another layer's message UUID |
189 | * Support fragmentation and re-assembly (for layers like BT), map byte-sequence range (2 byte) of current and other layer data |
190 | * |
191 | * @param LOGOBJECT os_log_t object to write data into |
192 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
193 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
194 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
195 | * @param PREV_UUID uuid_t Other layer 16-byte UUID of message |
196 | * @param PREV_RANGE_START uint16_t Current layer byte sequence range start |
197 | * @param PREV_RANGE_END uint16_t Current layer byte sequence range end |
198 | * @param PREV_LEN uint16_t PRevious layer message length |
199 | * @param CUR_SEQ_N uint16_t Current layer message length |
200 | * @param CUR_RANGE_START uint16_t Current layer byte sequence range start |
201 | * @param CUR_RANGE_END uint16_t Current layer byte sequence range end |
202 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
203 | */ |
204 | |
205 | #define MPKL_SEQN_UUID_ASSOCIATE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_RANGE_START, PREV_RANGE_END, PREV_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ |
206 | os_log(LOGOBJECT, "7 {Send, curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, prevStart: %hu, prevEnd: %hu, prevPktLen %hu, curSeqN: %hu, curStart: %hu, curEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_RANGE_START, PREV_RANGE_END, PREV_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) |
207 | |
208 | /*! |
209 | * @macro MPKL_SEQN_UUID_ASSOCIATE_NEXT |
210 | * @discussion Associate current layer's packet unique protocol sequenceNumber to another layer's message UUID |
211 | * Support fragmentation and re-assembly (for layers like BT), map byte-sequence range (2 byte) of current and other layer data |
212 | * |
213 | * @param LOGOBJECT os_log_t object to write data into |
214 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
215 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
216 | * @param NEXT_PROTOCOL_ID uint8_t ID of other layer being associated |
217 | * @param NEXT_UUID uuid_t Other layer 16-byte UUID of message |
218 | * @param NEXT_RANGE_START uint16_t Current layer byte sequence range start |
219 | * @param NEXT_RANGE_END uint16_t Current layer byte sequence range end |
220 | * @param NEXT_LEN uint16_t Current layer message length |
221 | * @param CUR_SEQ_N uint16_t Current layer message length |
222 | * @param CUR_RANGE_START uint16_t Current layer byte sequence range start |
223 | * @param CUR_RANGE_END uint16_t Current layer byte sequence range end |
224 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
225 | */ |
226 | |
227 | #define MPKL_SEQN_UUID_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, NEXT_UUID, NEXT_RANGE_START, NEXT_RANGE_END, NEXT_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ |
228 | os_log(LOGOBJECT, "8 {Receive, curProtocol: %hhu, nextProtocol: %hhu, nextUUID: %{public,uuid_t}.16P, nextStart: %hu, nextEnd: %hu, nextPktLen %hu, curSeqN: %hu, curStart: %hu, curEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, NEXT_UUID, NEXT_RANGE_START, NEXT_RANGE_END, NEXT_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) |
229 | |
230 | /* |
231 | * APIs to indicate transitioning of messages; example in/out of a layer |
232 | */ |
233 | |
234 | /*! |
235 | * @macro MPKL_UUID_NEXT |
236 | * @discussion Log the transition of current layer's message with UUID to next layer |
237 | * |
238 | * @param LOGOBJECT os_log_t object to write data into |
239 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
240 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
241 | * @param NEXT_PROTOCOL_ID uint8_t ID of next layer |
242 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of message |
243 | * @param CUR_LEN uint32_t Current layer message length |
244 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
245 | */ |
246 | |
247 | #define MPKL_UUID_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ |
248 | os_log(LOGOBJECT, "9 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, curPktLen: %u, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) |
249 | |
250 | /*! |
251 | * @macro MPKL_SEQRANGE_NEXT |
252 | * @discussion Log the transition of current layer's message with UUID to next layer |
253 | * |
254 | * @param LOGOBJECT os_log_t object to write data into |
255 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
256 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
257 | * @param NEXT_PROTOCOL_ID uint8_t ID of next layer |
258 | * @param CUR_RANGE_START uint16_t Current layer byte sequence range start |
259 | * @param CUR_RANGE_END uint16_t Current layer byte sequence range end |
260 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
261 | */ |
262 | |
263 | #define MPKL_SEQRANGE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ |
264 | os_log(LOGOBJECT, "10 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) |
265 | |
266 | |
267 | /*! |
268 | * @macro MPKL_UUID_PREV |
269 | * @discussion Log the transition of previous layer's message with UUID to current layer |
270 | * |
271 | * @param LOGOBJECT os_log_t object to write data into |
272 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
273 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
274 | * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated |
275 | * @param PREV_UUID uuid_t Previous layer 16-byte UUID of message |
276 | * @param PREV_LEN uint16_t Previous layer message length |
277 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
278 | */ |
279 | |
280 | #define MPKL_UUID_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_LEN, LOG_SEQN) \ |
281 | os_log(LOGOBJECT, "11 {curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, prevPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_LEN, LOG_SEQN) |
282 | |
283 | /* |
284 | * APIs to indicate a Task Start/End |
285 | */ |
286 | |
287 | /*! |
288 | * @macro MPKL_TASK_START |
289 | * @discussion Log the start of a task |
290 | * |
291 | * @param LOGOBJECT os_log_t object to write data into |
292 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
293 | * @param CLIENT_BUNDLE_ID NSString bundleID of the client |
294 | * @param TASK_UUID uuid_t 16-byte UUID of NSURL task |
295 | * @param CONN_UUID uuid_t 16-byte UUID of associated libnetcore connection |
296 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
297 | */ |
298 | |
299 | #define MPKL_TASK_START(LOGOBJECT, CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) \ |
300 | os_log(LOGOBJECT, "12 {startBundleID: %@, taskUUID: %{public,uuid_t}.16P, connUUID: %{public,uuid_t}.16P, logSeqn: %hhu}", CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) |
301 | |
302 | /*! |
303 | * @macro MPKL_TASK_START |
304 | * @discussion Log the end of a task |
305 | * |
306 | * @param LOGOBJECT os_log_t object to write data into |
307 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
308 | * @param CLIENT_BUNDLE_ID NSString bundleID of the client |
309 | * @param TASK_UUID uuid_t 16-byte UUID of NSURL task |
310 | * @param CONN_UUID uuid_t 16-byte UUID of associated libnetcore connection |
311 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
312 | */ |
313 | |
314 | #define MPKL_TASK_END(LOGOBJECT, CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) \ |
315 | os_log(LOGOBJECT, "13 {endBundleID: %@, taskUUID: %{public,uuid_t}.16P, connUUID: %{public,uuid_t}.16P, logSeqn: %hhu}", CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) |
316 | |
317 | /*! |
318 | * @macro MPKL_SEQN_INCOMPLETE_PREV |
319 | * @discussion An incomplete packet was sent with a given protocol sequence number and couldn't be associated to another protocol. |
320 | * The incomplete packet is saved, its byte sequence range is logged and it is associated once more data arrives. |
321 | * |
322 | */ |
323 | |
324 | #define MPKL_SEQN_INCOMPLETE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, PREV_RANGE_START, PREV_RANGE_END, LOG_SEQN) \ |
325 | os_log(LOGOBJECT, "14 {Send Incomplete. curProtocol: %hhu, prevProtocol: %hhu, curSeqN: %hu, curStart: %hu, curEnd: %hu, prevStart: %hu, prevEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, PREV_RANGE_START, PREV_RANGE_END, LOG_SEQN) |
326 | |
327 | /*! |
328 | * @macro MPKL_SEQN_INCOMPLETE_NEXT |
329 | * @discussion An incomplete packet was sent with a given protocol sequence number and couldn't be associated to another protocol. |
330 | * The incomplete packet is saved, its byte sequence range is logged and it is associated once more data arrives. |
331 | * |
332 | */ |
333 | |
334 | #define MPKL_SEQN_INCOMPLETE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, NEXT_RANGE_START, NEXT_RANGE_END, LOG_SEQN) \ |
335 | os_log(LOGOBJECT, "15 {Receive Incomplete. curProtocol: %hhu, nextProtocol: %hhu, curSeqN: %hu, curStart: %hu, curEnd: %hu, nextStart: %hu, nextEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, NEXT_RANGE_START, NEXT_RANGE_END, LOG_SEQN) |
336 | |
337 | #ifdef KERNEL |
338 | /*! |
339 | * @macro MPKL_TCP_SEND |
340 | * @discussion Associate data sent by a process with a TCP connection |
341 | * |
342 | * @param LOGOBJECT os_log_t object to write data into |
343 | * @param PREV_PROTOCOL_ID uint8_t Protocol identifier passed by the process (may be 0) |
344 | * @param PREV_UUID uuid_t UUID passed by the process (may be null UUID) |
345 | * @param LOCAL_PORT uint16_t Local port of the TCP connection |
346 | * @param REMOTE_PORT uint16_t Remote port of the TCP connection |
347 | * @param TCP_SEQ uint32_t TCP sequence number of the first byte of the data being sent by the process |
348 | * @param TCP_LEN uint32_t Length of the data |
349 | * @param PID uint16_t pid of the process using the TCP connection |
350 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
351 | */ |
352 | #define MPKL_TCP_SEND(LOGOBJECT, PREV_PROTOCOL_ID, PREV_UUID, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN, PID, LOG_SEQN) \ |
353 | os_log_with_type(LOGOBJECT, net_mpklog_type, \ |
354 | "16 {curProtocol: 100, prevProtocol: %hhu, " \ |
355 | "prevUUID: " \ |
356 | "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X, " \ |
357 | "localPort: %hu, remotePort: %hu, tcpSeq: %u, length: %u, " \ |
358 | "pid: %hu, logSeqn: %hhu}", \ |
359 | PREV_PROTOCOL_ID, \ |
360 | PREV_UUID[0], PREV_UUID[1], PREV_UUID[2], PREV_UUID[3], PREV_UUID[4], PREV_UUID[5], PREV_UUID[6], PREV_UUID[7], \ |
361 | PREV_UUID[8], PREV_UUID[9], PREV_UUID[10], PREV_UUID[11], PREV_UUID[12], PREV_UUID[13], PREV_UUID[14], PREV_UUID[15], \ |
362 | LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN, \ |
363 | (uint16_t)PID, LOG_SEQN) |
364 | |
365 | /*! |
366 | * @macro MPKL_TCP_INPUT |
367 | * @discussion Associate TCP segment being with a packet received to a TCP connection |
368 | * |
369 | * @param LOGOBJECT os_log_t object to write data into |
370 | * @param LOCAL_PORT uint16_t Local port in the TCP header of the segment |
371 | * @param REMOTE_PORT uint16_t Remote port in the TCP header of the segment |
372 | * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment |
373 | * @param TCP_ACK uint32_t Acknowledgement number in the TCP header of the segment |
374 | * @param TCP_LEN uint16_t Length in the TCP header of the segment |
375 | * @param TCP_FLAGS uint8_t Flags of the TCP header of the segment |
376 | * @param PID uint16_t pid of the process using the TCP connection |
377 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
378 | */ |
379 | #define MPKL_TCP_INPUT(LOGOBJECT, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, TCP_LEN, TCP_FLAGS, PID, LOG_SEQN) \ |
380 | os_log_with_type(LOGOBJECT, net_mpklog_type, \ |
381 | "17 {curProtocol: 100, prevProtocol: 80, " \ |
382 | "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpAck: %u, tcpLen: %hu, tcpFlags: 0x%02x, " \ |
383 | "pid: %hu, logSeqn: %hhu}", \ |
384 | LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, (uint16_t)TCP_LEN, TCP_FLAGS, \ |
385 | (uint16_t)PID, LOG_SEQN) |
386 | |
387 | /*! |
388 | * @macro MPKL_ESP_OUTPUT_TCP |
389 | * @discussion Associate a packet with a TCP segment being sent to an ESP packet |
390 | * |
391 | * @param LOGOBJECT os_log_t object to write data into |
392 | * @param SPI uint32_t SPI field in the ESP header |
393 | * @param ESP_SEQ uint32_t Sequence number field in the ESP header |
394 | * @param LOCAL_PORT uint16_t Local port of the TCP connection |
395 | * @param REMOTE_PORT uint16_t Remote port of the TCP connection |
396 | * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment |
397 | * @param TCP_ACK uint32_t Acknowledgement number in the TCP header of the segment |
398 | * @param TCP_LEN uint16_t Length in the TCP header of the segment |
399 | * @param TCP_FLAGS uint8_t Flags of the TCP header of the segment |
400 | */ |
401 | #define MPKL_ESP_OUTPUT_TCP(LOGOBJECT, SPI, ESP_SEQ, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, TCP_LEN, TCP_FLAGS) \ |
402 | os_log_with_type(LOGOBJECT, (os_log_type_t)net_mpklog_type, \ |
403 | "18 {curProtocol: 80, spi: 0x%X, espSeq: %u, PayloadProtocol: 100, " \ |
404 | "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpAck: %u, tcpLen: %hu, tcpFlags: 0x%02x}", \ |
405 | SPI, ESP_SEQ, \ |
406 | LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, (uint16_t)TCP_LEN, TCP_FLAGS) |
407 | |
408 | /*! |
409 | * @macro MPKL_ESP_INPUT_TCP |
410 | * @discussion Associate an ESP packet for TCP to the TCP segment |
411 | * |
412 | * @param LOGOBJECT os_log_t object to write data into |
413 | * @param SPI uint32_t SPI field in the ESP header |
414 | * @param ESP_SEQ uint32_t Sequence number field in the ESP header |
415 | * @param LOCAL_PORT uint16_t Local port of the TCP connection |
416 | * @param REMOTE_PORT uint16_t Remote port of the TCP connection |
417 | * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment |
418 | * @param TCP_LEN uint16_t Length in the TCP header of the segment |
419 | */ |
420 | #define MPKL_ESP_INPUT_TCP(LOGOBJECT, SPI, ESP_SEQ, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN) \ |
421 | os_log_with_type(LOGOBJECT, (os_log_type_t)net_mpklog_type, \ |
422 | "19 {curProtocol: 80 spi: 0x%X, espSeq: %u, PayloadProtocol: 100, " \ |
423 | "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpLen: %hu}", \ |
424 | SPI, ESP_SEQ, \ |
425 | LOCAL_PORT, REMOTE_PORT, TCP_SEQ, (uint16_t)TCP_LEN) |
426 | #endif /* KERNEL */ |
427 | |
428 | /*! |
429 | * @macro MPKL_BYTERANGE_UUID_ASSOCIATE |
430 | * @discussion Associate current layer's byte range (start/end) to current layer's UUID |
431 | * |
432 | * @param LOGOBJECT os_log_t object to write data into |
433 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
434 | * @param NEXT_PROTOCOL_ID uint8_t ID of other layer being associated |
435 | * @param CUR_UUID uuid_t Current layer 16-byte UUID of endpoint handler |
436 | * @param CUR_RANGE_START uint64_t Current layer byte range start |
437 | * @param CUR_RANGE_END uint64_t Current layer byte range end |
438 | * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages |
439 | */ |
440 | #define MPKL_BYTERANGE_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ |
441 | os_log(LOGOBJECT, "32 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public}.16P, curStart: %llu, curEnd: %llu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) |
442 | |
443 | /*! |
444 | * @macro MPKL_UUID_ONLY_ASSOCIATE_NEXT |
445 | * @discussion Associate current layer's UUID to next layer's UUID |
446 | * |
447 | * @param LOGOBJECT os_log_t object to write data into |
448 | * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} |
449 | * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above |
450 | * @param NEXT_PROTOCOL_ID uint8_t ID of next layer being associated |
451 | * @param CUR_UUID uuid_t Current layer 16-byte UUID |
452 | * @param NEXT_UUID uuid_t Next layer 16-byte UUID |
453 | * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages |
454 | */ |
455 | #define MPKL_UUID_ONLY_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, LOG_SEQN) \ |
456 | os_log(LOGOBJECT, "33 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public}.16P, nextUUID: %{public}.16P, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, LOG_SEQN) |
457 | |
458 | #ifdef KERNEL_PRIVATE |
459 | extern int net_mpklog_enabled; |
460 | extern uint8_t net_mpklog_type; |
461 | #endif /* KERNEL_PRIVATE */ |
462 | |
463 | #endif /* _NET_MULTI_LAYER_PKT_LOG_H_ */ |
464 | |