diff --git a/Sources/SwiftNetwork/Path/PathProperties.swift b/Sources/SwiftNetwork/Path/PathProperties.swift index f1fe7ad..e130ba7 100644 --- a/Sources/SwiftNetwork/Path/PathProperties.swift +++ b/Sources/SwiftNetwork/Path/PathProperties.swift @@ -245,6 +245,7 @@ public struct PathProperties: CustomStringConvertible { static public let useLinkHeuristics = Flags(rawValue: 1 << 31) static public let hasOverrideTrafficClass = Flags(rawValue: 1 << 32) static public let fallbackIsOpportunistic = Flags(rawValue: 1 << 33) + static public let hasMigrationInfoFlag = Flags(rawValue: 1 << 34) } /// The link quality measurement of the link-layer network attachment. @@ -361,6 +362,12 @@ public struct PathProperties: CustomStringConvertible { get { flags.contains(.fallbackIsOpportunistic) } set { if newValue { flags.insert(.fallbackIsOpportunistic) } else { flags.remove(.fallbackIsOpportunistic) } } } + #if !(NETWORK_PRIVATE || NETWORK_DRIVERKIT) + var hasMigrationInfo: Bool { + get { flags.contains(.hasMigrationInfoFlag) } + set { if newValue { flags.insert(.hasMigrationInfoFlag) } else { flags.remove(.hasMigrationInfoFlag) } } + } + #endif var fallbackIsForced: Bool { get { flags.contains(.fallbackIsForced) } set { if newValue { flags.insert(.fallbackIsForced) } else { flags.remove(.fallbackIsForced) } } diff --git a/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift b/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift index 1c213b6..0c3f7e3 100644 --- a/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift +++ b/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift @@ -246,6 +246,7 @@ public protocol MultiplexingPath: UpperProtocolHandler { var identifier: MultiplexingPathIdentifier { get } init(parent: ParentProtocol) var pathIsPrimary: Bool { get set } + var pathHasMigrationInfo: Bool { get set } } @_spi(ProtocolProvider) @@ -969,8 +970,13 @@ extension ManyToManyDatapathProtocol where Path.ParentProtocol == Self, Path: In parameters: parameters, path: path ) - if multiplexingPaths.isEmpty { newPath.pathIsPrimary = true } + let isFirstPath = multiplexingPaths.isEmpty + if isFirstPath { newPath.pathIsPrimary = true } + if path?.hasMigrationInfo == true { newPath.pathHasMigrationInfo = true } multiplexingPaths[newPath.identifier] = newPath + if !isFirstPath { + handlePathChanged(path: newPath.identifier, event: .available, isPrimary: newPath.pathIsPrimary) + } } } @@ -2016,6 +2022,7 @@ open class MultiplexingDatagramPath