File: | builds/wireshark/wireshark/build/epan/wslua/taps_wslua.c |
Warning: | line 262, column 2 Potential leak of memory pointed to by 'a' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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,"ip_dst"); | |||
360 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_dst)); pushAddress(L,a); } | |||
361 | lua_settable(L,-3); | |||
362 | lua_pushstring(L,"ip_src"); | |||
363 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_src)); pushAddress(L,a); } | |||
364 | lua_settable(L,-3); | |||
365 | lua_pushstring(L,"num_sack_ranges"); | |||
366 | lua_pushinteger(L,(lua_Integer)v->num_sack_ranges); | |||
367 | lua_settable(L,-3); | |||
368 | lua_pushstring(L,"th_ack"); | |||
369 | lua_pushinteger(L,(lua_Integer)v->th_ack); | |||
370 | lua_settable(L,-3); | |||
371 | lua_pushstring(L,"th_dport"); | |||
372 | lua_pushinteger(L,(lua_Integer)v->th_dport); | |||
373 | lua_settable(L,-3); | |||
374 | lua_pushstring(L,"th_flags"); | |||
375 | lua_pushinteger(L,(lua_Integer)v->th_flags); | |||
376 | lua_settable(L,-3); | |||
377 | lua_pushstring(L,"th_have_seglen"); | |||
378 | lua_pushboolean(L,(int)v->th_have_seglen); | |||
379 | lua_settable(L,-3); | |||
380 | lua_pushstring(L,"th_hlen"); | |||
381 | lua_pushinteger(L,(lua_Integer)v->th_hlen); | |||
382 | lua_settable(L,-3); | |||
383 | lua_pushstring(L,"th_rawack"); | |||
384 | lua_pushinteger(L,(lua_Integer)v->th_rawack); | |||
385 | lua_settable(L,-3); | |||
386 | lua_pushstring(L,"th_rawseq"); | |||
387 | lua_pushinteger(L,(lua_Integer)v->th_rawseq); | |||
388 | lua_settable(L,-3); | |||
389 | lua_pushstring(L,"th_seglen"); | |||
390 | lua_pushinteger(L,(lua_Integer)v->th_seglen); | |||
391 | lua_settable(L,-3); | |||
392 | lua_pushstring(L,"th_seq"); | |||
393 | lua_pushinteger(L,(lua_Integer)v->th_seq); | |||
394 | lua_settable(L,-3); | |||
395 | lua_pushstring(L,"th_sport"); | |||
396 | lua_pushinteger(L,(lua_Integer)v->th_sport); | |||
397 | lua_settable(L,-3); | |||
398 | lua_pushstring(L,"th_stream"); | |||
399 | lua_pushinteger(L,(lua_Integer)v->th_stream); | |||
400 | lua_settable(L,-3); | |||
401 | lua_pushstring(L,"th_use_ace"); | |||
402 | lua_pushboolean(L,(int)v->th_use_ace); | |||
403 | lua_settable(L,-3); | |||
404 | lua_pushstring(L,"th_win"); | |||
405 | lua_pushinteger(L,(lua_Integer)v->th_win); | |||
406 | lua_settable(L,-3); | |||
407 | } | |||
408 | ||||
409 | #include "../dissectors/packet-ieee80211.h" | |||
410 | static void wslua_wlan_to_table(lua_State* L, const void* p) { | |||
411 | const wlan_hdr_t* v; | |||
412 | ||||
413 | v = (const wlan_hdr_t*)p; | |||
414 | lua_newtable(L)lua_createtable(L, 0, 0); | |||
415 | ||||
416 | lua_pushstring(L,"bssid"); | |||
417 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->bssid)); pushAddress(L,a); } | |||
418 | lua_settable(L,-3); | |||
419 | lua_pushstring(L,"dst"); | |||
420 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->dst)); pushAddress(L,a); } | |||
421 | lua_settable(L,-3); | |||
422 | lua_pushstring(L,"src"); | |||
423 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->src)); pushAddress(L,a); } | |||
424 | lua_settable(L,-3); | |||
425 | lua_pushstring(L,"type"); | |||
426 | lua_pushinteger(L,(lua_Integer)v->type); | |||
427 | lua_settable(L,-3); | |||
428 | } | |||
429 | ||||
430 | static tappable_t tappables[] = { | |||
431 | {"actrace", wslua_actrace_to_table }, | |||
432 | {"ansi_a", wslua_ansi_a_to_table }, | |||
433 | {"ansi_map", wslua_ansi_map_to_table }, | |||
434 | {"bacapp", wslua_bacapp_to_table }, | |||
435 | {"eth", wslua_eth_to_table }, | |||
436 | {"h225", wslua_h225_to_table }, | |||
437 | {"http", wslua_http_to_table }, | |||
438 | {"ip", wslua_ip_to_table }, | |||
439 | {"ldap", wslua_ldap_to_table }, | |||
440 | {"smb", wslua_smb_to_table }, | |||
441 | {"smb2", wslua_smb2_to_table }, | |||
442 | {"tcp", wslua_tcp_to_table }, | |||
443 | {"udp", wslua_udp_to_table }, | |||
444 | {"wlan", wslua_wlan_to_table }, | |||
445 | {"frame",NULL((void*)0)}, | |||
446 | {NULL((void*)0),NULL((void*)0)} | |||
447 | }; | |||
448 | ||||
449 | int wslua_set_tap_enums(lua_State* L) { | |||
450 | ||||
451 | /* | |||
452 | * h225_cs_type | |||
453 | */ | |||
454 | lua_newtable(L)lua_createtable(L, 0, 0); | |||
455 | lua_pushinteger(L,(lua_Integer)H225_SETUP); | |||
456 | lua_setglobal(L,"H225_SETUP"); | |||
457 | lua_pushinteger(L,(lua_Integer)H225_SETUP); | |||
458 | lua_pushstring(L,"H225_SETUP"); | |||
459 | lua_settable(L,-3); | |||
460 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING); | |||
461 | lua_setglobal(L,"H225_CALL_PROCEDING"); | |||
462 | lua_pushinteger(L,(lua_Integer)H225_CALL_PROCEDING); | |||
463 | lua_pushstring(L,"H225_CALL_PROCEDING"); | |||
464 | lua_settable(L,-3); | |||
465 | lua_pushinteger(L,(lua_Integer)H225_CONNECT); | |||
466 | lua_setglobal(L,"H225_CONNECT"); | |||
467 | lua_pushinteger(L,(lua_Integer)H225_CONNECT); | |||
468 | lua_pushstring(L,"H225_CONNECT"); | |||
469 | lua_settable(L,-3); | |||
470 | lua_pushinteger(L,(lua_Integer)H225_ALERTING); | |||
471 | lua_setglobal(L,"H225_ALERTING"); | |||
472 | lua_pushinteger(L,(lua_Integer)H225_ALERTING); | |||
473 | lua_pushstring(L,"H225_ALERTING"); | |||
474 | lua_settable(L,-3); | |||
475 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION); | |||
476 | lua_setglobal(L,"H225_INFORMATION"); | |||
477 | lua_pushinteger(L,(lua_Integer)H225_INFORMATION); | |||
478 | lua_pushstring(L,"H225_INFORMATION"); | |||
479 | lua_settable(L,-3); | |||
480 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET); | |||
481 | lua_setglobal(L,"H225_RELEASE_COMPLET"); | |||
482 | lua_pushinteger(L,(lua_Integer)H225_RELEASE_COMPLET); | |||
483 | lua_pushstring(L,"H225_RELEASE_COMPLET"); | |||
484 | lua_settable(L,-3); | |||
485 | lua_pushinteger(L,(lua_Integer)H225_FACILITY); | |||
486 | lua_setglobal(L,"H225_FACILITY"); | |||
487 | lua_pushinteger(L,(lua_Integer)H225_FACILITY); | |||
488 | lua_pushstring(L,"H225_FACILITY"); | |||
489 | lua_settable(L,-3); | |||
490 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS); | |||
491 | lua_setglobal(L,"H225_PROGRESS"); | |||
492 | lua_pushinteger(L,(lua_Integer)H225_PROGRESS); | |||
493 | lua_pushstring(L,"H225_PROGRESS"); | |||
494 | lua_settable(L,-3); | |||
495 | lua_pushinteger(L,(lua_Integer)H225_EMPTY); | |||
496 | lua_setglobal(L,"H225_EMPTY"); | |||
497 | lua_pushinteger(L,(lua_Integer)H225_EMPTY); | |||
498 | lua_pushstring(L,"H225_EMPTY"); | |||
499 | lua_settable(L,-3); | |||
500 | lua_pushinteger(L,(lua_Integer)H225_STATUS); | |||
501 | lua_setglobal(L,"H225_STATUS"); | |||
502 | lua_pushinteger(L,(lua_Integer)H225_STATUS); | |||
503 | lua_pushstring(L,"H225_STATUS"); | |||
504 | lua_settable(L,-3); | |||
505 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY); | |||
506 | lua_setglobal(L,"H225_STATUS_INQUIRY"); | |||
507 | lua_pushinteger(L,(lua_Integer)H225_STATUS_INQUIRY); | |||
508 | lua_pushstring(L,"H225_STATUS_INQUIRY"); | |||
509 | lua_settable(L,-3); | |||
510 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK); | |||
511 | lua_setglobal(L,"H225_SETUP_ACK"); | |||
512 | lua_pushinteger(L,(lua_Integer)H225_SETUP_ACK); | |||
513 | lua_pushstring(L,"H225_SETUP_ACK"); | |||
514 | lua_settable(L,-3); | |||
515 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY); | |||
516 | lua_setglobal(L,"H225_NOTIFY"); | |||
517 | lua_pushinteger(L,(lua_Integer)H225_NOTIFY); | |||
518 | lua_pushstring(L,"H225_NOTIFY"); | |||
519 | lua_settable(L,-3); | |||
520 | lua_pushinteger(L,(lua_Integer)H225_OTHER); | |||
521 | lua_setglobal(L,"H225_OTHER"); | |||
522 | lua_pushinteger(L,(lua_Integer)H225_OTHER); | |||
523 | lua_pushstring(L,"H225_OTHER"); | |||
524 | lua_settable(L,-3); | |||
525 | lua_setglobal(L,"h225_cs_type"); | |||
526 | ||||
527 | /* | |||
528 | * h225_msg_type | |||
529 | */ | |||
530 | lua_newtable(L)lua_createtable(L, 0, 0); | |||
531 | lua_pushinteger(L,(lua_Integer)H225_RAS); | |||
532 | lua_setglobal(L,"H225_RAS"); | |||
533 | lua_pushinteger(L,(lua_Integer)H225_RAS); | |||
534 | lua_pushstring(L,"H225_RAS"); | |||
535 | lua_settable(L,-3); | |||
536 | lua_pushinteger(L,(lua_Integer)H225_CS); | |||
537 | lua_setglobal(L,"H225_CS"); | |||
538 | lua_pushinteger(L,(lua_Integer)H225_CS); | |||
539 | lua_pushstring(L,"H225_CS"); | |||
540 | lua_settable(L,-3); | |||
541 | lua_pushinteger(L,(lua_Integer)H225_OTHERS); | |||
542 | lua_setglobal(L,"H225_OTHERS"); | |||
543 | lua_pushinteger(L,(lua_Integer)H225_OTHERS); | |||
544 | lua_pushstring(L,"H225_OTHERS"); | |||
545 | lua_settable(L,-3); | |||
546 | lua_setglobal(L,"h225_msg_type"); | |||
547 | return 0; | |||
548 | } | |||
549 | ||||
550 | ||||
551 | tap_extractor_t wslua_get_tap_extractor(const gchar* name) { | |||
552 | tappable_t* t; | |||
553 | for(t = tappables; t->name; t++ ) { | |||
554 | if (g_str_equal(t->name,name)(strcmp ((const char *) (t->name), (const char *) (name)) == 0)) return t->extractor; | |||
555 | } | |||
556 | ||||
557 | return NULL((void*)0); | |||
558 | } |
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 <[email protected]> |
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 | |
53 | AT_END_OF_LIST /* Must be last in list */ |
54 | } address_type; |
55 | |
56 | typedef struct _address { |
57 | int type; /* type of address */ |
58 | int len; /* length of address, in bytes */ |
59 | const void *data; /* pointer to address data */ |
60 | |
61 | /* private */ |
62 | void *priv; |
63 | } address; |
64 | |
65 | #define ADDRESS_INIT(type, len, data){type, len, data, ((void*)0)} {type, len, data, NULL((void*)0)} |
66 | #define ADDRESS_INIT_NONE{AT_NONE, 0, ((void*)0), ((void*)0)} ADDRESS_INIT(AT_NONE, 0, NULL){AT_NONE, 0, ((void*)0), ((void*)0)} |
67 | |
68 | static inline void |
69 | clear_address(address *addr) |
70 | { |
71 | addr->type = AT_NONE; |
72 | addr->len = 0; |
73 | addr->data = NULL((void*)0); |
74 | addr->priv = NULL((void*)0); |
75 | } |
76 | |
77 | /** Initialize an address with the given values. |
78 | * |
79 | * @param addr [in,out] The address to initialize. |
80 | * @param addr_type [in] Address type. |
81 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
82 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
83 | * @param addr_data [in] Pointer to the address data. |
84 | */ |
85 | static inline void |
86 | set_address(address *addr, int addr_type, int addr_len, const void *addr_data) { |
87 | if (addr_len == 0) { |
88 | /* Zero length must mean no data */ |
89 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 89, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0); |
90 | } else { |
91 | /* Must not be AT_NONE - AT_NONE must have no data */ |
92 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 92, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
93 | /* Make sure we *do* have data */ |
94 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 94, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0); |
95 | } |
96 | addr->type = addr_type; |
97 | addr->len = addr_len; |
98 | addr->data = addr_data; |
99 | addr->priv = NULL((void*)0); |
100 | } |
101 | |
102 | static inline void |
103 | set_address_ipv4(address *addr, const ipv4_addr_and_mask *ipv4) { |
104 | addr->type = AT_IPv4; |
105 | addr->len = 4; |
106 | 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)))))); |
107 | addr->priv = g_memdup2(&val, sizeof(val)); |
108 | addr->data = addr->priv; |
109 | } |
110 | |
111 | static inline void |
112 | set_address_ipv6(address *addr, const ipv6_addr_and_prefix *ipv6) { |
113 | set_address(addr, AT_IPv6, sizeof(ws_in6_addr), &ipv6->addr); |
114 | } |
115 | |
116 | /** Initialize an address from TVB data. |
117 | * |
118 | * Same as set_address but it takes a TVB and an offset. This is preferred |
119 | * over passing the return value of tvb_get_ptr() to set_address(). |
120 | * |
121 | * This calls tvb_get_ptr() (including throwing any exceptions) before |
122 | * modifying the address. |
123 | * |
124 | * @param addr [in,out] The address to initialize. |
125 | * @param addr_type [in] Address type. |
126 | * @param tvb [in] Pointer to the TVB. |
127 | * @param offset [in] Offset within the TVB. |
128 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
129 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
130 | */ |
131 | static inline void |
132 | set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int offset) { |
133 | const void *p; |
134 | |
135 | if (addr_len != 0) { |
136 | /* Must not be AT_NONE - AT_NONE must have no data */ |
137 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 137, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
138 | p = tvb_get_ptr(tvb, offset, addr_len); |
139 | } else |
140 | p = NULL((void*)0); |
141 | set_address(addr, addr_type, addr_len, p); |
142 | } |
143 | |
144 | /** Initialize an address with the given values, allocating a new buffer |
145 | * for the address data using wmem-scoped memory. |
146 | * |
147 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
148 | * @param addr [in,out] The address to initialize. |
149 | * @param addr_type [in] Address type. |
150 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
151 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
152 | * @param addr_data [in] Pointer to the address data. |
153 | */ |
154 | static inline void |
155 | alloc_address_wmem(wmem_allocator_t *scope, address *addr, |
156 | int addr_type, int addr_len, const void *addr_data) { |
157 | ws_assert(addr)do { if ((1) && !(addr)) ws_log_fatal_full("", LOG_LEVEL_ERROR , "epan/address.h", 157, __func__, "assertion failed: %s", "addr" ); } while (0); |
158 | clear_address(addr); |
159 | addr->type = addr_type; |
160 | if (addr_len == 0) { |
161 | /* Zero length must mean no data */ |
162 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 162, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0); |
163 | /* Nothing to copy */ |
164 | return; |
165 | } |
166 | /* Must not be AT_NONE - AT_NONE must have no data */ |
167 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 167, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
168 | /* Make sure we *do* have data to copy */ |
169 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 169, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0); |
170 | addr->data = addr->priv = wmem_memdup(scope, addr_data, addr_len); |
171 | addr->len = addr_len; |
172 | } |
173 | |
174 | /** Allocate an address from TVB data. |
175 | * |
176 | * Same as alloc_address_wmem but it takes a TVB and an offset. |
177 | * |
178 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
179 | * @param addr [in,out] The address to initialize. |
180 | * @param addr_type [in] Address type. |
181 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
182 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
183 | * @param tvb [in] Pointer to the TVB. |
184 | * @param offset [in] Offset within the TVB. |
185 | */ |
186 | static inline void |
187 | alloc_address_tvb(wmem_allocator_t *scope, address *addr, |
188 | int addr_type, int addr_len, tvbuff_t *tvb, int offset) { |
189 | const void *p; |
190 | |
191 | p = tvb_get_ptr(tvb, offset, addr_len); |
192 | alloc_address_wmem(scope, addr, addr_type, addr_len, p); |
193 | } |
194 | |
195 | /** Compare two addresses. |
196 | * |
197 | * @param addr1 [in] The first address to compare. |
198 | * @param addr2 [in] The second address to compare. |
199 | * @return 0 if the addresses are equal, |
200 | * A positive number if addr1 > addr2 in some nondefined metric, |
201 | * A negative number if addr1 < addr2 in some nondefined metric. |
202 | */ |
203 | static inline int |
204 | cmp_address(const address *addr1, const address *addr2) { |
205 | if (addr1->type > addr2->type) return 1; |
206 | if (addr1->type < addr2->type) return -1; |
207 | if (addr1->len > addr2->len) return 1; |
208 | if (addr1->len < addr2->len) return -1; |
209 | if (addr1->len == 0) { |
210 | /* |
211 | * memcmp(NULL, NULL, 0) is *not* guaranteed to work, so |
212 | * if both addresses are zero-length, don't compare them |
213 | * (there's nothing to compare, so they're equal). |
214 | */ |
215 | return 0; |
216 | } |
217 | return memcmp(addr1->data, addr2->data, addr1->len); |
218 | } |
219 | |
220 | /** Check two addresses for equality. |
221 | * |
222 | * Given two addresses, return "true" if they're equal, "false" otherwise. |
223 | * Addresses are equal only if they have the same type and length; if the |
224 | * length is zero, they are then equal, otherwise the data must be the |
225 | * same. |
226 | * |
227 | * @param addr1 [in] The first address to compare. |
228 | * @param addr2 [in] The second address to compare. |
229 | * @return true if the addresses are equal, false otherwise. |
230 | */ |
231 | static inline bool_Bool |
232 | addresses_equal(const address *addr1, const address *addr2) { |
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 | if (addr1->type == addr2->type && |
239 | addr1->len == addr2->len && |
240 | (addr1->len == 0 || |
241 | memcmp(addr1->data, addr2->data, addr1->len) == 0)) |
242 | return true1; |
243 | return false0; |
244 | } |
245 | |
246 | /** Check the data of two addresses for equality. |
247 | * |
248 | * Given two addresses, return "true" if they have the same length and, |
249 | * their data is equal, "false" otherwise. |
250 | * The address types are ignored. This can be used to compare custom |
251 | * address types defined with address_type_dissector_register. |
252 | * |
253 | * @param addr1 [in] The first address to compare. |
254 | * @param addr2 [in] The second address to compare. |
255 | * @return true if the addresses are equal, false otherwise. |
256 | */ |
257 | static inline bool_Bool |
258 | addresses_data_equal(const address *addr1, const address *addr2) { |
259 | if ( addr1->len == addr2->len |
260 | && memcmp(addr1->data, addr2->data, addr1->len) == 0 |
261 | ) return true1; |
262 | return false0; |
263 | } |
264 | |
265 | /** Perform a shallow copy of the address (both addresses point to the same |
266 | * memory location). |
267 | * |
268 | * @param to [in,out] The destination address. |
269 | * @param from [in] The source address. |
270 | * |
271 | * \warning Make sure 'from' memory stays valid for the lifetime of this object. |
272 | * Also it's strongly recommended to use this function instead of copy-assign. |
273 | */ |
274 | static inline void |
275 | copy_address_shallow(address *to, const address *from) { |
276 | set_address(to, from->type, from->len, from->data); |
277 | } |
278 | |
279 | /** Copy an address, allocating a new buffer for the address data |
280 | * using wmem-scoped memory. |
281 | * |
282 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
283 | * @param to [in,out] The destination address. |
284 | * @param from [in] The source address. |
285 | */ |
286 | static inline void |
287 | copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) { |
288 | alloc_address_wmem(scope, to, from->type, from->len, from->data); |
289 | } |
290 | |
291 | /** Copy an address, allocating a new buffer for the address data. |
292 | * |
293 | * @param to [in,out] The destination address. |
294 | * @param from [in] The source address. |
295 | */ |
296 | static inline void |
297 | copy_address(address *to, const address *from) { |
298 | copy_address_wmem(NULL((void*)0), to, from); |
299 | } |
300 | |
301 | /** Free an address allocated with wmem-scoped memory. |
302 | * |
303 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
304 | * @param addr [in,out] The address whose data to free. |
305 | */ |
306 | static inline void |
307 | free_address_wmem(wmem_allocator_t *scope, address *addr) { |
308 | /* Because many dissectors set 'type = AT_NONE' to mean clear we check for that */ |
309 | if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL((void*)0)) { |
310 | /* Make sure API use is correct */ |
311 | /* if priv is not null then data == priv */ |
312 | ws_assert(addr->data == addr->priv)do { if ((1) && !(addr->data == addr->priv)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 312, __func__, "assertion failed: %s" , "addr->data == addr->priv"); } while (0); |
313 | wmem_free(scope, addr->priv); |
314 | } |
315 | clear_address(addr); |
316 | } |
317 | |
318 | /** Free an address. |
319 | * |
320 | * @param addr [in,out] The address whose data to free. |
321 | */ |
322 | static inline void |
323 | free_address(address *addr) { |
324 | free_address_wmem(NULL((void*)0), addr); |
325 | } |
326 | |
327 | /** Hash an address into a hash value (which must already have been set). |
328 | * |
329 | * @param hash_val The existing hash value. |
330 | * @param addr The address to add. |
331 | * @return The new hash value. |
332 | */ |
333 | static inline unsigned |
334 | add_address_to_hash(unsigned hash_val, const address *addr) { |
335 | const uint8_t *hash_data = (const uint8_t *)(addr)->data; |
336 | int idx; |
337 | |
338 | for (idx = 0; idx < (addr)->len; idx++) { |
339 | hash_val += hash_data[idx]; |
340 | hash_val += ( hash_val << 10 ); |
341 | hash_val ^= ( hash_val >> 6 ); |
342 | } |
343 | return hash_val; |
344 | } |
345 | |
346 | /** Hash an address into a hash value (which must already have been set). |
347 | * 64-bit version of add_address_to_hash(). |
348 | * |
349 | * @param hash_val The existing hash value. |
350 | * @param addr The address to add. |
351 | * @return The new hash value. |
352 | */ |
353 | static inline uint64_t |
354 | add_address_to_hash64(uint64_t hash_val, const address *addr) { |
355 | const uint8_t *hash_data = (const uint8_t *)(addr)->data; |
356 | int idx; |
357 | |
358 | for (idx = 0; idx < (addr)->len; idx++) { |
359 | hash_val += hash_data[idx]; |
360 | hash_val += ( hash_val << 10 ); |
361 | hash_val ^= ( hash_val >> 6 ); |
362 | } |
363 | return hash_val; |
364 | } |
365 | |
366 | WS_DLL_PUBLIC__attribute__ ((visibility ("default"))) extern unsigned address_to_bytes(const address *addr, uint8_t *buf, unsigned buf_len); |
367 | |
368 | /* Types of port numbers Wireshark knows about. */ |
369 | typedef enum { |
370 | PT_NONE, /* no port number */ |
371 | PT_SCTP, /* SCTP */ |
372 | PT_TCP, /* TCP */ |
373 | PT_UDP, /* UDP */ |
374 | PT_DCCP, /* DCCP */ |
375 | PT_IPX, /* IPX sockets */ |
376 | PT_DDP, /* DDP AppleTalk connection */ |
377 | PT_IDP, /* XNS IDP sockets */ |
378 | PT_USB, /* USB endpoint 0xffff means the host */ |
379 | PT_I2C, |
380 | PT_IBQP, /* Infiniband QP number */ |
381 | PT_BLUETOOTH, |
382 | PT_IWARP_MPA, /* iWarp MPA */ |
383 | PT_MCTP |
384 | } port_type; |
385 | |
386 | #ifdef __cplusplus |
387 | } |
388 | #endif /* __cplusplus */ |
389 | |
390 | #endif /* __ADDRESS_H__ */ |
391 | |
392 | /* |
393 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
394 | * |
395 | * Local variables: |
396 | * c-basic-offset: 4 |
397 | * tab-width: 8 |
398 | * indent-tabs-mode: nil |
399 | * End: |
400 | * |
401 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
402 | * :indentSize=4:tabSize=8:noTabs=true: |
403 | */ |