### Bug Summary

File: | builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c
Warning: | line 433, column 2 Potential leak of memory pointed to by 'a'

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name taps_wslua.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-22/lib/clang/22 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/lua5.5 -isystem /builds/wireshark/wireshark/build/epan/wslua -isystem /builds/wireshark/wireshark/epan/wslua -D CARES_NO_DEPRECATED -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-nonliteral -std=gnu17 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /builds/wireshark/wireshark/sbout/2026-07-28-100419-3660-1 -x c /builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

#### /builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c

→

1 | /* This file is autogenerated from ./taps by ./make-taps.py */
2 | /* DO NOT EDIT! */
3 |
4 | #include "config.h"
5 |
6 | #include "wslua.h"
7 |
8 | #include <wsutil/nstime.h>
9 |
10 | #include "../dissectors/packet-ip.h"
11 | static void wslua_ip_to_table(lua_State* L, const void* p) {
12 | const ws_ip4* v;
13 |
14 | v = (const ws_ip4*)p;
15 | lua_newtable(L)lua_createtable(L, 0, 0);
16 |
17 | lua_pushstring(L,"ip_dst");
18 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_dst)); pushAddress(L,a); }
19 | lua_settable(L,-3);
20 | lua_pushstring(L,"ip_id");
21 | lua_pushinteger(L,(lua_Integer)v->ip_id);
22 | lua_settable(L,-3);
23 | lua_pushstring(L,"ip_len");
24 | lua_pushinteger(L,(lua_Integer)v->ip_len);
25 | lua_settable(L,-3);
26 | lua_pushstring(L,"ip_off");
27 | lua_pushinteger(L,(lua_Integer)v->ip_off);
28 | lua_settable(L,-3);
29 | lua_pushstring(L,"ip_proto");
30 | lua_pushinteger(L,(lua_Integer)v->ip_proto);
31 | lua_settable(L,-3);
32 | lua_pushstring(L,"ip_src");
33 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_src)); pushAddress(L,a); }
34 | lua_settable(L,-3);
35 | lua_pushstring(L,"ip_stream");
36 | lua_pushinteger(L,(lua_Integer)v->ip_stream);
37 | lua_settable(L,-3);
38 | lua_pushstring(L,"ip_sum");
39 | lua_pushinteger(L,(lua_Integer)v->ip_sum);
40 | lua_settable(L,-3);
41 | lua_pushstring(L,"ip_tos");
42 | lua_pushinteger(L,(lua_Integer)v->ip_tos);
43 | lua_settable(L,-3);
44 | lua_pushstring(L,"ip_ttl");
45 | lua_pushinteger(L,(lua_Integer)v->ip_ttl);
46 | lua_settable(L,-3);
47 | lua_pushstring(L,"ip_ver");
48 | lua_pushinteger(L,(lua_Integer)v->ip_ver);
49 | lua_settable(L,-3);
50 | }
51 |
52 | #include "../dissectors/packet-udp.h"
53 | static void wslua_udp_to_table(lua_State* L, const void* p) {
54 | const e_udphdr* v;
55 |
56 | v = (const e_udphdr*)p;
57 | lua_newtable(L)lua_createtable(L, 0, 0);
58 |
59 | lua_pushstring(L,"ip_dst");
60 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_dst)); pushAddress(L,a); }
61 | lua_settable(L,-3);
62 | lua_pushstring(L,"ip_src");
63 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_src)); pushAddress(L,a); }
64 | lua_settable(L,-3);
65 | lua_pushstring(L,"uh_dport");
66 | lua_pushinteger(L,(lua_Integer)v->uh_dport);
67 | lua_settable(L,-3);
68 | lua_pushstring(L,"uh_sport");
69 | lua_pushinteger(L,(lua_Integer)v->uh_sport);
70 | lua_settable(L,-3);
71 | lua_pushstring(L,"uh_stream");
72 | lua_pushinteger(L,(lua_Integer)v->uh_stream);
73 | lua_settable(L,-3);
74 | lua_pushstring(L,"uh_sum");
75 | lua_pushinteger(L,(lua_Integer)v->uh_sum);
76 | lua_settable(L,-3);
77 | lua_pushstring(L,"uh_sum_cov");
78 | lua_pushinteger(L,(lua_Integer)v->uh_sum_cov);
79 | lua_settable(L,-3);
80 | lua_pushstring(L,"uh_ulen");
81 | lua_pushinteger(L,(lua_Integer)v->uh_ulen);
82 | lua_settable(L,-3);
83 | }
84 |
85 | #include "../dissectors/packet-http.h"
86 | static void wslua_http_to_table(lua_State* L, const void* p) {
87 | const http_info_value_t* v;
88 |
89 | v = (const http_info_value_t*)p;
90 | lua_newtable(L)lua_createtable(L, 0, 0);
91 |
92 | lua_pushstring(L,"framenum");
93 | lua_pushinteger(L,(lua_Integer)v->framenum);
94 | lua_settable(L,-3);
95 | lua_pushstring(L,"full_uri");
96 | lua_pushstring(L,(const char*)v->full_uri);
97 | lua_settable(L,-3);
98 | lua_pushstring(L,"http_host");
99 | lua_pushstring(L,(const char*)v->http_host);
100 | lua_settable(L,-3);
101 | lua_pushstring(L,"location_base_uri");
102 | lua_pushstring(L,(const char*)v->location_base_uri);
103 | lua_settable(L,-3);
104 | lua_pushstring(L,"location_target");
105 | lua_pushstring(L,(const char*)v->location_target);
106 | lua_settable(L,-3);
107 | lua_pushstring(L,"referer_uri");
108 | lua_pushstring(L,(const char*)v->referer_uri);
109 | lua_settable(L,-3);
110 | lua_pushstring(L,"request_method");
111 | lua_pushstring(L,(const char*)v->request_method);
112 | lua_settable(L,-3);
113 | lua_pushstring(L,"request_uri");
114 | lua_pushstring(L,(const char*)v->request_uri);
115 | lua_settable(L,-3);
116 | lua_pushstring(L,"response_code");
117 | lua_pushinteger(L,(lua_Integer)v->response_code);
118 | lua_settable(L,-3);
119 | }
120 |
121 | #include "../dissectors/packet-bacapp.h"
122 | static void wslua_bacapp_to_table(lua_State* L, const void* p) {
123 | const bacapp_info_value_t* v;
124 |
125 | v = (const bacapp_info_value_t*)p;
126 | lua_newtable(L)lua_createtable(L, 0, 0);
127 |
128 | lua_pushstring(L,"instance_ident");
129 | lua_pushstring(L,(const char*)v->instance_ident);
130 | lua_settable(L,-3);
131 | lua_pushstring(L,"invoke_id");
132 | lua_pushstring(L,(const char*)v->invoke_id);
133 | lua_settable(L,-3);
134 | lua_pushstring(L,"object_ident");
135 | lua_pushstring(L,(const char*)v->object_ident);
136 | lua_settable(L,-3);
137 | lua_pushstring(L,"service_type");
138 | lua_pushstring(L,(const char*)v->service_type);
139 | lua_settable(L,-3);
140 | }
141 |
142 | #include "../dissectors/packet-h225.h"
143 | static void wslua_h225_to_table(lua_State* L, const void* p) {
144 | const h225_packet_info* v;
145 |
146 | v = (const h225_packet_info*)p;
147 | lua_newtable(L)lua_createtable(L, 0, 0);
148 |
149 | lua_pushstring(L,"cs_type");
150 | lua_pushinteger(L,(lua_Integer)v->cs_type); /* h225_cs_type */
151 | lua_settable(L,-3);
152 | lua_pushstring(L,"delta_time");
153 | lua_pushnumber(L,(lua_Number)nstime_to_sec(&(v->delta_time)));
154 | lua_settable(L,-3);
155 | lua_pushstring(L,"dialedDigits");
156 | lua_pushstring(L,(const char*)v->dialedDigits);
157 | lua_settable(L,-3);
158 | lua_pushstring(L,"frame_label");
159 | lua_pushstring(L,(const char*)v->frame_label);
160 | lua_settable(L,-3);
161 | lua_pushstring(L,"h245_address");
162 | lua_pushinteger(L,(lua_Integer)v->h245_address);
163 | lua_settable(L,-3);
164 | lua_pushstring(L,"h245_port");
165 | lua_pushinteger(L,(lua_Integer)v->h245_port);
166 | lua_settable(L,-3);
167 | lua_pushstring(L,"is_destinationInfo");
168 | lua_pushboolean(L,(int)v->is_destinationInfo);
169 | lua_settable(L,-3);
170 | lua_pushstring(L,"is_duplicate");
171 | lua_pushboolean(L,(int)v->is_duplicate);
172 | lua_settable(L,-3);
173 | lua_pushstring(L,"is_faststart");
174 | lua_pushboolean(L,(int)v->is_faststart);
175 | lua_settable(L,-3);
176 | lua_pushstring(L,"is_h245");
177 | lua_pushboolean(L,(int)v->is_h245);
178 | lua_settable(L,-3);
179 | lua_pushstring(L,"is_h245Tunneling");
180 | lua_pushboolean(L,(int)v->is_h245Tunneling);
181 | lua_settable(L,-3);
182 | lua_pushstring(L,"msg_tag");
183 | lua_pushinteger(L,(lua_Integer)v->msg_tag);
184 | lua_settable(L,-3);
185 | lua_pushstring(L,"msg_type");
186 | lua_pushinteger(L,(lua_Integer)v->msg_type); /* h225_msg_type */
187 | lua_settable(L,-3);
188 | lua_pushstring(L,"reason");
189 | lua_pushinteger(L,(lua_Integer)v->reason);
190 | lua_settable(L,-3);
191 | lua_pushstring(L,"requestSeqNum");
192 | lua_pushinteger(L,(lua_Integer)v->requestSeqNum);
193 | lua_settable(L,-3);
194 | lua_pushstring(L,"request_available");
195 | lua_pushboolean(L,(int)v->request_available);
196 | lua_settable(L,-3);
197 | }
198 |
199 | #include "../dissectors/packet-actrace.h"
200 | static void wslua_actrace_to_table(lua_State* L, const void* p) {
201 | const actrace_info_t* v;
202 |
203 | v = (const actrace_info_t*)p;
204 | lua_newtable(L)lua_createtable(L, 0, 0);
205 |
206 | lua_pushstring(L,"cas_frame_label");
207 | lua_pushstring(L,(const char*)v->cas_frame_label);
208 | lua_settable(L,-3);
209 | lua_pushstring(L,"direction");
210 | lua_pushinteger(L,(lua_Integer)v->direction);
211 | lua_settable(L,-3);
212 | lua_pushstring(L,"trunk");
213 | lua_pushinteger(L,(lua_Integer)v->trunk);
214 | lua_settable(L,-3);
215 | lua_pushstring(L,"type");
216 | lua_pushinteger(L,(lua_Integer)v->type);
217 | lua_settable(L,-3);
218 | }
219 |
220 | #include "../dissectors/packet-ansi_a.h"
221 | static void wslua_ansi_a_to_table(lua_State* L, const void* p) {
222 | const ansi_a_tap_rec_t* v;
223 |
224 | v = (const ansi_a_tap_rec_t*)p;
225 | lua_newtable(L)lua_createtable(L, 0, 0);
226 |
227 | lua_pushstring(L,"message_type");
228 | lua_pushinteger(L,(lua_Integer)v->message_type);
229 | lua_settable(L,-3);
230 | lua_pushstring(L,"pdu_type");
231 | lua_pushinteger(L,(lua_Integer)v->pdu_type);
232 | lua_settable(L,-3);
233 | }
234 |
235 | #include "../dissectors/packet-ansi_map.h"
236 | static void wslua_ansi_map_to_table(lua_State* L, const void* p) {
237 | const ansi_map_tap_rec_t* v;
238 |
239 | v = (const ansi_map_tap_rec_t*)p;
240 | lua_newtable(L)lua_createtable(L, 0, 0);
241 |
242 | lua_pushstring(L,"message_type");
243 | lua_pushinteger(L,(lua_Integer)v->message_type);
244 | lua_settable(L,-3);
245 | lua_pushstring(L,"size");
246 | lua_pushinteger(L,(lua_Integer)v->size);
247 | lua_settable(L,-3);
248 | }
249 |
250 | #include "../dissectors/packet-eth.h"
251 | static void wslua_eth_to_table(lua_State* L, const void* p) {
252 | const eth_hdr* v;
253 |
254 | v = (const eth_hdr*)p;
255 | lua_newtable(L)lua_createtable(L, 0, 0);
256 |
257 | lua_pushstring(L,"dst");
258 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->dst)); pushAddress(L,a); }
259 | lua_settable(L,-3);
260 | lua_pushstring(L,"src");
261 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->src)); pushAddress(L,a); }
262 | lua_settable(L,-3);
263 | lua_pushstring(L,"stream");
264 | lua_pushinteger(L,(lua_Integer)v->stream);
265 | lua_settable(L,-3);
266 | lua_pushstring(L,"type");
267 | lua_pushinteger(L,(lua_Integer)v->type);
268 | lua_settable(L,-3);
269 | }
270 |
271 | #include "../dissectors/packet-ldap.h"
272 | static void wslua_ldap_to_table(lua_State* L, const void* p) {
273 | const ldap_call_response_t* v;
274 |
275 | v = (const ldap_call_response_t*)p;
276 | lua_newtable(L)lua_createtable(L, 0, 0);
277 |
278 | lua_pushstring(L,"is_request");
279 | lua_pushboolean(L,(int)v->is_request);
280 | lua_settable(L,-3);
281 | lua_pushstring(L,"messageId");
282 | lua_pushinteger(L,(lua_Integer)v->messageId);
283 | lua_settable(L,-3);
284 | lua_pushstring(L,"protocolOpTag");
285 | lua_pushinteger(L,(lua_Integer)v->protocolOpTag);
286 | lua_settable(L,-3);
287 | lua_pushstring(L,"rep_frame");
288 | lua_pushinteger(L,(lua_Integer)v->rep_frame);
289 | lua_settable(L,-3);
290 | lua_pushstring(L,"req_frame");
291 | lua_pushinteger(L,(lua_Integer)v->req_frame);
292 | lua_settable(L,-3);
293 | lua_pushstring(L,"req_time");
294 | lua_pushnumber(L,(lua_Number)nstime_to_sec(&(v->req_time)));
295 | lua_settable(L,-3);
296 | }
297 |
298 | #include "../dissectors/packet-smb.h"
299 | static void wslua_smb_to_table(lua_State* L, const void* p) {
300 | const smb_info_t* v;
301 |
302 | v = (const smb_info_t*)p;
303 | lua_newtable(L)lua_createtable(L, 0, 0);
304 |
305 | lua_pushstring(L,"cmd");
306 | lua_pushinteger(L,(lua_Integer)v->cmd);
307 | lua_settable(L,-3);
308 | lua_pushstring(L,"info_count");
309 | lua_pushinteger(L,(lua_Integer)v->info_count);
310 | lua_settable(L,-3);
311 | lua_pushstring(L,"info_level");
312 | lua_pushinteger(L,(lua_Integer)v->info_level);
313 | lua_settable(L,-3);
314 | lua_pushstring(L,"nt_status");
315 | lua_pushinteger(L,(lua_Integer)v->nt_status);
316 | lua_settable(L,-3);
317 | lua_pushstring(L,"request");
318 | lua_pushboolean(L,(int)v->request);
319 | lua_settable(L,-3);
320 | lua_pushstring(L,"unicode");
321 | lua_pushboolean(L,(int)v->unicode);
322 | lua_settable(L,-3);
323 | lua_pushstring(L,"unidir");
324 | lua_pushboolean(L,(int)v->unidir);
325 | lua_settable(L,-3);
326 | }
327 |
328 | #include "../dissectors/packet-smb2.h"
329 | static void wslua_smb2_to_table(lua_State* L, const void* p) {
330 | const smb2_info_t* v;
331 |
332 | v = (const smb2_info_t*)p;
333 | lua_newtable(L)lua_createtable(L, 0, 0);
334 |
335 | lua_pushstring(L,"flags");
336 | lua_pushinteger(L,(lua_Integer)v->flags);
337 | lua_settable(L,-3);
338 | lua_pushstring(L,"ioctl_function");
339 | lua_pushinteger(L,(lua_Integer)v->ioctl_function);
340 | lua_settable(L,-3);
341 | lua_pushstring(L,"opcode");
342 | lua_pushinteger(L,(lua_Integer)v->opcode);
343 | lua_settable(L,-3);
344 | lua_pushstring(L,"status");
345 | lua_pushinteger(L,(lua_Integer)v->status);
346 | lua_settable(L,-3);
347 | lua_pushstring(L,"tid");
348 | lua_pushinteger(L,(lua_Integer)v->tid);
349 | lua_settable(L,-3);
350 | }
351 |
352 | #include "../dissectors/packet-tcp.h"
353 | static void wslua_tcp_to_table(lua_State* L, const void* p) {
354 | const tcp_info_t* v;
355 |
356 | v = (const tcp_info_t*)p;
357 | lua_newtable(L)lua_createtable(L, 0, 0);
358 |
359 | lua_pushstring(L,"flagkarn");
360 | lua_pushboolean(L,(int)v->flagkarn);
361 | lua_settable(L,-3);
362 | lua_pushstring(L,"ip_dst");
363 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_dst)); pushAddress(L,a); }
364 | lua_settable(L,-3);
365 | lua_pushstring(L,"ip_src");
366 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_src)); pushAddress(L,a); }
367 | lua_settable(L,-3);
368 | lua_pushstring(L,"num_sack_ranges");
369 | lua_pushinteger(L,(lua_Integer)v->num_sack_ranges);
370 | lua_settable(L,-3);
371 | lua_pushstring(L,"th_ack");
372 | lua_pushinteger(L,(lua_Integer)v->th_ack);
373 | lua_settable(L,-3);
374 | lua_pushstring(L,"th_dport");
375 | lua_pushinteger(L,(lua_Integer)v->th_dport);
376 | lua_settable(L,-3);
377 | lua_pushstring(L,"th_dup_count");
378 | lua_pushinteger(L,(lua_Integer)v->th_dup_count);
379 | lua_settable(L,-3);
380 | lua_pushstring(L,"th_dup_orig_frame");
381 | lua_pushinteger(L,(lua_Integer)v->th_dup_orig_frame);
382 | lua_settable(L,-3);
383 | lua_pushstring(L,"th_flags");
384 | lua_pushinteger(L,(lua_Integer)v->th_flags);
385 | lua_settable(L,-3);
386 | lua_pushstring(L,"th_have_seglen");
387 | lua_pushboolean(L,(int)v->th_have_seglen);
388 | lua_settable(L,-3);
389 | lua_pushstring(L,"th_hlen");
390 | lua_pushinteger(L,(lua_Integer)v->th_hlen);
391 | lua_settable(L,-3);
392 | lua_pushstring(L,"th_rawack");
393 | lua_pushinteger(L,(lua_Integer)v->th_rawack);
394 | lua_settable(L,-3);
395 | lua_pushstring(L,"th_rawseq");
396 | lua_pushinteger(L,(lua_Integer)v->th_rawseq);
397 | lua_settable(L,-3);
398 | lua_pushstring(L,"th_seglen");
399 | lua_pushinteger(L,(lua_Integer)v->th_seglen);
400 | lua_settable(L,-3);
401 | lua_pushstring(L,"th_seq");
402 | lua_pushinteger(L,(lua_Integer)v->th_seq);
403 | lua_settable(L,-3);
404 | lua_pushstring(L,"th_sport");
405 | lua_pushinteger(L,(lua_Integer)v->th_sport);
406 | lua_settable(L,-3);
407 | lua_pushstring(L,"th_stream");
408 | lua_pushinteger(L,(lua_Integer)v->th_stream);
409 | lua_settable(L,-3);
410 | lua_pushstring(L,"th_use_ace");
411 | lua_pushboolean(L,(int)v->th_use_ace);
412 | lua_settable(L,-3);
413 | lua_pushstring(L,"th_win");
414 | lua_pushinteger(L,(lua_Integer)v->th_win);
415 | lua_settable(L,-3);
416 | }
417 |
418 | #include "../dissectors/packet-ieee80211.h"
419 | static void wslua_wlan_to_table(lua_State* L, const void* p) {
420 | const wlan_hdr_t* v;
421 |
422 | v = (const wlan_hdr_t*)p;
423 | lua_newtable(L)lua_createtable(L, 0, 0);
424 |
425 | lua_pushstring(L,"bssid");
426 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->bssid)); pushAddress(L,a); }
427 | lua_settable(L,-3);
428 | lua_pushstring(L,"dst");
429 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->dst)); pushAddress(L,a); }
430 | lua_settable(L,-3);
431 | lua_pushstring(L,"src");
432 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->src)); pushAddress(L,a); }
1 | Memory is allocated | →
2 | ← | Calling 'copy_address' | →
15 | ← | Returning from 'copy_address' | →
433 | lua_settable(L,-3);
16 | ← | Potential leak of memory pointed to by 'a'
434 | lua_pushstring(L,"type");
435 | lua_pushinteger(L,(lua_Integer)v->type);
436 | lua_settable(L,-3);
437 | }
438 |
439 | static tappable_t tappables[] = {
440 | {"actrace", wslua_actrace_to_table },
441 | {"ansi_a", wslua_ansi_a_to_table },
442 | {"ansi_map", wslua_ansi_map_to_table },
443 | {"bacapp", wslua_bacapp_to_table },
444 | {"eth", wslua_eth_to_table },
445 | {"h225", wslua_h225_to_table },
446 | {"http", wslua_http_to_table },
447 | {"ip", wslua_ip_to_table },
448 | {"ldap", wslua_ldap_to_table },
449 | {"smb", wslua_smb_to_table },
450 | {"smb2", wslua_smb2_to_table },
451 | {"tcp", wslua_tcp_to_table },
452 | {"udp", wslua_udp_to_table },
453 | {"wlan", wslua_wlan_to_table },
454 | {"frame",NULL((void*)0)},
455 | {NULL((void*)0),NULL((void*)0)}
456 | };
457 |
458 | int wslua_set_tap_enums(lua_State* L) {
459 |
460 | /*
461 | * h225_cs_type
462 | */
463 | lua_newtable(L)lua_createtable(L, 0, 0);
464 | lua_pushinteger(L,(lua_Integer)H225_SETUP);
465 | lua_setglobal(L,"H225_SETUP");
466 | lua_pushinteger(L,(lua_Integer)H225_SETUP);
467 | lua_pushstring(L,"H225_SETUP");
468 | lua_settable(L,-3);
469 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING);
470 | lua_setglobal(L,"H225_CALL_PROCEDING");
471 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING);
472 | lua_pushstring(L,"H225_CALL_PROCEDING");
473 | lua_settable(L,-3);
474 | lua_pushinteger(L,(lua_Integer)H225_CONNECT);
475 | lua_setglobal(L,"H225_CONNECT");
476 | lua_pushinteger(L,(lua_Integer)H225_CONNECT);
477 | lua_pushstring(L,"H225_CONNECT");
478 | lua_settable(L,-3);
479 | lua_pushinteger(L,(lua_Integer)H225_ALERTING);
480 | lua_setglobal(L,"H225_ALERTING");
481 | lua_pushinteger(L,(lua_Integer)H225_ALERTING);
482 | lua_pushstring(L,"H225_ALERTING");
483 | lua_settable(L,-3);
484 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION);
485 | lua_setglobal(L,"H225_INFORMATION");
486 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION);
487 | lua_pushstring(L,"H225_INFORMATION");
488 | lua_settable(L,-3);
489 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET);
490 | lua_setglobal(L,"H225_RELEASE_COMPLET");
491 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET);
492 | lua_pushstring(L,"H225_RELEASE_COMPLET");
493 | lua_settable(L,-3);
494 | lua_pushinteger(L,(lua_Integer)H225_FACILITY);
495 | lua_setglobal(L,"H225_FACILITY");
496 | lua_pushinteger(L,(lua_Integer)H225_FACILITY);
497 | lua_pushstring(L,"H225_FACILITY");
498 | lua_settable(L,-3);
499 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS);
500 | lua_setglobal(L,"H225_PROGRESS");
501 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS);
502 | lua_pushstring(L,"H225_PROGRESS");
503 | lua_settable(L,-3);
504 | lua_pushinteger(L,(lua_Integer)H225_EMPTY);
505 | lua_setglobal(L,"H225_EMPTY");
506 | lua_pushinteger(L,(lua_Integer)H225_EMPTY);
507 | lua_pushstring(L,"H225_EMPTY");
508 | lua_settable(L,-3);
509 | lua_pushinteger(L,(lua_Integer)H225_STATUS);
510 | lua_setglobal(L,"H225_STATUS");
511 | lua_pushinteger(L,(lua_Integer)H225_STATUS);
512 | lua_pushstring(L,"H225_STATUS");
513 | lua_settable(L,-3);
514 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY);
515 | lua_setglobal(L,"H225_STATUS_INQUIRY");
516 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY);
517 | lua_pushstring(L,"H225_STATUS_INQUIRY");
518 | lua_settable(L,-3);
519 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK);
520 | lua_setglobal(L,"H225_SETUP_ACK");
521 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK);
522 | lua_pushstring(L,"H225_SETUP_ACK");
523 | lua_settable(L,-3);
524 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY);
525 | lua_setglobal(L,"H225_NOTIFY");
526 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY);
527 | lua_pushstring(L,"H225_NOTIFY");
528 | lua_settable(L,-3);
529 | lua_pushinteger(L,(lua_Integer)H225_OTHER);
530 | lua_setglobal(L,"H225_OTHER");
531 | lua_pushinteger(L,(lua_Integer)H225_OTHER);
532 | lua_pushstring(L,"H225_OTHER");
533 | lua_settable(L,-3);
534 | lua_setglobal(L,"h225_cs_type");
535 |
536 | /*
537 | * h225_msg_type
538 | */
539 | lua_newtable(L)lua_createtable(L, 0, 0);
540 | lua_pushinteger(L,(lua_Integer)H225_RAS);
541 | lua_setglobal(L,"H225_RAS");
542 | lua_pushinteger(L,(lua_Integer)H225_RAS);
543 | lua_pushstring(L,"H225_RAS");
544 | lua_settable(L,-3);
545 | lua_pushinteger(L,(lua_Integer)H225_CS);
546 | lua_setglobal(L,"H225_CS");
547 | lua_pushinteger(L,(lua_Integer)H225_CS);
548 | lua_pushstring(L,"H225_CS");
549 | lua_settable(L,-3);
550 | lua_pushinteger(L,(lua_Integer)H225_OTHERS);
551 | lua_setglobal(L,"H225_OTHERS");
552 | lua_pushinteger(L,(lua_Integer)H225_OTHERS);
553 | lua_pushstring(L,"H225_OTHERS");
554 | lua_settable(L,-3);
555 | lua_setglobal(L,"h225_msg_type");
556 | return 0;
557 | }
558 |
559 |
560 | tap_extractor_t wslua_get_tap_extractor(const gchar* name) {
561 | tappable_t* t;
562 | for(t = tappables; t->name; t++ ) {
563 | if (g_str_equal(t->name,name)(strcmp ((const char *) (t->name), (const char *) (name)) == 0)) return t->extractor;
564 | }
565 |
566 | return NULL((void*)0);
567 | }

←

#### /builds/wireshark/wireshark/epan/address.h

1 | /** @file
2 | * Definitions for structures storing addresses, and for the type of
3 | * variables holding port-type values
4 | *
5 | * Wireshark - Network traffic analyzer
6 | * By Gerald Combs <gerald@wireshark.org>
7 | * Copyright 1998 Gerald Combs
8 | *
9 | * SPDX-License-Identifier: GPL-2.0-or-later
10 | */
11 | #pragma once
12 | #include <string.h> /* for memcmp */
13 |
14 | #include "tvbuff.h"
15 | #include <epan/wmem_scopes.h>
16 | #include <wsutil/ws_assert.h>
17 | #include <wsutil/inet_cidr.h>
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif /* __cplusplus */
22 |
23 | /* Types of "global" addresses Wireshark knows about. */
24 | /**
25 | * @brief Identifies the type of a network layer or link layer address.
26 | *
27 | * Address types can be added here if there are many dissectors that use them or just
28 | * within a specific dissector.
29 | * If an address type is added here, it must be "registered" within address_types.c
30 | * For dissector address types, just use the address_type_dissector_register function
31 | * from address_types.h
32 | *
33 | * AT_NUMERIC - a numeric address type can consist of a uint8_t, uint16_t, uint32_t or uint64_t
34 | * value. If no correct length is provided, to avoid data bleed, a uint8_t is
35 | * assumed. Only representation (aka conversion of value to string) is implemented for this type.
36 | */
37 | typedef enum {
38 | AT_NONE, /**< No address / unset. */
39 | AT_ETHER, /**< MAC address (Ethernet, 802.x, FDDI); 6 bytes. */
40 | AT_IPv4, /**< IPv4 address; 4 bytes. */
41 | AT_IPv6, /**< IPv6 address; 16 bytes. */
42 | AT_IPX, /**< IPX network + node address; 10 bytes. */
43 | AT_FC, /**< Fibre Channel address; 3 bytes. */
44 | AT_FCWWN, /**< Fibre Channel World Wide Name; 8 bytes. */
45 | AT_STRINGZ, /**< Null-terminated string address. */
46 | AT_EUI64, /**< IEEE EUI-64 address; 8 bytes. */
47 | AT_IB, /**< InfiniBand GID (16 bytes) or LID (2 bytes). */
48 | AT_AX25, /**< AX.25 amateur radio address; 7 bytes. */
49 | AT_VINES, /**< Banyan VINES address; 6 bytes. */
50 | AT_NUMERIC, /**< Numeric scalar address (uint8/16/32/64); display-only. */
51 | AT_MCTP, /**< Management Component Transport Protocol address. */
52 | AT_ILNP_NID, /**< ILNP Node Identifier (NID); 8 bytes. */
53 | AT_ILNP_L64, /**< ILNP 64-bit Locator (L64); 8 bytes. */
54 | AT_ILNP_ILV, /**< ILNP Identifier-Locator Vector (ILV); 16 bytes. */
55 | AT_END_OF_LIST /**< Sentinel — must remain the last enumerator. */
56 | } address_type;
57 |
58 |
59 | /**
60 | * @brief Holds a network or link-layer address of any supported type.
61 | */
62 | typedef struct _address {
63 | int type; /**< Address family; one of the #address_type values. */
64 | int len; /**< Length of the address data pointed to by @c data, in bytes. */
65 | const void *data; /**< Pointer to the raw address bytes; not owned by this struct. */
66 |
67 | /* private */
68 | void *priv; /**< Reserved for internal address-type implementation use; must not be accessed by callers. */
69 | } address;
70 |
71 |
72 | /** @brief Static initializer for an #address with explicit type, length, and data pointer. */
73 | #define ADDRESS_INIT(type, len, data){type, len, data, ((void*)0)} {type, len, data, NULL((void*)0)}
74 |
75 | /** @brief Static initializer for an empty #address (@c AT_NONE, zero length, NULL data). */
76 | #define ADDRESS_INIT_NONE{AT_NONE, 0, ((void*)0), ((void*)0)} ADDRESS_INIT(AT_NONE, 0, NULL){AT_NONE, 0, ((void*)0), ((void*)0)}
77 |
78 | /** @brief Clear an address structure by setting its fields to default values.
79 |
80 | @param addr Pointer to the address structure to be cleared.
81 | */
82 | static inline void
83 | clear_address(address *addr)
84 | {
85 | addr->type = AT_NONE;
86 | addr->len = 0;
87 | addr->data = NULL((void*)0);
88 | addr->priv = NULL((void*)0);
89 | }
90 |
91 | /** Initialize an address with the given values.
92 | *
93 | * @param addr [in,out] The address to initialize.
94 | * @param addr_type [in] Address type.
95 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for
96 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
97 | * @param addr_data [in] Pointer to the address data.
98 | */
99 | static inline void
100 | set_address(address *addr, int addr_type, int addr_len, const void *addr_data) {
101 | if (addr_len == 0) {
102 | /* Zero length must mean no data */
103 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 103, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0);
104 | } else {
105 | /* Must not be AT_NONE - AT_NONE must have no data */
106 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 106, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0);
107 | /* Make sure we *do* have data */
108 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 108, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0);
109 | }
110 | addr->type = addr_type;
111 | addr->len = addr_len;
112 | addr->data = addr_data;
113 | addr->priv = NULL((void*)0);
114 | }
115 |
116 | /**
117 | * @brief Sets an address with the values from a provided IPv4 address.
118 | *
119 | * This function initializes an address structure with the provided IPv4 address and its length.
120 | *
121 | * @param addr Pointer to the address structure to be initialized.
122 | * @param ipv4 Pointer to the IPv4 address and mask information.
123 | */
124 | static inline void
125 | set_address_ipv4(address *addr, const ipv4_addr_and_mask *ipv4) {
126 | addr->type = AT_IPv4;
127 | addr->len = 4;
128 | uint32_t val = g_htonl(ipv4->addr)(((((guint32) ( (((guint32) (ipv4->addr) & (guint32) 0x000000ffU ) << 24) | (((guint32) (ipv4->addr) & (guint32) 0x0000ff00U ) << 8) | (((guint32) (ipv4->addr) & (guint32) 0x00ff0000U ) >> 8) | (((guint32) (ipv4->addr) & (guint32) 0xff000000U ) >> 24))))));
129 | addr->priv = g_memdup2(&val, sizeof(val));
130 | addr->data = addr->priv;
131 | }
132 |
133 | /**
134 | * @brief Sets an address with the values from a provided IPv6 address.
135 | *
136 | * This function initializes an address structure with the provided IPv6 address and its length.
137 | *
138 | * @param addr Pointer to the address structure to be initialized.
139 | * @param ipv6 Pointer to the IPv6 address and prefix information.
140 | */
141 | static inline void
142 | set_address_ipv6(address *addr, const ipv6_addr_and_prefix *ipv6) {
143 | set_address(addr, AT_IPv6, sizeof(ws_in6_addr), &ipv6->addr);
144 | }
145 |
146 | /**
147 | * @brief Initialize an address from TVB data.
148 | *
149 | * Same as set_address but it takes a TVB and an offset. This is preferred
150 | * over passing the return value of tvb_get_ptr() to set_address().
151 | *
152 | * This calls tvb_get_ptr() (including throwing any exceptions) before
153 | * modifying the address.
154 | *
155 | * @param addr [in,out] The address to initialize.
156 | * @param addr_type [in] Address type.
157 | * @param tvb [in] Pointer to the TVB.
158 | * @param offset [in] Offset within the TVB.
159 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for
160 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
161 | */
162 | static inline void
163 | set_address_tvb(address *addr, int addr_type, unsigned addr_len, tvbuff_t *tvb, unsigned offset) {
164 | const void *p;
165 |
166 | if (addr_len != 0) {
167 | /* Must not be AT_NONE - AT_NONE must have no data */
168 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 168, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0);
169 | p = tvb_get_ptr(tvb, offset, addr_len);
170 | } else
171 | p = NULL((void*)0);
172 | set_address(addr, addr_type, addr_len, p);
173 | }
174 |
175 | /**
176 | * @brief Initialize an address with the given values, allocating a new buffer
177 | * for the address data using wmem-scoped memory.
178 | *
179 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
180 | * @param addr [in,out] The address to initialize.
181 | * @param addr_type [in] Address type.
182 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for
183 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
184 | * @param addr_data [in] Pointer to the address data.
185 | */
186 | static inline void
187 | alloc_address_wmem(wmem_allocator_t *scope, address *addr,
188 | int addr_type, int addr_len, const void *addr_data) {
189 | ws_assert(addr)do { if ((1) && !(addr)) ws_log_fatal_full("", LOG_LEVEL_ERROR , "epan/address.h", 189, __func__, "assertion failed: %s", "addr" ); } while (0);
5 | ← | Assuming 'addr' is non-null | →
6 | ← | Taking false branch | →
7 | ← | Loop condition is false. Exiting loop | →
190 | clear_address(addr);
191 | addr->type = addr_type;
192 | if (addr_len == 0) {
8 | ← | Assuming 'addr_len' is equal to 0 | →
193 | /* Zero length must mean no data */
194 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 194, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0);
9 | ← | Taking true branch | →
10 | ← | Assuming 'addr_data' is equal to null | →
11 | ← | Taking false branch | →
12 | ← | Loop condition is false. Exiting loop | →
195 | /* Nothing to copy */
196 | return;
197 | }
198 | /* Must not be AT_NONE - AT_NONE must have no data */
199 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 199, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0);
200 | /* Make sure we *do* have data to copy */
201 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 201, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0);
202 | addr->data = addr->priv = wmem_memdup(scope, addr_data, addr_len);
203 | addr->len = addr_len;
204 | }
205 |
206 | /**
207 | * @brief Allocate an address from TVB data.
208 | *
209 | * Same as alloc_address_wmem but it takes a TVB and an offset.
210 | *
211 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
212 | * @param addr [in,out] The address to initialize.
213 | * @param addr_type [in] Address type.
214 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for
215 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6.
216 | * @param tvb [in] Pointer to the TVB.
217 | * @param offset [in] Offset within the TVB.
218 | */
219 | static inline void
220 | alloc_address_tvb(wmem_allocator_t *scope, address *addr,
221 | int addr_type, int addr_len, tvbuff_t *tvb, int offset) {
222 | const void *p;
223 |
224 | p = tvb_get_ptr(tvb, offset, addr_len);
225 | alloc_address_wmem(scope, addr, addr_type, addr_len, p);
226 | }
227 |
228 | /**
229 | * @brief Compare two addresses.
230 | *
231 | * @param addr1 [in] The first address to compare.
232 | * @param addr2 [in] The second address to compare.
233 | * @return 0 if the addresses are equal,
234 | * A positive number if addr1 > addr2 in some nondefined metric,
235 | * A negative number if addr1 < addr2 in some nondefined metric.
236 | */
237 | static inline int
238 | cmp_address(const address *addr1, const address *addr2) {
239 | if (addr1->type > addr2->type) return 1;
240 | if (addr1->type < addr2->type) return -1;
241 | if (addr1->len > addr2->len) return 1;
242 | if (addr1->len < addr2->len) return -1;
243 | if (addr1->len == 0) {
244 | /*
245 | * memcmp(NULL, NULL, 0) is *not* guaranteed to work, so
246 | * if both addresses are zero-length, don't compare them
247 | * (there's nothing to compare, so they're equal).
248 | */
249 | return 0;
250 | }
251 | return memcmp(addr1->data, addr2->data, addr1->len);
252 | }
253 |
254 | /**
255 | * @brief Check two addresses for equality.
256 | *
257 | * Given two addresses, return "true" if they're equal, "false" otherwise.
258 | * Addresses are equal only if they have the same type and length; if the
259 | * length is zero, they are then equal, otherwise the data must be the
260 | * same.
261 | *
262 | * @param addr1 [in] The first address to compare.
263 | * @param addr2 [in] The second address to compare.
264 | * @return true if the addresses are equal, false otherwise.
265 | */
266 | static inline bool_Bool
267 | addresses_equal(const address *addr1, const address *addr2) {
268 | /*
269 | * memcmp(NULL, NULL, 0) is *not* guaranteed to work, so
270 | * if both addresses are zero-length, don't compare them
271 | * (there's nothing to compare, so they're equal).
272 | */
273 | if (addr1->type == addr2->type &&
274 | addr1->len == addr2->len &&
275 | (addr1->len == 0 ||
276 | memcmp(addr1->data, addr2->data, addr1->len) == 0))
277 | return true1;
278 | return false0;
279 | }
280 |
281 | /**
282 | * @brief Check the data of two addresses for equality.
283 | *
284 | * Given two addresses, return "true" if they have the same length and,
285 | * their data is equal, "false" otherwise.
286 | * The address types are ignored. This can be used to compare custom
287 | * address types defined with address_type_dissector_register.
288 | *
289 | * @param addr1 [in] The first address to compare.
290 | * @param addr2 [in] The second address to compare.
291 | * @return true if the addresses are equal, false otherwise.
292 | */
293 | static inline bool_Bool
294 | addresses_data_equal(const address *addr1, const address *addr2) {
295 | if ( addr1->len == addr2->len
296 | && memcmp(addr1->data, addr2->data, addr1->len) == 0
297 | ) return true1;
298 | return false0;
299 | }
300 |
301 | /**
302 | * @brief Perform a shallow copy of the address (both addresses point to the same
303 | * memory location).
304 | *
305 | * @param to [in,out] The destination address.
306 | * @param from [in] The source address.
307 | *
308 | * \warning Make sure 'from' memory stays valid for the lifetime of this object.
309 | * Also it's strongly recommended to use this function instead of copy-assign.
310 | */
311 | static inline void
312 | copy_address_shallow(address *to, const address *from) {
313 | set_address(to, from->type, from->len, from->data);
314 | }
315 |
316 | /**
317 | * @brief Copy an address, allocating a new buffer for the address data
318 | * using wmem-scoped memory.
319 | *
320 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
321 | * @param to [in,out] The destination address.
322 | * @param from [in] The source address.
323 | */
324 | static inline void
325 | copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) {
326 | alloc_address_wmem(scope, to, from->type, from->len, from->data);
4 | ← | Calling 'alloc_address_wmem' | →
13 | ← | Returning from 'alloc_address_wmem' | →
327 | }
328 |
329 | /**
330 | * @brief Copy an address, allocating a new buffer for the address data.
331 | *
332 | * @param to [in,out] The destination address.
333 | * @param from [in] The source address.
334 | */
335 | static inline void
336 | copy_address(address *to, const address *from) {
337 | copy_address_wmem(NULL((void*)0), to, from);
3 | ← | Calling 'copy_address_wmem' | →
14 | ← | Returning from 'copy_address_wmem' | →
338 | }
339 |
340 | /**
341 | * @brief Free an address allocated with wmem-scoped memory.
342 | *
343 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool
344 | * @param addr [in,out] The address whose data to free.
345 | */
346 | static inline void
347 | free_address_wmem(wmem_allocator_t *scope, address *addr) {
348 | /* Because many dissectors set 'type = AT_NONE' to mean clear we check for that */
349 | if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL((void*)0)) {
350 | /* Make sure API use is correct */
351 | /* if priv is not null then data == priv */
352 | ws_assert(addr->data == addr->priv)do { if ((1) && !(addr->data == addr->priv)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 352, __func__, "assertion failed: %s" , "addr->data == addr->priv"); } while (0);
353 | wmem_free(scope, addr->priv);
354 | }
355 | clear_address(addr);
356 | }
357 |
358 | /**
359 | * @brief Free an address.
360 | *
361 | * @param addr [in,out] The address whose data to free.
362 | */
363 | static inline void
364 | free_address(address *addr) {
365 | free_address_wmem(NULL((void*)0), addr);
366 | }
367 |
368 | /**
369 | * @brief Hash an address into a hash value (which must already have been set).
370 | *
371 | * @param hash_val The existing hash value.
372 | * @param addr The address to add.
373 | * @return The new hash value.
374 | */
375 | static inline unsigned
376 | add_address_to_hash(unsigned hash_val, const address *addr) {
377 | const uint8_t *hash_data = (const uint8_t *)(addr)->data;
378 | int idx;
379 |
380 | for (idx = 0; idx < (addr)->len; idx++) {
381 | hash_val += hash_data[idx];
382 | hash_val += ( hash_val << 10 );
383 | hash_val ^= ( hash_val >> 6 );
384 | }
385 | return hash_val;
386 | }
387 |
388 | /**
389 | * @brief Hash an address into a hash value (which must already have been set).
390 | * 64-bit version of add_address_to_hash().
391 | *
392 | * @param hash_val The existing hash value.
393 | * @param addr The address to add.
394 | * @return The new hash value.
395 | */
396 | static inline uint64_t
397 | add_address_to_hash64(uint64_t hash_val, const address *addr) {
398 | const uint8_t *hash_data = (const uint8_t *)(addr)->data;
399 | int idx;
400 |
401 | for (idx = 0; idx < (addr)->len; idx++) {
402 | hash_val += hash_data[idx];
403 | hash_val += ( hash_val << 10 );
404 | hash_val ^= ( hash_val >> 6 );
405 | }
406 | return hash_val;
407 | }
408 |
409 | /**
410 | * @brief Converts an address to a byte array.
411 | *
412 | * This function takes an address structure and converts it into a byte array.
413 | * The output buffer must be provided with sufficient space to hold the address data.
414 | *
415 | * @param addr Pointer to the address structure to convert.
416 | * @param buf Buffer to store the converted byte array.
417 | * @param buf_len Length of the output buffer.
418 | * @return Number of bytes copied to the buffer, or 0 if an error occurred.
419 | */
420 | WS_DLL_PUBLIC__attribute__ ((visibility ("default"))) extern unsigned address_to_bytes(const address *addr, uint8_t *buf, unsigned buf_len);
421 |
422 | /**
423 | * @brief Transport-layer port number types recognized by Wireshark.
424 | */
425 | typedef enum {
426 | PT_NONE, /**< No port number applicable */
427 | PT_SCTP, /**< Stream Control Transmission Protocol (SCTP) port */
428 | PT_TCP, /**< Transmission Control Protocol (TCP) port */
429 | PT_UDP, /**< User Datagram Protocol (UDP) port */
430 | PT_DCCP, /**< Datagram Congestion Control Protocol (DCCP) port */
431 | PT_IPX, /**< IPX socket number */
432 | PT_DDP, /**< AppleTalk Datagram Delivery Protocol (DDP) connection */
433 | PT_IDP, /**< XNS Internet Datagram Protocol (IDP) socket number */
434 | PT_USB, /**< USB endpoint number; 0xffff denotes the host */
435 | PT_I2C, /**< I2C bus endpoint */
436 | PT_IBQP, /**< InfiniBand Queue Pair (QP) number */
437 | PT_BLUETOOTH, /**< Bluetooth endpoint */
438 | PT_IWARP_MPA, /**< iWARP Marker PDU Aligned (MPA) framing endpoint */
439 | PT_MCTP /**< Management Component Transport Protocol (MCTP) endpoint */
440 | } port_type;
441 |
442 | #ifdef __cplusplus
443 | }
444 | #endif /* __cplusplus */
445 |
446 | /*
447 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
448 | *
449 | * Local variables:
450 | * c-basic-offset: 4
451 | * tab-width: 8
452 | * indent-tabs-mode: nil
453 | * End:
454 | *
455 | * vi: set shiftwidth=4 tabstop=8 expandtab:
456 | * :indentSize=4:tabSize=8:noTabs=true:
457 | */