function __SearchIP($params) { global $xmlrpcerruser; // import user errcode value // $params is an Array of xmlrpcval objects $errstr = ""; $err = 0; if (IPPLAN_API_VER != DBF_API_VER) { return new xmlrpcresp(0, $xmlrpcerruser + 3, "Incorrect API version"); } // get the first param $ipobj = $params->getParam(0); // if it's there and the correct type if (isset($ipobj) && $ipobj->scalartyp() == "string") { // extract the value of the state number $ipaddr = $ipobj->scalarval(); if (testIP($ipaddr)) { $err = 50; $errstr = "Invalid IP address!"; } else { if (!($ds = new IPplanDbf())) { return new xmlrpcresp(0, $xmlrpcerruser + 1, "Could not connect to database"); } $result = $ds->GetDuplicateSubnetAll(inet_aton($ipaddr), 1); // returns the following fields: // base.baseaddr, base.subnetsize, base.baseindex, base.descrip, customer.custdescrip, // customer.customer, base.lastmod, base.userid, base.swipmod while ($row = $result->FetchRow()) { $myVal[] = new xmlrpcval(array("baseaddr" => new xmlrpcval(inet_ntoa($row["baseaddr"])), "subnetsize" => new xmlrpcval($row["subnetsize"], "int"), "baseindex" => new xmlrpcval($row["baseindex"], "int"), "descrip" => new xmlrpcval($row["descrip"]), "customer" => new xmlrpcval($row["customer"], "int"), "custdescrip" => new xmlrpcval($row["custdescrip"])), "struct"); } } } else { // parameter mismatch, complain $err = 2; $errstr = "Incorrect parameters"; } if ($err) { // this is an error condition return new xmlrpcresp(0, $xmlrpcerruser + 1, $errstr); } else { // this is a successful value being returned return new xmlrpcresp(new xmlrpcval($myVal, "array")); } }
} } // could not find new subnet within any of the defined bounds // so do not create if (!$extst) { $warn = 1; myError($w, $p, sprintf(my_("Subnet %s not created - out of defined authority boundary"), inet_ntoa($base)) . "\n", FALSE); continue; } $restemp = $ds->GetDuplicateSubnet($base, $size, $cust); if ($restemp->FetchRow()) { $warn = 1; myError($w, $p, sprintf(my_("Subnet %s could not be created - possibly overlaps with an existing subnet"), inet_ntoa($base)) . "\n", FALSE); } else { // find subnets from other customers that overlap $result = $ds->GetDuplicateSubnetAll($base, $size, $grps); if ($row = $result->FetchRow()) { $warn = 1; insert($w, textb(my_("WARNING: "))); insert($w, text(sprintf(my_("Subnet %s overlaps with the following subnets from other customers. This may not be a problem as the subnet may occur in both customers routing tables:"), inet_ntoa($base)))); insert($w, block("<p>")); // create a table insert($w, $t = table(array("cols" => "3", "class" => "outputtable"))); // draw heading setdefault("cell", array("class" => "heading")); insert($t, $c = cell()); insert($c, text(my_("Base address"))); insert($t, $c = cell()); insert($c, text(my_("Subnet description"))); insert($t, $c = cell()); insert($c, text(my_("Customer")));