提交 2664e0ee authored 作者: Viktor Krykun's avatar Viktor Krykun 提交者: Travis Cross

Add high-level test engine

Remove some old tests and implement a few test-cases to emulate zrtp
enrollment and sasrelay logic
Modified-by: 's avatarTravis Cross <tc@traviscross.com>
Signed-off-by: 's avatarTravis Cross <tc@traviscross.com>
上级 a7286bff
......@@ -17,7 +17,6 @@ INCLUDES = -I$(TOP_SRCDIR)/include \
-I$(TOP_SRCDIR)/third_party/bnlib
#check_PROGRAMS = cache_test libzrtp_test
check_PROGRAMS = cache_test
### ZRTP Cache testing
......@@ -27,15 +26,6 @@ cache_test_SOURCES = $(TOP_SRCDIR)/test/cmockery/cmockery.c \
cache_test_LDADD = ../libzrtp.a $(TOP_SRCDIR)/third_party/bnlib/libbn.a -lpthread
### ZRTP high-level test-case
libzrtp_test_SOURCES = $(TOP_SRCDIR)/test/pc/zrtp_test_core.c \
$(TOP_SRCDIR)/test/pc/zrtp_test_crypto.c \
$(TOP_SRCDIR)/test/pc/zrtp_test_queue.c \
$(TOP_SRCDIR)/test/pc/zrtp_test_ui.c
libzrtp_test_LDADD = ../libzrtp.a $(TOP_SRCDIR)/third_party/bnlib/libbn.a -lpthread
SUBDIRS = .
check:
......
static zrtp_test_id_t g_alice, g_bob, g_pbx;
static zrtp_test_id_t g_alice_sid, g_bob_sid, g_pbxa_sid, g_pbxb_sid;
static zrtp_test_id_t g_alice2pbx_channel, g_bob2pbx_channel;
static void pbx_setup() {
zrtp_status_t s;
zrtp_test_endpoint_cfg_t endpoint_cfg;
zrtp_test_endpoint_config_defaults(&endpoint_cfg);
s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice);
s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob);
endpoint_cfg.zrtp.is_mitm = 1;
s = zrtp_test_endpoint_create(&endpoint_cfg, "PBX", &g_pbx);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbx);
}
static void pbx_teardown() {
zrtp_test_endpoint_destroy(g_alice);
zrtp_test_endpoint_destroy(g_bob);
zrtp_test_endpoint_destroy(g_pbx);
}
static void prepare_alice_pbx_bob_setup(zrtp_test_session_cfg_t *alice_sconfig,
zrtp_test_session_cfg_t *bob_sconfig,
zrtp_test_session_cfg_t *pbxa_sconfig,
zrtp_test_session_cfg_t *pbxb_sconfig) {
zrtp_status_t s;
if (alice_sconfig) {
assert_non_null(pbxa_sconfig);
s = zrtp_test_session_create(g_alice, alice_sconfig, &g_alice_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid);
s = zrtp_test_session_create(g_pbx, pbxa_sconfig, &g_pbxa_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxa_sid);
s = zrtp_test_channel_create2(g_alice_sid, g_pbxa_sid, 0, &g_alice2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice2pbx_channel);
}
if (bob_sconfig) {
assert_non_null(pbxb_sconfig);
s = zrtp_test_session_create(g_bob, bob_sconfig, &g_bob_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid);
s = zrtp_test_session_create(g_pbx, pbxb_sconfig, &g_pbxb_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxb_sid);
s = zrtp_test_channel_create2(g_bob_sid, g_pbxb_sid, 0, &g_bob2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob2pbx_channel);
}
}
static void cleanup_alice_pbx_bob_setup() {
zrtp_test_session_destroy(g_alice_sid);
zrtp_test_session_destroy(g_bob_sid);
zrtp_test_session_destroy(g_pbxa_sid);
zrtp_test_session_destroy(g_pbxb_sid);
zrtp_test_channel_destroy(g_alice2pbx_channel);
zrtp_test_channel_destroy(g_bob2pbx_channel);
}
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#include <setjmp.h> /*chmockery dependency*/
#include <stdio.h> /*chmockery dependency*/
#include <unistd.h> /*for usleep*/
#include "cmockery/cmockery.h"
#include "test_engine.h"
#include "enroll_test_helpers.c"
static void enrollment_test() {
zrtp_status_t s;
zrtp_test_channel_info_t a2pbx_channel_info;
zrtp_test_session_cfg_t session_config, session_config_enroll;
zrtp_test_session_config_defaults(&session_config);
zrtp_test_session_config_defaults(&session_config_enroll);
session_config_enroll.is_enrollment = 1;
/**************************************************************************
* Enroll Alice to PBX and check triggered events.
*/
prepare_alice_pbx_bob_setup(&session_config, NULL, &session_config_enroll, NULL);
/* Everything is ready. Let's start the stream and give it few seconds to switch secure. */
s = zrtp_test_channel_start(g_alice2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
int i = 30;
for (; i>0; i--) {
usleep(100*1000);
}
s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
/* Both, Alice and PBX should switch secure */
assert_true(a2pbx_channel_info.is_secure);
/* Alice should receive Enrollment notification */
zrtp_test_id_t alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0);
assert_true(zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_IS_CLIENT_ENROLLMENT));
/* PBX streams should receive incoming enrollment notification */
zrtp_test_id_t pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0);
assert_true(zrtp_stream_did_event_receive(pbx2alice_stream, ZRTP_EVENT_NEW_USER_ENROLLED));
/* Clean-up */
cleanup_alice_pbx_bob_setup();
/**************************************************************************
* Try to make one more enrollment call. This time it should say "Already enrolled"
*/
prepare_alice_pbx_bob_setup(&session_config, NULL, &session_config_enroll, NULL);
/* Everything is ready. Let's start the stream and give it few seconds to switch secure. */
s = zrtp_test_channel_start(g_alice2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
i = 30;
for (; i>0; i--) {
usleep(100*1000);
}
s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
assert_true(a2pbx_channel_info.is_secure);
/* Alice should receive Enrollment notification */
alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0);
assert_true(zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_IS_CLIENT_ENROLLMENT));
/* PBX streams should receive incoming enrollment notification */
pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0);
assert_true(zrtp_stream_did_event_receive(pbx2alice_stream, ZRTP_EVENT_USER_ALREADY_ENROLLED));
// TODO: check if we have PBX secret cached
// TODO: test zrtp_is_user_enrolled()
// TODO: use zrtp_register_with_trusted_mitm()
}
int main(void) {
const UnitTest tests[] = {
unit_test_setup_teardown(enrollment_test, pbx_setup, pbx_teardown),
};
return run_tests(tests);
}
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#include <setjmp.h> /*chmockery dependency*/
#include <stdio.h> /*chmockery dependency*/
#include <unistd.h> /*for usleep*/
#include "cmockery/cmockery.h"
#include "test_engine.h"
static zrtp_test_id_t g_alice, g_bob;
static zrtp_test_id_t g_alice_sid, g_bob_sid;
static zrtp_test_id_t g_secure_audio_channel;
static void setup() {
zrtp_status_t s;
zrtp_test_endpoint_cfg_t endpoint_cfg;
zrtp_test_endpoint_config_defaults(&endpoint_cfg);
s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice);
s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob);
}
static void teardown() {
zrtp_test_endpoint_destroy(g_alice);
zrtp_test_endpoint_destroy(g_bob);
}
static void go_secure_test() {
zrtp_status_t s;
zrtp_test_channel_info_t channel_info;
zrtp_test_session_cfg_t session_config;
zrtp_test_session_config_defaults(&session_config);
/*
* Create two test sessions, one for Alice and one for Bob and link them
* into test secure channel
*/
s = zrtp_test_session_create(g_alice, &session_config, &g_alice_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid);
s = zrtp_test_session_create(g_bob, &session_config, &g_bob_sid);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid);
s = zrtp_test_channel_create2(g_alice_sid, g_bob_sid, 0, &g_secure_audio_channel);
assert_int_equal(zrtp_status_ok, s);
assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_secure_audio_channel);
/* Everything is ready. Let's start the stream and give it few seconds to switch secure. */
s = zrtp_test_channel_start(g_secure_audio_channel);
assert_int_equal(zrtp_status_ok, s);
int i = 30;
for (; i>0; i--) {
usleep(100*1000);
}
s = zrtp_test_channel_get(g_secure_audio_channel, &channel_info);
assert_int_equal(zrtp_status_ok, s);
/* Both, Alice and Bob should switch secure */
assert_true(channel_info.is_secure);
zrtp_test_session_destroy(g_alice_sid);
zrtp_test_session_destroy(g_bob_sid);
zrtp_test_channel_destroy(g_secure_audio_channel);
}
int main(void) {
const UnitTest tests[] = {
unit_test_setup_teardown(go_secure_test, setup, teardown),
};
return run_tests(tests);
}
差异被折叠。
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#ifndef __ZRTP_TEST_CORE_H__
#define __ZRTP_TEST_CORE_H__
#include "zrtp.h"
extern zrtp_global_t* zrtp_global;
typedef uint32_t zrtp_test_channel_id_t;
typedef struct zrtp_test_channel_config
{
unsigned streams_count;
unsigned char is_autosecure;
unsigned char is_preshared;
} zrtp_test_channel_config_t;
void zrtp_test_crypto(zrtp_global_t* zrtp);
int zrtp_test_zrtp_init();
int zrtp_test_zrtp_down();
int zrtp_test_channel_create( const zrtp_test_channel_config_t* config,
zrtp_test_channel_id_t* chan_id);
int zrtp_test_channel_delete(zrtp_test_channel_id_t chan_id);
int zrtp_test_channel_start(zrtp_test_channel_id_t chan_id);
int zrtp_test_channel_secure(zrtp_test_channel_id_t chan_id);
int zrtp_test_channel_clear(zrtp_test_channel_id_t chan_id);
#endif /*__ZRTP_TEST_CORE_H__*/
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#include "zrtp_test_core.h"
#ifndef ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS
#define ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS 0
#endif
static zrtp_test_channel_id_t tmp_id;
void do_create()
{
zrtp_test_channel_config_t config;
int status = 0;
config.is_autosecure = 1;
config.is_preshared = 0;
config.streams_count = 1;
status = zrtp_test_channel_create(&config, &tmp_id);
}
void do_delete()
{
zrtp_test_channel_delete(tmp_id);
}
void do_quit()
{
zrtp_test_zrtp_down();
}
int main()
{
int status;
status = zrtp_test_zrtp_init();
if (0 != status) {
return status;
}
#if (ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS == 1)
zrtp_test_crypto(zrtp_global);
#endif
{
zrtp_test_channel_id_t id;
zrtp_test_channel_config_t sconfig;
sconfig.is_autosecure = 0;
sconfig.is_preshared = 0;
sconfig.streams_count = 1;
status = zrtp_test_channel_create(&sconfig, &id);
if (0 == status) {
zrtp_test_channel_start(id);
}
}
while (1) {
zrtp_sleep(1000);
}
do_quit();
return 0;
}
......@@ -8,10 +8,9 @@
*/
#include "zrtp.h"
#include "zrtp_test_queue.h"
#include "queue.h"
struct zrtp_queue
{
struct zrtp_queue {
zrtp_sem_t* size_sem;
zrtp_sem_t* main_sem;
zrtp_mutex_t* mutex;
......@@ -19,9 +18,9 @@ struct zrtp_queue
uint32_t size;
};
/*----------------------------------------------------------------------------*/
zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue)
{
zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue) {
zrtp_status_t s = zrtp_status_fail;
zrtp_queue_t* new_queue = (zrtp_queue_t*) zrtp_sys_alloc(sizeof(zrtp_queue_t));
if (! new_queue) {
......@@ -67,8 +66,7 @@ zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue)
return s;
}
void zrtp_test_queue_destroy(zrtp_queue_t* queue)
{
void zrtp_test_queue_destroy(zrtp_queue_t* queue) {
if (queue->size_sem) {
zrtp_sem_destroy(queue->size_sem);
}
......@@ -80,9 +78,8 @@ void zrtp_test_queue_destroy(zrtp_queue_t* queue)
}
}
/*----------------------------------------------------------------------------*/
void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem)
{
void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem) {
zrtp_sem_wait(queue->size_sem);
zrtp_mutex_lock(queue->mutex);
......@@ -93,8 +90,7 @@ void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem)
zrtp_sem_post(queue->main_sem);
}
zrtp_queue_elem_t* zrtp_test_queue_pop(zrtp_queue_t* queue)
{
zrtp_queue_elem_t* zrtp_test_queue_pop(zrtp_queue_t* queue) {
zrtp_queue_elem_t* res = NULL;
zrtp_sem_wait(queue->main_sem);
......
......@@ -14,8 +14,7 @@
#define ZRTP_QUEUE_SIZE 2000
typedef struct zrtp_queue_elem
{
typedef struct zrtp_queue_elem {
char data[1500];
uint32_t size;
mlist_t _mlist;
......
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#include <setjmp.h> /*chmockery dependency*/
#include <stdio.h> /*chmockery dependency*/
#include <unistd.h> /*for usleep*/
#include "cmockery/cmockery.h"
#include "test_engine.h"
#include "enroll_test_helpers.c"
static void enrollment_test() {
zrtp_status_t s;
zrtp_test_channel_info_t a2pbx_channel_info, b2pbx_channel_info;
zrtp_test_session_cfg_t session_config, session_config_enroll;
zrtp_test_session_config_defaults(&session_config);
zrtp_test_session_config_defaults(&session_config_enroll);
session_config_enroll.is_enrollment = 1;
/**************************************************************************
* Enroll both Alice and Bob to PBX
*/
prepare_alice_pbx_bob_setup(&session_config, &session_config, &session_config_enroll, &session_config_enroll);
/* Everything is ready. Let's start the stream and give it few seconds to switch secure. */
s = zrtp_test_channel_start(g_alice2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
s = zrtp_test_channel_start(g_bob2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
int i = 30;
for (; i>0; i--) {
usleep(100*1000);
}
s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
s = zrtp_test_channel_get(g_bob2pbx_channel, &b2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
/* Both, Alice and Bob should switch secure and ready for enrollment */
assert_true(a2pbx_channel_info.is_secure);
assert_true(b2pbx_channel_info.is_secure);
/* Confirm enrollment for both, Alice and Bob */
zrtp_test_id_t alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0);
zrtp_test_id_t bob2pbx_stream = zrtp_test_session_get_stream_by_idx(g_bob_sid, 0);
s = zrtp_register_with_trusted_mitm(zrtp_stream_for_test_stream(alice2pbx_stream));
assert_int_equal(zrtp_status_ok, s);
s = zrtp_register_with_trusted_mitm(zrtp_stream_for_test_stream(bob2pbx_stream));
assert_int_equal(zrtp_status_ok, s);
/* Clean-up */
cleanup_alice_pbx_bob_setup();
/**************************************************************************
* Now, when we have two enrolled parties, make one more call and initiate
* SAS Relay at the PBX side. Both endpoints should received SASRelay, but
* just one should get ZRTP_EVENT_LOCAL_SAS_UPDATED event.
*/
prepare_alice_pbx_bob_setup(&session_config, &session_config, &session_config, &session_config);
/* Everything is ready. Let's start the stream and give it few seconds to switch secure. */
s = zrtp_test_channel_start(g_alice2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
s = zrtp_test_channel_start(g_bob2pbx_channel);
assert_int_equal(zrtp_status_ok, s);
i = 30;
for (; i>0; i--) {
usleep(100*1000);
}
s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
s = zrtp_test_channel_get(g_bob2pbx_channel, &b2pbx_channel_info);
assert_int_equal(zrtp_status_ok, s);
/* Both, Alice and Bob should switch secure */
assert_true(a2pbx_channel_info.is_secure);
assert_true(b2pbx_channel_info.is_secure);
zrtp_test_id_t pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0);
zrtp_test_id_t pbx2bob_stream = zrtp_test_session_get_stream_by_idx(g_pbxb_sid, 0);
alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0);
bob2pbx_stream = zrtp_test_session_get_stream_by_idx(g_bob_sid, 0);
/* Resolve MiTM call! */
s = zrtp_resolve_mitm_call(zrtp_stream_for_test_stream(pbx2alice_stream),
zrtp_stream_for_test_stream(pbx2bob_stream));
i = 20;
for (; i>0; i--) {
usleep(100*1000);
}
/* Alice and Bob should receive Enrollment notification */
unsigned sas_update1 = zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_LOCAL_SAS_UPDATED);
unsigned sas_update2 = zrtp_stream_did_event_receive(bob2pbx_stream, ZRTP_EVENT_LOCAL_SAS_UPDATED);
assert_true(sas_update1 ^ sas_update2);
/* Clean-up */
cleanup_alice_pbx_bob_setup();
}
int main(void) {
const UnitTest tests[] = {
unit_test_setup_teardown(enrollment_test, pbx_setup, pbx_teardown),
};
return run_tests(tests);
}
差异被折叠。
/*
* libZRTP SDK library, implements the ZRTP secure VoIP protocol.
* Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
* Contact: http://philzimmermann.com
* For licensing and other legal details, see the file zrtp_legal.c.
*
* Viktor Krykun <v.krikun at zfoneproject.com>
*/
#include "zrtp.h"
/** libzrtp test elements identifier */
typedef uint32_t zrtp_test_id_t;
/** Defines constant for unknown test element identifier */
#define ZRTP_TEST_UNKNOWN_ID 0
/** Default lengths for libzrtp test string buffers */
#define ZRTP_TEST_STR_LEN 128
/** libzrtp test endpoint configuration */
typedef struct {
zrtp_config_t zrtp; /** libzrtp global configuration parameters */
unsigned generate_traffic; /** switch On to emulate RTP/RTCP traffic generation. Off by default. */
} zrtp_test_endpoint_cfg_t;
/** ZRTP test session parameters*/
typedef struct {
zrtp_profile_t zrtp; /** libzrtp session parameters */
unsigned streams_count; /** number of zrtp streams to be attached to the session */
zrtp_signaling_role_t role; /** signaling role, default is ZRTP_SIGNALING_ROLE_UNKNOWN */
unsigned is_enrollment; /** true if enrollment session should be created */
} zrtp_test_session_cfg_t;
/** ZRTP test stream info */
typedef struct {
zrtp_stream_info_t zrtp; /** libzrtp stream info */
unsigned zrtp_events_queueu[128]; /** list of received zrtp events*/
unsigned zrtp_events_count; /** number of received events */
} zrtp_test_stream_info_t;
/** ZRTP test session state snapshot */
typedef struct {
zrtp_session_info_t zrtp; /** libzrtp session info*/
zrtp_test_stream_info_t streams[ZRTP_MAX_STREAMS_PER_SESSION]; /** array of attached streams info */
unsigned streams_count; /** number streams attached to the session */
} zrtp_test_session_info_t;
/** *ZRTP test channel state */
typedef struct {
zrtp_test_stream_info_t left; /** one-leg zrtp stream */
zrtp_test_stream_info_t right; /** second-leg zrtp stream */
unsigned char is_secure; /** enabled when both streams in the channel are secure */
} zrtp_test_channel_info_t;
/**
* Initialize zrtp test endpoint configuration with default values
* @param cfg - endpoint config to initialize
*/
void zrtp_test_endpoint_config_defaults(zrtp_test_endpoint_cfg_t *cfg);
/**
* ZRTP test endpoint constructor
* One endpoint is created, it starts processing threads and ready to emulate ZRTP exchange.
*
* @param cfg - endpoint configuration
* @param name - endpoint name for debug purposes and cache naming, e.h "Alice", "Bob".
* @param id - just created endpoint identifier will be placed here
*
* @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure
*/
zrtp_status_t zrtp_test_endpoint_create(zrtp_test_endpoint_cfg_t *cfg,
const char *name,
zrtp_test_id_t *id);
/**
* ZRTP test endpoint destructor
* zrtp_test_endpoint_destroy() stops processing threads and release all
* recurses allocated in zrtp_test_endpoint_create().
*
* @param id - endpoint identifier
* @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure
*/
zrtp_status_t zrtp_test_endpoint_destroy(zrtp_test_id_t id);
/**
* Enables test session config with default values
* @param cfg - session config for initialization
*/
void zrtp_test_session_config_defaults(zrtp_test_session_cfg_t *cfg);
/**
* Create zrtp test session
*
* @param endpoint - test endpoint creating endpoint should belong to
* @param cfg - session parameters
* @param id - created session identifier will be placed here
* @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure
*/
zrtp_status_t zrtp_test_session_create(zrtp_test_id_t endpoint,
zrtp_test_session_cfg_t *cfg,
zrtp_test_id_t *id);
zrtp_status_t zrtp_test_session_destroy(zrtp_test_id_t id);
zrtp_status_t zrtp_test_session_get(zrtp_test_id_t id, zrtp_test_session_info_t *info);
/**
* Get stream Id by it's index in zrtp session
*
* @param session_id - zrtp test session id where needed stream should be taken
* @param idx - stream index
* @return found stream id, or ZRTP_TEST_UNKNOWN_ID if idex is out of stream array range
*/
zrtp_test_id_t zrtp_test_session_get_stream_by_idx(zrtp_test_id_t session_id, unsigned idx);
zrtp_status_t zrtp_test_stream_get(zrtp_test_id_t id, zrtp_test_stream_info_t *info);
zrtp_status_t zrtp_test_channel_create(zrtp_test_id_t left_stream, zrtp_test_id_t right_stream, zrtp_test_id_t *id);
zrtp_status_t zrtp_test_channel_create2(zrtp_test_id_t left_session, zrtp_test_id_t right_session, unsigned stream_idx, zrtp_test_id_t *id);
zrtp_status_t zrtp_test_channel_destroy(zrtp_test_id_t id);
zrtp_status_t zrtp_test_channel_start(zrtp_test_id_t id);
zrtp_status_t zrtp_test_channel_get(zrtp_test_id_t id, zrtp_test_channel_info_t *info);
zrtp_stream_t *zrtp_stream_for_test_stream(zrtp_test_id_t stream_id);
unsigned zrtp_stream_did_event_receive(zrtp_test_id_t stream_id, unsigned event);
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论