2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-01-12 11:16:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( $config [ 'enable_pseudowires' ]  &&  $device [ 'os_group' ]  ==  " cisco " ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-12-26 21:57:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-18 15:38:13 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  unset ( $cpw_count ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  unset ( $cpw_exists ); 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-02-28 22:04:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  echo ( " Cisco Pseudowires :  " ); 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 12:24:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  // Pre-cache the existing state of pseudowires for this device from the database
 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  $pws_db_raw  =  dbFetchRows ( " SELECT * FROM `pseudowires` WHERE `device_id` = ? " ,  array ( $device [ 'device_id' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 22:02:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  foreach  ( $pws_db_raw  as  $pw_db ) 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $device [ 'pws_db' ][ $pw_db [ 'cpwVcID' ]]  =  $pw_db [ 'pseudowire_id' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  unset ( $pws_db_raw );  unset ( $pw_db ); 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcID " ,  array (),  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcName " ,  $pws ,  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcType " ,  $pws ,  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcPsnType " ,  $pws ,  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcDescr " ,  $pws ,  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 12:24:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  // For MPLS pseudowires
 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  $pws  =  snmpwalk_cache_oid ( $device ,  " cpwVcMplsPeerLdpID " ,  $pws ,  " CISCO-IETF-PW-MPLS-MIB " ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-15 11:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 22:02:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  foreach  ( $pws  as  $pw_id  =>  $pw ) 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        list ( $cpw_remote_id )  =  explode ( " : " ,  $pw [ 'cpwVcMplsPeerLdpID' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 17:43:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $cpw_remote_device  =  dbFetchCell ( " SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id " , array ( $cpw_remote_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $if_id  =  dbFetchCell ( " SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=? " , array ( $pw [ 'cpwVcName' ], $device [ 'device_id' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( ! empty ( $device [ 'pws_db' ][ $pw [ 'cpwVcID' ]])) 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:22:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          $pseudowire_id  =  $device [ 'pws_db' ][ $pw [ 'cpwVcID' ]]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          echo ( " . " ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:22:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-16 13:25:50 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          $pseudowire_id  =  dbInsert ( array ( 'device_id'  =>  $device [ 'device_id' ],  'port_id'  =>  $if_id ,  'peer_device_id'  =>  $cpw_remote_device ,  'peer_ldp_id'  =>  $cpw_remote_id , 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                                          'cpwVcID'  =>  $pw [ 'cpwVcID' ],  'cpwOid'  =>  $pw_id ,  'pw_type'  =>  $pw [ 'cpwVcType' ],  'pw_descr'  =>  $pw [ 'cpwVcDescr' ],  'pw_psntype'  =>  $pw [ 'cpwVcPsnType' ]),  'pseudowires' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          echo ( " + " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $device [ 'pws' ][ $pw [ 'cpwVcID' ]]  =  $pseudowire_id ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-28 18:25:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 12:24:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  // Cycle the list of pseudowires we cached earlier and make sure we saw them again.
 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 22:02:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  foreach  ( $device [ 'pws_db' ]  as  $pw_id  =>  $pseudowire_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-12-26 21:57:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 22:02:30 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( empty ( $device [ 'pws' ][ $pw_id ])) 
							 
						 
					
						
							
								
									
										
										
										
											2010-12-26 21:57:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-02 17:23:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      dbDelete ( 'vlans' ,  " `pseudowire_id` = ? " ,  array ( $pseudowire_id )); 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-05 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-19 12:12:54 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-05 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  echo ( " \n " ); 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-12 15:59:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-01-12 11:16:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}  # enable_pseudowires + os_group=cisco
 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 15:24:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-01-12 11:16:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								?>