Ejemplo n.º 1
0
 /**
  * @param DOMElement $xml
  */
 public function load_from_domxml($xml)
 {
     $this->xmlroot = $xml;
     $this->name = DH::findAttribute('name', $xml);
     if ($this->name === FALSE) {
         derr("tunnel name not found\n");
     }
     foreach ($xml->childNodes as $node) {
         if ($node->nodeType != 1) {
             continue;
         }
         if ($node->nodeName == 'auto-key') {
             $this->type = 'auto-key';
             $this->typeRoot = $node;
             //print "found type auto key\n";
             // now extracts ProxyID
             $this->proxyIdRoot = DH::findFirstElementOrCreate('proxy-id', $node);
             foreach ($this->proxyIdRoot->childNodes as $proxyNode) {
                 if ($proxyNode->nodeType != 1) {
                     continue;
                 }
                 $local = DH::findFirstElementOrDie('local', $proxyNode);
                 $remote = DH::findFirstElementOrDie('remote', $proxyNode);
                 $proxyName = DH::findAttribute('name', $proxyNode);
                 $record = array('name' => $proxyName, 'local' => $local->nodeValue, 'remote' => $remote->nodeValue, 'xmlroot' => $proxyNode);
                 $this->proxys[] =& $record;
                 unset($record);
             }
         }
     }
 }
 /**
  * @param DOMElement $xml
  */
 public function load_from_domxml($xml)
 {
     $this->xmlroot = $xml;
     $this->name = DH::findAttribute('name', $xml);
     if ($this->name === FALSE) {
         derr("virtual-router name not found\n");
     }
     $node = DH::findFirstElementOrCreate('interface', $xml);
     $this->attachedInterfaces->load_from_domxml($node);
     $node = DH::findXPath('/routing-table/ip/static-route/entry', $xml);
     if ($node !== false) {
         for ($i = 0; $i < $node->length; $i++) {
             $newRoute = new StaticRoute('***tmp**', $this);
             $newRoute->load_from_xml($node->item($i));
             $this->_staticRoutes[] = $newRoute;
         }
     }
 }
 function load_from_domxml(DOMElement $xml)
 {
     $this->xmlroot = $xml;
     $tmp = DH::findFirstElementOrCreate('tunnel', $this->xmlroot);
     $tmp = DH::findFirstElementOrCreate('ipsec', $tmp);
     $this->ipsecTunnelStore->load_from_domxml($tmp);
     $tmp = DH::findFirstElementOrCreate('interface', $this->xmlroot);
     $tmp = DH::findFirstElementOrCreate('ethernet', $tmp);
     $this->ethernetIfStore->load_from_domxml($tmp);
     $tmp = DH::findFirstElementOrCreate('interface', $this->xmlroot);
     $tmp = DH::findFirstElementOrCreate('aggregate-ethernet', $tmp);
     $this->aggregateEthernetIfStore->load_from_domxml($tmp);
     $tmp = DH::findFirstElementOrCreate('interface', $this->xmlroot);
     $tmp = DH::findFirstElementOrCreate('loopback', $tmp);
     $tmp = DH::findFirstElementOrCreate('units', $tmp);
     $this->loopbackIfStore->load_from_domxml($tmp);
     $tmp = DH::findFirstElementOrCreate('virtual-router', $this->xmlroot);
     $this->virtualRouterStore->load_from_domxml($tmp);
 }
 /**
  * @param null|string $newDescription
  * @return bool
  */
 function setDescription($newDescription = null)
 {
     if ($newDescription === null || strlen($newDescription) < 1) {
         if ($this->_description === null) {
             return false;
         }
         $this->_description = null;
         $tmpRoot = DH::findFirstElement('description', $this->xmlroot);
         if ($tmpRoot === false) {
             return true;
         }
         $this->xmlroot->removeChild($tmpRoot);
     } else {
         if ($this->_description == $newDescription) {
             return false;
         }
         $this->_description = $newDescription;
         $tmpRoot = DH::findFirstElementOrCreate('description', $this->xmlroot);
         DH::setDomNodeText($tmpRoot, $this->description());
     }
     return true;
 }
 public function setAlternativeName($newName)
 {
     if ($newName == $this->_alternativeName) {
         return false;
     }
     if ($newName === null || strlen($newName) == 0) {
         $node = DH::findFirstElement('display-name', $this->xmlroot);
         if ($node === false) {
             return false;
         }
         $this->xmlroot->removeChild($node);
         return true;
     }
     $node = DH::findFirstElementOrCreate('display-name', $this->xmlroot);
     DH::setDomNodeText($node, $newName);
     return true;
 }
Ejemplo n.º 6
0
 public function load_from_domxml($xml)
 {
     $this->xmlroot = $xml;
     $this->name = DH::findAttribute('name', $xml);
     if ($this->name === FALSE) {
         derr("name not found\n");
     }
     //print "found rule name '".$this->name."'\n";
     $this->extract_disabled_from_domxml();
     $this->extract_description_from_domxml();
     $this->load_tags();
     $this->load_from();
     $this->load_to();
     $this->load_source();
     $this->load_destination();
     //						//
     // Destination NAT properties Extraction	//
     //						//
     $this->dnatroot = DH::findFirstElement('destination-translation', $xml);
     if ($this->dnatroot !== FALSE) {
         //print "rule '".$this->name."' has destination-translation\n";
         if ($this->dnatroot->hasChildNodes()) {
             $this->subdnatTAroot = DH::findFirstElement('translated-address', $this->dnatroot);
             if ($this->subdnatTAroot !== FALSE) {
                 $f = $this->parentAddressStore->findOrCreate($this->subdnatTAroot->textContent, $this);
                 $this->dnathost = $f;
                 $this->subdnatTProot = DH::findFirstElement('translated-port', $this->dnatroot);
                 if ($this->subdnatTProot !== FALSE) {
                     $this->subdnatport = $this->subdnatTProot->textContent;
                 }
             }
         }
     }
     // end of destination translation extraction
     //										//
     // Source NAT properties Extraction		//
     //										//
     $this->snatroot = DH::findFirstElement('source-translation', $xml);
     if ($this->snatroot !== FALSE) {
         //print "we have found a source NAT\n";
         // next <tag> will determine NAT type
         $firstE = DH::firstChildElement($this->snatroot);
         $this->snattype = $firstE->nodeName;
         // Do we support this type of NAT ?
         if ($this->snattype != "static-ip" && $this->snattype != "dynamic-ip-and-port" && $this->snattype != "dynamic-ip") {
             derr("SNAT type '" . $this->snattype . "' for rule '" . $this->name . "' is not supported, EXIT\n");
         }
         //print "Determined NAT type ".$tcur['name']."\n";
         if ($this->snattype == "static-ip") {
             $isbidrx = DH::findFirstElement('bi-directional', $firstE);
             if ($isbidrx !== FALSE) {
                 $this->snatbidir = $isbidrx->textContent;
             }
             $transladx = DH::findFirstElement('translated-address', $firstE);
             $fad = $this->parentAddressStore->findOrCreate($transladx->textContent, $this);
             $this->snathosts->addObject($fad);
             $this->snathosts->xmlroot = $transladx;
         } else {
             if ($this->snattype == "dynamic-ip-and-port") {
                 // Is it <translated-address> type ?
                 $subtype = DH::findFirstElement('translated-address', $firstE);
                 if ($subtype !== FALSE) {
                     if (DH::firstChildElement($subtype) === FALSE) {
                         // this rule has no address specified
                     } else {
                         foreach ($subtype->childNodes as $node) {
                             if ($node->nodeType != 1) {
                                 continue;
                             }
                             $translad = $this->parentAddressStore->findOrCreate($node->textContent, $this);
                             $this->snathosts->addObject($translad);
                         }
                         $this->snathosts->xmlroot = $subtype;
                     }
                 } else {
                     $subtype = DH::findFirstElement('interface-address', $firstE);
                     if ($subtype !== FALSE) {
                         if (DH::firstChildElement($subtype) === FALSE) {
                             derr("Cannot understand dynmaic NAT for rule '" . $this->name . "'\n");
                         }
                         foreach ($subtype->childNodes as $node) {
                             if ($node->nodeType != 1) {
                                 continue;
                             }
                             if ($node->nodeName == 'interface') {
                                 $this->snatinterface = $node->textContent;
                             } else {
                                 if ($node->nodeName == 'ip') {
                                     $translad = $this->parentAddressStore->findOrCreate($node->textContent, $this);
                                     $this->snathosts->addObject($translad);
                                 } else {
                                     derr("Cannot understand dynmaic NAT for rule '" . $this->name . "'\n");
                                 }
                             }
                         }
                     } else {
                         mwarning("Unknown dynamic SNAT type on rule '" . $this->name . " don't mess too much with this rule or face unpredictable results");
                     }
                 }
             }
         }
     }
     //
     // End of Source NAT properties extraction	//
     //  								//
     //	Begin of <service> extraction				//
     //								//
     $this->serviceroot = DH::findFirstElementOrCreate('service', $xml, 'any');
     if ($this->serviceroot !== FALSE) {
         $lname = $this->serviceroot->textContent;
         if (strtolower($lname) != 'any') {
             //print "found service named $lname in  NAT rule '".$this->name."'\n";
             $f = $this->parentServiceStore->findOrCreate($lname, $this, true);
             if (!$f) {
                 derr("Error: service object named '{$lname}' not found in NAT rule '" . $this->name . "'\n");
             }
             $this->service = $f;
         }
     } else {
         derr('unexpected error');
     }
     // End of <service> extraction 	//
 }
Ejemplo n.º 7
0
 /**
  * For developper use only
  *
  */
 protected function extract_disabled_from_domxml()
 {
     $xml = $this->xmlroot;
     $this->disabledroot = DH::findFirstElementOrCreate('disabled', $xml, 'no');
     //print "this rule has a <disabled>\n";
     $lstate = strtolower($this->disabledroot->textContent);
     if ($lstate == 'yes') {
         //print "rule '".$this->name."' is <disabled>\n";
         $this->disabled = true;
     }
 }
Ejemplo n.º 8
0
 public function load_from_domxml($xml)
 {
     $this->xmldoc = $xml;
     $this->configroot = DH::findFirstElementOrDie('config', $this->xmldoc);
     $this->xmlroot = $this->configroot;
     $versionAttr = DH::findAttribute('version', $this->configroot);
     if ($versionAttr !== false) {
         $this->version = PH::versionFromString($versionAttr);
     } else {
         if (isset($this->connector) && $this->connector !== null) {
             $version = $this->connector->getSoftwareVersion();
         } else {
             derr('cannot find PANOS version used for make this config');
         }
         $this->version = $version['version'];
     }
     $tmp = DH::findFirstElementOrCreate('mgt-config', $this->configroot);
     $tmp = DH::findFirstElementOrCreate('devices', $tmp);
     foreach ($tmp->childNodes as $serial) {
         if ($serial->nodeType != 1) {
             continue;
         }
         $s = DH::findAttribute('name', $serial);
         if ($s === FALSE) {
             derr('no serial found');
         }
         $this->managedFirewallsSerials[] = $s;
     }
     $this->sharedroot = DH::findFirstElementOrDie('shared', $this->configroot);
     $this->devicesroot = DH::findFirstElementOrDie('devices', $this->configroot);
     $this->localhostroot = DH::findFirstElementByNameAttrOrDie('entry', 'localhost.localdomain', $this->devicesroot);
     $this->devicegrouproot = DH::findFirstElementOrDie('device-group', $this->localhostroot);
     $this->templateroot = DH::findFirstElementOrDie('template', $this->localhostroot);
     //
     // Extract Tag objects
     //
     if ($this->version >= 60) {
         $tmp = DH::findFirstElementOrCreate('tag', $this->sharedroot);
         $this->tagStore->load_from_domxml($tmp);
     }
     // End of Tag objects extraction
     //
     // Shared address objects extraction
     //
     $tmp = DH::findFirstElementOrCreate('address', $this->sharedroot);
     $this->addressStore->load_addresses_from_domxml($tmp);
     // end of address extraction
     //
     // Extract address groups
     //
     $tmp = DH::findFirstElementOrCreate('address-group', $this->sharedroot);
     $this->addressStore->load_addressgroups_from_domxml($tmp);
     // End of address groups extraction
     //
     // Extract services
     //
     $tmp = DH::findFirstElementOrCreate('service', $this->sharedroot);
     $this->serviceStore->load_services_from_domxml($tmp);
     // End of address groups extraction
     //
     // Extract service groups
     //
     $tmp = DH::findFirstElementOrCreate('service-group', $this->sharedroot);
     $this->serviceStore->load_servicegroups_from_domxml($tmp);
     // End of address groups extraction
     $prerulebase = DH::findFirstElementOrCreate('pre-rulebase', $this->sharedroot);
     $postrulebase = DH::findFirstElementOrCreate('post-rulebase', $this->sharedroot);
     $tmp = DH::findFirstElementOrCreate('security', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('security', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->securityRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('nat', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('nat', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->natRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('decryption', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('decryption', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->decryptionRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('application-override', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('application-override', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->appOverrideRules->load_from_domxml($tmp, $tmpPost);
     //
     // loading templates
     //
     foreach ($this->templateroot->childNodes as $node) {
         if ($node->nodeType != XML_ELEMENT_NODE) {
             continue;
         }
         $ldv = new Template('*tmp*', $this);
         $ldv->load_from_domxml($node);
         $this->templates[] = $ldv;
         //print "Template '{$ldv->name()}' found\n";
     }
     //
     // end of Templates
     //
     //
     // loading Device Groups now
     //
     if ($this->version < 70) {
         foreach ($this->devicegrouproot->childNodes as $node) {
             if ($node->nodeType != XML_ELEMENT_NODE) {
                 continue;
             }
             $lvname = $node->nodeName;
             //print "Device Group '$lvname' found\n";
             $ldv = new DeviceGroup($this);
             $ldv->load_from_domxml($node);
             $this->deviceGroups[] = $ldv;
         }
     } else {
         $dgMetaDataNode = DH::findXPathSingleEntryOrDie('/config/readonly/dg-meta-data/dginfo', $this->xmlroot);
         $dgToParent = array();
         $parentToDG = array();
         foreach ($dgMetaDataNode->childNodes as $node) {
             if ($node->nodeType != XML_ELEMENT_NODE) {
                 continue;
             }
             $dgName = DH::findAttribute('name', $node);
             if ($dgName === false) {
                 derr("DeviceGroup name attribute not found in dg-meta-data", $node);
             }
             $parentDG = DH::findFirstElement('parent-dg', $node);
             if ($parentDG === false) {
                 $dgToParent[$dgName] = 'shared';
                 $parentToDG['shared'][] = $dgName;
             } else {
                 $dgToParent[$dgName] = $parentDG->textContent;
                 $parentToDG[$parentDG->textContent][] = $dgName;
             }
         }
         $dgLoadOrder = array('shared');
         while (count($parentToDG) > 0) {
             $dgLoadOrderCount = count($dgLoadOrder);
             foreach ($dgLoadOrder as &$dgName) {
                 if (isset($parentToDG[$dgName])) {
                     foreach ($parentToDG[$dgName] as &$newDGName) {
                         $dgLoadOrder[] = $newDGName;
                     }
                     unset($parentToDG[$dgName]);
                 }
             }
             if (count($dgLoadOrder) <= $dgLoadOrderCount) {
                 derr('dg-meta-data seems to be corrupted, parent.child template cannot be calculated ', $dgMetaDataNode);
             }
             $dgLoadOrderCount = count($dgLoadOrder);
         }
         /*print "DG loading order:\n";
           foreach( $dgLoadOrder as &$dgName )
               print " - {$dgName}\n";*/
         $deviceGroupNodes = array();
         foreach ($this->devicegrouproot->childNodes as $node) {
             if ($node->nodeType != XML_ELEMENT_NODE) {
                 continue;
             }
             $nodeNameAttr = DH::findAttribute('name', $node);
             if ($nodeNameAttr === false) {
                 derr("DeviceGroup 'name' attribute was not found", $node);
             }
             if (!is_string($nodeNameAttr) || $nodeNameAttr == '') {
                 derr("DeviceGroup 'name' attribute has invalid value", $node);
             }
             $deviceGroupNodes[$nodeNameAttr] = $node;
         }
         foreach ($dgLoadOrder as $dgIndex => &$dgName) {
             if ($dgName == 'shared') {
                 continue;
             }
             if (!isset($deviceGroupNodes[$dgName])) {
                 mwarning("DeviceGroup '{$dgName}' is listed in dg-meta-data but doesn't exist in XML");
                 //unset($dgLoadOrder[$dgIndex]);
                 continue;
             }
             $ldv = new DeviceGroup($this);
             if (!isset($dgToParent[$dgName])) {
                 mwarning("DeviceGroup '{$dgName}' has not parent associated, assuming SHARED");
             } elseif ($dgToParent[$dgName] == 'shared') {
                 // do nothing
             } else {
                 $parentDG = $this->findDeviceGroup($dgToParent[$dgName]);
                 if ($parentDG === null) {
                     mwarning("DeviceGroup '{$dgName}' has DG '{$dgToParent[$dgName]}' listed as parent but it cannot be found in XML");
                 } else {
                     $parentDG->childDeviceGroups[$dgName] = $ldv;
                     $ldv->parentDeviceGroup = $parentDG;
                 }
             }
             $ldv->load_from_domxml($deviceGroupNodes[$dgName]);
             $this->deviceGroups[] = $ldv;
         }
     }
     //
     // End of DeviceGroup loading
     //
 }
Ejemplo n.º 9
0
 public function setSourcePort($newPorts)
 {
     if ($newPorts === null || strlen($newPorts) == 0) {
         if (strlen($this->_sport) == 0) {
             return false;
         }
         $this->_sport = $newPorts;
         $sportroot = DH::findFirstElement('source-port', $this->tcpOrUdpRoot);
         if ($sportroot !== false) {
             $this->tcpOrUdpRoot->removeChild($sportroot);
         }
         return true;
     }
     if ($this->_sport == $newPorts) {
         return false;
     }
     if (strlen($this->_sport) == 0) {
         DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot, $newPorts);
         return true;
     }
     $sportroot = DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot);
     DH::setDomNodeText($sportroot, $newPorts);
     return true;
 }
Ejemplo n.º 10
0
 public function setAction($newAction)
 {
     $newAction = strtolower($newAction);
     $actionFound = array_search($newAction, self::$RuleActions);
     if ($actionFound !== FALSE) {
         $this->action = $actionFound;
         if ($this->owner->version < 70 && $actionFound > self::ActionDeny) {
             derr("action '{$newAction}' is not supported before PANOS 7.0");
         }
         $domNode = DH::findFirstElementOrCreate('action', $this->xmlroot);
         DH::setDomNodeText($domNode, $newAction);
     } else {
         derr("'{$newAction}' is not supported action type\n");
     }
 }
Ejemplo n.º 11
0
 /**
  * @param $xml DOMElement|DOMDocument
  * @throws Exception
  */
 public function load_from_domxml($xml)
 {
     if ($xml->nodeType == XML_DOCUMENT_NODE) {
         $this->xmldoc = $xml;
         $this->configroot = DH::findFirstElementOrDie('config', $this->xmldoc);
         $this->xmlroot = $this->configroot;
     } else {
         $this->xmlroot = $xml;
         $this->configroot = $xml;
     }
     if ($this->owner !== null) {
         $this->version = $this->owner->owner->version;
     } else {
         $versionAttr = DH::findAttribute('version', $this->configroot);
         if ($versionAttr !== false) {
             $this->version = PH::versionFromString($versionAttr);
         } else {
             if (isset($this->connector) && $this->connector !== null) {
                 $version = $this->connector->getSoftwareVersion();
             } else {
                 derr('cannot find PANOS version used for make this config');
             }
             $this->version = $version['version'];
         }
     }
     $this->devicesroot = DH::findFirstElementOrCreate('devices', $this->configroot);
     $this->localhostroot = DH::findFirstElement('entry', $this->devicesroot);
     if ($this->localhostroot === false) {
         $this->localhostroot = DH::createElement($this->devicesroot, 'entry');
         $this->localhostroot->setAttribute('name', 'localhost.localdomain');
     }
     $this->vsyssroot = DH::findFirstElementOrCreate('vsys', $this->localhostroot);
     if ($this->owner === null) {
         $this->sharedroot = DH::findFirstElementOrDie('shared', $this->configroot);
         //
         // Extract Tag objects
         //
         if ($this->version >= 60) {
             $tmp = DH::findFirstElementOrCreate('tag', $this->sharedroot);
             $this->tagStore->load_from_domxml($tmp);
         }
         // End of Tag objects extraction
         //
         // Shared address objects extraction
         //
         $tmp = DH::findFirstElementOrCreate('address', $this->sharedroot);
         $this->addressStore->load_addresses_from_domxml($tmp);
         // end of address extraction
         //
         // Extract address groups
         //
         $tmp = DH::findFirstElementOrCreate('address-group', $this->sharedroot);
         $this->addressStore->load_addressgroups_from_domxml($tmp);
         // End of address groups extraction
         //
         // Extract services
         //
         $tmp = DH::findFirstElementOrCreate('service', $this->sharedroot);
         $this->serviceStore->load_services_from_domxml($tmp);
         // End of address groups extraction
         //
         // Extract service groups
         //
         $tmp = DH::findFirstElementOrCreate('service-group', $this->sharedroot);
         $this->serviceStore->load_servicegroups_from_domxml($tmp);
         // End of address groups extraction
     }
     //
     // Extract network related configs
     //
     $tmp = DH::findFirstElementOrCreate('network', $this->localhostroot);
     $this->network->load_from_domxml($tmp);
     //
     // Now listing and extracting all VirtualSystem configurations
     foreach ($this->vsyssroot->childNodes as $node) {
         if ($node->nodeType != 1) {
             continue;
         }
         //print "DOM type: ".$node->nodeType."\n";
         $lvsys = new VirtualSystem($this);
         $lvname = DH::findAttribute('name', $node);
         if ($lvname === FALSE) {
             derr('cannot find VirtualSystem name');
         }
         if (isset($this->panorama)) {
             $dg = $this->panorama->findApplicableDGForVsys($this->serial, $lvname);
             if ($dg !== FALSE) {
                 $lvsys->addressStore->panoramaDG = $dg->addressStore;
                 $lvsys->serviceStore->panoramaDG = $dg->serviceStore;
             }
         }
         $lvsys->load_from_domxml($node);
         $this->virtualSystems[] = $lvsys;
         $importedInterfaces = $lvsys->importedInterfaces->interfaces();
         foreach ($importedInterfaces as &$ifName) {
             $resolvedIf = $this->network->findInterface($ifName);
             if ($resolvedIf !== null) {
                 $resolvedIf->importedByVSYS = $lvsys;
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * !! Should not be used outside of a PanoramaConf constructor. !!
  *
  */
 public function load_from_domxml($xml)
 {
     $this->xmlroot = $xml;
     // this VirtualSystem has a name ?
     $this->name = DH::findAttribute('name', $xml);
     if ($this->name === FALSE) {
         derr("VirtualSystem name not found\n");
     }
     //
     // Extract Tag objects
     //
     if ($this->owner->version >= 60) {
         $tmp = DH::findFirstElementOrCreate('tag', $xml);
         $this->tagStore->load_from_domxml($tmp);
     }
     // End of Tag objects extraction
     //
     // Extract address objects
     //
     $tmp = DH::findFirstElementOrCreate('address', $xml);
     $this->addressStore->load_addresses_from_domxml($tmp);
     //print "VirtualSystem '".$this->name."' address objectsloaded\n" ;
     // End of address objects extraction
     //
     // Extract address groups in this DV
     //
     $tmp = DH::findFirstElementOrCreate('address-group', $xml);
     $this->addressStore->load_addressgroups_from_domxml($tmp);
     //print "VirtualSystem '".$this->name."' address groups loaded\n" ;
     // End of address groups extraction
     //												//
     // Extract service objects in this VirtualSystem			//
     //												//
     $tmp = DH::findFirstElementOrCreate('service', $xml);
     $this->serviceStore->load_services_from_domxml($tmp);
     //print "VirtualSystem '".$this->name."' service objects\n" ;
     // End of <service> extraction
     //												//
     // Extract service groups in this VirtualSystem			//
     //												//
     $tmp = DH::findFirstElementOrCreate('service-group', $xml);
     $this->serviceStore->load_servicegroups_from_domxml($tmp);
     //print "VirtualSystem '".$this->name."' service groups loaded\n" ;
     // End of <service-group> extraction
     $prerulebase = DH::findFirstElementOrCreate('pre-rulebase', $xml);
     $postrulebase = DH::findFirstElementOrCreate('post-rulebase', $xml);
     $tmp = DH::findFirstElementOrCreate('security', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('security', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->securityRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('nat', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('nat', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->natRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('decryption', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('decryption', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->decryptionRules->load_from_domxml($tmp, $tmpPost);
     $tmp = DH::findFirstElementOrCreate('application-override', $prerulebase);
     $tmp = DH::findFirstElementOrCreate('rules', $tmp);
     $tmpPost = DH::findFirstElementOrCreate('application-override', $postrulebase);
     $tmpPost = DH::findFirstElementOrCreate('rules', $tmpPost);
     $this->appOverrideRules->load_from_domxml($tmp, $tmpPost);
     // Devices extraction
     $this->devicesRoot = DH::findFirstElementOrCreate('devices', $xml);
     foreach ($this->devicesRoot->childNodes as $device) {
         if ($device->nodeType != 1) {
             continue;
         }
         $devname = DH::findAttribute('name', $device);
         $vsyslist = array();
         $vsysChild = DH::firstChildElement($device);
         if ($vsysChild !== FALSE) {
             foreach ($vsysChild->childNodes as $vsysentry) {
                 if ($vsysentry->nodeType != 1) {
                     continue;
                 }
                 $vname = DH::findAttribute('name', $vsysentry);
                 $vsyslist[] = $vname;
             }
         } else {
             //print "No vsys for device '$devname'\n";
             $vsyslist[] = 'vsys1';
         }
         $this->devices[] = array('serial' => $devname, 'vsyslist' => $vsyslist);
     }
 }
 /** @param App|null $app
  * @return bool */
 public function setApplication($app)
 {
     if ($app === null) {
         derr("app cannot be null");
     }
     if ($this->_app !== $app) {
         if ($this->_app !== null) {
             $this->_app->removeReference($this);
         }
         $app->addReference($this);
         $this->_app = $app;
         $root = DH::findFirstElementOrCreate('application', $this->xmlroot);
         DH::setDomNodeText($root, $app->name());
         return true;
     }
     return false;
 }