Example #1
0
 public function store()
 {
     //if address is ipv6 link local, then it is possible to store more than one of these adresses
     //on different interfaces in different networks. So we need to check if the address already exists
     //on the given interface and if not, add
     if ($this->getInterfaceId() != 0 and $this->getIp() != "" and $this->ipIsInNetwork()) {
         if (strpos($this->getIp(), "fe80") !== false) {
             $ip = new Ip(false, $this->getInterfaceId(), $this->getNetworkId(), $this->getIp());
             if (!$ip->fetch()) {
                 return $this->insert();
             }
         } else {
             $ip = new Ip(false, false, $this->getNetworkId(), $this->getIp());
             $result = $ip->fetch();
             if ($this->getIpId() != 0 and ($result and $ip->getIpId() == $this->getIpId() or !$result)) {
                 return $this->update();
             } elseif ($this->getInterfaceId() != 0 and $this->getIp() != "" and $this->getNetworkId() != 0 and $ip->getIpId() == 0) {
                 return $this->insert();
             }
         }
     }
     return false;
 }