/* Initialize all the allocators here. * This function should be called only once when Wireshark or TShark starts * up. */ void emem_init(void) { ep_init_chunk(); se_init_chunk(); if (getenv("WIRESHARK_DEBUG_SCRUB_MEMORY")) debug_use_memory_scrubber = TRUE; #if defined (_WIN32) /* Set up our guard page info for Win32 */ GetSystemInfo(&sysinfo); pagesize = sysinfo.dwPageSize; #if (_MSC_VER >= 1800) /* * On VS2103, GetVersionEx is deprecated. Microsoft recommend to * use VerifyVersionInfo instead */ { OSVERSIONINFOEX osvi; DWORDLONG dwlConditionMask = 0; int op = VER_EQUAL; SecureZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, op); iswindowsplatform = VerifyVersionInfo(&osvi, VER_PLATFORMID, dwlConditionMask); } #else /* calling GetVersionEx using the OSVERSIONINFO structure. * OSVERSIONINFOEX requires Win NT4 with SP6 or newer NT Versions. * OSVERSIONINFOEX will fail on Win9x and older NT Versions. * See also: * http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp */ { OSVERSIONINFO versinfo; SecureZeroMemory(&versinfo, sizeof(OSVERSIONINFO)); versinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&versinfo); iswindowsplatform = (versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); } #endif #elif defined(USE_GUARD_PAGES) pagesize = sysconf(_SC_PAGESIZE); if (pagesize == -1) fprintf(stderr, "Warning: call to sysconf() for _SC_PAGESIZE has failed...\n"); #ifdef NEED_DEV_ZERO dev_zero_fd = ws_open("/dev/zero", O_RDWR); g_assert(dev_zero_fd != -1); #endif #endif /* _WIN32 / USE_GUARD_PAGES */ }
int main(int argc, char **argv) { frame_data fd; char src[] = {1,2,3,4}, dst[] = {5,6,7,8}; unsigned int i; void (*tests[])(void) = { test_simple_fragment_add_seq, test_fragment_add_seq_partial_reassembly, test_fragment_add_dcerpc_dg, test_fragment_add_seq_check, test_fragment_add_seq_check_1, test_fragment_add_seq_802_11_0, test_fragment_add_seq_802_11_1, test_simple_fragment_add_seq_next, test_missing_data_fragment_add_seq_next, test_missing_data_fragment_add_seq_next_2, test_missing_data_fragment_add_seq_next_3 }; /* we don't use our params */ argc=argc; argv=argv; /* initialise stuff */ ep_init_chunk(); tvbuff_init(); reassemble_init(); /* a tvbuff for testing with */ data = g_malloc(DATA_LEN); /* make sure it's full of stuff */ for(i=0; i<DATA_LEN; i++) { data[i]=i & 0xFF; } tvb = tvb_new_real_data(data, DATA_LEN, DATA_LEN*2); /* other test stuff */ pinfo.fd = &fd; fd.flags.visited = 0; SET_ADDRESS(&pinfo.src,AT_IPv4,4,src); SET_ADDRESS(&pinfo.dst,AT_IPv4,4,dst); /*************************************************************************/ for(i=0; i < sizeof(tests)/sizeof(tests[0]); i++ ) { /* re-init the fragment tables */ fragment_table_init(&fragment_table); ASSERT(fragment_table != NULL); reassembled_table_init(&reassembled_table); ASSERT(reassembled_table != NULL); pinfo.fd->flags.visited = FALSE; tests[i](); } printf(failure?"FAILURE\n":"SUCCESS\n"); return failure; }
void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data, void (*report_failure)(const char *, va_list), void (*report_open_failure)(const char *, int, gboolean), void (*report_read_failure)(const char *, int), void (*report_write_failure)(const char *, int)) { init_report_err(report_failure, report_open_failure, report_read_failure, report_write_failure); /* initialize memory allocation subsystem */ ep_init_chunk(); se_init_chunk(); /* initialize the GUID to name mapping table */ guids_init(); except_init(); #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #elif defined(HAVE_LIBGCRYPT) gcry_check_version(NULL); #endif tvbuff_init(); tap_init(); prefs_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_init(); dfilter_init(); final_registration_all_protocols(); host_name_lookup_init(); expert_init(); oids_init(); #ifdef HAVE_LUA_5_1 wslua_init(NULL); #endif #ifdef HAVE_GEOIP geoip_db_init(); #endif }