summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-12-09 13:39:47 +0200
committerYuval Adam <yuval@y3xz.com>2015-12-09 13:39:47 +0200
commit41ae79e2699118120b976eb657782d614089aec4 (patch)
treee67af8c2882e4cec43e0810acd2200f0f1584fb1
parent758d6f2c4a6db148fe1912ce28f88465e3e79d26 (diff)
Add address count
-rw-r--r--index.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/index.js b/index.js
index 720639a..60e4611 100644
--- a/index.js
+++ b/index.js
@@ -49,6 +49,13 @@ class IPAddress extends React.Component {
}
}
+ getCount = () => {
+ if (this.state.cidr == 32) {
+ return 1;
+ }
+ return ((0xFFFFFFFF >>> this.state.cidr) >>> 0) + 1
+ }
+
render() {
return <div className="ip-address">
<div className="address">
@@ -76,7 +83,7 @@ class IPAddress extends React.Component {
</div>
<div className="details">
- <span className="netmask">Netmask: {this.getNetmask()}</span>
+ <span className="netmask">Netmask: {this.getNetmask()}</span>, <span className="count">Address Count: {this.getCount()}</span>
</div>
</div>