File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // SocketAddress.swift
3+ //
4+ //
5+ // Created by Alsey Coleman Miller on 4/22/22.
6+ //
7+
8+ import Foundation
9+ import SystemPackage
10+
11+ @frozen
12+ public struct NetlinkSocketAddress : Equatable , Hashable , SocketAddress {
13+
14+ public typealias ProtocolID = NetlinkSocketProtocol
15+
16+ public var processID : ProcessID
17+
18+ public var group : CInt
19+
20+ public init (
21+ processID: ProcessID = . current,
22+ group: CInt = 0
23+ ) {
24+ self . processID = processID
25+ self . group = group
26+ }
27+
28+ public func withUnsafePointer< Result> (
29+ _ body: ( UnsafePointer < CInterop . SocketAddress > , UInt32 ) throws -> Result
30+ ) rethrows -> Result {
31+ let address = CInterop . NetlinkSocketAddress (
32+ processID: processID,
33+ group: group
34+ )
35+ return try address. withUnsafePointer ( body)
36+ }
37+
38+ public static func withUnsafePointer(
39+ _ body: ( UnsafeMutablePointer < CInterop . SocketAddress > , UInt32 ) throws -> ( )
40+ ) rethrows -> Self {
41+ var value = CInterop . NetlinkSocketAddress ( )
42+ try value. withUnsafeMutablePointer ( body)
43+ return Self . init (
44+ processID: . init( rawValue: numericCast ( value. nl_pid) ) ,
45+ group: . init( bitPattern: value. nl_groups)
46+ )
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments