2
0

map.js 2.7 KB

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