| 166 | } |
| 167 | |
| 168 | inline bool CrcMatches(ui32 pktCrc, ui32 crc, const sockaddr_in6& addr) { |
| 169 | Y_ASSERT(LocalHostFound); |
| 170 | Y_ASSERT(addr.sin6_family == AF_INET6); |
| 171 | // determine our ip address family based on the sender address |
| 172 | // address family can not change in network, so sender address type determines type of our address used |
| 173 | const ui64* addr64 = (const ui64*)addr.sin6_addr.s6_addr; |
| 174 | const ui32* addr32 = (const ui32*)addr.sin6_addr.s6_addr; |
| 175 | yint ipType; |
| 176 | if (addr64[0] == 0 && addr32[2] == 0xffff0000ll) { |
| 177 | // ipv4 |
| 178 | ipType = IPv4; |
| 179 | } else { |
| 180 | // ipv6 |
| 181 | ipType = IPv6; |
| 182 | } |
| 183 | if (crc + LocalHostIP[ipType] == pktCrc) { |
| 184 | return true; |
| 185 | } |
| 186 | // crc failed |
| 187 | // check if packet was sent to different IP address |
| 188 | for (int idx = 0; idx < LocalHostIPList[ipType].ysize(); ++idx) { |
| 189 | ui32 otherIP = LocalHostIPList[ipType][idx]; |
| 190 | if (crc + otherIP == pktCrc) { |
| 191 | LocalHostIP[ipType] = otherIP; |
| 192 | return true; |
| 193 | } |
| 194 | } |
| 195 | // crc is really failed, discard packet |
| 196 | return false; |
| 197 | } |
| 198 | |
| 199 | bool TNetSocket::RecvFrom(char* buf, int* size, sockaddr_in6* fromAddress) const { |
| 200 | for (;;) { |
no test coverage detected