Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPv6 Support #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions calculations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function inet_ntoa(mode, addrint) {
var fn = "inet_ntoa_" + mode;
return window[fn](addrint);
}

function inet_aton(mode, addrint) {
var fn = "inet_aton_" + mode;
return window[fn](addrint);
}

function network_address(mode, addrint) {
var fn = "network_address_" + mode;
return window[fn](addrint);
}

function subnet_addresses(mode, addrint) {
var fn = "subnet_addresses_" + mode;
return window[fn](addrint);
}

function subnet_first_address_useable(mode, addrint) {
var fn = "subnet_first_address_useable_" + mode;
return window[fn](addrint);
}

function subnet_last_address_useable(mode, addrint) {
var fn = "subnet_last_address_useable_" + mode;
return window[fn](addrint);
}

function subnet_last_address(mode, subnet, mask) {
var fn = "subnet_last_address_" + mode;
return window[fn](mode, subnet, mask);
}

function subnet_netmask(mode, addrint) {
var fn = "subnet_netmask_" + mode;
return window[fn](addrint);
}

function num_hosts(mode, useableFirst, useableLast) {
var fn = "num_hosts_" + mode;
return window[fn](useableFirst, useableLast);
}
60 changes: 60 additions & 0 deletions calculations_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
function inet_ntoa_4(addrint) {
return (
((addrint >> 24) & 0xff) +
"." +
((addrint >> 16) & 0xff) +
"." +
((addrint >> 8) & 0xff) +
"." +
(addrint & 0xff)
);
};

function inet_aton_4(addrstr) {
var re = /^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/;
var res = re.exec(addrstr);

if (res === null) {
return null;
}

for (var i = 1; i <= 4; i++) {
if (res[i] < 0 || res[i] > 255) {
return null;
}
}

return (res[1] << 24) | (res[2] << 16) | (res[3] << 8) | res[4];
}

function network_address_4(ip, mask) {
var maskbits = 0;
for (var i = 31 - mask; i >= 0; i--) {
ip &= ~1 << i;
}
return ip;
}

function subnet_addresses_4(mask) {
return 1 << (32 - mask);
}

function subnet_first_address_useable_4(addrint) {
return addrint + 1;
}

function subnet_last_address_useable_4(addrint) {
return addrint - 1;
}

function subnet_last_address_4(mode, subnet, mask) {
return subnet + subnet_addresses(mode, mask) - 1;
}

function subnet_netmask_4(mask) {
return network_address(4, 0xffffffff, mask);
}

function num_hosts_4(useableFirst, useableLast) {
return 1 + useableLast - useableFirst;
}
79 changes: 79 additions & 0 deletions calculations_6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function inet_ntoa_6(addrint) {
return "" +
((addrint >> 112n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 96n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 80n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 64n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 48n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 32n) & BigInt(0xffff)).toString(16) +
":" +
((addrint >> 16n) & BigInt(0xffff)).toString(16) +
":" +
(addrint & BigInt(0xffff)).toString(16);
}

function inet_aton_6(addrstr) {
var re =
/^([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})\:([0-9a-f]{1,4})$/;
var res = re.exec(addrstr);

if (res === null) {
return null;
}

for (var i = 1; i <= 8; i++) {
if (res[i] < 0 || res[i] > 0xffff) {
return null;
}
}

var r1 = BigInt(parseInt(res[1], 16)) << 112n;
var r2 = BigInt(parseInt(res[2], 16)) << 96n;
var r3 = BigInt(parseInt(res[3], 16)) << 80n;
var r4 = BigInt(parseInt(res[4], 16)) << 64n;
var r5 = BigInt(parseInt(res[5], 16)) << 48n;
var r6 = BigInt(parseInt(res[6], 16)) << 32n;
var r7 = BigInt(parseInt(res[7], 16)) << 16n;
var r8 = BigInt(parseInt(res[8], 16));

var rt = r1 | r2 | r3 | r4 | r5 | r6 | r7 | r8;

return rt;
}

function network_address_6(ip, mask) {
var maskbits = 0;
for (var i = 128 - mask; i >= 0; i--) {
ip &= ~1 << i;
}
return ip;
}

function subnet_addresses_6(mask) {
return 1n << (128n - BigInt(mask));
}

function subnet_first_address_useable_6(addrint) {
return addrint + 1n;
}

function subnet_last_address_useable_6(addrint) {
return addrint - 1n;
}

function subnet_last_address_6(mode, subnet, mask) {
return subnet + subnet_addresses(mode, mask) - 1n;
}

function subnet_netmask_6(mask) {
return undefined;
}

function num_hosts_6(useableFirst, useableLast) {
return 1n + useableLast - useableFirst;
}
6 changes: 3 additions & 3 deletions gennum.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?
for ($i=0;$i<=32; $i++) {
<?php
for ($i=0;$i<=128; $i++) {

$str = '/'.$i;
$font = 2;
Expand All @@ -20,4 +20,4 @@


//for i in tmp/*; do convert -rotate 90 $i img/`basename $i`; done
}
}
Binary file modified img/0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/10.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/100.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/101.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/102.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/103.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/104.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/105.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/106.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/107.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/108.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/109.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/11.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/110.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/111.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/112.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/113.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/114.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/115.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/116.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/117.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/118.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/119.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/12.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/120.gif
Binary file added img/121.gif
Binary file added img/122.gif
Binary file added img/123.gif
Binary file added img/124.gif
Binary file added img/125.gif
Binary file added img/126.gif
Binary file added img/127.gif
Binary file added img/128.gif
Binary file modified img/13.gif
Binary file modified img/14.gif
Binary file modified img/15.gif
Binary file modified img/16.gif
Binary file modified img/17.gif
Binary file modified img/18.gif
Binary file modified img/19.gif
Binary file modified img/2.gif
Binary file modified img/20.gif
Binary file modified img/21.gif
Binary file modified img/22.gif
Binary file modified img/23.gif
Binary file modified img/24.gif
Binary file modified img/25.gif
Binary file modified img/26.gif
Binary file modified img/27.gif
Binary file modified img/28.gif
Binary file modified img/29.gif
Binary file modified img/3.gif
Binary file modified img/30.gif
Binary file modified img/31.gif
Binary file modified img/32.gif
Binary file added img/33.gif
Binary file added img/34.gif
Binary file added img/35.gif
Binary file added img/36.gif
Binary file added img/37.gif
Binary file added img/38.gif
Binary file added img/39.gif
Binary file modified img/4.gif
Binary file added img/40.gif
Binary file added img/41.gif
Binary file added img/42.gif
Binary file added img/43.gif
Binary file added img/44.gif
Binary file added img/45.gif
Binary file added img/46.gif
Binary file added img/47.gif
Binary file added img/48.gif
Binary file added img/49.gif
Binary file modified img/5.gif
Binary file added img/50.gif
Binary file added img/51.gif
Binary file added img/52.gif
Binary file added img/53.gif
Binary file added img/54.gif
Binary file added img/55.gif
Binary file added img/56.gif
Binary file added img/57.gif
Binary file added img/58.gif
Binary file added img/59.gif
Binary file modified img/6.gif
Binary file added img/60.gif
Binary file added img/61.gif
Binary file added img/62.gif
Binary file added img/63.gif
Binary file added img/64.gif
Binary file added img/65.gif
Binary file added img/66.gif
Binary file added img/67.gif
Binary file added img/68.gif
Binary file added img/69.gif
Binary file modified img/7.gif
Binary file added img/70.gif
Binary file added img/71.gif
Binary file added img/72.gif
Binary file added img/73.gif
Binary file added img/74.gif
Binary file added img/75.gif
Binary file added img/76.gif
Binary file added img/77.gif
Binary file added img/78.gif
Binary file added img/79.gif
Binary file modified img/8.gif
Binary file added img/80.gif
Binary file added img/81.gif
Binary file added img/82.gif
Binary file added img/83.gif
Binary file added img/84.gif
Binary file added img/85.gif
Binary file added img/86.gif
Binary file added img/87.gif
Binary file added img/88.gif
Binary file added img/89.gif
Binary file modified img/9.gif
Binary file added img/90.gif
Binary file added img/91.gif
Binary file added img/92.gif
Binary file added img/93.gif
Binary file added img/94.gif
Binary file added img/95.gif
Binary file added img/96.gif
Binary file added img/97.gif
Binary file added img/98.gif
Binary file added img/99.gif
Loading