Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log ice candidate protocol appropriately #1230

Merged
merged 3 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: true
branches:
only:
- master
- develop

cache:
- directories:
Expand Down
41 changes: 21 additions & 20 deletions src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
PDoubleListNode pCurNode = NULL;
SDP_ICE_CANDIDATE_PARSER_STATE state;
ICE_CANDIDATE_TYPE iceCandidateType = ICE_CANDIDATE_TYPE_HOST;
CHAR remoteProtocol[MAX_PROTOCOL_LENGTH] = {'\0'};

CHK(pIceAgent != NULL && pIceCandidateString != NULL, STATUS_NULL_ARG);
CHK(!IS_EMPTY_STRING(pIceCandidateString), STATUS_INVALID_ARG);
Expand Down Expand Up @@ -354,6 +355,9 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
STRTOUI32(curr, next, 10, &priority);
break;
case SDP_ICE_CANDIDATE_PARSER_STATE_PROTOCOL:
if(tokenLen < MAX_PROTOCOL_LENGTH) {
STRNCPY(remoteProtocol, curr, tokenLen);
}
CHK(STRNCMPI("tcp", curr, tokenLen) != 0, STATUS_ICE_CANDIDATE_STRING_IS_TCP);
break;
case SDP_ICE_CANDIDATE_PARSER_STATE_IP:
Expand Down Expand Up @@ -411,11 +415,12 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
pIceCandidate->state = ICE_CANDIDATE_STATE_VALID;
pIceCandidate->priority = priority;
pIceCandidate->iceCandidateType = iceCandidateType;
STRNCPY(pIceCandidate->remoteProtocol, remoteProtocol, SIZEOF(remoteProtocol));

CHK_STATUS(doubleListInsertItemHead(pIceAgent->remoteCandidates, (UINT64) pIceCandidate));
freeIceCandidateIfFail = FALSE;

CHK_STATUS(createIceCandidatePairs(pIceAgent, pIceCandidate, TRUE));

iceAgentLogNewCandidate(pIceCandidate);

/* pass remote candidate to each turnConnection */
Expand All @@ -430,7 +435,6 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
}

CleanUp:

if (locked) {
MUTEX_UNLOCK(pIceAgent->lock);
}
Expand Down Expand Up @@ -2631,27 +2635,24 @@ VOID iceAgentLogNewCandidate(PIceCandidate pIceCandidate)
{
CHAR ipAddr[KVS_IP_ADDRESS_STRING_BUFFER_LEN];
PCHAR protocol = "UNKNOWN";

if (pIceCandidate != NULL) {
getIpAddrStr(&pIceCandidate->ipAddress, ipAddr, ARRAY_SIZE(ipAddr));
if (pIceCandidate->iceCandidateType == ICE_CANDIDATE_TYPE_RELAYED) {
if (pIceCandidate->pTurnConnection == NULL) {
protocol = "NA";
} else {
switch (pIceCandidate->pTurnConnection->protocol) {
case KVS_SOCKET_PROTOCOL_TCP:
protocol = "TCP";
break;
case KVS_SOCKET_PROTOCOL_UDP:
protocol = "UDP";
break;
case KVS_SOCKET_PROTOCOL_NONE:
protocol = "NONE";
break;
default:
break;
}
if (!pIceCandidate->isRemote && pIceCandidate->pSocketConnection != NULL) {
switch (pIceCandidate->pSocketConnection->protocol) {
case KVS_SOCKET_PROTOCOL_TCP:
protocol = "tcp";
break;
case KVS_SOCKET_PROTOCOL_UDP:
protocol = "udp";
break;
case KVS_SOCKET_PROTOCOL_NONE:
protocol = "none";
break;
default:
break;
}
} else {
protocol = pIceCandidate->remoteProtocol;
}

DLOGD("New %s ice candidate discovered. Id: %s. Ip: %s:%u. Type: %s. Protocol: %s.", pIceCandidate->isRemote ? "remote" : "local",
Expand Down
1 change: 1 addition & 0 deletions src/source/Ice/IceAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ typedef struct {
* has been reported through IceNewLocalCandidateFunc */
BOOL reported;
CHAR id[ICE_CANDIDATE_ID_LEN + 1];
CHAR remoteProtocol[MAX_PROTOCOL_LENGTH];
} IceCandidate, *PIceCandidate;

typedef struct {
Expand Down