summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2019-12-13 15:44:22 +0100
committerMichael Brown2019-12-13 15:44:22 +0100
commit53af9905e023c89c9d7c30c22eb25f2b0105026c (patch)
treed9b71e05c4aa0f0b82de5cecbc31ac8c519c9fc2
parent[lan78xx] Always enable automatic speed and duplex detection (diff)
downloadipxe-53af9905e023c89c9d7c30c22eb25f2b0105026c.tar.gz
ipxe-53af9905e023c89c9d7c30c22eb25f2b0105026c.tar.xz
ipxe-53af9905e023c89c9d7c30c22eb25f2b0105026c.zip
[peerdist] Allow PeerDist to be globally enabled or disabled
Allow the use of PeerDist content encoding to be enabled or disabled via the ${peerdist} setting, e.g.: # Disable PeerDist set peerdist 0 Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/net/peerdist.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/net/peerdist.c b/src/net/peerdist.c
index 48933f95..3210ac0e 100644
--- a/src/net/peerdist.c
+++ b/src/net/peerdist.c
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdio.h>
#include <ipxe/http.h>
+#include <ipxe/settings.h>
#include <ipxe/peermux.h>
/** @file
@@ -35,6 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* misfortune to encounter, and I've encountered multicast TFTP.
*/
+/** PeerDist is globally enabled */
+static long peerdist_enabled = 1;
+
/**
* Check whether or not to support PeerDist encoding for this request
*
@@ -43,6 +47,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
static int http_peerdist_supported ( struct http_transaction *http ) {
+ /* Allow PeerDist to be globally enabled/disabled */
+ if ( ! peerdist_enabled )
+ return 0;
+
/* Support PeerDist encoding only if we can directly access an
* underlying data transfer buffer. Direct access is required
* in order to support decryption of data received via the
@@ -143,3 +151,33 @@ struct http_content_encoding peerdist_encoding __http_content_encoding = {
.supported = http_peerdist_supported,
.init = http_peerdist_init,
};
+
+/** PeerDist enabled setting */
+const struct setting peerdist_setting __setting ( SETTING_MISC, peerdist ) = {
+ .name = "peerdist",
+ .description = "PeerDist enabled",
+ .type = &setting_type_int8,
+};
+
+/**
+ * Apply PeerDist settings
+ *
+ * @ret rc Return status code
+ */
+static int apply_peerdist_settings ( void ) {
+
+ /* Fetch global PeerDist enabled setting */
+ if ( fetch_int_setting ( NULL, &peerdist_setting,
+ &peerdist_enabled ) < 0 ) {
+ peerdist_enabled = 1;
+ }
+ DBGC ( &peerdist_enabled, "PEERDIST is %s\n",
+ ( peerdist_enabled ? "enabled" : "disabled" ) );
+
+ return 0;
+}
+
+/** PeerDist settings applicator */
+struct settings_applicator peerdist_applicator __settings_applicator = {
+ .apply = apply_peerdist_settings,
+};