4 'require tools.widgets as widgets';
6 network
.registerPatternVirtual(/^gre4t-.+$/);
8 return network
.registerProtocol('gretap', {
10 return _('GRETAP tunnel over IPv4');
13 getIfname: function() {
14 return this._ubus('l3_device') || 'gre4t-%s'.format(this.sid
);
17 getOpkgPackage: function() {
21 isFloating: function() {
25 isVirtual: function() {
29 getDevices: function() {
33 containsDevice: function(ifname
) {
34 return (network
.getIfnameOf(ifname
) == this.getIfname());
37 renderFormOptions: function(s
) {
40 // -- general ---------------------------------------------------------------------
42 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."));
44 o
.datatype
= 'or(hostname,ip4addr("nomask"))';
46 o
= s
.taboption('general', form
.Value
, 'ipaddr', _("Local IPv4 address"), _("The local IPv4 address over which the tunnel is created (optional)."));
48 o
.datatype
= 'ip4addr("nomask")';
49 o
.load = function(section_id
) {
50 return network
.getWANNetworks().then(L
.bind(function(nets
) {
52 this.placeholder
= nets
[0].getIPAddr();
53 return form
.Value
.prototype.load
.apply(this, [section_id
]);
57 o
= s
.taboption('general', widgets
.NetworkSelect
, 'network', _("Network interface"), _("Logical network to which the tunnel will be added (bridged) (optional)."));
58 o
.exclude
= s
.section
;
62 // -- advanced ---------------------------------------------------------------------
64 o
= s
.taboption('advanced', widgets
.NetworkSelect
, 'tunlink', _("Bind interface"), _("Bind the tunnel to this interface (optional)."));
65 o
.exclude
= s
.section
;
69 o
= s
.taboption('advanced', form
.Value
, 'mtu', _("Override MTU"), _("Specify an MTU (Maximum Transmission Unit) other than the default (1280 bytes) (optional)."));
72 o
.datatype
= 'range(68, 9200)';
74 o
= s
.taboption('advanced', form
.Value
, 'ttl', _("Override TTL"), _("Specify a TTL (Time to Live) for the encapsulating packet other than the default (64) (optional)."));
77 o
.datatype
= 'min(1)';
79 o
= s
.taboption('advanced', form
.Value
, 'tos', _("Override TOS"), _("Specify a TOS (Type of Service). Can be <code>inherit</code> (the outer header inherits the value of the inner header) or an hexadecimal value <code>00..FF</code> (optional)."));
81 o
.validate = function(section_id
, value
) {
82 if (value
.length
> 0 && !value
.match(/^[a-f0-9]{1,2}$/i) && !value
.match(/^inherit$/i))
83 return _("Invalid TOS value, expected 00..FF or inherit");
88 o
= s
.taboption('advanced', form
.Flag
, 'df', _("Don't Fragment"), _("Enable the DF (Don't Fragment) flag of the encapsulating packets."));
89 o
.default = o
.enabled
;
91 o
= s
.taboption('advanced', form
.Flag
, 'nohostroute', _("No host route"), _("Do not create host route to peer (optional)."));
94 o
= s
.taboption('advanced', form
.Flag
, 'multicast', _("Multicast"), _("Enable support for multicast traffic (optional)."));
97 o
= s
.taboption('advanced', form
.Value
, 'ikey', _("Incoming key"), _("Key for incoming packets (optional)."));
99 o
.datatype
= 'integer';
101 o
= s
.taboption('advanced', form
.Value
, 'okey', _("Outgoing key"), _("Key for outgoing packets (optinal)."));
103 o
.datatype
= 'integer';
105 s
.taboption('advanced', form
.Flag
, 'icsum', _("Incoming checksum"), _("Require incoming checksum (optional)."));
106 s
.taboption('advanced', form
.Flag
, 'ocsum', _("Outgoing checksum"), _("Compute outgoing checksum (optional)."));
107 s
.taboption('advanced', form
.Flag
, 'iseqno', _("Incoming serialization"), _("Require incoming packets serialization (optional)."));
108 s
.taboption('advanced', form
.Flag
, 'oseqno', _("Outgoing serialization"), _("Perform outgoing packets serialization (optional)."));