File: | epan/dissectors/packet-darwin.c |
Warning: | line 432, column 13 Value stored to 'first_metadata_item' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* packet-darwin.c |
2 | * Support for Apple Legacy and Custom pcapng blocks and options |
3 | * Copyright 2025, Omer Shapira <[email protected]> |
4 | * |
5 | * Wireshark - Network traffic analyzer |
6 | * By Gerald Combs <[email protected]> |
7 | * Copyright 1998 Gerald Combs |
8 | * |
9 | * |
10 | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | */ |
12 | |
13 | |
14 | #include "config.h" |
15 | |
16 | #include <wiretap/wtap.h> |
17 | #include <epan/packet.h> |
18 | #include <epan/proto_data.h> |
19 | #include <epan/tfs.h> |
20 | |
21 | #define PNAME"Apple Darwin" "Apple Darwin" |
22 | #define PSNAME"Darwin" "Darwin" |
23 | #define PFNAME"darwin" "darwin" |
24 | |
25 | void proto_register_darwin(void); |
26 | void proto_reg_handoff_darwin(void); |
27 | |
28 | /* Initialize the protocol and registered fields */ |
29 | static int proto_darwin; |
30 | |
31 | static int hf_process_info; |
32 | static int hf_process_info_pname; |
33 | static int hf_process_info_pid; |
34 | static int hf_process_info_epname; |
35 | static int hf_process_info_epid; |
36 | |
37 | static int hf_darwin_metadata; |
38 | static int hf_darwin_metadata_svc_code; |
39 | static int hf_darwin_metadata_flags; |
40 | static int hf_darwin_metadata_flags_reserved; |
41 | static int hf_darwin_metadata_flags_wk; |
42 | static int hf_darwin_metadata_flags_ch; |
43 | static int hf_darwin_metadata_flags_so; |
44 | static int hf_darwin_metadata_flags_re; |
45 | static int hf_darwin_metadata_flags_ka; |
46 | static int hf_darwin_metadata_flags_nf; |
47 | |
48 | static int hf_darwin_metadata_flow_id; |
49 | static int hf_darwin_metadata_trace_tag; |
50 | static int hf_darwin_metadata_dropped; |
51 | static int hf_darwin_metadata_drop_reason; |
52 | static int hf_darwin_metadata_drop_line; |
53 | static int hf_darwin_metadata_drop_func; |
54 | |
55 | static int hf_darwin_metadata_comp_gencnt; |
56 | |
57 | static int ett_proc_info; |
58 | static int ett_proc_info_proc; |
59 | static int ett_proc_info_eproc; |
60 | static int ett_darwin_metadata; |
61 | static int ett_darwin_metadata_flags; |
62 | static int ett_darwin_metadata_dropped; |
63 | |
64 | static const value_string darwin_svc_class_vals[] = { |
65 | { 0x0000, "BE" }, |
66 | { 0x0064, "BK_SYS" }, |
67 | { 0x00C8, "BK" }, |
68 | { 0x012C, "RD" }, |
69 | { 0x0190, "OAM" }, |
70 | { 0x01F4, "AV" }, |
71 | { 0x0258, "RV" }, |
72 | { 0x02BC, "VI" }, |
73 | { 0x0320, "VO" }, |
74 | { 0x0384, "CTL" }, |
75 | { 0, NULL((void*)0) } |
76 | }; |
77 | |
78 | typedef struct darwin_md { |
79 | #define PINFO_DARWIN_MD_HAS_DPIB_ID1 1 |
80 | uint32_t dpib_id; /**< Id of the Darwin Process Info Block that corresponds to the `proc` */ |
81 | #define PINFO_DARWIN_MD_HAS_EDPIB_ID2 2 |
82 | uint32_t effective_dpib_id; /**< Id of the Darwin Process Info Block that corresponds to the `eproc` */ |
83 | #define PINFO_DARWIN_MD_HAS_SVC_CODE4 4 |
84 | uint32_t svc_code; /**< Service Class Code */ |
85 | #define PINFO_DARWIN_MD_HAS_MD_FLAGS8 8 |
86 | uint32_t md_flags; /**< Metadata flags */ |
87 | #define PINFO_DARWIN_MD_HAS_FLOW_ID16 16 |
88 | uint32_t flow_id; /**< Internal flow id (flow =~ TCP / QUIC conn) */ |
89 | #define PINFO_DARWIN_MD_HAS_TRACE_TAG32 32 |
90 | uint32_t trace_tag; /**< Internal trace tag */ |
91 | #define PINFO_DARWIN_MD_HAS_DROP_REASON64 64 |
92 | uint32_t drop_reason; /**< Packet was dropped by kernel (not by libpcap) */ |
93 | #define PINFO_DARWIN_MD_HAS_DROP_LINE128 128 |
94 | uint32_t drop_line; /**< Packet was dropped by kernel (not by libpcap) */ |
95 | #define PINFO_DARWIN_MD_HAS_DROP_FUNC256 256 |
96 | const char* drop_func; /**< Packet was dropped by kernel (not by libpcap) */ |
97 | #define PINFO_DARWIN_MD_HAS_COMP_GENCNT512 512 |
98 | uint32_t comp_gencnt; /**< Generation count */ |
99 | #define PINFO_DARWIN_MD_OPT_BITMASK( 4| 8| 16| 32| 64| 128| 256| 512) (\ |
100 | PINFO_DARWIN_MD_HAS_SVC_CODE4|\ |
101 | PINFO_DARWIN_MD_HAS_MD_FLAGS8|\ |
102 | PINFO_DARWIN_MD_HAS_FLOW_ID16|\ |
103 | PINFO_DARWIN_MD_HAS_TRACE_TAG32|\ |
104 | PINFO_DARWIN_MD_HAS_DROP_REASON64|\ |
105 | PINFO_DARWIN_MD_HAS_DROP_LINE128|\ |
106 | PINFO_DARWIN_MD_HAS_DROP_FUNC256|\ |
107 | PINFO_DARWIN_MD_HAS_COMP_GENCNT512\ |
108 | ) /**< Bitmask for Darwin-specific options (v.s. process info, which *may* be present on other systems ) */ |
109 | uint64_t present_opts; /**< Bitmask for present codes */ |
110 | } darwin_md; |
111 | |
112 | |
113 | #define DARWIN_MD_FLAG_WK0x00000020 0x00000020 |
114 | #define DARWIN_MD_FLAG_CH0x00000010 0x00000010 |
115 | #define DARWIN_MD_FLAG_SO0x00000008 0x00000008 |
116 | #define DARWIN_MD_FLAG_RE0x00000004 0x00000004 |
117 | #define DARWIN_MD_FLAG_KA0x00000002 0x00000002 |
118 | #define DARWIN_MD_FLAG_NF0x00000001 0x00000001 |
119 | #define DARWIN_MD_FLAG_RESERVED(~( 0x00000020| 0x00000010| 0x00000008| 0x00000004| 0x00000002 | 0x00000001)) (~(\ |
120 | DARWIN_MD_FLAG_WK0x00000020|\ |
121 | DARWIN_MD_FLAG_CH0x00000010|\ |
122 | DARWIN_MD_FLAG_SO0x00000008|\ |
123 | DARWIN_MD_FLAG_RE0x00000004|\ |
124 | DARWIN_MD_FLAG_KA0x00000002|\ |
125 | DARWIN_MD_FLAG_NF0x00000001)) |
126 | static int* const darwin_md_flags[] = { |
127 | &hf_darwin_metadata_flags_reserved, |
128 | &hf_darwin_metadata_flags_wk, |
129 | &hf_darwin_metadata_flags_ch, |
130 | &hf_darwin_metadata_flags_so, |
131 | &hf_darwin_metadata_flags_re, |
132 | &hf_darwin_metadata_flags_ka, |
133 | &hf_darwin_metadata_flags_nf, |
134 | NULL((void*)0) |
135 | }; |
136 | |
137 | static struct darwin_md* |
138 | get_darwin_proto_data(packet_info* pinfo) |
139 | { |
140 | struct darwin_md* darwin = (struct darwin_md*)p_get_proto_data(wmem_file_scope(), pinfo, proto_darwin, 0); |
141 | if (darwin == NULL((void*)0)) |
142 | { |
143 | darwin = wmem_new0(wmem_file_scope(), struct darwin_md)((struct darwin_md*)wmem_alloc0((wmem_file_scope()), sizeof(struct darwin_md))); |
144 | p_add_proto_data(wmem_file_scope(), pinfo, proto_darwin, 0, darwin); |
145 | } |
146 | |
147 | return darwin; |
148 | } |
149 | |
150 | static int |
151 | dissect_darwin_dpib_id(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
152 | { |
153 | wtap_optval_t* optval = (wtap_optval_t*)data; |
154 | |
155 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
156 | darwin->dpib_id = optval->uint32val; |
157 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_DPIB_ID1; |
158 | |
159 | return 1; |
160 | } |
161 | |
162 | static int |
163 | dissect_darwin_effective_dpib_id(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
164 | { |
165 | wtap_optval_t* optval = (wtap_optval_t*)data; |
166 | |
167 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
168 | darwin->effective_dpib_id = optval->uint32val; |
169 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_EDPIB_ID2; |
170 | |
171 | return 1; |
172 | } |
173 | |
174 | static int |
175 | dissect_darwin_svc_code(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
176 | { |
177 | wtap_optval_t* optval = (wtap_optval_t*)data; |
178 | |
179 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
180 | darwin->svc_code = optval->uint32val; |
181 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_SVC_CODE4; |
182 | |
183 | return 1; |
184 | } |
185 | |
186 | static int |
187 | dissect_darwin_md_flags(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
188 | { |
189 | wtap_optval_t* optval = (wtap_optval_t*)data; |
190 | |
191 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
192 | darwin->md_flags = optval->uint32val; |
193 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_MD_FLAGS8; |
194 | |
195 | return 1; |
196 | } |
197 | |
198 | static int |
199 | dissect_darwin_flow_id(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
200 | { |
201 | wtap_optval_t* optval = (wtap_optval_t*)data; |
202 | |
203 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
204 | darwin->flow_id = optval->uint32val; |
205 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_FLOW_ID16; |
206 | |
207 | return 1; |
208 | } |
209 | |
210 | static int |
211 | dissect_darwin_trace_tag(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
212 | { |
213 | wtap_optval_t* optval = (wtap_optval_t*)data; |
214 | |
215 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
216 | darwin->trace_tag = optval->uint32val; |
217 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_TRACE_TAG32; |
218 | |
219 | return 1; |
220 | } |
221 | |
222 | static int |
223 | dissect_darwin_drop_reason(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
224 | { |
225 | wtap_optval_t* optval = (wtap_optval_t*)data; |
226 | |
227 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
228 | darwin->drop_reason = optval->uint32val; |
229 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_DROP_REASON64; |
230 | |
231 | return 1; |
232 | } |
233 | |
234 | static int |
235 | dissect_darwin_drop_line(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
236 | { |
237 | wtap_optval_t* optval = (wtap_optval_t*)data; |
238 | |
239 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
240 | darwin->drop_line = optval->uint32val; |
241 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_DROP_LINE128; |
242 | |
243 | return 1; |
244 | } |
245 | |
246 | static int |
247 | dissect_darwin_drop_func(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
248 | { |
249 | wtap_optval_t* optval = (wtap_optval_t*)data; |
250 | |
251 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
252 | darwin->drop_func = optval->stringval; |
253 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_DROP_FUNC256; |
254 | |
255 | return 1; |
256 | } |
257 | |
258 | static int |
259 | dissect_darwin_comp_gencnt(tvbuff_t* tvb _U___attribute__((unused)), packet_info* pinfo, proto_tree* tree _U___attribute__((unused)), void* data) |
260 | { |
261 | wtap_optval_t* optval = (wtap_optval_t*)data; |
262 | |
263 | struct darwin_md* darwin = get_darwin_proto_data(pinfo); |
264 | darwin->comp_gencnt = optval->uint32val; |
265 | darwin->present_opts |= PINFO_DARWIN_MD_HAS_COMP_GENCNT512; |
266 | |
267 | return 1; |
268 | } |
269 | |
270 | static int |
271 | dissect_darwin_data(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused))) |
272 | { |
273 | struct darwin_md* darwin = (struct darwin_md*)p_get_proto_data(wmem_file_scope(), pinfo, proto_darwin, 0); |
274 | proto_item* ti; |
275 | |
276 | /* Reqiure darwin data */ |
277 | if (darwin == NULL((void*)0)) |
278 | return 0; |
279 | |
280 | int section_number = (pinfo->rec->presence_flags & WTAP_HAS_SECTION_NUMBER0x00000008) ? pinfo->rec->section_number : 0; |
281 | |
282 | if (darwin->present_opts & (PINFO_DARWIN_MD_HAS_DPIB_ID1 | PINFO_DARWIN_MD_HAS_EDPIB_ID2)) { |
283 | uint32_t proc_id; |
284 | const char* proc_name; |
285 | uint32_t eproc_id; |
286 | const char* eproc_name; |
287 | |
288 | proc_id = epan_get_process_id(pinfo->epan, darwin->dpib_id, section_number); |
289 | proc_name = epan_get_process_name(pinfo->epan, darwin->dpib_id, section_number); |
290 | |
291 | /* If the effective dpib id is not present, or is equal to the primary dpib id, |
292 | * set the eproc_id to proc_id. |
293 | */ |
294 | if (((darwin->present_opts & PINFO_DARWIN_MD_HAS_EDPIB_ID2) == 0) || |
295 | (darwin->dpib_id == darwin->effective_dpib_id)) { |
296 | eproc_id = proc_id; |
297 | eproc_name = proc_name; |
298 | } |
299 | else { |
300 | eproc_id = epan_get_process_id(pinfo->epan, darwin->effective_dpib_id, section_number); |
301 | eproc_name = epan_get_process_name(pinfo->epan, darwin->effective_dpib_id, section_number); |
302 | } |
303 | |
304 | if (proc_name) { |
305 | proto_item* proc_info_item; |
306 | proto_tree* proc_info_tree; |
307 | |
308 | if (proc_id == eproc_id) { |
309 | proc_info_item = proto_tree_add_item(tree, hf_process_info, tvb, 0, 0, ENC_NA0x00000000); |
310 | proc_info_tree = proto_item_add_subtree(proc_info_item, ett_proc_info); |
311 | PROTO_ITEM_SET_GENERATED(proc_info_item)proto_item_set_generated((proc_info_item)); |
312 | proto_item_append_text(proc_info_item, ": %s(%u)", proc_name, proc_id); |
313 | ti = proto_tree_add_uint(proc_info_tree, hf_process_info_pid, tvb, 0, 0, proc_id); |
314 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
315 | ti = proto_tree_add_string(proc_info_tree, hf_process_info_pname, tvb, 0, 0, proc_name); |
316 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
317 | } |
318 | else { |
319 | proc_info_item = proto_tree_add_item(tree, hf_process_info, tvb, 0, 0, ENC_NA0x00000000); |
320 | proc_info_tree = proto_item_add_subtree(proc_info_item, ett_proc_info); |
321 | PROTO_ITEM_SET_GENERATED(proc_info_item)proto_item_set_generated((proc_info_item)); |
322 | proto_item_append_text(proc_info_item, ": %s(%u) [%s(%u)]", proc_name, proc_id, eproc_name, eproc_id); |
323 | ti = proto_tree_add_uint(proc_info_tree, hf_process_info_pid, tvb, 0, 0, proc_id); |
324 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
325 | ti = proto_tree_add_string(proc_info_tree, hf_process_info_pname, tvb, 0, 0, proc_name); |
326 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
327 | } |
328 | |
329 | proto_item_append_text(tree, " proc: %s(%u)", proc_name, proc_id); |
330 | } |
331 | else { |
332 | proto_item_append_text(tree, " pid: %u", proc_id); |
333 | } |
334 | |
335 | /* This extra scrutiny is to ensure that the effective process id |
336 | * is _actually_ different from the primary process id. |
337 | */ |
338 | if ((proc_id != eproc_id) && (eproc_name != NULL((void*)0))) { |
339 | proto_item_append_text(tree, " [%s(%u)]", eproc_name, eproc_id); |
340 | } |
341 | else { |
342 | proto_item_append_text(tree, " [%u]", eproc_id); |
343 | } |
344 | } |
345 | |
346 | /* Check for Darwin-specific options, and create a subtree if needed */ |
347 | if (darwin->present_opts & PINFO_DARWIN_MD_OPT_BITMASK( 4| 8| 16| 32| 64| 128| 256| 512)) { |
348 | proto_item* dmd_item; |
349 | proto_tree* dmd_tree; |
350 | bool_Bool first_metadata_item = true1; |
351 | |
352 | dmd_item = proto_tree_add_boolean_format(tree, hf_darwin_metadata, tvb, 0, 0, true1, "Darwin Metadata:"); |
353 | dmd_tree = proto_item_add_subtree(dmd_item, ett_darwin_metadata); |
354 | PROTO_ITEM_SET_GENERATED(dmd_item)proto_item_set_generated((dmd_item)); |
355 | |
356 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_MD_FLAGS8) { |
357 | ti = proto_tree_add_bitmask_value(dmd_tree, tvb, 0, hf_darwin_metadata_flags, ett_darwin_metadata_flags, darwin_md_flags, darwin->md_flags); |
358 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
359 | proto_item_append_text(dmd_item, " flags=%s%s%s%s%s%s", |
360 | (darwin->md_flags & DARWIN_MD_FLAG_WK0x00000020) ? "W" : ".", |
361 | (darwin->md_flags & DARWIN_MD_FLAG_CH0x00000010) ? "C" : ".", |
362 | (darwin->md_flags & DARWIN_MD_FLAG_SO0x00000008) ? "S" : ".", |
363 | (darwin->md_flags & DARWIN_MD_FLAG_RE0x00000004) ? "R" : ".", |
364 | (darwin->md_flags & DARWIN_MD_FLAG_KA0x00000002) ? "K" : ".", |
365 | (darwin->md_flags & DARWIN_MD_FLAG_NF0x00000001) ? "N" : "." |
366 | ); |
367 | first_metadata_item = false0; |
368 | } |
369 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_SVC_CODE4) { |
370 | ti = proto_tree_add_uint(dmd_tree, hf_darwin_metadata_svc_code, tvb, 0, 0, darwin->svc_code); |
371 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
372 | proto_item_append_text(dmd_item, "%ssc=%s", |
373 | first_metadata_item ? " " : "; ", |
374 | val_to_str_const(darwin->svc_code, darwin_svc_class_vals, "Unknown")); |
375 | first_metadata_item = false0; |
376 | } |
377 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_FLOW_ID16) { |
378 | ti = proto_tree_add_uint(dmd_tree, hf_darwin_metadata_flow_id, tvb, 0, 0, darwin->flow_id); |
379 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
380 | proto_item_append_text(dmd_item, "%sfi=%x", |
381 | first_metadata_item ? " " : "; ", |
382 | darwin->flow_id); |
383 | first_metadata_item = false0; |
384 | } |
385 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_TRACE_TAG32) { |
386 | ti = proto_tree_add_uint(dmd_tree, hf_darwin_metadata_trace_tag, tvb, 0, 0, darwin->trace_tag); |
387 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
388 | proto_item_append_text(dmd_item, "%strace=%x", |
389 | first_metadata_item ? " " : "; ", |
390 | darwin->trace_tag); |
391 | first_metadata_item = false0; |
392 | } |
393 | if (darwin->present_opts & (PINFO_DARWIN_MD_HAS_DROP_REASON64 | PINFO_DARWIN_MD_HAS_DROP_LINE128 | PINFO_DARWIN_MD_HAS_DROP_FUNC256)) { |
394 | proto_tree* drop_tree; |
395 | proto_item* drop_item; |
396 | |
397 | drop_item = proto_tree_add_boolean(dmd_tree, hf_darwin_metadata_dropped, tvb, 0, 0, true1); |
398 | drop_tree = proto_item_add_subtree(drop_item, ett_darwin_metadata_dropped); |
399 | PROTO_ITEM_SET_GENERATED(drop_item)proto_item_set_generated((drop_item)); |
400 | proto_item_append_text(dmd_item, "%sdrop", first_metadata_item ? " " : "; "); |
401 | |
402 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_DROP_FUNC256) { |
403 | ti = proto_tree_add_string(drop_tree, hf_darwin_metadata_drop_func, tvb, 0, 0, darwin->drop_func); |
404 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
405 | proto_item_append_text(dmd_item, " %s", darwin->drop_func); |
406 | proto_item_append_text(drop_item, " %s", darwin->drop_func); |
407 | } |
408 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_DROP_LINE128) { |
409 | ti = proto_tree_add_uint(drop_tree, hf_darwin_metadata_drop_line, tvb, 0, 0, darwin->drop_line); |
410 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
411 | proto_item_append_text(dmd_item, "%s%u", |
412 | (darwin->present_opts & PINFO_DARWIN_MD_HAS_DROP_FUNC256) ? ":" : " ", |
413 | darwin->drop_line); |
414 | proto_item_append_text(drop_item, "%s%u", |
415 | (darwin->present_opts & PINFO_DARWIN_MD_HAS_DROP_FUNC256) ? ":" : " ", |
416 | darwin->drop_line); |
417 | } |
418 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_DROP_REASON64) { |
419 | ti = proto_tree_add_uint(drop_tree, hf_darwin_metadata_drop_reason, tvb, 0, 0, darwin->drop_reason); |
420 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
421 | proto_item_append_text(dmd_item, " 0x%x", darwin->drop_reason); |
422 | proto_item_append_text(drop_item, " 0x%x", darwin->drop_reason); |
423 | } |
424 | first_metadata_item = false0; |
425 | } |
426 | if (darwin->present_opts & PINFO_DARWIN_MD_HAS_COMP_GENCNT512) { |
427 | ti = proto_tree_add_uint(dmd_tree, hf_darwin_metadata_trace_tag, tvb, 0, 0, darwin->trace_tag); |
428 | PROTO_ITEM_SET_GENERATED(ti)proto_item_set_generated((ti)); |
429 | proto_item_append_text(dmd_item, "%sgencnt=%u", |
430 | first_metadata_item ? " " : "; ", |
431 | darwin->comp_gencnt); |
432 | first_metadata_item = false0; |
Value stored to 'first_metadata_item' is never read | |
433 | } |
434 | } |
435 | |
436 | return 1; |
437 | } |
438 | |
439 | void |
440 | proto_register_darwin(void) |
441 | { |
442 | /* Register the protocol name and description */ |
443 | proto_darwin = proto_register_protocol(PNAME"Apple Darwin", PSNAME"Darwin", PFNAME"darwin"); |
444 | |
445 | register_dissector("darwin", dissect_darwin_data, proto_darwin); |
446 | } |
447 | |
448 | |
449 | void |
450 | proto_reg_handoff_darwin(void) |
451 | { |
452 | static hf_register_info hf_darwin_options[] = { |
453 | { &hf_process_info, |
454 | { "Process Information", "frame.darwin.process_info", |
455 | FT_NONE, BASE_NONE, NULL((void*)0), 0x0, |
456 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
457 | { &hf_process_info_pid, |
458 | { "Id", "frame.darwin.process_info.pid", |
459 | FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
460 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
461 | { &hf_process_info_pname, |
462 | { "Name", "frame.darwin.process_info.pname", |
463 | FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
464 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
465 | { &hf_process_info_epid, |
466 | { "Effective Id", "frame.darwin.process_info.epid", |
467 | FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
468 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
469 | { &hf_process_info_epname, |
470 | { "Effective Name", "frame.darwin.process_info.epname", |
471 | FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
472 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
473 | { &hf_darwin_metadata, |
474 | { "Darwin MD", "frame.darwin", |
475 | FT_BOOLEAN, BASE_NONE, NULL((void*)0), 0x0, |
476 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
477 | { &hf_darwin_metadata_svc_code, |
478 | { "Service Class", "frame.darwin.sc", |
479 | FT_UINT8, BASE_DEC, VALS(darwin_svc_class_vals)((0 ? (const struct _value_string*)0 : ((darwin_svc_class_vals )))), 0x0, |
480 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
481 | { &hf_darwin_metadata_flags, |
482 | { "Flags", "frame.darwin.flags", |
483 | FT_UINT32, BASE_HEX, NULL((void*)0), 0x0, |
484 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
485 | { &hf_darwin_metadata_flags_reserved, |
486 | { "Reserved", "frame.darwin.flags.reserved", |
487 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_RESERVED(~( 0x00000020| 0x00000010| 0x00000008| 0x00000004| 0x00000002 | 0x00000001)), |
488 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
489 | { &hf_darwin_metadata_flags_wk, |
490 | { "Wake Packet(wk)", "frame.darwin.flags.wk", |
491 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_WK0x00000020, |
492 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
493 | { &hf_darwin_metadata_flags_ch, |
494 | { "Nexus Channel(ch)", "frame.darwin.flags.ch", |
495 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_CH0x00000010, |
496 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
497 | { &hf_darwin_metadata_flags_so, |
498 | { "Socket(so)", "frame.darwin.flags.so", |
499 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_SO0x00000008, |
500 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
501 | { &hf_darwin_metadata_flags_re, |
502 | { "ReXmit(re)", "frame.darwin.flags.re", |
503 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_RE0x00000004, |
504 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
505 | { &hf_darwin_metadata_flags_ka, |
506 | { "Keep Alive(ka)", "frame.darwin.flags.ka", |
507 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_KA0x00000002, |
508 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
509 | { &hf_darwin_metadata_flags_nf, |
510 | { "New Flow(nf)", "frame.darwin.flags.nf", |
511 | FT_BOOLEAN, 32, TFS(&tfs_set_notset)((0 ? (const struct true_false_string*)0 : ((&tfs_set_notset )))), DARWIN_MD_FLAG_NF0x00000001, |
512 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
513 | { &hf_darwin_metadata_flow_id, |
514 | { "Flow Id", "frame.darwin.flow_id", |
515 | FT_UINT32, BASE_HEX, NULL((void*)0), 0x0, |
516 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
517 | { &hf_darwin_metadata_trace_tag, |
518 | { "Trace Tag", "frame.darwin.trace_tag", |
519 | FT_UINT32, BASE_HEX, NULL((void*)0), 0x0, |
520 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
521 | { &hf_darwin_metadata_dropped, |
522 | { "Packet Dropped By Kernel", "frame.darwin.drop", |
523 | FT_BOOLEAN, BASE_NONE, NULL((void*)0), 0x0, |
524 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
525 | { &hf_darwin_metadata_drop_reason, |
526 | { "Drop Reason", "frame.darwin.drop.reason_code", |
527 | FT_UINT32, BASE_HEX, NULL((void*)0), 0x0, |
528 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
529 | { &hf_darwin_metadata_drop_line, |
530 | { "Drop Line", "frame.darwin.drop.line", |
531 | FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
532 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
533 | { &hf_darwin_metadata_drop_func, |
534 | { "Drop Func", "frame.darwin.drop.func", |
535 | FT_STRING, BASE_NONE, NULL((void*)0), 0x0, |
536 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
537 | { &hf_darwin_metadata_comp_gencnt, |
538 | { "Compression gencnt", "frame.darwin.gencnt", |
539 | FT_UINT32, BASE_DEC, NULL((void*)0), 0x0, |
540 | NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }}, |
541 | }; |
542 | |
543 | static int *ett_frame_darwin_options[] = { |
544 | &ett_proc_info, |
545 | &ett_proc_info_proc, |
546 | &ett_proc_info_eproc, |
547 | &ett_darwin_metadata, |
548 | &ett_darwin_metadata_flags, |
549 | }; |
550 | |
551 | int proto_frame = proto_registrar_get_id_byname("frame"); |
552 | |
553 | proto_register_subtree_array(ett_frame_darwin_options, array_length(ett_frame_darwin_options)(sizeof (ett_frame_darwin_options) / sizeof (ett_frame_darwin_options )[0])); |
554 | proto_register_field_array(proto_frame, hf_darwin_options, array_length(hf_darwin_options)(sizeof (hf_darwin_options) / sizeof (hf_darwin_options)[0])); |
555 | |
556 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_PIB_ID32769, create_dissector_handle(dissect_darwin_dpib_id, proto_darwin)); |
557 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_EFFECTIVE_PIB_ID32771, create_dissector_handle(dissect_darwin_effective_dpib_id, proto_darwin)); |
558 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_SVC_CODE32770, create_dissector_handle(dissect_darwin_svc_code, proto_darwin)); |
559 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_MD_FLAGS32772, create_dissector_handle(dissect_darwin_md_flags, proto_darwin)); |
560 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_FLOW_ID32773, create_dissector_handle(dissect_darwin_flow_id, proto_darwin)); |
561 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_TRACE_TAG32774, create_dissector_handle(dissect_darwin_trace_tag, proto_darwin)); |
562 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_DROP_REASON32775, create_dissector_handle(dissect_darwin_drop_reason, proto_darwin)); |
563 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_DROP_LINE32776, create_dissector_handle(dissect_darwin_drop_line, proto_darwin)); |
564 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_DROP_FUNC32777, create_dissector_handle(dissect_darwin_drop_func, proto_darwin)); |
565 | dissector_add_uint("pcapng_packet_block_option", OPT_PKT_DARWIN_COMP_GENCNT32778, create_dissector_handle(dissect_darwin_comp_gencnt, proto_darwin)); |
566 | } |
567 | |
568 | /* |
569 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
570 | * |
571 | * Local variables: |
572 | * c-basic-offset: 4 |
573 | * tab-width: 8 |
574 | * indent-tabs-mode: nil |
575 | * End: |
576 | * |
577 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
578 | * :indentSize=4:tabSize=8:noTabs=true: |
579 | */ |