summaryrefslogtreecommitdiffhomepage
path: root/protocols/luci-proto-vxlan
diff options
context:
space:
mode:
authorWojciech Jowsa <wojciech.jowsa@gmail.com>2020-05-27 09:21:25 +0200
committerJo-Philipp Wich <jo@mein.io>2020-05-27 18:46:18 +0200
commitd79bbdd5b08e2630d2320b82e365c5779b6c7298 (patch)
tree6f9f17dfce5f690b1197b0a7fcc2901ac8a72930 /protocols/luci-proto-vxlan
parentd2dfc522f1e5315fc06a93738483ca8cc3d6f6c1 (diff)
luci-proto-vxlan: add vxlan protol handler
Allow users to add vxlan inteface in luci. Signed-off-by: Wojciech Jowsa <wojciech.jowsa@gmail.com>
Diffstat (limited to 'protocols/luci-proto-vxlan')
-rw-r--r--protocols/luci-proto-vxlan/Makefile16
-rw-r--r--protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan.js84
-rw-r--r--protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan6.js84
3 files changed, 184 insertions, 0 deletions
diff --git a/protocols/luci-proto-vxlan/Makefile b/protocols/luci-proto-vxlan/Makefile
new file mode 100644
index 000000000..d6b2e6faa
--- /dev/null
+++ b/protocols/luci-proto-vxlan/Makefile
@@ -0,0 +1,16 @@
+#
+# Copyright 2020 Wojciech Jowsa <wojciech.jowsa@gmail.com>
+#
+# This is free software, licensed under the Apache License, Version 2.0 .
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=Support for Virtual eXtensible Local Area Network (VXLAN, RFC7348)
+LUCI_DEPENDS:=+vxlan
+
+PKG_MAINTAINER:=Wojciech Jowsa <wojciech.jowsa@gmail.com>
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan.js b/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan.js
new file mode 100644
index 000000000..3a7f8a1d1
--- /dev/null
+++ b/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan.js
@@ -0,0 +1,84 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^vxlan-.+$/);
+
+return network.registerProtocol('vxlan', {
+ getI18n: function() {
+ return _('VXLAN (RFC7348)');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'vxlan-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'vxlan';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ o = s.taboption('general', form.Value, 'remote', _('Remote IPv4 address'), _('The IPv4 address or the fully-qualified domain name of the remote end.'));
+ o.optional = false;
+ o.datatype = 'or(hostname,ip4addr("nomask"))';
+
+ o = s.taboption('general', form.Value, 'local', _('Local IPv4 address'), _('The local IPv4 address over which the tunnel is created (optional).'));
+ o.optional = true;
+ o.datatype = 'ip4addr("nomask")';
+
+ o = s.taboption('general', form.Value, 'id', _('VXLAN network identifier'), _('ID used to uniquely identify the VXLAN'));
+ o.optional = true;
+ o.datatype = 'range(1, 16777216)';
+
+ o = s.taboption('general', widgets.NetworkSelect, 'link', _('Bind interface'), _('Bind the tunnel to this interface (optional).'));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'), _('Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes).'));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _('Override TTL'), _('Specify a TTL (Time to Live) for the encapsulating packet other than the default (64).'));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _('Specify a TOS (Type of Service).'));
+ o.optional = true;
+ o.datatype = 'range(0, 255)';
+
+ o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
+ o.optional = true;
+ o.datatype = 'macaddr';
+
+ o = s.taboption('advanced', form.Flag, 'rxcsum', _('Enable rx checksum'));
+ o.optional = true;
+ o.default = o.enabled;
+
+ o = s.taboption('advanced', form.Flag, 'txcsum', _('Enable tx checksum'));
+ o.optional = true;
+ o.default = o.enabled;
+
+ }
+});
diff --git a/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan6.js b/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan6.js
new file mode 100644
index 000000000..99bbeb369
--- /dev/null
+++ b/protocols/luci-proto-vxlan/htdocs/luci-static/resources/protocol/vxlan6.js
@@ -0,0 +1,84 @@
+'use strict';
+'require form';
+'require network';
+'require tools.widgets as widgets';
+
+network.registerPatternVirtual(/^vxlan-.+$/);
+
+return network.registerProtocol('vxlan6', {
+ getI18n: function() {
+ return _('VXLANv6 (RFC7348)');
+ },
+
+ getIfname: function() {
+ return this._ubus('l3_device') || 'vxlan-%s'.format(this.sid);
+ },
+
+ getOpkgPackage: function() {
+ return 'vxlan';
+ },
+
+ isFloating: function() {
+ return true;
+ },
+
+ isVirtual: function() {
+ return true;
+ },
+
+ getDevices: function() {
+ return null;
+ },
+
+ containsDevice: function(ifname) {
+ return (network.getIfnameOf(ifname) == this.getIfname());
+ },
+
+ renderFormOptions: function(s) {
+ var o;
+
+ o = s.taboption('general', form.Value, 'remote', _('Remote IPv6 address'), _('The IPv6 address or the fully-qualified domain name of the remote end.'));
+ o.optional = false;
+ o.datatype = 'or(hostname,cidr6)';
+
+ o = s.taboption('general', form.Value, 'local', _('Local IPv6 address'), _('The local IPv6 address over which the tunnel is created (optional).'));
+ o.optional = true;
+ o.datatype = 'cidr6';
+
+ o = s.taboption('general', form.Value, 'id', _('VXLAN network identifier'), _('ID used to uniquely identify the VXLAN'));
+ o.optional = true;
+ o.datatype = 'range(1, 16777216)';
+
+ o = s.taboption('general', widgets.NetworkSelect, 'link', _('Bind interface'), _('Bind the tunnel to this interface (optional).'));
+ o.exclude = s.section;
+ o.nocreate = true;
+ o.optional = true;
+
+ o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'), _('Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes).'));
+ o.optional = true;
+ o.placeholder = 1280;
+ o.datatype = 'range(68, 9200)';
+
+ o = s.taboption('advanced', form.Value, 'ttl', _('Override TTL'), _('Specify a TTL (Time to Live) for the encapsulating packet other than the default (64).'));
+ o.optional = true;
+ o.placeholder = 64;
+ o.datatype = 'min(1)';
+
+ o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _('Specify a TOS (Type of Service).'));
+ o.optional = true;
+ o.datatype = 'range(0, 255)';
+
+ o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
+ o.optional = true;
+ o.datatype = 'macaddr';
+
+ o = s.taboption('advanced', form.Flag, 'rxcsum', _('Enable rx checksum'));
+ o.optional = true;
+ o.default = o.enabled;
+
+ o = s.taboption('advanced', form.Flag, 'txcsum', _('Enable tx checksum'));
+ o.optional = true;
+ o.default = o.enabled;
+
+ }
+});