/** * @param string $value * @param int $port * * @return $this * @throws \InvalidArgumentException */ public function add($value, $port = null) { if ($value == "*") { $this->_values[] = "*"; return $this; } if (Ipv4::test($value)) { $this->_values[] = new Ipv4($value, $port); return $this; } if (Ipv6::test($value)) { $this->_values[] = new Ipv6($value, $port); return $this; } throw new \InvalidArgumentException("{$value} is invalid address"); }
/** * Does the substraction of this address with the given address. Each byte * substracts up separately with remainteds. No adderss may substract lower * than the :: address. * * @param Ipv6 $other */ public function substract(Ipv6 $other) { $new1 = $other->_not(); $new2 = $this->add($new1); return $new2->add(new Ipv6(array(0, 0, 0, 0, 0, 0, 0, 1))); }
/** * Gets whether given ipv6 is included in this network. * * @param Ipv6 $address * @return boolean */ public function contains(Ipv6 $address) { return $address->_and($this->getNetmaskIp())->equals($this->getNetworkIp()); }