| 2481 | }; |
| 2482 | |
| 2483 | Future<Reference<IUDPSocket>> Sim2::createUDPSocket(NetworkAddress toAddr) { |
| 2484 | NetworkAddress localAddress; |
| 2485 | auto process = g_simulator.getCurrentProcess(); |
| 2486 | if (process->address.ip.isV6()) { |
| 2487 | IPAddress::IPAddressStore store = process->address.ip.toV6(); |
| 2488 | uint16_t* ipParts = (uint16_t*)store.data(); |
| 2489 | ipParts[7] += deterministicRandom()->randomInt(0, 256); |
| 2490 | localAddress.ip = IPAddress(store); |
| 2491 | } else { |
| 2492 | localAddress.ip = IPAddress(process->address.ip.toV4() + deterministicRandom()->randomInt(0, 256)); |
| 2493 | } |
| 2494 | localAddress.port = deterministicRandom()->randomInt(40000, 60000); |
| 2495 | while (process->boundUDPSockets.find(localAddress) != process->boundUDPSockets.end()) { |
| 2496 | localAddress.port = deterministicRandom()->randomInt(40000, 60000); |
| 2497 | } |
| 2498 | return Reference<IUDPSocket>(new UDPSimSocket(localAddress, toAddr)); |
| 2499 | } |
| 2500 | |
| 2501 | Future<Reference<IUDPSocket>> Sim2::createUDPSocket(bool isV6) { |
| 2502 | NetworkAddress localAddress; |
no test coverage detected