mirror of
https://github.com/coolsnowwolf/luci
synced 2025-01-09 04:57:28 +08:00
luci-proto-vxlan: add new package (#95)
Co-authored-by: gaosen <gaosen@tuya.com>
This commit is contained in:
parent
712e201c49
commit
8aed181ec3
7
protocols/luci-proto-vxlan/Makefile
Normal file
7
protocols/luci-proto-vxlan/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Support for Virtual eXtensible Local Area Network (VXLAN, RFC7348)
|
||||
LUCI_DEPENDS:=+vxlan
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include ../../luci.mk
|
@ -0,0 +1,47 @@
|
||||
|
||||
local map, section, net = ...
|
||||
|
||||
local peeraddr, ipaddr, port, vid, tunlink, mtu, ttl, tos, rxcsum, txcsum
|
||||
|
||||
peeraddr = section:taboption("general", Value, "peeraddr", translate("Remote IPv4 address or FQDN"), translate("The IPv4 address or the fully-qualified domain name of the remote tunnel end."))
|
||||
peeraddr.optional = false
|
||||
peeraddr.datatype = "or(hostname,ip4addr)"
|
||||
|
||||
ipaddr = section:taboption("general", Value, "ipaddr", translate("Local IPv4 address"), translate("The local IPv4 address over which the tunnel is created (optional)."))
|
||||
ipaddr.optional = true
|
||||
ipaddr.datatype = "ip4addr"
|
||||
|
||||
port = section:taboption("general", Value, "port", translate("Destination port"))
|
||||
port.optional = true
|
||||
port.placeholder = 4789
|
||||
port.datatype = "port"
|
||||
|
||||
vid = section:taboption("general", Value, "vid", translate("VXLAN network identifier"), translate("ID used to uniquely identify the VXLAN"))
|
||||
vid.optional = true
|
||||
vid.datatype = 'range(1, 16777216)'
|
||||
|
||||
tunlink = section:taboption("general", Value, "tunlink", translate("Bind interface"), translate("Bind the tunnel to this interface (optional)."))
|
||||
tunlink.optional = true
|
||||
|
||||
|
||||
mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"), translate("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes)."))
|
||||
mtu.optional = true
|
||||
mtu.placeholder = 1280
|
||||
mtu.datatype = "range(68, 9200)"
|
||||
|
||||
ttl = section:taboption("advanced", Value, "ttl", translate("Override TTL"), translate("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64)."))
|
||||
ttl.optional = true
|
||||
ttl.placeholder = 64
|
||||
ttl.datatype = "min(1)"
|
||||
|
||||
tos = section:taboption("advanced", Value, "tos", translate("Override TOS"), translate("Specify a TOS (Type of Service)."))
|
||||
tos.optional = true
|
||||
tos.datatype = "range(0, 255)"
|
||||
|
||||
rxcsum = section:taboption("advanced", Flag, "rxcsum", translate("Enable rx checksum"))
|
||||
rxcsum.optional = true
|
||||
rxcsum.default = rxcsum.enabled
|
||||
|
||||
txcsum = section:taboption("advanced", Flag, "txcsum", translate("Enable tx checksum"))
|
||||
txcsum.optional = true
|
||||
txcsum.default = txcsum.enabled
|
@ -0,0 +1,47 @@
|
||||
|
||||
local map, section, net = ...
|
||||
|
||||
local peer6addr, ip6addr, port, vid, tunlink, mtu, ttl, tos, rxcsum, txcsum
|
||||
|
||||
peer6addr = section:taboption("general", Value, "peer6addr", translate("Remote IPv6 address or FQDN"), translate("The IPv6 address or the fully-qualified domain name of the remote end."))
|
||||
peer6addr.optional = false
|
||||
peer6addr.datatype = "or(hostname,cidr6)"
|
||||
|
||||
ip6addr = section:taboption("general", Value, "ip6addr", translate("Local IPv6 address"), translate("The local IPv6 address over which the tunnel is created (optional)."))
|
||||
ip6addr.optional = true
|
||||
ip6addr.datatype = "cidr6"
|
||||
|
||||
port = section:taboption("general", Value, "port", translate("Destination port"))
|
||||
port.optional = true
|
||||
port.placeholder = 4789
|
||||
port.datatype = "port"
|
||||
|
||||
vid = section:taboption("general", Value, "vid", translate("VXLAN network identifier"), translate("ID used to uniquely identify the VXLAN"))
|
||||
vid.optional = true
|
||||
vid.datatype = 'range(1, 16777216)'
|
||||
|
||||
tunlink = section:taboption("general", Value, "tunlink", translate("Bind interface"), translate("Bind the tunnel to this interface (optional)."))
|
||||
tunlink.optional = true
|
||||
|
||||
|
||||
mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"), translate("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes)."))
|
||||
mtu.optional = true
|
||||
mtu.placeholder = 1280
|
||||
mtu.datatype = "range(68, 9200)"
|
||||
|
||||
ttl = section:taboption("advanced", Value, "ttl", translate("Override TTL"), translate("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64)."))
|
||||
ttl.optional = true
|
||||
ttl.placeholder = 64
|
||||
ttl.datatype = "min(1)"
|
||||
|
||||
tos = section:taboption("advanced", Value, "tos", translate("Override TOS"), translate("Specify a TOS (Type of Service)."))
|
||||
tos.optional = true
|
||||
tos.datatype = "range(0, 255)"
|
||||
|
||||
rxcsum = section:taboption("advanced", Flag, "rxcsum", translate("Enable rx checksum"))
|
||||
rxcsum.optional = true
|
||||
rxcsum.default = rxcsum.enabled
|
||||
|
||||
txcsum = section:taboption("advanced", Flag, "txcsum", translate("Enable tx checksum"))
|
||||
txcsum.optional = true
|
||||
txcsum.default = txcsum.enabled
|
@ -0,0 +1,38 @@
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("vxlan")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("VXLAN (RFC7348)")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "vxlan-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "vxlan"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/vxlan.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^vxlan%-%w")
|
@ -0,0 +1,38 @@
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("vxlan6")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("VXLANv6 (RFC7348)")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "vxlan-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "vxlan"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/vxlan.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^vxlan%-%w")
|
Loading…
Reference in New Issue
Block a user