Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/platform/datapath_raw_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,33 @@ RawSocketCreateUdp(
memcpy(Socket->CibirId, Config->CibirId, Config->CibirIdLength);
}

//
// The socket addresses have been set in the SocketCreateUdp call earlier,
// either form the config or assigned by the OS (for unspecified ports).
// Do no override them from the config here: we need to keep the same OS assigned ports if the
// config doesn't specify them.
//
CXPLAT_DBG_ASSERT(
Config->RemoteAddress == NULL ||
QuicAddrCompare(&Socket->RemoteAddress, Config->RemoteAddress));
CXPLAT_DBG_ASSERT(
Config->LocalAddress == NULL ||
QuicAddrGetPort(Config->LocalAddress) == 0 ||
QuicAddrGetPort(&Socket->LocalAddress) == QuicAddrGetPort(Config->LocalAddress));

if (Config->RemoteAddress) {
//
// This CxPlatSocket is part of a client connection.
//
CXPLAT_FRE_ASSERT(!QuicAddrIsWildCard(Config->RemoteAddress)); // No wildcard remote addresses allowed.
if (Socket->ReserveAuxTcpSock) {
Socket->RemoteAddress = *Config->RemoteAddress;
if (Config->LocalAddress != NULL) {
Socket->LocalAddress = *Config->LocalAddress;
} else {
QuicAddrSetFamily(&Socket->LocalAddress, QUIC_ADDRESS_FAMILY_INET6);
}
}

Socket->Connected = TRUE;
} else {
//
// This CxPlatSocket is part of a server listener.
//
CXPLAT_FRE_ASSERT(Config->LocalAddress != NULL);
if (Socket->ReserveAuxTcpSock) {
Socket->LocalAddress = *Config->LocalAddress;
}

if (!QuicAddrIsWildCard(Config->LocalAddress)) { // For server listeners, the local address MUST be a wildcard address.
Status = QUIC_STATUS_INVALID_STATE;
goto Error;
Expand Down
Loading