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

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-05-09-100339-3641-1 -x c /builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c

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