| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo 'MEF Links: '; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Get a list of all the known MEF Links for this host. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $db_info_list = dbFetchRows('SELECT id, mefID, mefType, mefIdent, mefMTU, mefAdmState, mefRowState FROM mefinfo WHERE device_id = ?', array($device['device_id'])); | 
					
						
							| 
									
										
										
										
											2017-12-02 17:18:45 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (!empty($db_info_list)) { | 
					
						
							|  |  |  |     $current_mefinfo = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', array(), 'MEF-UNI-EVC-MIB'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach ($db_info_list as $db_info) { | 
					
						
							|  |  |  |         $mef_info = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $mef_info['mefType'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgServiceType']; | 
					
						
							|  |  |  |         $mef_info['mefIdent'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgIdentifier']; | 
					
						
							|  |  |  |         $mef_info['mefMTU'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgMtuSize']; | 
					
						
							|  |  |  |         $mef_info['mefAdmState'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgAdminState']; | 
					
						
							|  |  |  |         $mef_info['mefRowState'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgRowStatus']; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  |         /* | 
					
						
							| 
									
										
										
										
											2017-12-02 17:18:45 -06:00
										 |  |  |          * Coriant MEF-EVC is quite strange, MTU is sometime set to 0 so we can set it into 1600 instead | 
					
						
							|  |  |  |          * According to Coriant this should be fixed in Nov 2017 | 
					
						
							| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  |          */ | 
					
						
							| 
									
										
										
										
											2017-12-02 17:18:45 -06:00
										 |  |  |         if (($mef_info['mefMTU'] == 0) && ($device['os'] == 'coriant')) { | 
					
						
							|  |  |  |             $mef_info['mefMTU'] = 1600; | 
					
						
							| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-02 17:18:45 -06:00
										 |  |  |         /* | 
					
						
							|  |  |  |          * Process all the MEF properties. | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         foreach ($mef_info as $property => $value) { | 
					
						
							|  |  |  |             /* | 
					
						
							|  |  |  |              * Check the property for any modifications. | 
					
						
							|  |  |  |              */ | 
					
						
							|  |  |  |             if ($mef_info[$property] != $db_info[$property]) { | 
					
						
							|  |  |  |                 // FIXME - this should loop building a query and then run the query after the loop (bad geert!)
 | 
					
						
							|  |  |  |                 dbUpdate(array($property => mres($mef_info[$property])), 'mefinfo', '`id` = ?', array($db_info['id'])); | 
					
						
							|  |  |  |                 if ($db_info['mefIdent'] != null) { | 
					
						
							|  |  |  |                     log_event("MEF Link : " . mres($db_info['mefIdent']) . ' (' . preg_replace('/^mef/', '', mres($db_info[$property])) . ') -> ' . $mef_info[$property], $device); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }//end foreach
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  | /* | 
					
						
							|  |  |  |  * Finished discovering MEF Links information. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-29 02:23:19 -06:00
										 |  |  | unset($db_info_list, $current_mefinfo); | 
					
						
							| 
									
										
										
										
											2017-03-11 14:30:31 +01:00
										 |  |  | echo PHP_EOL; |