| File: | build/epan/wslua/taps_wslua.c |
| Warning: | line 364, 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,"flagkarn"); | |||
| 360 | lua_pushboolean(L,(int)v->flagkarn); | |||
| 361 | lua_settable(L,-3); | |||
| 362 | lua_pushstring(L,"ip_dst"); | |||
| 363 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_dst)); pushAddress(L,a); } | |||
| ||||
| 364 | lua_settable(L,-3); | |||
| ||||
| 365 | lua_pushstring(L,"ip_src"); | |||
| 366 | { Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->ip_src)); pushAddress(L,a); } | |||
| 367 | lua_settable(L,-3); | |||
| 368 | lua_pushstring(L,"num_sack_ranges"); | |||
| 369 | lua_pushinteger(L,(lua_Integer)v->num_sack_ranges); | |||
| 370 | lua_settable(L,-3); | |||
| 371 | lua_pushstring(L,"th_ack"); | |||
| 372 | lua_pushinteger(L,(lua_Integer)v->th_ack); | |||
| 373 | lua_settable(L,-3); | |||
| 374 | lua_pushstring(L,"th_dport"); | |||
| 375 | lua_pushinteger(L,(lua_Integer)v->th_dport); | |||
| 376 | lua_settable(L,-3); | |||
| 377 | lua_pushstring(L,"th_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 | } |
| 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 | 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 | static inline void |
| 71 | clear_address(address *addr) |
| 72 | { |
| 73 | addr->type = AT_NONE; |
| 74 | addr->len = 0; |
| 75 | addr->data = NULL((void*)0); |
| 76 | addr->priv = NULL((void*)0); |
| 77 | } |
| 78 | |
| 79 | /** Initialize an address with the given values. |
| 80 | * |
| 81 | * @param addr [in,out] The address to initialize. |
| 82 | * @param addr_type [in] Address type. |
| 83 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
| 84 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
| 85 | * @param addr_data [in] Pointer to the address data. |
| 86 | */ |
| 87 | static inline void |
| 88 | set_address(address *addr, int addr_type, int addr_len, const void *addr_data) { |
| 89 | if (addr_len == 0) { |
| 90 | /* Zero length must mean no data */ |
| 91 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 91, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0); |
| 92 | } else { |
| 93 | /* Must not be AT_NONE - AT_NONE must have no data */ |
| 94 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 94, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
| 95 | /* Make sure we *do* have data */ |
| 96 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 96, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0); |
| 97 | } |
| 98 | addr->type = addr_type; |
| 99 | addr->len = addr_len; |
| 100 | addr->data = addr_data; |
| 101 | addr->priv = NULL((void*)0); |
| 102 | } |
| 103 | |
| 104 | static inline void |
| 105 | set_address_ipv4(address *addr, const ipv4_addr_and_mask *ipv4) { |
| 106 | addr->type = AT_IPv4; |
| 107 | addr->len = 4; |
| 108 | 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)))))); |
| 109 | addr->priv = g_memdup2(&val, sizeof(val)); |
| 110 | addr->data = addr->priv; |
| 111 | } |
| 112 | |
| 113 | static inline void |
| 114 | set_address_ipv6(address *addr, const ipv6_addr_and_prefix *ipv6) { |
| 115 | set_address(addr, AT_IPv6, sizeof(ws_in6_addr), &ipv6->addr); |
| 116 | } |
| 117 | |
| 118 | /** Initialize an address from TVB data. |
| 119 | * |
| 120 | * Same as set_address but it takes a TVB and an offset. This is preferred |
| 121 | * over passing the return value of tvb_get_ptr() to set_address(). |
| 122 | * |
| 123 | * This calls tvb_get_ptr() (including throwing any exceptions) before |
| 124 | * modifying the address. |
| 125 | * |
| 126 | * @param addr [in,out] The address to initialize. |
| 127 | * @param addr_type [in] Address type. |
| 128 | * @param tvb [in] Pointer to the TVB. |
| 129 | * @param offset [in] Offset within the TVB. |
| 130 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
| 131 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
| 132 | */ |
| 133 | static inline void |
| 134 | set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int offset) { |
| 135 | const void *p; |
| 136 | |
| 137 | if (addr_len != 0) { |
| 138 | /* Must not be AT_NONE - AT_NONE must have no data */ |
| 139 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 139, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
| 140 | p = tvb_get_ptr(tvb, offset, addr_len); |
| 141 | } else |
| 142 | p = NULL((void*)0); |
| 143 | set_address(addr, addr_type, addr_len, p); |
| 144 | } |
| 145 | |
| 146 | /** Initialize an address with the given values, allocating a new buffer |
| 147 | * for the address data using wmem-scoped memory. |
| 148 | * |
| 149 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
| 150 | * @param addr [in,out] The address to initialize. |
| 151 | * @param addr_type [in] Address type. |
| 152 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
| 153 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
| 154 | * @param addr_data [in] Pointer to the address data. |
| 155 | */ |
| 156 | static inline void |
| 157 | alloc_address_wmem(wmem_allocator_t *scope, address *addr, |
| 158 | int addr_type, int addr_len, const void *addr_data) { |
| 159 | ws_assert(addr)do { if ((1) && !(addr)) ws_log_fatal_full("", LOG_LEVEL_ERROR , "epan/address.h", 159, __func__, "assertion failed: %s", "addr" ); } while (0); |
| 160 | clear_address(addr); |
| 161 | addr->type = addr_type; |
| 162 | if (addr_len == 0) { |
| 163 | /* Zero length must mean no data */ |
| 164 | ws_assert(addr_data == NULL)do { if ((1) && !(addr_data == ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 164, __func__, "assertion failed: %s" , "addr_data == ((void*)0)"); } while (0); |
| 165 | /* Nothing to copy */ |
| 166 | return; |
| 167 | } |
| 168 | /* Must not be AT_NONE - AT_NONE must have no data */ |
| 169 | ws_assert(addr_type != AT_NONE)do { if ((1) && !(addr_type != AT_NONE)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 169, __func__, "assertion failed: %s" , "addr_type != AT_NONE"); } while (0); |
| 170 | /* Make sure we *do* have data to copy */ |
| 171 | ws_assert(addr_data != NULL)do { if ((1) && !(addr_data != ((void*)0))) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 171, __func__, "assertion failed: %s" , "addr_data != ((void*)0)"); } while (0); |
| 172 | addr->data = addr->priv = wmem_memdup(scope, addr_data, addr_len); |
| 173 | addr->len = addr_len; |
| 174 | } |
| 175 | |
| 176 | /** Allocate an address from TVB data. |
| 177 | * |
| 178 | * Same as alloc_address_wmem but it takes a TVB and an offset. |
| 179 | * |
| 180 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
| 181 | * @param addr [in,out] The address to initialize. |
| 182 | * @param addr_type [in] Address type. |
| 183 | * @param addr_len [in] The length in bytes of the address data. For example, 4 for |
| 184 | * AT_IPv4 or sizeof(ws_in6_addr) for AT_IPv6. |
| 185 | * @param tvb [in] Pointer to the TVB. |
| 186 | * @param offset [in] Offset within the TVB. |
| 187 | */ |
| 188 | static inline void |
| 189 | alloc_address_tvb(wmem_allocator_t *scope, address *addr, |
| 190 | int addr_type, int addr_len, tvbuff_t *tvb, int offset) { |
| 191 | const void *p; |
| 192 | |
| 193 | p = tvb_get_ptr(tvb, offset, addr_len); |
| 194 | alloc_address_wmem(scope, addr, addr_type, addr_len, p); |
| 195 | } |
| 196 | |
| 197 | /** Compare two addresses. |
| 198 | * |
| 199 | * @param addr1 [in] The first address to compare. |
| 200 | * @param addr2 [in] The second address to compare. |
| 201 | * @return 0 if the addresses are equal, |
| 202 | * A positive number if addr1 > addr2 in some nondefined metric, |
| 203 | * A negative number if addr1 < addr2 in some nondefined metric. |
| 204 | */ |
| 205 | static inline int |
| 206 | cmp_address(const address *addr1, const address *addr2) { |
| 207 | if (addr1->type > addr2->type) return 1; |
| 208 | if (addr1->type < addr2->type) return -1; |
| 209 | if (addr1->len > addr2->len) return 1; |
| 210 | if (addr1->len < addr2->len) return -1; |
| 211 | if (addr1->len == 0) { |
| 212 | /* |
| 213 | * memcmp(NULL, NULL, 0) is *not* guaranteed to work, so |
| 214 | * if both addresses are zero-length, don't compare them |
| 215 | * (there's nothing to compare, so they're equal). |
| 216 | */ |
| 217 | return 0; |
| 218 | } |
| 219 | return memcmp(addr1->data, addr2->data, addr1->len); |
| 220 | } |
| 221 | |
| 222 | /** Check two addresses for equality. |
| 223 | * |
| 224 | * Given two addresses, return "true" if they're equal, "false" otherwise. |
| 225 | * Addresses are equal only if they have the same type and length; if the |
| 226 | * length is zero, they are then equal, otherwise the data must be the |
| 227 | * same. |
| 228 | * |
| 229 | * @param addr1 [in] The first address to compare. |
| 230 | * @param addr2 [in] The second address to compare. |
| 231 | * @return true if the addresses are equal, false otherwise. |
| 232 | */ |
| 233 | static inline bool_Bool |
| 234 | addresses_equal(const address *addr1, const address *addr2) { |
| 235 | /* |
| 236 | * memcmp(NULL, NULL, 0) is *not* guaranteed to work, so |
| 237 | * if both addresses are zero-length, don't compare them |
| 238 | * (there's nothing to compare, so they're equal). |
| 239 | */ |
| 240 | if (addr1->type == addr2->type && |
| 241 | addr1->len == addr2->len && |
| 242 | (addr1->len == 0 || |
| 243 | memcmp(addr1->data, addr2->data, addr1->len) == 0)) |
| 244 | return true1; |
| 245 | return false0; |
| 246 | } |
| 247 | |
| 248 | /** Check the data of two addresses for equality. |
| 249 | * |
| 250 | * Given two addresses, return "true" if they have the same length and, |
| 251 | * their data is equal, "false" otherwise. |
| 252 | * The address types are ignored. This can be used to compare custom |
| 253 | * address types defined with address_type_dissector_register. |
| 254 | * |
| 255 | * @param addr1 [in] The first address to compare. |
| 256 | * @param addr2 [in] The second address to compare. |
| 257 | * @return true if the addresses are equal, false otherwise. |
| 258 | */ |
| 259 | static inline bool_Bool |
| 260 | addresses_data_equal(const address *addr1, const address *addr2) { |
| 261 | if ( addr1->len == addr2->len |
| 262 | && memcmp(addr1->data, addr2->data, addr1->len) == 0 |
| 263 | ) return true1; |
| 264 | return false0; |
| 265 | } |
| 266 | |
| 267 | /** Perform a shallow copy of the address (both addresses point to the same |
| 268 | * memory location). |
| 269 | * |
| 270 | * @param to [in,out] The destination address. |
| 271 | * @param from [in] The source address. |
| 272 | * |
| 273 | * \warning Make sure 'from' memory stays valid for the lifetime of this object. |
| 274 | * Also it's strongly recommended to use this function instead of copy-assign. |
| 275 | */ |
| 276 | static inline void |
| 277 | copy_address_shallow(address *to, const address *from) { |
| 278 | set_address(to, from->type, from->len, from->data); |
| 279 | } |
| 280 | |
| 281 | /** Copy an address, allocating a new buffer for the address data |
| 282 | * using wmem-scoped memory. |
| 283 | * |
| 284 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
| 285 | * @param to [in,out] The destination address. |
| 286 | * @param from [in] The source address. |
| 287 | */ |
| 288 | static inline void |
| 289 | copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) { |
| 290 | alloc_address_wmem(scope, to, from->type, from->len, from->data); |
| 291 | } |
| 292 | |
| 293 | /** Copy an address, allocating a new buffer for the address data. |
| 294 | * |
| 295 | * @param to [in,out] The destination address. |
| 296 | * @param from [in] The source address. |
| 297 | */ |
| 298 | static inline void |
| 299 | copy_address(address *to, const address *from) { |
| 300 | copy_address_wmem(NULL((void*)0), to, from); |
| 301 | } |
| 302 | |
| 303 | /** Free an address allocated with wmem-scoped memory. |
| 304 | * |
| 305 | * @param scope [in] The lifetime of the allocated memory, e.g., pinfo->pool |
| 306 | * @param addr [in,out] The address whose data to free. |
| 307 | */ |
| 308 | static inline void |
| 309 | free_address_wmem(wmem_allocator_t *scope, address *addr) { |
| 310 | /* Because many dissectors set 'type = AT_NONE' to mean clear we check for that */ |
| 311 | if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL((void*)0)) { |
| 312 | /* Make sure API use is correct */ |
| 313 | /* if priv is not null then data == priv */ |
| 314 | ws_assert(addr->data == addr->priv)do { if ((1) && !(addr->data == addr->priv)) ws_log_fatal_full ("", LOG_LEVEL_ERROR, "epan/address.h", 314, __func__, "assertion failed: %s" , "addr->data == addr->priv"); } while (0); |
| 315 | wmem_free(scope, addr->priv); |
| 316 | } |
| 317 | clear_address(addr); |
| 318 | } |
| 319 | |
| 320 | /** Free an address. |
| 321 | * |
| 322 | * @param addr [in,out] The address whose data to free. |
| 323 | */ |
| 324 | static inline void |
| 325 | free_address(address *addr) { |
| 326 | free_address_wmem(NULL((void*)0), addr); |
| 327 | } |
| 328 | |
| 329 | /** Hash an address into a hash value (which must already have been set). |
| 330 | * |
| 331 | * @param hash_val The existing hash value. |
| 332 | * @param addr The address to add. |
| 333 | * @return The new hash value. |
| 334 | */ |
| 335 | static inline unsigned |
| 336 | add_address_to_hash(unsigned hash_val, const address *addr) { |
| 337 | const uint8_t *hash_data = (const uint8_t *)(addr)->data; |
| 338 | int idx; |
| 339 | |
| 340 | for (idx = 0; idx < (addr)->len; idx++) { |
| 341 | hash_val += hash_data[idx]; |
| 342 | hash_val += ( hash_val << 10 ); |
| 343 | hash_val ^= ( hash_val >> 6 ); |
| 344 | } |
| 345 | return hash_val; |
| 346 | } |
| 347 | |
| 348 | /** Hash an address into a hash value (which must already have been set). |
| 349 | * 64-bit version of add_address_to_hash(). |
| 350 | * |
| 351 | * @param hash_val The existing hash value. |
| 352 | * @param addr The address to add. |
| 353 | * @return The new hash value. |
| 354 | */ |
| 355 | static inline uint64_t |
| 356 | add_address_to_hash64(uint64_t hash_val, const address *addr) { |
| 357 | const uint8_t *hash_data = (const uint8_t *)(addr)->data; |
| 358 | int idx; |
| 359 | |
| 360 | for (idx = 0; idx < (addr)->len; idx++) { |
| 361 | hash_val += hash_data[idx]; |
| 362 | hash_val += ( hash_val << 10 ); |
| 363 | hash_val ^= ( hash_val >> 6 ); |
| 364 | } |
| 365 | return hash_val; |
| 366 | } |
| 367 | |
| 368 | WS_DLL_PUBLIC__attribute__ ((visibility ("default"))) extern unsigned address_to_bytes(const address *addr, uint8_t *buf, unsigned buf_len); |
| 369 | |
| 370 | /* Types of port numbers Wireshark knows about. */ |
| 371 | typedef enum { |
| 372 | PT_NONE, /* no port number */ |
| 373 | PT_SCTP, /* SCTP */ |
| 374 | PT_TCP, /* TCP */ |
| 375 | PT_UDP, /* UDP */ |
| 376 | PT_DCCP, /* DCCP */ |
| 377 | PT_IPX, /* IPX sockets */ |
| 378 | PT_DDP, /* DDP AppleTalk connection */ |
| 379 | PT_IDP, /* XNS IDP sockets */ |
| 380 | PT_USB, /* USB endpoint 0xffff means the host */ |
| 381 | PT_I2C, |
| 382 | PT_IBQP, /* Infiniband QP number */ |
| 383 | PT_BLUETOOTH, |
| 384 | PT_IWARP_MPA, /* iWarp MPA */ |
| 385 | PT_MCTP |
| 386 | } port_type; |
| 387 | |
| 388 | #ifdef __cplusplus |
| 389 | } |
| 390 | #endif /* __cplusplus */ |
| 391 | |
| 392 | #endif /* __ADDRESS_H__ */ |
| 393 | |
| 394 | /* |
| 395 | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
| 396 | * |
| 397 | * Local variables: |
| 398 | * c-basic-offset: 4 |
| 399 | * tab-width: 8 |
| 400 | * indent-tabs-mode: nil |
| 401 | * End: |
| 402 | * |
| 403 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
| 404 | * :indentSize=4:tabSize=8:noTabs=true: |
| 405 | */ |