From 68f0721c6a1aea6bb97320ec0cf6b8f7f723603d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 3 Mar 2019 05:20:13 +0100 Subject: tun: import mobile particularities --- device/queueconstants.go | 16 ---------------- device/queueconstants_android.go | 16 ++++++++++++++++ device/queueconstants_default.go | 16 ++++++++++++++++ device/queueconstants_ios.go | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+), 16 deletions(-) delete mode 100644 device/queueconstants.go create mode 100644 device/queueconstants_android.go create mode 100644 device/queueconstants_default.go create mode 100644 device/queueconstants_ios.go (limited to 'device') diff --git a/device/queueconstants.go b/device/queueconstants.go deleted file mode 100644 index 3e94b7f..0000000 --- a/device/queueconstants.go +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: MIT - * - * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved. - */ - -package device - -/* Implementation specific constants */ - -const ( - QueueOutboundSize = 1024 - QueueInboundSize = 1024 - QueueHandshakeSize = 1024 - MaxSegmentSize = (1 << 16) - 1 // largest possible UDP datagram - PreallocatedBuffersPerPool = 0 // Disable and allow for infinite memory growth -) diff --git a/device/queueconstants_android.go b/device/queueconstants_android.go new file mode 100644 index 0000000..8d051ad --- /dev/null +++ b/device/queueconstants_android.go @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved. + */ + +package device + +/* Reduce memory consumption for Android */ + +const ( + QueueOutboundSize = 1024 + QueueInboundSize = 1024 + QueueHandshakeSize = 1024 + MaxSegmentSize = 2200 + PreallocatedBuffersPerPool = 4096 +) \ No newline at end of file diff --git a/device/queueconstants_default.go b/device/queueconstants_default.go new file mode 100644 index 0000000..cf86ba1 --- /dev/null +++ b/device/queueconstants_default.go @@ -0,0 +1,16 @@ +// +build !android,!ios + +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved. + */ + +package device + +const ( + QueueOutboundSize = 1024 + QueueInboundSize = 1024 + QueueHandshakeSize = 1024 + MaxSegmentSize = (1 << 16) - 1 // largest possible UDP datagram + PreallocatedBuffersPerPool = 0 // Disable and allow for infinite memory growth +) diff --git a/device/queueconstants_ios.go b/device/queueconstants_ios.go new file mode 100644 index 0000000..589b0aa --- /dev/null +++ b/device/queueconstants_ios.go @@ -0,0 +1,18 @@ +// +build ios + +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved. + */ + +package device + +/* Fit within memory limits for iOS's Network Extension API, which has stricter requirements */ + +const ( + QueueOutboundSize = 1024 + QueueInboundSize = 1024 + QueueHandshakeSize = 1024 + MaxSegmentSize = 1700 + PreallocatedBuffersPerPool = 1024 +) -- cgit v1.2.3