Commit e7aaa5dc authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête
Browse files

agent: fix boundary test of max turn servers and local addresses

We can accept up to 8 turn servers, with turn preference value
starting at zero. Also fix the error message.
parent 65fd9663
......@@ -3119,7 +3119,7 @@ nice_agent_gather_candidates (
length = g_slist_length (local_addresses);
if (length > NICE_CANDIDATE_MAX_LOCAL_ADDRESSES) {
nice_debug ("Agent %p : cannot have more than %d local addresses.",
agent, length);
agent, NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
}
for (cid = 1; cid <= stream->n_components; cid++) {
......@@ -3139,7 +3139,7 @@ nice_agent_gather_candidates (
/* generate a local host candidate for each local address */
length = 0;
for (i = local_addresses;
i && length <= NICE_CANDIDATE_MAX_LOCAL_ADDRESSES;
i && length < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES;
i = i->next, length++) {
NiceAddress *addr = i->data;
NiceCandidate *host_candidate;
......
......@@ -147,8 +147,8 @@ nice_candidate_ice_local_preference_full (guint direction_preference,
* 9-12: <unused>
* 13-15: direction_preference
*/
g_assert (other_preference <= NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
g_assert (turn_preference <= NICE_CANDIDATE_MAX_TURN_SERVERS);
g_assert (other_preference < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
g_assert (turn_preference < NICE_CANDIDATE_MAX_TURN_SERVERS);
g_assert (direction_preference < 8);
return (direction_preference << 13) +
......@@ -253,8 +253,8 @@ nice_candidate_ms_ice_local_preference_full (guint transport_preference,
* 9-11: direction_preference
* 12-15: transport_preference
*/
g_assert (other_preference <= NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
g_assert (turn_preference <= NICE_CANDIDATE_MAX_TURN_SERVERS);
g_assert (other_preference < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
g_assert (turn_preference < NICE_CANDIDATE_MAX_TURN_SERVERS);
g_assert (direction_preference < 8);
g_assert (transport_preference < 16);
......
......@@ -86,7 +86,7 @@ G_BEGIN_DECLS
*
* The maximum number of turns servers.
*/
#define NICE_CANDIDATE_MAX_TURN_SERVERS 7
#define NICE_CANDIDATE_MAX_TURN_SERVERS 8
/**
* NICE_CANDIDATE_MAX_LOCAL_ADDRESSES
......@@ -97,7 +97,7 @@ G_BEGIN_DECLS
* @NICE_CANDIDATE_MAX_TURN_SERVERS. We choose 6 bits for the number of
* local addresses, and 3 bits for the number of turn servers.
*/
#define NICE_CANDIDATE_MAX_LOCAL_ADDRESSES 63
#define NICE_CANDIDATE_MAX_LOCAL_ADDRESSES 64
/**
* NiceCandidateType:
......
......@@ -64,7 +64,7 @@ main (void)
g_list_free_full (ips, g_free);
/* test 0 */
g_assert (ip_local_preference <= NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
g_assert (ip_local_preference < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES);
/* test 1 */
g_assert_cmpuint (nice_candidate_jingle_priority (candidate), ==, 1000);
......
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