-
Notifications
You must be signed in to change notification settings - Fork 313
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
Conversation
e6aa068
to
1fcb008
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
0b2c49a
to
83b4492
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
src/source/Ice/IceAgent.c
Outdated
@@ -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]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/source/Ice/IceAgent.c
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use SIZEOF(ip6Buf) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, makes sense.
src/source/Ice/IceAgent.c
Outdated
} 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; |
There was a problem hiding this comment.
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.
src/source/Ice/IceAgent.c
Outdated
} | ||
|
||
curr = next + 1; | ||
foundIpAndPort = (candidateIpAddr.port != 0) && (candidateIpAddr.address[0] != 0); | ||
foundIpAndPort = (candidateIpAddr.port != 0) && ((candidateIpAddr.address[0] != 0) || foundIp6); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/source/Ice/IceAgent.c
Outdated
@@ -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; |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
Issue IPv6 Support #115
Description of changes:
iceAgentAddRemoteCandidate
Todo:
getIpWithHostName
to usegetaddrinfo
instead ofgethostbyname
sincegethostbyname
doesn't support IPv6 (Update getIpWithHostName to use getaddrinfo instead of gethostbyname #395)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.