improvements for ipv6#703
Conversation
|
Have confirmation from ZD Ticket that this change is working as expected. |
| inet_ntop(AF_INET, | ||
| #ifdef TEST_IPV6 | ||
| &clientAddr.sin6_addr, | ||
| inet_ntop(AF_INET, &clientAddr.sin6_addr, conn->ip, |
There was a problem hiding this comment.
This doesn't actually work. inet_ntop() is going to take the first 32-bits of sin6_addr and turn it into a dotted-quad string.
|
|
||
|
|
||
| static INLINE void tcp_socket(WS_SOCKET_T* sockFd) | ||
| static INLINE void tcp_socket(WS_SOCKET_T* sockFd, int specifyProtocol, int targetProtocol) |
There was a problem hiding this comment.
Can we make this a little smarter? Maybe have tcp_socket() and tcp6_socket() that call a utility function?
| build_addr(&clientAddr, config.hostname, config.port); | ||
| tcp_socket(&sockFd); | ||
| tcp_socket(&sockFd, 1, | ||
| #ifdef TEST_IPV6 |
There was a problem hiding this comment.
These checks are really awkward. TEST_IPV6 is meant to force the example tools to use IPV6 for testing. It was a quick-and-dirty way to support IPv6. In general, we shouldn't need checks like this. Information about the IP address type are kept with the IP address. (clientAddr.sin_family)
There was a problem hiding this comment.
I'm not sure how to make it less awkward. Since we have the typedef for SOCKADDR_IN_T , the check of the member will need this macro wrap. (clientAddr.sin_family vs. clientAddr.sin6_family).
| #else | ||
| SOCKADDR_IN_T clientAddr; | ||
| socklen_t clientAddrSz = sizeof(clientAddr); | ||
| struct sockaddr_in6 clientAddr; |
There was a problem hiding this comment.
Is there a reason we don't have all this wrapped with TEST_IPV6 and use SOCKADDR_IN_T in the non IPv6 case? I noticed a bit of a mess between the examples for the IPv4 and IPv6 support.
There was a problem hiding this comment.
Already discussed internally. No need for changes. Back to @dgarske.
There was a problem hiding this comment.
The sshd will always support IPv6
Fixes ZD18053