1 L
.NetworkModel
.Protocol
.extend({
3 description
: L
.tr('Static address'),
7 _ev_broadcast: function(ev
)
9 var self
= ev
.data
.self
;
10 var sid
= ev
.data
.sid
;
12 var i
= ($('#' + self
.ownerSection
.id('field', sid
, 'ipaddr')).val() || '').split(/\./);
13 var m
= ($('#' + self
.ownerSection
.id('field', sid
, 'netmask') + ' select').val() || '').split(/\./);
18 for (var n
= 0; n
< 4; n
++)
20 i
[n
] = parseInt(i
[n
]);
21 m
[n
] = parseInt(m
[n
]);
23 if (isNaN(i
[n
]) || i
[n
] < 0 || i
[n
] > 255 ||
24 isNaN(m
[n
]) || m
[n
] < 0 || m
[n
] > 255)
27 I
|= (i
[n
] << ((3 - n
) * 8));
28 M
|= (m
[n
] << ((3 - n
) * 8));
33 $('#' + self
.section
.id('field', sid
, 'broadcast'))
34 .attr('placeholder', '%d.%d.%d.%d'.format(
35 (B
>> 24) & 0xFF, (B
>> 16) & 0xFF,
36 (B
>> 8) & 0xFF, (B
>> 0) & 0xFF
40 populateForm: function(section
, iface
)
42 var device
= L
.NetworkModel
.getDeviceByInterface(iface
);
44 section
.taboption('general', L
.cbi
.InputValue
, 'ipaddr', {
45 caption
: L
.tr('IPv4 address'),
48 }).on('blur validate', this._ev_broadcast
);
50 section
.taboption('general', L
.cbi
.ComboBox
, 'netmask', {
51 caption
: L
.tr('IPv4 netmask'),
54 }).on('blur validate', this._ev_broadcast
)
55 .value('255.255.255.0')
59 section
.taboption('general', L
.cbi
.InputValue
, 'broadcast', {
60 caption
: L
.tr('IPv4 broadcast'),
65 section
.taboption('general', L
.cbi
.InputValue
, 'gateway', {
66 caption
: L
.tr('IPv4 gateway'),
71 section
.taboption('general', L
.cbi
.DynamicList
, 'dns', {
72 caption
: L
.tr('DNS servers'),
78 section
.taboption('ipv6', L
.cbi
.ComboBox
, 'ip6assign', {
79 caption
: L
.tr('IPv6 assignment length'),
80 description
: L
.tr('Assign a part of given length of every public IPv6-prefix to this interface'),
83 }).value('', L
.tr('disabled')).value('64');
85 var ip6hint
= section
.taboption('ipv6', L
.cbi
.InputValue
, 'ip6hint', {
86 caption
: L
.tr('IPv6 assignment hint'),
87 description
: L
.tr('Assign prefix parts using this hexadecimal subprefix ID for this interface'),
91 for (var i
= 33; i
<= 64; i
++)
92 ip6hint
.depends('ip6assign', i
);
94 section
.taboption('ipv6', L
.cbi
.InputValue
, 'ip6addr', {
95 caption
: L
.tr('IPv6 address'),
98 }).depends('ip6assign', false);
100 section
.taboption('ipv6', L
.cbi
.InputValue
, 'ip6gw', {
101 caption
: L
.tr('IPv6 gateway'),
104 }).depends('ip6assign', false);
106 section
.taboption('ipv6', L
.cbi
.InputValue
, 'ip6prefix', {
107 caption
: L
.tr('IPv6 routed prefix'),
108 description
: L
.tr('Public prefix routed to this device for distribution to clients'),
111 }).depends('ip6assign', false);