blob: 0da7f7a3f06465468fc0fc055c459eef9717bc7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
//
// PingerProtocol.swift
// PacketTunnelCore
//
// Created by pronebird on 10/08/2023.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
import Network
/// The result of processing ICMP reply.
public enum PingerReply {
/// ICMP reply was successfully parsed.
case success(_ sender: IPAddress, _ sequenceNumber: UInt16)
/// ICMP reply couldn't be parsed.
case parseError(Error)
}
/// The result of sending ICMP echo.
public struct PingerSendResult {
/// Sequence id.
public var sequenceNumber: UInt16
public init(sequenceNumber: UInt16) {
self.sequenceNumber = sequenceNumber
}
}
/// A type capable of sending and receving ICMP traffic.
public protocol PingerProtocol: Sendable {
var onReply: ((PingerReply) -> Void)? { get set }
func startPinging(destAddress: IPv4Address) throws
func stopPinging()
func send() throws -> PingerSendResult
}
|