Commit bc6574e8 authored by Ghislain MARY's avatar Ghislain MARY

Add API to force the use of relay when using ICE (for tests purpose).

parent a58e977f
......@@ -119,6 +119,7 @@ typedef struct _IceSession {
bool_t send_event; /**< Boolean value telling whether an event must be sent or not */
uint8_t max_connectivity_checks; /**< Configuration parameter to limit the number of connectivity checks performed by the agent (default is 100) */
uint8_t keepalive_timeout; /**< Configuration parameter to define the timeout between each keepalive packets (default is 15s) */
bool_t forced_relay; /**< Force use of relay by modifying the local and reflexive candidates */
} IceSession;
typedef struct _IceStunServerCheckTransaction {
......@@ -480,6 +481,14 @@ MS2_PUBLIC void ice_session_gather_candidates(IceSession *session, const struct
*/
MS2_PUBLIC int ice_session_gathering_duration(IceSession *session);
/**
* Enable forced relay for tests.
* The local and reflexive candidates are changed so that these paths do not work to force the use of the relay.
* @param session A pointer to a session.
* @param enable A boolean value telling whether to force relay or not.
*/
MS2_PUBLIC void ice_session_enable_forced_relay(IceSession *session, bool_t enable);
/**
* Tell the average round trip time during the gathering process for an ICE session in ms.
*
......
......@@ -1009,6 +1009,11 @@ int ice_session_gathering_duration(IceSession *session)
+ ((session->gathering_end_ts.tv_nsec - session->gathering_start_ts.tv_nsec) / 1000000.0));
}
void ice_session_enable_forced_relay(IceSession *session, bool_t enable)
{
session->forced_relay = enable;
}
static void ice_transaction_sum_gathering_round_trip_time(const IceStunServerCheckTransaction *transaction, StunRequestRoundTripTime *rtt)
{
if ((transaction->response_time.tv_sec != 0) && (transaction->response_time.tv_nsec != 0)) {
......@@ -1278,7 +1283,13 @@ static void ice_send_binding_request(IceCheckList *cl, IceCandidatePair *pair, c
pair->remote->taddr.ip, pair->remote->taddr.port, candidate_type_values[pair->remote->type], tr_id_str);
}
ice_send_message_to_stun_addr(rtptp, buf, len, &dest);
if ((cl->session->forced_relay == TRUE) && (pair->remote->type != ICT_RelayedCandidate)) {
ms_message("ice: Forced relay, did not send binding request for %s pair %p: %s:%u:%s --> %s:%u:%s [%s]", candidate_pair_state_values[pair->state], pair,
pair->local->taddr.ip, pair->local->taddr.port, candidate_type_values[pair->local->type],
pair->remote->taddr.ip, pair->remote->taddr.port, candidate_type_values[pair->remote->type], tr_id_str);
} else {
ice_send_message_to_stun_addr(rtptp, buf, len, &dest);
}
if (pair->state != ICP_InProgress) {
/* First transmission of the request, initialize the retransmission timer. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment