diff --git a/Sources/SwiftNetwork/Path/PathProperties.swift b/Sources/SwiftNetwork/Path/PathProperties.swift index 086500b..dafbeb9 100644 --- a/Sources/SwiftNetwork/Path/PathProperties.swift +++ b/Sources/SwiftNetwork/Path/PathProperties.swift @@ -242,6 +242,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. @@ -358,6 +359,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 735b6e2..12c6dd0 100644 --- a/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift +++ b/Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift @@ -240,6 +240,7 @@ public protocol MultiplexingPath: UpperProtocolHandler { var identifier: MultiplexingPathIdentifier { get } init(parent: ParentProtocol) var pathIsPrimary: Bool { get set } + var pathHasMigrationInfo: Bool { get set } } @_spi(ProtocolProvider) @@ -932,8 +933,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) + } } } @@ -1953,6 +1959,7 @@ open class MultiplexingDatagramPath