/[locfinder]/locfinder/functions/func_iprouting.php
ViewVC logotype

Diff of /locfinder/functions/func_iprouting.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by yob, Wed Jan 15 11:19:39 2003 UTC revision 1.2 by yob, Sun Jan 19 14:58:08 2003 UTC
# Line 55  if($in_locfinder) { Line 55  if($in_locfinder) {
55    
56          // find the record that contains the specified addess and set the          // find the record that contains the specified addess and set the
57          //  node_interface field to an appropriate value          //  node_interface field to an appropriate value
58          $sql = "UPDATE ip_assignments SET node_interface='$node_interface' WHERE ((address='$address'))";          $sql = "UPDATE addresses SET node_interface='$node_interface' WHERE ((address='$address'))";
59    
60          $loc_db->query( $sql );          $loc_db->query( $sql );
61    
62          // delete the request fields (which are inserted when requested)          // delete the request fields (which are inserted when requested)
63          $sql = "DELETE FROM ip_assignments WHERE ((node_interface='$node_interface') AND (address IS NULL) AND (type='$type')) LIMIT 1";          $sql = "DELETE FROM addresses WHERE ((node_interface='$node_interface') AND (address IS NULL) AND (type='$type')) LIMIT 1";
64    
65          $loc_db->query( $sql );          $loc_db->query( $sql );
66    
# Line 90  if($in_locfinder) { Line 90  if($in_locfinder) {
90          $node_id = $loc_db->f("node_id");          $node_id = $loc_db->f("node_id");
91                    
92          // the final details for email          // the final details for email
93          $sql = "SELECT subnet, area FROM ip_assignments WHERE address = '" . $address . "'";          $sql = "SELECT subnet, area FROM addresses WHERE address = '" . $address . "'";
94    
95          $loc_db->query( $sql );          $loc_db->query( $sql );
96    
# Line 131  if($in_locfinder) { Line 131  if($in_locfinder) {
131          // delete a single request where the node/interface and type match          // delete a single request where the node/interface and type match
132          //  its possible that there will be more than one match, but the          //  its possible that there will be more than one match, but the
133          //  LIMIT 1 makes it stop after 1          //  LIMIT 1 makes it stop after 1
134          $sql = "DELETE FROM ip_assignments WHERE ((node_interface='$node_interface') AND (address IS NULL) AND (type='$type')) LIMIT 1";          $sql = "DELETE FROM addresses WHERE ((node_interface='$node_interface') AND (address IS NULL) AND (type='$type')) LIMIT 1";
135    
136          $loc_db->query( $sql );          $loc_db->query( $sql );
137                    
# Line 158  if($in_locfinder) { Line 158  if($in_locfinder) {
158          $loc_db = new locDatabase;          $loc_db = new locDatabase;
159    
160          // Change node/interface to null for the designated address          // Change node/interface to null for the designated address
161          $sql = "UPDATE ip_assignments SET node_interface=NULL WHERE (address='$address')";          $sql = "UPDATE addresses SET node_interface=NULL WHERE (address='$address')";
162    
163          $loc_db->query( $sql );          $loc_db->query( $sql );
164                    
# Line 182  if($in_locfinder) { Line 182  if($in_locfinder) {
182       *       *
183       */       */
184    
185      function flush_assignments($node_id, $flush_blocks, $flush_router, $flush_backbone) {      function flush_assignments($node_id, $flush_blocks, $flush_router) {
186    
187          // create the DB classes          // create the DB classes
188          $loc_db = new locDatabase;          $loc_db = new locDatabase;
# Line 192  if($in_locfinder) { Line 192  if($in_locfinder) {
192          if ($flush_blocks) {          if ($flush_blocks) {
193                    
194              // remove the allocations already made              // remove the allocations already made
195              $sql = "UPDATE ip_assignments SET node_interface=NULL WHERE (node_interface='$node_id') AND (address IS NOT NULL)";              $sql = "UPDATE addresses SET node_interface=NULL WHERE (node_interface='$node_id') AND (address IS NOT NULL)";
196    
197              $loc_db->query( $sql );              $loc_db->query( $sql );
198    
199              // remove the requests that havent been fullfilled yet              // remove the requests that havent been fullfilled yet
200              $sql = "DELETE FROM ip_assignments WHERE node_interface='" . $node_id. "'";              $sql = "DELETE FROM addresses WHERE node_interface='" . $node_id. "'";
201    
202              $loc_db->query( $sql );              $loc_db->query( $sql );
203                    
# Line 216  if($in_locfinder) { Line 216  if($in_locfinder) {
216              while ($loc_db->next_record()) {              while ($loc_db->next_record()) {
217    
218                  // delete the allocations already made                  // delete the allocations already made
219                  $sql = "UPDATE ip_assignments SET node_interface=NULL WHERE ((node_interface='" . $loc_db_2->f("int_id") . "') AND (address IS NOT NULL) AND (type='router'))";                  $sql = "UPDATE addresses SET node_interface=NULL WHERE ((node_interface='" . $loc_db_2->f("int_id") . "') AND (address IS NOT NULL) AND (type='router'))";
220    
221                  $loc_db_2->query( $sql );                  $loc_db_2->query( $sql );
222    
223                  // delete the unfulfilled requests                  // delete the unfulfilled requests
224                  $sql = "DELETE FROM ip_assignments WHERE ((node_interface='" . $loc_db->f("int_id") . "') AND (type='router'))";                  $sql = "DELETE FROM addresses WHERE ((node_interface='" . $loc_db->f("int_id") . "') AND (type='router'))";
   
                 $loc_db_2->query( $sql );  
   
             } // end while  
           
         } // end if  
   
         // if the router allocations are to be deleted  
         if ($flush_backbone) {  
   
             // select all the interfaces from the node, since router  
             //  allocations are stored by interface, not node  
             $sql = "SELECT * FROM interfaces WHERE (node='" . $node_id . "')";  
   
             $loc_db->query( $sql );  
   
             // for each interface  
             while ($loc_db->next_record()) {  
   
                 // delete the allocations already made  
                 $sql = "UPDATE ip_assignments SET node_interface=NULL WHERE ((node_interface='" . $loc_db_2->f("int_id") . "') AND (address IS NOT NULL) AND (type='backbone'))";  
   
                 $loc_db_2->query( $sql );  
   
                 // delete the unfulfilled requests  
                 $sql = "DELETE FROM ip_assignments WHERE ((node_interface='" . $loc_db->f("int_id") . "') AND (type='backbone'))";  
225    
226                  $loc_db_2->query( $sql );                  $loc_db_2->query( $sql );
227    
# Line 275  if($in_locfinder) { Line 249  if($in_locfinder) {
249          $area = $loc_db->f("area");          $area = $loc_db->f("area");
250    
251          // Setup the SQL Statement          // Setup the SQL Statement
252          $sql = "INSERT INTO ip_assignments(node_interface, type, area) VALUES('$node_id','block', $area)";          $sql = "INSERT INTO addresses(node_interface, type, area) VALUES('$node_id','block', $area)";
253    
254          // Run the query          // Run the query
255          $loc_db->query( $sql );          $loc_db->query( $sql );
256    
257          email_request_ip($opt_ip_allocater, $node_id, "block", $area);          email_request_ip($opt_ip_allocater, $node_id, "block", $area);
258    
259          $success_message = "ip block successfully requested";          $_SESSION["msg"] = "ip block successfully requested";
260            $_SESSION["msg_type"] = 0;
261          return true;          return true;
262    
263      }      }
# Line 296  if($in_locfinder) { Line 271  if($in_locfinder) {
271    
272          $loc_db = new locDatabase;          $loc_db = new locDatabase;
273    
274          $sql = "SELECT id, area, ospf_mode from nodes, interfaces WHERE ((nodes.id = interfaces.node) AND (interfaces.int_id='$int_id'))";          $sql = "SELECT id, area, from nodes, interfaces WHERE ((nodes.id = interfaces.node) AND (interfaces.int_id='$int_id'))";
275    
276          $loc_db->query( $sql );          $loc_db->query( $sql );
277    
# Line 306  if($in_locfinder) { Line 281  if($in_locfinder) {
281          $mode = $loc_db->f("ospf_mode");          $mode = $loc_db->f("ospf_mode");
282          $node_id = $loc_db->f("id");          $node_id = $loc_db->f("id");
283    
         //if ($mode == "none") {  
   
             //error  
             //$err_message = "error. only routing nodes running OSPF may request routing addresses";  
             //return false;  
   
284          if (get_ip_router($int_id) != "")  {          if (get_ip_router($int_id) != "")  {
285    
286              //error              //error
# Line 322  if($in_locfinder) { Line 291  if($in_locfinder) {
291          } else {          } else {
292    
293              // Setup the SQL Statement              // Setup the SQL Statement
294              $sql = "INSERT INTO ip_assignments(node_interface, type, area) VALUES('$int_id', 'router', $area)";              $sql = "INSERT INTO addresses(node_interface, type, area) VALUES('$int_id', 'router', $area)";
295    
296              // Run the query              // Run the query
297              $loc_db->query( $sql );              $loc_db->query( $sql );
# Line 341  if($in_locfinder) { Line 310  if($in_locfinder) {
310          }          }
311      }      }
312    
     function request_ip_backbone($int_id) {  
   
         GLOBAL $opt_maintainer_email;  
         GLOBAL $opt_ip_allocater;  
         GLOBAL $err_message;  
         GLOBAL $success_message;  
   
         $loc_db = new locDatabase;  
   
         $sql = "SELECT id, area, ospf_mode from nodes, interfaces WHERE ((nodes.id = interfaces.node) AND (interfaces.int_id='$int_id'))";  
   
         $loc_db->query( $sql );  
   
         $loc_db->next_record();  
   
         $area = $loc_db->f("area");  
         $mode = $loc_db->f("ospf_mode");  
         $node_id = $loc_db->f("id");  
   
         if ($mode == "none") {  
   
             //error  
             $err_message = "error. only routing nodes running OSPF may request backbone addresses";  
               
             return false;  
   
         } elseif (get_ip_backbone($int_id) != "") {  
   
             //error  
             $err_message = "error. Interfaces may only have one IP address";  
               
             return false;  
   
         } else {  
   
             // Setup the SQL Statement  
             $sql = "INSERT INTO ip_assignments(node_interface, type, area) VALUES('$int_id', 'backbone', 0)";  
   
             // Run the query  
             $loc_db->query( $sql );  
   
             $sql = "SELECT node FROM interfaces WHERE int_id=" . $int_id;  
   
             $loc_db->query( $sql );  
   
             $loc_db->next_record();  
   
             email_request_ip($opt_ip_allocater, $loc_db->f("node"), "backbone", 0);  
   
             $success_message = "backbone ip successfully requested";  
             return true;  
   
         }  
     }  
   
313      function get_ip_block($node_id) {      function get_ip_block($node_id) {
314    
315          $loc_db = new locDatabase;          $loc_db = new locDatabase;
316    
317          $sql = "SELECT * from ip_assignments WHERE ((node_interface='$node_id') AND (type='block'))";          $sql = "SELECT * from addresses WHERE ((node_interface='$node_id') AND (type='block'))";
318    
319          $loc_db->query( $sql );          $loc_db->query( $sql );
320    
# Line 433  if($in_locfinder) { Line 347  if($in_locfinder) {
347    
348          $loc_db = new locDatabase;          $loc_db = new locDatabase;
349    
350          $sql = "SELECT * from ip_assignments WHERE ((node_interface='$int_id') AND (type='router'))";          $sql = "SELECT * from addresses WHERE ((node_interface='$int_id') AND (type='router'))";
351    
352          $loc_db->query( $sql );          $loc_db->query( $sql );
353    
# Line 455  if($in_locfinder) { Line 369  if($in_locfinder) {
369    
370          return $ip_router;          return $ip_router;
371      }      }
   
     function get_ip_backbone($int_id) {  
   
         $loc_db = new locDatabase;  
   
         $sql = "SELECT * from ip_assignments WHERE ((node_interface='$int_id') AND (type='backbone'))";  
   
         $loc_db->query( $sql );  
   
         $loc_db->next_record();  
   
         if ($loc_db->num_rows() == 0) {  
   
             $ip_backbone = "";  
   
         } elseif ($loc_db->f("address") == "") {  
   
             $ip_backbone = "Request Recorded - awaiting authorisation";  
   
         } else {  
   
             $ip_backbone = $loc_db->f("address") . "/" . $loc_db->f("subnet");  
   
         }  
           
         return $ip_backbone;  
     }  
372            
373      function area_exist($area_id) {      function area_exist($area_id) {
374            
# Line 516  if($in_locfinder) { Line 403  if($in_locfinder) {
403      }      }
404    
405  }  }
 ?>  
406    ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26