luci-proto-vxlan: add vxlan protol handler
[oweals/luci.git] / protocols / luci-proto-vxlan / htdocs / luci-static / resources / protocol / vxlan6.js
1 'use strict';
2 'require form';
3 'require network';
4 'require tools.widgets as widgets';
5
6 network.registerPatternVirtual(/^vxlan-.+$/);
7
8 return network.registerProtocol('vxlan6', {
9         getI18n: function() {
10                 return _('VXLANv6 (RFC7348)');
11         },
12
13         getIfname: function() {
14                 return this._ubus('l3_device') || 'vxlan-%s'.format(this.sid);
15         },
16
17         getOpkgPackage: function() {
18                 return 'vxlan';
19         },
20
21         isFloating: function() {
22                 return true;
23         },
24
25         isVirtual: function() {
26                 return true;
27         },
28
29         getDevices: function() {
30                 return null;
31         },
32
33         containsDevice: function(ifname) {
34                 return (network.getIfnameOf(ifname) == this.getIfname());
35         },
36
37         renderFormOptions: function(s) {
38                 var o;
39
40                 o = s.taboption('general', form.Value, 'remote', _('Remote IPv6 address'), _('The IPv6 address or the fully-qualified domain name of the remote end.'));
41                 o.optional = false;
42                 o.datatype = 'or(hostname,cidr6)';
43
44                 o = s.taboption('general', form.Value, 'local', _('Local IPv6 address'), _('The local IPv6 address over which the tunnel is created (optional).'));
45                 o.optional = true;
46                 o.datatype = 'cidr6';
47
48                 o = s.taboption('general', form.Value, 'id', _('VXLAN network identifier'), _('ID used to uniquely identify the VXLAN'));
49                 o.optional = true;
50                 o.datatype = 'range(1, 16777216)';
51
52                 o = s.taboption('general', widgets.NetworkSelect, 'link', _('Bind interface'), _('Bind the tunnel to this interface (optional).'));
53                 o.exclude = s.section;
54                 o.nocreate = true;
55                 o.optional = true;
56
57                 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'), _('Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes).'));
58                 o.optional = true;
59                 o.placeholder = 1280;
60                 o.datatype = 'range(68, 9200)';
61
62                 o = s.taboption('advanced', form.Value, 'ttl', _('Override TTL'), _('Specify a TTL (Time to Live) for the encapsulating packet other than the default (64).'));
63                 o.optional = true;
64                 o.placeholder = 64;
65                 o.datatype = 'min(1)';
66
67                 o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _('Specify a TOS (Type of Service).'));
68                 o.optional = true;
69                 o.datatype = 'range(0, 255)';
70
71                 o = s.taboption('advanced', form.Value, 'macaddr', _('Override MAC address'));
72                 o.optional = true;
73                 o.datatype = 'macaddr';
74
75                 o = s.taboption('advanced', form.Flag, 'rxcsum', _('Enable rx checksum'));
76                 o.optional = true;
77                 o.default = o.enabled;
78
79                 o = s.taboption('advanced', form.Flag, 'txcsum', _('Enable tx checksum'));
80                 o.optional = true;
81                 o.default = o.enabled;
82
83         }
84 });