]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/multi_layer_pkt_log.h
2 * Copyright (c) 2019 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _NET_MULTI_LAYER_PKT_LOG_H_
30 #define _NET_MULTI_LAYER_PKT_LOG_H_
35 * Bump this version whenever the format of a log is modified
37 #define MPKL_VERSION 1
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.
46 #define MPKL_PROTOCOL_PHYSICAL ((uint8_t)0) /* (OTA/serial-port/etc..) */
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)
59 #define MPKL_TOPMOST_LAYER ((uint8_t)255) /* Top-most layer */
63 * @macro MPKL_CREATE_LOGOBJECT
64 * @discussion Creates a log object with input category name for the transportpacketlog subsystem
66 * @param Name string name of os_log_t category
68 * @return os_log_t object
71 #define MPKL_CREATE_LOGOBJECT(Name) os_log_create("com.apple.magnetpacketlog", Name)
74 * Cross-layer association APIs
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
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
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)
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
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
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)
112 * @macro MPKL_SEQRANGE_UUID_ASSOCIATE
113 * @discussion Associate previous layer's byte sequence range (start/end) to current layer's packet UUID
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
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)
130 * @macro MPKL_UUID_SEQRANGE_ASSOCIATE
131 * @discussion Associate previous layer's packet UUID to current layer's byte sequence range (start/end)
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
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)
149 * @macro MPKL_BUNDLEID_UUID_ASSOCIATE
150 * @discussion Associate previous layer's packet BUNDLEID to current layer's UUID
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
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)
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
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
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)
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
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
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)
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
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
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)
231 * APIs to indicate transitioning of messages; example in/out of a layer
235 * @macro MPKL_UUID_NEXT
236 * @discussion Log the transition of current layer's message with UUID to next layer
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
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)
251 * @macro MPKL_SEQRANGE_NEXT
252 * @discussion Log the transition of current layer's message with UUID to next layer
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
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)
268 * @macro MPKL_UUID_PREV
269 * @discussion Log the transition of previous layer's message with UUID to current layer
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
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)
284 * APIs to indicate a Task Start/End
288 * @macro MPKL_TASK_START
289 * @discussion Log the start of a task
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
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)
303 * @macro MPKL_TASK_START
304 * @discussion Log the end of a task
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
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)
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.
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)
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.
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)
339 * @macro MPKL_TCP_SEND
340 * @discussion Associate data sent by a process with a TCP connection
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
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, " \
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}", \
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)
366 * @macro MPKL_TCP_INPUT
367 * @discussion Associate TCP segment being with a packet received to a TCP connection
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
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)
388 * @macro MPKL_ESP_OUTPUT_TCP
389 * @discussion Associate a packet with a TCP segment being sent to an ESP packet
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
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}", \
406 LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, (uint16_t)TCP_LEN, TCP_FLAGS)
409 * @macro MPKL_ESP_INPUT_TCP
410 * @discussion Associate an ESP packet for TCP to the TCP segment
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
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}", \
425 LOCAL_PORT, REMOTE_PORT, TCP_SEQ, (uint16_t)TCP_LEN)
429 * @macro MPKL_BYTERANGE_UUID_ASSOCIATE
430 * @discussion Associate current layer's byte range (start/end) to current layer's UUID
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
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)
444 * @macro MPKL_UUID_ONLY_ASSOCIATE_NEXT
445 * @discussion Associate current layer's UUID to next layer's UUID
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
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)
458 #ifdef KERNEL_PRIVATE
459 extern int net_mpklog_enabled
;
460 extern uint8_t net_mpklog_type
;
461 #endif /* KERNEL_PRIVATE */
463 #endif /* _NET_MULTI_LAYER_PKT_LOG_H_ */