|
51 | 51 | { |
52 | 52 | void* ptr = NULL; |
53 | 53 |
|
54 | | - if (__builtin_available(macOS 12.3, iOS 15.4, tvOS 15.4, watchOS 8.4, *)) |
55 | | - { |
56 | | - nw_protocol_options_t framer_options = nw_framer_copy_options(framer); |
57 | | - assert(framer_options != NULL); |
| 54 | + nw_protocol_options_t framer_options = nw_framer_copy_options(framer); |
| 55 | + assert(framer_options != NULL); |
58 | 56 |
|
59 | | - NSNumber* num = nw_framer_options_copy_object_value(framer_options, MANAGED_CONTEXT_KEY); |
60 | | - assert(num != NULL); |
61 | | - [num getValue:&ptr]; |
62 | | - [num release]; |
| 57 | + NSNumber* num = nw_framer_options_copy_object_value(framer_options, MANAGED_CONTEXT_KEY); |
| 58 | + assert(num != NULL); |
| 59 | + [num getValue:&ptr]; |
| 60 | + [num release]; |
63 | 61 |
|
64 | | - nw_release(framer_options); |
65 | | - } |
| 62 | + nw_release(framer_options); |
66 | 63 |
|
67 | 64 | return ptr; |
68 | 65 | } |
69 | 66 |
|
70 | 67 | static void FramerOptionsSetManagedContext(nw_protocol_options_t framer_options, void* context) |
71 | 68 | { |
72 | | - if (__builtin_available(macOS 12.3, iOS 15.4, tvOS 15.4.0, watchOS 8.4, *)) |
73 | | - { |
74 | | - NSNumber *ref = [NSNumber numberWithLong:(long)context]; |
75 | | - nw_framer_options_set_object_value(framer_options, MANAGED_CONTEXT_KEY, ref); |
76 | | - [ref release]; |
77 | | - } |
| 69 | + NSNumber *ref = [NSNumber numberWithLong:(long)context]; |
| 70 | + nw_framer_options_set_object_value(framer_options, MANAGED_CONTEXT_KEY, ref); |
| 71 | + [ref release]; |
78 | 72 | } |
79 | 73 |
|
80 | 74 | static tls_protocol_version_t PalSslProtocolToTlsProtocolVersion(PAL_SslProtocol palProtocolId) |
@@ -313,23 +307,17 @@ PALEXPORT nw_connection_t AppleCryptoNative_NwConnectionCreate(int32_t isServer, |
313 | 307 | // This writes encrypted TLS frames to the safe handle. It is executed on NW Thread pool |
314 | 308 | static nw_framer_output_handler_t framer_output_handler = ^(nw_framer_t framer, nw_framer_message_t message, size_t message_length, bool is_complete) |
315 | 309 | { |
316 | | - if (__builtin_available(macOS 12.3, iOS 15.4, tvOS 15.4, watchOS 2.0, *)) |
317 | | - { |
318 | | - void* context = FramerGetManagedContext(framer); |
319 | | - size_t size = message_length; |
| 310 | + void* context = FramerGetManagedContext(framer); |
| 311 | + size_t size = message_length; |
320 | 312 |
|
321 | | - nw_framer_parse_output(framer, 1, message_length, NULL, ^size_t(uint8_t *buffer, size_t buffer_length, bool is_complete2) |
322 | | - { |
323 | | - (_writeFunc)(context, buffer, buffer_length); |
324 | | - (void)is_complete2; |
325 | | - (void)message; |
326 | | - return buffer_length; |
327 | | - }); |
328 | | - } |
329 | | - else |
| 313 | + nw_framer_parse_output(framer, 1, message_length, NULL, ^size_t(uint8_t *buffer, size_t buffer_length, bool is_complete2) |
330 | 314 | { |
331 | | - assert(0); |
332 | | - } |
| 315 | + (_writeFunc)(context, buffer, buffer_length); |
| 316 | + (void)is_complete2; |
| 317 | + (void)message; |
| 318 | + return buffer_length; |
| 319 | + }); |
| 320 | + |
333 | 321 | (void)is_complete; |
334 | 322 | }; |
335 | 323 |
|
@@ -584,23 +572,18 @@ PALEXPORT int32_t AppleCryptoNative_Init(StatusUpdateCallback statusFunc, WriteC |
584 | 572 | assert(statusFunc != NULL); |
585 | 573 | assert(writeFunc != NULL); |
586 | 574 |
|
587 | | - if (__builtin_available(macOS 12.3, iOS 15.4, tvOS 15.4.0, watchOS 8.4, *)) |
588 | | - { |
589 | | - _writeFunc = writeFunc; |
590 | | - _statusFunc = statusFunc; |
591 | | - _challengeFunc = challengeFunc; |
592 | | - _framerDefinition = nw_framer_create_definition("com.dotnet.networkframework.tlsframer", |
593 | | - NW_FRAMER_CREATE_FLAGS_DEFAULT, framer_start); |
594 | | - _tlsDefinition = nw_protocol_copy_tls_definition(); |
595 | | - _tlsQueue = dispatch_queue_create("com.dotnet.networkframework.tlsqueue", NULL); |
596 | | - _inputQueue = _tlsQueue; |
597 | | - |
598 | | - // The endpoint values (127.0.0.1:42) are arbitrary - they just need to be |
599 | | - // syntactically and semantically valid since the connection is never established. |
600 | | - _endpoint = nw_endpoint_create_host("127.0.0.1", "42"); |
601 | | - |
602 | | - return 0; |
603 | | - } |
604 | | - |
605 | | - return 1; |
| 575 | + _writeFunc = writeFunc; |
| 576 | + _statusFunc = statusFunc; |
| 577 | + _challengeFunc = challengeFunc; |
| 578 | + _framerDefinition = nw_framer_create_definition("com.dotnet.networkframework.tlsframer", |
| 579 | + NW_FRAMER_CREATE_FLAGS_DEFAULT, framer_start); |
| 580 | + _tlsDefinition = nw_protocol_copy_tls_definition(); |
| 581 | + _tlsQueue = dispatch_queue_create("com.dotnet.networkframework.tlsqueue", NULL); |
| 582 | + _inputQueue = _tlsQueue; |
| 583 | + |
| 584 | + // The endpoint values (127.0.0.1:42) are arbitrary - they just need to be |
| 585 | + // syntactically and semantically valid since the connection is never established. |
| 586 | + _endpoint = nw_endpoint_create_host("127.0.0.1", "42"); |
| 587 | + |
| 588 | + return 0; |
606 | 589 | } |
0 commit comments