static void linphone_stun_test_encode(void) { char smallBuff[12]; size_t smallLen = 12; char bigBuff[STUN_MAX_MESSAGE_SIZE]; size_t bigLen = STUN_MAX_MESSAGE_SIZE; size_t len = test_stun_encode(smallBuff, smallLen, TRUE); BC_ASSERT(len == -1); len = test_stun_encode(bigBuff, bigLen, TRUE); BC_ASSERT(len > 0); ms_message("STUN message encoded in %i bytes", (int)len); }
static void linphone_stun_test_encode(void) { char *buffer = NULL; size_t len = test_stun_encode(&buffer); BC_ASSERT(len > 0); BC_ASSERT_PTR_NOT_NULL(buffer); if (buffer != NULL) ms_free(buffer); ms_message("STUN message encoded in %i bytes", (int)len); }
static void linphone_stun_test_grab_ip(void) { LinphoneCoreManager* lc_stun = linphone_core_manager_new2( "stun_rc", FALSE); LinphoneCall dummy_call; int ping_time; int tmp=0; memset(&dummy_call, 0, sizeof(LinphoneCall)); dummy_call.main_audio_stream_index = 0; dummy_call.main_video_stream_index = 1; dummy_call.main_text_stream_index = 2; dummy_call.media_ports[dummy_call.main_audio_stream_index].rtp_port = 7078; dummy_call.media_ports[dummy_call.main_video_stream_index].rtp_port = 9078; dummy_call.media_ports[dummy_call.main_text_stream_index].rtp_port = 11078; linphone_core_set_stun_server(lc_stun->lc, stun_address); BC_ASSERT_STRING_EQUAL(stun_address, linphone_core_get_stun_server(lc_stun->lc)); wait_for(lc_stun->lc,lc_stun->lc,&tmp,1); ping_time = linphone_core_run_stun_tests(lc_stun->lc, &dummy_call); BC_ASSERT(ping_time != -1); ms_message("Round trip to STUN: %d ms", ping_time); BC_ASSERT( dummy_call.ac.addr[0] != '\0'); BC_ASSERT( dummy_call.ac.port != 0); #ifdef VIDEO_ENABLED BC_ASSERT( dummy_call.vc.addr[0] != '\0'); BC_ASSERT( dummy_call.vc.port != 0); #endif BC_ASSERT( dummy_call.tc.addr[0] != '\0'); BC_ASSERT( dummy_call.tc.port != 0); ms_message("STUN test result: local audio port maps to %s:%i", dummy_call.ac.addr, dummy_call.ac.port); #ifdef VIDEO_ENABLED ms_message("STUN test result: local video port maps to %s:%i", dummy_call.vc.addr, dummy_call.vc.port); #endif ms_message("STUN test result: local text port maps to %s:%i", dummy_call.tc.addr, dummy_call.tc.port); linphone_core_manager_destroy(lc_stun); }