Advertisement
Guest User

Add_Static_Routes provision

a guest
Mar 16th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let location = null;
  2. let model = null;
  3. let serial = null;
  4. let igd = declare("VirtualParameters.location", {value: 1});
  5. const now = Date.now();
  6.  
  7. if (igd.size) {
  8.   for (let p of igd) {
  9.     if (p.value[0]) {
  10.       location = p.value[0];
  11.       break;
  12.     }
  13.   }  
  14. }
  15.  
  16. if (!location) {
  17.   log("No location, exiting");
  18.   return;
  19. }
  20.  
  21. igd = declare("InternetGatewayDevice.DeviceInfo.ModelName", {value: 1});
  22. if (igd.size) {
  23.   for (let p of igd) {
  24.     if (p.value[0]) {
  25.       model = p.value[0];
  26.       break;
  27.     }
  28.   }  
  29. }
  30.  
  31. if (!model) {
  32.   log("No model. This should never happen");
  33.   return;
  34. }
  35.  
  36. switch (location) {
  37.   case 'Wasilla':
  38.     switch (model) {
  39.         case 'SR515ac':
  40.           log('Adding static route to ' + location + ' for ' + model);
  41.           let foo = declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*", null, {path: 1});
  42.           log('Foo: ' + Object.keys(foo).join(', '));
  43.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.DestIPAddress", {value: now}, {value: '192.168.7.80'});
  44.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.GatewayIPAddress", {value: now}, {value: '172.27.240.1'});
  45.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.ForwardingPolicy", {value: now}, {value: -1});
  46.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.ForwardingMetric", {value: now}, {value: -1});
  47.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.Interface", {value: now}, {value: 'atm1.1'});
  48.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.DestSubnetMask", {value: now}, {value: '255.255.255.255'});
  49.           declare("InternetGatewayDevice.Layer3Forwarding.Forwarding.*.Enable", {value: now}, {value: true});
  50.           break;
  51.       default:
  52.         log('Unknown model: ' + model + ', location: ' + location);
  53.     }
  54.  
  55.     break;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement