treewide: remove rendundant proto handler options
[project/luci.git] / protocols / luci-proto-ipv6 / htdocs / luci-static / resources / protocol / map.js
1 'use strict';
2 'require form';
3 'require network';
4 'require tools.widgets as widgets';
5
6 network.registerPatternVirtual(/^map-.+$/);
7 network.registerErrorCode('INVALID_MAP_RULE', _('MAP rule is invalid'));
8 network.registerErrorCode('NO_MATCHING_PD', _('No matching prefix delegation'));
9 network.registerErrorCode('UNSUPPORTED_TYPE', _('Unsupported MAP type'));
10
11 return network.registerProtocol('map', {
12 getI18n: function() {
13 return _('MAP / LW4over6');
14 },
15
16 getIfname: function() {
17 return this._ubus('l3_device') || 'map-%s'.format(this.sid);
18 },
19
20 getOpkgPackage: function() {
21 return 'map-t';
22 },
23
24 isFloating: function() {
25 return true;
26 },
27
28 isVirtual: function() {
29 return true;
30 },
31
32 getDevices: function() {
33 return null;
34 },
35
36 containsDevice: function(ifname) {
37 return (network.getIfnameOf(ifname) == this.getIfname());
38 },
39
40 renderFormOptions: function(s) {
41 var o;
42
43 o = s.taboption('general', form.ListValue, 'maptype', _('Type'));
44 o.value('map-e', 'MAP-E');
45 o.value('map-t', 'MAP-T');
46 o.value('lw4o6', 'LW4over6');
47
48 o = s.taboption('general', form.Value, 'peeraddr', _('BR / DMR / AFTR'));
49 o.rmempty = false;
50 o.datatype = 'ip6addr';
51
52 o = s.taboption('general', form.Value, 'ipaddr', _('IPv4 prefix'));
53 o.datatype = 'ip4addr';
54
55 o = s.taboption('general', form.Value, 'ip4prefixlen', _('IPv4 prefix length'), _('The length of the IPv4 prefix in bits, the remainder is used in the IPv6 addresses.'));
56 o.placeholder = '32';
57 o.datatype = 'range(0,32)';
58
59 o = s.taboption('general', form.Value, 'ip6prefix', _('IPv6 prefix'), _('The IPv6 prefix assigned to the provider, usually ends with <code>::</code>'));
60 o.rmempty = false;
61 o.datatype = 'ip6addr';
62
63 o = s.taboption('general', form.Value, 'ip6prefixlen', _('IPv6 prefix length'), _('The length of the IPv6 prefix in bits'));
64 o.placeholder = '16';
65 o.datatype = 'range(0,64)';
66
67 o = s.taboption('general', form.Value, 'ealen', _('EA-bits length'));
68 o.datatype = 'range(0,48)';
69
70 o = s.taboption('general', form.Value, 'psidlen', _('PSID-bits length'));
71 o.datatype = 'range(0,16)';
72
73 o = s.taboption('general', form.Value, 'offset', _('PSID offset'));
74 o.datatype = 'range(0,16)';
75
76 o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _('Tunnel Link'));
77 o.nocreate = true;
78 o.exclude = s.section;
79
80 o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
81 o.placeholder = '64';
82 o.datatype = 'range(1,255)';
83
84 o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
85 o.placeholder = '1280';
86 o.datatype = 'max(9200)';
87
88 o = s.taboption('advanced', form.Flag, 'legacymap', _('Use legacy MAP'), _('Use legacy MAP interface identifier format (draft-ietf-softwire-map-00) instead of RFC7597'));
89 }
90 });