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

Add IPv6 support for host candidates #382

Merged
merged 3 commits into from
Apr 28, 2020
Merged

Conversation

lherman-cs
Copy link
Contributor

@lherman-cs lherman-cs commented Apr 23, 2020

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-io
Copy link

codecov-io commented Apr 24, 2020

Codecov Report

Merging #382 into master will decrease coverage by 33.34%.
The diff coverage is 57.44%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #382       +/-   ##
===========================================
- Coverage   87.07%   53.73%   -33.35%     
===========================================
  Files          33       33               
  Lines        8265     8267        +2     
===========================================
- Hits         7197     4442     -2755     
- Misses       1068     3825     +2757     
Impacted Files Coverage Δ
src/source/Ice/IceUtils.c 95.49% <ø> (-1.43%) ⬇️
src/source/Ice/IceAgent.c 81.50% <56.81%> (-13.21%) ⬇️
src/source/Ice/Network.c 72.85% <66.66%> (-3.79%) ⬇️
src/source/Ice/TurnConnection.c 0.00% <0.00%> (-90.23%) ⬇️
src/source/Signaling/ChannelInfo.c 0.00% <0.00%> (-88.49%) ⬇️
src/source/Signaling/LwsApiCalls.c 1.55% <0.00%> (-83.02%) ⬇️
src/source/Signaling/Signaling.c 14.73% <0.00%> (-80.57%) ⬇️
src/source/Rtp/Codecs/RtpVP8Payloader.c 0.00% <0.00%> (-80.00%) ⬇️
src/source/Signaling/StateMachine.c 0.00% <0.00%> (-75.13%) ⬇️
src/source/PeerConnection/Rtp.c 30.40% <0.00%> (-43.25%) ⬇️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a33d542...68ffd29. Read the comment docs.

Copy link
Contributor

@MushMal MushMal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@@ -256,12 +256,15 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
PCHAR curr, tail, next;
UINT32 tokenLen, portValue, remoteCandidateCount, i;
BOOL foundIpAndPort = FALSE, freeIceCandidateIfFail = TRUE;
BOOL foundIp6 = FALSE;
CHAR ip6Buf[KVS_MAX_IPV6_ADDRESS_STRING_LEN+1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to setup some editor auto-formatting preferences. In this case, the '+' sign should have spaces around it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use KVS_IP_ADDRESS_STRING_BUFFER_LEN instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a standard format config? Something like .clang-format?

Ah, didn't realize that we have KVS_IP_ADDRESS_STRING_BUFFER_LEN. I'll update it. Thanks.

KvsIpAddress candidateIpAddr;

CHK(pIceAgent != NULL && pIceCandidateString != NULL, STATUS_NULL_ARG);
CHK(!IS_EMPTY_STRING(pIceCandidateString), STATUS_INVALID_ARG);

MEMSET(&candidateIpAddr, 0x00, SIZEOF(KvsIpAddress));
MEMSET(ip6Buf, 0x00, KVS_MAX_IPV6_ADDRESS_STRING_LEN+1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. I won't add comments about the formatting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use SIZEOF(ip6Buf) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, makes sense.

} else if (STRNCHR(curr, tokenLen, '.') != NULL) {
CHK(tokenLen <= KVS_MAX_IPV4_ADDRESS_STRING_LEN, STATUS_ICE_CANDIDATE_STRING_INVALID_IP); // IPv4 is 15 characters at most
CHK_STATUS(populateIpFromString(&candidateIpAddr, curr));
} else {
STRNCPY(ip6Buf, curr, KVS_MAX_IPV6_ADDRESS_STRING_LEN);
foundIp6 = inet_pton(AF_INET6, ip6Buf, candidateIpAddr.address) == 1 ? TRUE : FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually Windows supported.

}

curr = next + 1;
foundIpAndPort = (candidateIpAddr.port != 0) && (candidateIpAddr.address[0] != 0);
foundIpAndPort = (candidateIpAddr.port != 0) && ((candidateIpAddr.address[0] != 0) || foundIp6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I am not following the logic correctly. KvsIpAddress can hold both IPv4 and IPv6 addresses. The inners of the while loop should set this param and you can check this param only. Also, consult with Felix, I am not sure why the check is against 0s. Can't the first byte of the address be 0 and the port be 0? I think an explicit 'found' boolean should be a good sentinel rather than checking for zeroed values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've discussed this offline with @chehefen. He didn't write this part. But, we agreed that it makes more sense to have a boolean to check this instead. So, I'll update the PR to use a boolean instead.

@@ -1047,6 +1055,9 @@ STATUS iceAgentSendSrflxCandidateRequest(PIceAgent pIceAgent)
switch(pCandidate->iceCandidateType) {
case ICE_CANDIDATE_TYPE_SERVER_REFLEXIVE:
pIceServer = &(pIceAgent->iceServers[pCandidate->iceServerIndex]);
if (pIceServer->ipAddress.family != pCandidate->ipAddress.family) {
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are trying to minimize the usage of the control flow keywords such as break and continue. It's not a good coding style to use break within a switch all together. Use the negation of the boolean predicate here

if (family == other) {
// do the stuff
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I'll update it.

@@ -1324,7 +1335,9 @@ STATUS iceAgentInitSrflxCandidate(PIceAgent pIceAgent)
pCurNode = pCurNode->pNext;
pCandidate = (PIceCandidate) data;

if (pCandidate->iceCandidateType == ICE_CANDIDATE_TYPE_HOST) {
// TODO: Stop skipping IPv6. Stun serialization and deserialization needs to be implemented properly first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a GitHub issue tracking this work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1402,8 +1415,15 @@ STATUS iceAgentInitRelayCandidate(PIceAgent pIceAgent)
pSocketAddrForTurn = NULL;
// if an VPN interface (isPointToPoint is TRUE) is found, use that instead
for(i = 0; i < pIceAgent->localNetworkInterfaceCount; ++i) {
if(pIceAgent->localNetworkInterfaces[i].family == pIceAgent->iceServers[j].ipAddress.family &&
(pSocketAddrForTurn == NULL || pIceAgent->localNetworkInterfaces[i].isPointToPoint)) {
// TODO: Stop skipping IPv6. Stun serialization and deserialization needs to be implemented properly first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about GitHub issue tracking it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@lherman-cs lherman-cs merged commit db511e1 into awslabs:master Apr 28, 2020
@lherman-cs lherman-cs deleted the ipv6 branch April 28, 2020 12:42
@lherman-cs lherman-cs mentioned this pull request May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants