### Bug Summary

File: | builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c
Warning: | line 364, 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-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/lua5.4 -isystem /builds/wireshark/wireshark/build/epan/wslua -isystem /builds/wireshark/wireshark/epan/wslua -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-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../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=gnu11 -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 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2026-04-20-100401-3641-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); }
1 | Memory is allocated | →
2 | ← | Calling 'copy_address' | →
15 | ← | Returning from 'copy_address' | →
364 | lua_settable(L,-3);
16 | ← | Potential leak of memory pointed to by 'a'
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_flags");
378 | lua_pushinteger(L,(lua_Integer)v->th_flags);
379 | lua_settable(L,-3);
380 | lua_pushstring(L,"th_have_seglen");
381 | lua_pushboolean(L,(int)v->th_have_seglen);
382 | lua_settable(L,-3);
383 | lua_pushstring(L,"th_hlen");
384 | lua_pushinteger(L,(lua_Integer)v->th_hlen);
385 | lua_settable(L,-3);
386 | lua_pushstring(L,"th_rawack");
387 | lua_pushinteger(L,(lua_Integer)v->th_rawack);
388 | lua_settable(L,-3);
389 | lua_pushstring(L,"th_rawseq");
390 | lua_pushinteger(L,(lua_Integer)v->th_rawseq);
391 | lua_settable(L,-3);
392 | lua_pushstring(L,"th_seglen");
393 | lua_pushinteger(L,(lua_Integer)v->th_seglen);
394 | lua_settable(L,-3);
395 | lua_pushstring(L,"th_seq");
396 | lua_pushinteger(L,(lua_Integer)v->th_seq);
397 | lua_settable(L,-3);
398 | lua_pushstring(L,"th_sport");
399 | lua_pushinteger(L,(lua_Integer)v->th_sport);
400 | lua_settable(L,-3);
401 | lua_pushstring(L,"th_stream");
402 | lua_pushinteger(L,(lua_Integer)v->th_stream);
403 | lua_settable(L,-3);
404 | lua_pushstring(L,"th_use_ace");
405 | lua_pushboolean(L,(int)v->th_use_ace);
406 | lua_settable(L,-3);
407 | lua_pushstring(L,"th_win");
408 | lua_pushinteger(L,(lua_Integer)v->th_win);
409 | lua_settable(L,-3);
410 | }
411 |
412 | #include "../dissectors/packet-ieee80211.h"
413 | static void wslua_wlan_to_table(lua_State* L, const void* p) {
414 | const wlan_hdr_t* v;
415 |
416 | v = (const wlan_hdr_t*)p;
417 | lua_newtable(L)lua_createtable(L, 0, 0);
418 |
419 | lua_pushstring(L,"bssid");
420 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->bssid)); pushAddress(L,a); }
421 | lua_settable(L,-3);
422 | lua_pushstring(L,"dst");
423 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->dst)); pushAddress(L,a); }
424 | lua_settable(L,-3);
425 | lua_pushstring(L,"src");
426 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->src)); pushAddress(L,a); }
427 | lua_settable(L,-3);
428 | lua_pushstring(L,"type");
429 | lua_pushinteger(L,(lua_Integer)v->type);
430 | lua_settable(L,-3);
431 | }
432 |
433 | static tappable_t tappables[] = {
434 | {"actrace", wslua_actrace_to_table },
435 | {"ansi_a", wslua_ansi_a_to_table },
436 | {"ansi_map", wslua_ansi_map_to_table },
437 | {"bacapp", wslua_bacapp_to_table },
438 | {"eth", wslua_eth_to_table },
439 | {"h225", wslua_h225_to_table },
440 | {"http", wslua_http_to_table },
441 | {"ip", wslua_ip_to_table },
442 | {"ldap", wslua_ldap_to_table },
443 | {"smb", wslua_smb_to_table },
444 | {"smb2", wslua_smb2_to_table },
445 | {"tcp", wslua_tcp_to_table },
446 | {"udp", wslua_udp_to_table },
447 | {"wlan", wslua_wlan_to_table },
448 | {"frame",NULL((void*)0)},
449 | {NULL((void*)0),NULL((void*)0)}
450 | };
451 |
452 | int wslua_set_tap_enums(lua_State* L) {
453 |
454 | /*
455 | * h225_cs_type
456 | */
457 | lua_newtable(L)lua_createtable(L, 0, 0);
458 | lua_pushinteger(L,(lua_Integer)H225_SETUP);
459 | lua_setglobal(L,"H225_SETUP");
460 | lua_pushinteger(L,(lua_Integer)H225_SETUP);
461 | lua_pushstring(L,"H225_SETUP");
462 | lua_settable(L,-3);
463 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING);
464 | lua_setglobal(L,"H225_CALL_PROCEDING");
465 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING);
466 | lua_pushstring(L,"H225_CALL_PROCEDING");
467 | lua_settable(L,-3);
468 | lua_pushinteger(L,(lua_Integer)H225_CONNECT);
469 | lua_setglobal(L,"H225_CONNECT");
470 | lua_pushinteger(L,(lua_Integer)H225_CONNECT);
471 | lua_pushstring(L,"H225_CONNECT");
472 | lua_settable(L,-3);
473 | lua_pushinteger(L,(lua_Integer)H225_ALERTING);
474 | lua_setglobal(L,"H225_ALERTING");
475 | lua_pushinteger(L,(lua_Integer)H225_ALERTING);
476 | lua_pushstring(L,"H225_ALERTING");
477 | lua_settable(L,-3);
478 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION);
479 | lua_setglobal(L,"H225_INFORMATION");
480 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION);
481 | lua_pushstring(L,"H225_INFORMATION");
482 | lua_settable(L,-3);
483 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET);
484 | lua_setglobal(L,"H225_RELEASE_COMPLET");
485 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET);
486 | lua_pushstring(L,"H225_RELEASE_COMPLET");
487 | lua_settable(L,-3);
488 | lua_pushinteger(L,(lua_Integer)H225_FACILITY);
489 | lua_setglobal(L,"H225_FACILITY");
490 | lua_pushinteger(L,(lua_Integer)H225_FACILITY);
491 | lua_pushstring(L,"H225_FACILITY");
492 | lua_settable(L,-3);
493 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS);
494 | lua_setglobal(L,"H225_PROGRESS");
495 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS);
496 | lua_pushstring(L,"H225_PROGRESS");
497 | lua_settable(L,-3);
498 | lua_pushinteger(L,(lua_Integer)H225_EMPTY);
499 | lua_setglobal(L,"H225_EMPTY");
500 | lua_pushinteger(L,(lua_Integer)H225_EMPTY);
501 | lua_pushstring(L,"H225_EMPTY");
502 | lua_settable(L,-3);
503 | lua_pushinteger(L,(lua_Integer)H225_STATUS);
504 | lua_setglobal(L,"H225_STATUS");
505 | lua_pushinteger(L,(lua_Integer)H225_STATUS);
506 | lua_pushstring(L,"H225_STATUS");
507 | lua_settable(L,-3);
508 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY);
509 | lua_setglobal(L,"H225_STATUS_INQUIRY");
510 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY);
511 | lua_pushstring(L,"H225_STATUS_INQUIRY");
512 | lua_settable(L,-3);
513 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK);
514 | lua_setglobal(L,"H225_SETUP_ACK");
515 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK);
516 | lua_pushstring(L,"H225_SETUP_ACK");
517 | lua_settable(L,-3);
518 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY);
519 | lua_setglobal(L,"H225_NOTIFY");
520 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY);
521 | lua_pushstring(L,"H225_NOTIFY");
522 | lua_settable(L,-3);
523 | lua_pushinteger(L,(lua_Integer)H225_OTHER);
524 | lua_setglobal(L,"H225_OTHER");
525 | lua_pushinteger(L,(lua_Integer)H225_OTHER);
526 | lua_pushstring(L,"H225_OTHER");
527 | lua_settable(L,-3);
528 | lua_setglobal(L,"h225_cs_type");
529 |
530 | /*
531 | * h225_msg_type
532 | */
533 | lua_newtable(L)lua_createtable(L, 0, 0);
534 | lua_pushinteger(L,(lua_Integer)H225_RAS);
535 | lua_setglobal(L,"H225_RAS");
536 | lua_pushinteger(L,(lua_Integer)H225_RAS);
537 | lua_pushstring(L,"H225_RAS");
538 | lua_settable(L,-3);
539 | lua_pushinteger(L,(lua_Integer)H225_CS);
540 | lua_setglobal(L,"H225_CS");
541 | lua_pushinteger(L,(lua_Integer)H225_CS);
542 | lua_pushstring(L,"H225_CS");
543 | lua_settable(L,-3);
544 | lua_pushinteger(L,(lua_Integer)H225_OTHERS);
545 | lua_setglobal(L,"H225_OTHERS");
546 | lua_pushinteger(L,(lua_Integer)H225_OTHERS);
547 | lua_pushstring(L,"H225_OTHERS");
548 | lua_settable(L,-3);
549 | lua_setglobal(L,"h225_msg_type");
550 | return 0;
551 | }
552 |
553 |
554 | tap_extractor_t wslua_get_tap_extractor(const gchar* name) {
555 | tappable_t* t;
556 | for(t = tappables; t->name; t++ ) {
557 | if (g_str_equal(t->name,name)(strcmp ((const char *) (t->name), (const char *) (name)) == 0)) return t->extractor;
558 | }
559 |
560 | return NULL((void*)0);
561 | }

←

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