Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / protocols / luci-proto-ipip / htdocs / luci-static / resources / protocol / ipip.js
1 'use strict';
2 'require form';
3 'require network';
4 'require tools.widgets as widgets';
5
6 network.registerPatternVirtual(/^ipip-.+$/);
7
8 return network.registerProtocol('ipip', {
9         getI18n: function() {
10                 return _('IPv4-in-IPv4 (RFC2003)');
11         },
12
13         getIfname: function() {
14                 return this._ubus('l3_device') || 'ipip-%s'.format(this.sid);
15         },
16
17         getOpkgPackage: function() {
18                 return 'ipip';
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, 'peeraddr', _('Remote IPv4 address or FQDN'), _('The IPv4 address or the fully-qualified domain name of the remote tunnel end.'));
41                 o.optional = false;
42                 o.datatype = 'or(hostname,ip4addr("nomask"))';
43
44                 o = s.taboption('general', form.Value, 'ipaddr', _('Local IPv4 address'), _('The local IPv4 address over which the tunnel is created (optional).'));
45                 o.optional = true;
46                 o.datatype = 'ip4addr("nomask")';
47
48                 o = s.taboption('general', widgets.NetworkSelect, 'tunlink', _('Bind interface'), _('Bind the tunnel to this interface (optional).'));
49                 o.exclude = s.section;
50                 o.nocreate = true;
51                 o.optional = true;
52
53                 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'), _('Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes).'));
54                 o.optional = true;
55                 o.placeholder = 1280;
56                 o.datatype = 'range(68, 9200)';
57
58                 o = s.taboption('advanced', form.Value, 'ttl', _('Override TTL'), _('Specify a TTL (Time to Live) for the encapsulating packet other than the default (64).'));
59                 o.optional = true;
60                 o.placeholder = 64;
61                 o.datatype = 'min(1)';
62
63                 o = s.taboption('advanced', form.Value, 'tos', _('Override TOS'), _('Specify a TOS (Type of Service).'));
64                 o.optional = true;
65                 o.datatype = 'range(0, 255)';
66
67                 s.taboption('advanced', form.Flag, 'df', _("Don't Fragment"), _("Enable the DF (Don't Fragment) flag of the encapsulating packets."));
68         }
69 });