| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-31 10:53:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  | $rewrite_entSensorType = array ( | 
					
						
							|  |  |  |   'celsius' => 'C', | 
					
						
							|  |  |  |   'unknown' => '', | 
					
						
							|  |  |  |   'specialEnum' => 'C', | 
					
						
							|  |  |  |   'watts' => 'W', | 
					
						
							|  |  |  |   'truthvalue' => '', | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function entPhysical_scale($value, $scale) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch ($scale) { | 
					
						
							|  |  |  |     case "nano": | 
					
						
							|  |  |  |   $value = $value / 1000000000; | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "micro": | 
					
						
							|  |  |  |   $value = $value / 1000000; | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "milli": | 
					
						
							|  |  |  |   $value = $value / 1000; | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "units": | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "kilo": | 
					
						
							|  |  |  |   $value = $value * 1000; | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "mega": | 
					
						
							|  |  |  |   $value = $value * 1000000; | 
					
						
							|  |  |  |   break; | 
					
						
							|  |  |  |     case "giga": | 
					
						
							|  |  |  |   $value = $value * 1000000000; | 
					
						
							|  |  |  |   break; | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   return $value; | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $translate_ifOperStatus = array( | 
					
						
							|  |  |  |   "1" => "up", | 
					
						
							|  |  |  |   "2" => "down", | 
					
						
							|  |  |  |   "3" => "testing", | 
					
						
							|  |  |  |   "4" => "unknown", | 
					
						
							|  |  |  |   "5" => "dormant", | 
					
						
							|  |  |  |   "6" => "notPresent", | 
					
						
							|  |  |  |   "7" => "lowerLayerDown", | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function translate_ifOperStatus ($ifOperStatus) { | 
					
						
							|  |  |  |   global $translate_ifOperStatus; | 
					
						
							|  |  |  |   if($translate_ifOperStatus['$ifOperStatus']) { | 
					
						
							|  |  |  |     $ifOperStatus = $translate_ifOperStatus['$ifOperStatus']; | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   return $ifOperStatus; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  | $translate_ifAdminStatus = array( | 
					
						
							|  |  |  |   "1" => "up", | 
					
						
							|  |  |  |   "2" => "down", | 
					
						
							|  |  |  |   "3" => "testing", | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  | function translate_ifAdminStatus ($ifAdminStatus) { | 
					
						
							|  |  |  |   global $translate_ifAdminStatus; | 
					
						
							|  |  |  |   if($translate_ifAdminStatus['$ifAdminStatus']) { | 
					
						
							|  |  |  |     $ifAdminStatus = $translate_ifAdminStatus['$ifAdminStatus']; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return $ifAdminStatus; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-02 15:57:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  | $rewrite_ios_features = array( | 
					
						
							|  |  |  |   "PK9S" => "IP w/SSH LAN Only", | 
					
						
							|  |  |  |   "LANBASEK9" => "Lan Base Crypto", | 
					
						
							|  |  |  |   "LANBASE" => "Lan Base", | 
					
						
							|  |  |  |   "ADVENTERPRISEK9" => "Advanced Enterprise Crypto", | 
					
						
							|  |  |  |   "ADVSECURITYK9" => "Advanced Security Crypto", | 
					
						
							|  |  |  |   "K91P" => "Provider Crypto", | 
					
						
							|  |  |  |   "K4P" => "Provider Crypto", | 
					
						
							|  |  |  |   "ADVIPSERVICESK9" => "Adv IP Services Crypto", | 
					
						
							|  |  |  |   "ADVIPSERVICES" => "Adv IP Services", | 
					
						
							|  |  |  |   "IK9P" => "IP Plus Crypto", | 
					
						
							|  |  |  |   "K9O3SY7" => "IP ADSL FW IDS Plus IPSEC 3DES", | 
					
						
							|  |  |  |   "SPSERVICESK9" => "SP Services Crypto", | 
					
						
							|  |  |  |   "PK9SV" => "IP MPLS/IPV6 W/SSH + BGP", | 
					
						
							|  |  |  |   "IS" => "IP Plus", | 
					
						
							|  |  |  |   "IPSERVICESK9" => "IP Services Crypto", | 
					
						
							|  |  |  |   "BROADBAND" => "Broadband", | 
					
						
							|  |  |  |   "IPBASE" => "IP Base", | 
					
						
							|  |  |  |   "IPSERVICE" => "IP Services", | 
					
						
							|  |  |  |   "P" => "Service Provider", | 
					
						
							|  |  |  |   "P11" => "Broadband Router", | 
					
						
							|  |  |  |   "G4P5" => "NRP", | 
					
						
							|  |  |  |   "JK9S" => "Enterprise Plus Crypto", | 
					
						
							|  |  |  |   "IK9S" => "IP Plus Crypto", | 
					
						
							|  |  |  |   "JK" => "Enterprise Plus", | 
					
						
							|  |  |  |   "I6Q4L2" => "Layer 2", | 
					
						
							|  |  |  |   "I6K2L2Q4" => "Layer 2 Crypto", | 
					
						
							|  |  |  |   "C3H2S" => "Layer 2 SI/EI", | 
					
						
							|  |  |  |   "_WAN" => " + WAN", | 
					
						
							| 
									
										
										
										
											2009-03-23 17:32:25 +00:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  |   $rewrite_shortif = array ( | 
					
						
							|  |  |  |     'tengigabitethernet' => 'Te', | 
					
						
							|  |  |  |     'gigabitethernet' => 'Gi', | 
					
						
							|  |  |  |     'fastethernet' => 'Fa', | 
					
						
							|  |  |  |     'ethernet' => 'Et', | 
					
						
							|  |  |  |     'serial' => 'Se', | 
					
						
							|  |  |  |     'pos' => 'Pos', | 
					
						
							|  |  |  |     'port-channel' => 'Po', | 
					
						
							|  |  |  |     'atm' => 'Atm', | 
					
						
							|  |  |  |     'null' => 'Null', | 
					
						
							|  |  |  |     'loopback' => 'Lo', | 
					
						
							|  |  |  |     'dialer' => 'Di', | 
					
						
							|  |  |  |     'vlan' => 'Vlan', | 
					
						
							|  |  |  |     'tunnel' => 'Tunnel', | 
					
						
							| 
									
										
										
										
											2009-08-07 16:10:52 +00:00
										 |  |  |     'serviceinstance' => 'SI', | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   $rewrite_iftype = array ( | 
					
						
							|  |  |  |     '/^frameRelay$/' => 'Frame Relay', | 
					
						
							|  |  |  |     '/^ethernetCsmacd$/' => 'Ethernet', | 
					
						
							|  |  |  |     '/^softwareLoopback$/' => 'Loopback', | 
					
						
							|  |  |  |     '/^tunnel$/' => 'Tunnel', | 
					
						
							|  |  |  |     '/^propVirtual$/' => 'Virtual Int', | 
					
						
							|  |  |  |     '/^ppp$/' => 'PPP', | 
					
						
							|  |  |  |     '/^ds1$/' => 'DS1', | 
					
						
							|  |  |  |     '/^pos$/' => 'POS', | 
					
						
							|  |  |  |     '/^sonet$/' => 'SONET', | 
					
						
							|  |  |  |     '/^slip$/' => 'SLIP', | 
					
						
							|  |  |  |     '/^mpls$/' => 'MPLS Layer', | 
					
						
							|  |  |  |     '/^l2vlan$/' => 'VLAN Subif', | 
					
						
							|  |  |  |     '/^atm$/' => 'ATM', | 
					
						
							|  |  |  |     '/^aal5$/' => 'ATM AAL5', | 
					
						
							|  |  |  |     '/^atmSubInterface$/' => 'ATM Subif', | 
					
						
							|  |  |  |     '/^propPointToPointSerial$/' => 'PtP Serial', | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   $rewrite_ifname = array ( | 
					
						
							|  |  |  |     'ether' => 'Ether', | 
					
						
							|  |  |  |     'gig' => 'Gig', | 
					
						
							|  |  |  |     'fast' => 'Fast', | 
					
						
							|  |  |  |     'ten' => 'Ten', | 
					
						
							|  |  |  |     '-802.1q vlan subif' => '', | 
					
						
							|  |  |  |     '-802.1q' => '', | 
					
						
							|  |  |  |     'bvi' => 'BVI', | 
					
						
							|  |  |  |     'vlan' => 'Vlan', | 
					
						
							|  |  |  |     'ether' => 'Ether', | 
					
						
							|  |  |  |     'tunnel' => 'Tunnel', | 
					
						
							|  |  |  |     'serial' => 'Serial', | 
					
						
							|  |  |  |     '-aal5 layer' => ' aal5', | 
					
						
							|  |  |  |     'null' => 'Null', | 
					
						
							|  |  |  |     'atm' => 'ATM', | 
					
						
							|  |  |  |     'port-channel' => 'Port-Channel', | 
					
						
							|  |  |  |     'dial' => 'Dial', | 
					
						
							|  |  |  |     'hp procurve switch software loopback interface' => 'Loopback Interface', | 
					
						
							|  |  |  |     'control plane interface' => 'Control Plane', | 
					
						
							|  |  |  |     'loop' => 'Loop', | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 17:32:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | // Specific rewrite functions
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function makeshortif($if) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   global $rewrite_shortif; | 
					
						
							|  |  |  |   $if = fixifName ($if); | 
					
						
							|  |  |  |   $if = strtolower($if); | 
					
						
							|  |  |  |   $if = array_str_replace($rewrite_shortif, $if); | 
					
						
							|  |  |  |   return $if; | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 17:32:25 +00:00
										 |  |  | function rewrite_ios_features ($features) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   global $rewrite_ios_features; | 
					
						
							|  |  |  |   $type = array_preg_replace($rewrite_ios_features, $features); | 
					
						
							|  |  |  |   return ($features); | 
					
						
							| 
									
										
										
										
											2009-03-23 17:32:25 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | function fixiftype ($type) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   global $rewrite_iftype; | 
					
						
							|  |  |  |   $type = array_preg_replace($rewrite_iftype, $type); | 
					
						
							|  |  |  |   return ($type); | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function fixifName ($inf) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-07 13:47:51 +00:00
										 |  |  |   global $rewrite_ifname; | 
					
						
							|  |  |  |   $inf = strtolower($inf); | 
					
						
							|  |  |  |   $inf = array_str_replace($rewrite_ifname, $inf); | 
					
						
							|  |  |  |   return $inf; | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-31 10:53:54 +00:00
										 |  |  | function short_port_descr ($desc) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   list($desc) = explode("(", $desc); | 
					
						
							|  |  |  |   list($desc) = explode("[", $desc); | 
					
						
							|  |  |  |   list($desc) = explode("{", $desc); | 
					
						
							|  |  |  |   list($desc) = explode("|", $desc); | 
					
						
							|  |  |  |   list($desc) = explode("<", $desc); | 
					
						
							|  |  |  |   $desc = trim($desc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return $desc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-28 12:59:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Underlying rewrite functions
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function array_str_replace($array, $string)  | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     foreach ($array as $search => $replace) { | 
					
						
							|  |  |  |       $string = str_replace($search, $replace, $string); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return $string; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function array_preg_replace($array, $string)  | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     foreach ($array as $search => $replace) { | 
					
						
							|  |  |  |       $string = preg_replace($search, $replace, $string); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return $string; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |