Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Adjust calculations for mesh ip and wlan ip outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkhanlar committed Jul 27, 2016
1 parent dc715bf commit 423b53c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ <h1>PittMesh IP address calculator</h1>
}

var macArrayDecimals = convertHexToDecimals(macArray);
var meshIP = calcMeshIP(lastThreeOctets(macArrayDecimals));
var wlanIP = calcWlanIP(lastTwoOctets(macArrayDecimals));
var meshIP = calcMeshIP(adjustOctets(lastThreeOctets(macArrayDecimals)));
var wlanIP = calcWlanIP(adjustOctets(lastTwoOctets(macArrayDecimals)));

meshEl.value = meshIP;
wlanEl.value = wlanIP;
Expand Down Expand Up @@ -170,6 +170,17 @@ <h1>PittMesh IP address calculator</h1>
return line;
}

function adjustOctets(arr) {
console.log(arr.length);
if (arr.length == 3) {
arr[0] %= 32 + 96;
arr[2] -= (arr[2] % 64 - arr[2] % 32);
} else if (arr.length == 2) {
arr[1] -= (arr[1] % 64 - arr[1] % 32);
}
return arr;
}

function convertHexToDecimals(arr) { return arr.map( function(h) { return parseInt(h, 16); } ); }
function firstThreeOctets(arr) { return arr.slice(0, 3); }
function lastThreeOctets(arr) { return arr.slice(3, 6); }
Expand Down

0 comments on commit 423b53c

Please sign in to comment.