Iface.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <?php
  2. /*
  3. Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
  4. All rights reserved.
  5. Contact: Barry O'Donovan - barry (at) opensolutions (dot) ie
  6. http://www.opensolutions.ie/
  7. This file is part of the OSS_SNMP package.
  8. Redistribution and use in source and binary forms, with or without
  9. modification, are permitted provided that the following conditions are met:
  10. * Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. * Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. * Neither the name of Open Source Solutions Limited nor the
  16. names of its contributors may be used to endorse or promote products
  17. derived from this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  22. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. namespace OSS\SNMP\MIBS;
  30. /**
  31. * A class for performing SNMP V2 queries on generic devices
  32. *
  33. * @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
  34. * @author Barry O'Donovan <barry@opensolutions.ie>
  35. */
  36. class Iface extends \OSS\SNMP\MIB
  37. {
  38. const OID_IF_NUMBER = '.1.3.6.1.2.1.2.1.0';
  39. const OID_IF_DESCRIPTION = '.1.3.6.1.2.1.2.2.1.2';
  40. const OID_IF_TYPE = '.1.3.6.1.2.1.2.2.1.3';
  41. const OID_IF_MTU = '.1.3.6.1.2.1.2.2.1.4';
  42. const OID_IF_SPEED = '.1.3.6.1.2.1.2.2.1.5';
  43. const OID_IF_PHYS_ADDRESS = '.1.3.6.1.2.1.2.2.1.6';
  44. const OID_IF_ADMIN_STATUS = '.1.3.6.1.2.1.2.2.1.7';
  45. const OID_IF_OPER_STATUS = '.1.3.6.1.2.1.2.2.1.8';
  46. const OID_IF_LAST_CHANGE = '.1.3.6.1.2.1.2.2.1.9';
  47. const OID_IF_IN_OCTETS = '.1.3.6.1.2.1.2.2.1.10';
  48. const OID_IF_IN_UNICAST_PACKETS = '.1.3.6.1.2.1.2.2.1.11';
  49. const OID_IF_IN_NON_UNICAST_PACKETS = '.1.3.6.1.2.1.2.2.1.12';
  50. const OID_IF_IN_DISCARDS = '.1.3.6.1.2.1.2.2.1.13';
  51. const OID_IF_IN_ERRORS = '.1.3.6.1.2.1.2.2.1.14';
  52. const OID_IF_IN_UNKNOWN_PROTOCOLS = '.1.3.6.1.2.1.2.2.1.15';
  53. const OID_IF_OUT_OCTETS = '.1.3.6.1.2.1.2.2.1.16';
  54. const OID_IF_OUT_UNICAST_PACKETS = '.1.3.6.1.2.1.2.2.1.17';
  55. const OID_IF_OUT_NON_UNICAST_PACKETS = '.1.3.6.1.2.1.2.2.1.18';
  56. const OID_IF_OUT_DISCARDS = '.1.3.6.1.2.1.2.2.1.19';
  57. const OID_IF_OUT_ERRORS = '.1.3.6.1.2.1.2.2.1.20';
  58. const OID_IF_OUT_QUEUE_LENGTH = '.1.3.6.1.2.1.2.2.1.21';
  59. const OID_IF_NAME = '.1.3.6.1.2.1.31.1.1.1.1';
  60. const OID_IF_ALIAS = '.1.3.6.1.2.1.31.1.1.1.18';
  61. /**
  62. * Get the number of network interfaces (regardless of
  63. * their current state) present on this system.
  64. *
  65. * @return int The number of network interfaces on the system
  66. */
  67. public function numberOfInterfaces()
  68. {
  69. return $this->getSNMP()->get( self::OID_IF_NUMBER );
  70. }
  71. /**
  72. * Get an array of device MTUs
  73. *
  74. * @return array An array of device MTUs
  75. */
  76. public function mtus()
  77. {
  78. return $this->getSNMP()->walk1d( self::OID_IF_MTU );
  79. }
  80. /**
  81. * Get an array of the interfaces' physical addresses
  82. *
  83. * "The interface's address at the protocol layer
  84. * immediately `below' the network layer in the
  85. * protocol stack. For interfaces which do not have
  86. * such an address (e.g., a serial line), this object
  87. * should contain an octet string of zero length."
  88. *
  89. * @return array An array of device physical addresses
  90. */
  91. public function physAddresses()
  92. {
  93. return $this->getSNMP()->walk1d( self::OID_IF_PHYS_ADDRESS );
  94. }
  95. /**
  96. * Constant for possible value of interface admin status.
  97. * @see adminStates()
  98. */
  99. const IF_ADMIN_STATUS_UP = 1;
  100. /**
  101. * Constant for possible value of interface admin status.
  102. * @see adminStates()
  103. */
  104. const IF_ADMIN_STATUS_DOWN = 2;
  105. /**
  106. * Constant for possible value of interface admin status.
  107. * @see adminStates()
  108. */
  109. const IF_ADMIN_STATUS_TESTING = 3;
  110. /**
  111. * Text representation of interface admin status.
  112. *
  113. * @see adminStates()
  114. * @var array Text representations of interface admin status.
  115. */
  116. public static $IF_ADMIN_STATES = array(
  117. self::IF_ADMIN_STATUS_UP => 'up',
  118. self::IF_ADMIN_STATUS_DOWN => 'down',
  119. self::IF_ADMIN_STATUS_TESTING => 'testing'
  120. );
  121. /**
  122. * Get an array of device interface admin status (up / down)
  123. *
  124. * E.g. the follow SNMP output yields the shown array:
  125. *
  126. * .1.3.6.1.2.1.2.2.1.7.10128 = INTEGER: up(1)
  127. * .1.3.6.1.2.1.2.2.1.7.10129 = INTEGER: down(2)
  128. * ...
  129. *
  130. * [10128] => 1
  131. * [10129] => 2
  132. *
  133. * @see IF_ADMIN_STATES
  134. * @param boolean $translate If true, return the string representation
  135. * @return array An array of interface admin states
  136. */
  137. public function adminStates( $translate = false )
  138. {
  139. $states = $this->getSNMP()->walk1d( self::OID_IF_ADMIN_STATUS );
  140. if( !$translate )
  141. return $states;
  142. return $this->getSNMP()->translate( $states, self::$IF_ADMIN_STATES );
  143. }
  144. /**
  145. * Get an array of device interface last change times
  146. *
  147. * Value returned is timeticks (one hundreds of a second)
  148. *
  149. * "The value of sysUpTime at the time the interface
  150. * entered its current operational state. If the
  151. * current state was entered prior to the last re-
  152. * initialization of the local network management
  153. * subsystem, then this object contains a zero
  154. * value."
  155. *
  156. * @see \OSS\SNMP\MIBS\System::uptime()
  157. * @return array Timeticks (or zero) since last change of the interfaces
  158. */
  159. public function lastChanges()
  160. {
  161. return $this->getSNMP()->walk1d( self::OID_IF_LAST_CHANGE );
  162. }
  163. /**
  164. * Get an array of device interface in octets
  165. *
  166. * "The total number of octets received on the
  167. * interface, including framing characters."
  168. *
  169. * @return array The total number of octets received on interfaces
  170. */
  171. public function inOctets()
  172. {
  173. return $this->getSNMP()->walk1d( self::OID_IF_IN_OCTETS );
  174. }
  175. /**
  176. * Get an array of device interface unicast packets in
  177. *
  178. * "The number of subnetwork-unicast packets
  179. * delivered to a higher-layer protocol."
  180. *
  181. * @return array The total number of unicast packets received on interfaces
  182. */
  183. public function inUnicastPackets()
  184. {
  185. return $this->getSNMP()->walk1d( self::OID_IF_IN_UNICAST_PACKETS );
  186. }
  187. /**
  188. * Get an array of device interface non-unicast packets in
  189. *
  190. * "The number of non-unicast (i.e., subnetwork-
  191. * broadcast or subnetwork-multicast) packets
  192. * delivered to a higher-layer protocol."
  193. *
  194. * @return array The total number of non-unicast packets received on interfaces
  195. */
  196. public function inNonUnicastPackets()
  197. {
  198. return $this->getSNMP()->walk1d( self::OID_IF_IN_NON_UNICAST_PACKETS );
  199. }
  200. /**
  201. * Get an array of device interface inbound discarded packets
  202. *
  203. * "The number of inbound packets which were chosen
  204. * to be discarded even though no errors had been
  205. * detected to prevent their being deliverable to a
  206. * higher-layer protocol. One possible reason for
  207. * discarding such a packet could be to free up
  208. * buffer space."
  209. *
  210. * @return arrary The total number of discarded inbound packets received on interfaces
  211. */
  212. public function inDiscards()
  213. {
  214. return $this->getSNMP()->walk1d( self::OID_IF_IN_DISCARDS );
  215. }
  216. /**
  217. * Get an array of device interface inbound error packets
  218. *
  219. * "The number of inbound packets that contained
  220. * errors preventing them from being deliverable to a
  221. * higher-layer protocol."
  222. *
  223. * @return array The total number of error inbound packets received on interfaces
  224. */
  225. public function inErrors()
  226. {
  227. return $this->getSNMP()->walk1d( self::OID_IF_IN_ERRORS );
  228. }
  229. /**
  230. * Get an array of device interface out octets
  231. *
  232. * "The total number of octets transmitted out of the
  233. * interface, including framing characters."
  234. *
  235. * @return array The total number of octets transmitted on interfaces
  236. */
  237. public function outOctets()
  238. {
  239. return $this->getSNMP()->walk1d( self::OID_IF_OUT_OCTETS );
  240. }
  241. /**
  242. * Get an array of device interface unicast packets out
  243. *
  244. * "The total number of packets that higher-level
  245. * protocols requested be transmitted to a
  246. * subnetwork-unicast address, including those that
  247. * were discarded or not sent."
  248. *
  249. * @return array The total number of unicast packets transmitted on interfaces
  250. */
  251. public function outUnicastPackets()
  252. {
  253. return $this->getSNMP()->walk1d( self::OID_IF_OUT_UNICAST_PACKETS );
  254. }
  255. /**
  256. * Get an array of device interface non-unicast packets out
  257. *
  258. * "The total number of packets that higher-level
  259. * protocols requested be transmitted to a non-
  260. * unicast (i.e., a subnetwork-broadcast or
  261. * subnetwork-multicast) address, including those
  262. * that were discarded or not sent."
  263. *
  264. * @return array The total number of non-unicast packets requested sent interfaces
  265. */
  266. public function outNonUnicastPackets()
  267. {
  268. return $this->getSNMP()->walk1d( self::OID_IF_OUT_NON_UNICAST_PACKETS );
  269. }
  270. /**
  271. * Get an array of device interface outbound discarded packets
  272. *
  273. * "The number of outbound packets which were chosen
  274. * to be discarded even though no errors had been
  275. * detected to prevent their being transmitted. One
  276. * possible reason for discarding such a packet could
  277. * be to free up buffer space."
  278. *
  279. * @return arrary The total number of discarded outbound packets
  280. */
  281. public function outDiscards()
  282. {
  283. return $this->getSNMP()->walk1d( self::OID_IF_OUT_DISCARDS );
  284. }
  285. /**
  286. * Get an array of device interface outbound error packets
  287. *
  288. * "The number of outbound packets that could not be
  289. * transmitted because of errors."
  290. *
  291. * @return array The total number of error outbound packets received on interfaces
  292. */
  293. public function outErrors()
  294. {
  295. return $this->getSNMP()->walk1d( self::OID_IF_OUT_ERRORS );
  296. }
  297. /**
  298. * Get an array of interface outbound queue lengths
  299. *
  300. * "The length of the output packet queue (in packets)"
  301. *
  302. * @return array The total number of packets in the outbound queues
  303. */
  304. public function outQueueLength()
  305. {
  306. return $this->getSNMP()->walk1d( self::OID_IF_OUT_QUEUE_LENGTH );
  307. }
  308. /**
  309. * Get an array of packets received on an interface of unknown protocol
  310. *
  311. * "The number of packets received via the interface
  312. * which were discarded because of an unknown or
  313. * unsupported protocol."
  314. *
  315. * @return array The number of packets received on an interface of unknown protocol
  316. */
  317. public function inUnknownProtocols()
  318. {
  319. return $this->getSNMP()->walk1d( self::OID_IF_IN_UNKNOWN_PROTOCOLS );
  320. }
  321. /**
  322. * Get an array of device interface names
  323. *
  324. * E.g. the following SNMP output yields the shown array:
  325. *
  326. * .1.3.6.1.2.1.31.1.1.1.1.10128 = STRING: Gi1/0/28
  327. * .1.3.6.1.2.1.31.1.1.1.1.10129 = STRING: Gi1/0/29
  328. * ...
  329. *
  330. * [10128] => "Gi1/0/28"
  331. * [10129] => "Gi1/0/29"
  332. *
  333. * @return array An array of interface names
  334. */
  335. public function names()
  336. {
  337. return $this->getSNMP()->walk1d( self::OID_IF_NAME );
  338. }
  339. /**
  340. * Get an array of device interface aliases (e.g. as set by the interface description / port-name parameter)
  341. *
  342. * E.g. the followig SNMP output yields the shown array:
  343. *
  344. * .1.3.6.1.2.1.2.2.1.2.18.10128 = STRING: Connection to switch2
  345. * .1.3.6.1.2.1.2.2.1.2.18.10129 = STRING: Connection to switch3
  346. * ...
  347. *
  348. * [10128] => "Connection to switch2"
  349. * [10129] => "Connection to switch3"
  350. *
  351. * @return array An array of interface aliases
  352. */
  353. public function aliases()
  354. {
  355. return $this->getSNMP()->walk1d( self::OID_IF_ALIAS );
  356. }
  357. /**
  358. * Get an array of device interface descriptions
  359. *
  360. * E.g. the following SNMP output yields the shown array:
  361. *
  362. * .1.3.6.1.2.1.31.1.1.1.1.10128 = STRING: GigabitEthernet1/0/28
  363. * .1.3.6.1.2.1.31.1.1.1.1.10129 = STRING: GigabitEthernet1/0/29
  364. * ...
  365. *
  366. * [10128] => "GigabitEthernet1/0/28"
  367. * [10129] => "GigabitEthernet1/0/29"
  368. *
  369. * @return array An array of interface descriptions
  370. */
  371. public function descriptions()
  372. {
  373. return $this->getSNMP()->walk1d( self::OID_IF_DESCRIPTION );
  374. }
  375. /**
  376. * Get an array of device interface (operating) speeds
  377. *
  378. * E.g. the following SNMP output yields the shown array:
  379. *
  380. * .1.3.6.1.2.1.2.2.1.5.10128 = Gauge32: 1000000000
  381. * .1.3.6.1.2.1.2.2.1.5.10129 = Gauge32: 100000000
  382. * ...
  383. *
  384. * [10128] => 1000000000
  385. * [10129] => 100000000
  386. *
  387. * NB: operating speed as opposed to maximum speed
  388. *
  389. * @return array An array of interface operating speeds
  390. */
  391. public function speeds()
  392. {
  393. return $this->getSNMP()->walk1d( self::OID_IF_SPEED );
  394. }
  395. /**
  396. * Constant for possible value of interface operation status.
  397. * @see operationStates()
  398. */
  399. const IF_OPER_STATUS_UP = 1;
  400. /**
  401. * Constant for possible value of interface operation status.
  402. * @see operationStates()
  403. */
  404. const IF_OPER_STATUS_DOWN = 2;
  405. /**
  406. * Constant for possible value of interface operation status.
  407. * @see operationStates()
  408. */
  409. const IF_OPER_STATUS_TESTING = 3;
  410. /**
  411. * Constant for possible value of interface operation status.
  412. * @see operationStates()
  413. */
  414. const IF_OPER_STATUS_UNKNOWN = 4;
  415. /**
  416. * Constant for possible value of interface operation status.
  417. * @see operationStates()
  418. */
  419. const IF_OPER_STATUS_DORMANT = 5;
  420. /**
  421. * Constant for possible value of interface operation status.
  422. * @see operationStates()
  423. */
  424. const IF_OPER_STATUS_NOT_PRESENT = 6;
  425. /**
  426. * Constant for possible value of interface operation status.
  427. * @see operationStates()
  428. */
  429. const IF_OPER_STATUS_LOWER_LAYER_DOWN = 7;
  430. /**
  431. * Text representation of interface operating status.
  432. *
  433. * @see operationStates()
  434. * @var array Text representations of interface operating status.
  435. */
  436. public static $IF_OPER_STATES = array(
  437. self::IF_OPER_STATUS_UP => 'up',
  438. self::IF_OPER_STATUS_DOWN => 'down',
  439. self::IF_OPER_STATUS_TESTING => 'testing',
  440. self::IF_OPER_STATUS_UNKNOWN => 'unknown',
  441. self::IF_OPER_STATUS_DORMANT => 'dormant',
  442. self::IF_OPER_STATUS_NOT_PRESENT => 'notPresent',
  443. self::IF_OPER_STATUS_LOWER_LAYER_DOWN => 'lowerLayerDown'
  444. );
  445. /**
  446. * Get an array of device interface operating status (up / down)
  447. *
  448. * E.g. the follow SNMP output yields the shown array:
  449. *
  450. * .1.3.6.1.2.1.2.2.1.8.10128 = INTEGER: up(1)
  451. * .1.3.6.1.2.1.2.2.1.8.10129 = INTEGER: down(2)
  452. * ...
  453. *
  454. * [10128] => 1
  455. * [10129] => 2
  456. *
  457. * @see IF_OPER_STATES
  458. * @param boolean $translate If true, return the string representation
  459. * @return array An array of interface states
  460. */
  461. public function operationStates( $translate = false )
  462. {
  463. $states = $this->getSNMP()->walk1d( self::OID_IF_OPER_STATUS );
  464. if( !$translate )
  465. return $states;
  466. return $this->getSNMP()->translate( $states, self::$IF_OPER_STATES );
  467. }
  468. /**
  469. * Constant for possible type of an interface
  470. * @see types()
  471. */
  472. const IF_TYPE_OTHER = 1;
  473. /**
  474. * Constant for possible type of an interface
  475. * @see types()
  476. */
  477. const IF_TYPE_REGULAR_1822 = 2;
  478. /**
  479. * Constant for possible type of an interface
  480. * @see types()
  481. */
  482. const IF_TYPE_HDH_1822 = 3;
  483. /**
  484. * Constant for possible type of an interface
  485. * @see types()
  486. */
  487. const IF_TYPE_DDN_X25 = 4;
  488. /**
  489. * Constant for possible type of an interface
  490. * @see types()
  491. */
  492. const IF_TYPE_RFC877_X25 = 5;
  493. /**
  494. * Constant for possible type of an interface
  495. * @see types()
  496. */
  497. const IF_TYPE_ETHERNET_CSMACD = 6;
  498. /**
  499. * Constant for possible type of an interface
  500. * @see types()
  501. */
  502. const IF_TYPE_ISO88023_CSMACD = 7;
  503. /**
  504. * Constant for possible type of an interface
  505. * @see types()
  506. */
  507. const IF_TYPE_ISO88024_TOKEN_BUS = 8;
  508. /**
  509. * Constant for possible type of an interface
  510. * @see types()
  511. */
  512. const IF_TYPE_ISO88025_TOKEN_RING = 9;
  513. /**
  514. * Constant for possible type of an interface
  515. * @see types()
  516. */
  517. const IF_TYPE_ISO88026_MAN = 10;
  518. /**
  519. * Constant for possible type of an interface
  520. * @see types()
  521. */
  522. const IF_TYPE_STAR_LAN = 11;
  523. /**
  524. * Constant for possible type of an interface
  525. * @see types()
  526. */
  527. const IF_TYPE_PROTEON_10MBIT = 12;
  528. /**
  529. * Constant for possible type of an interface
  530. * @see types()
  531. */
  532. const IF_TYPE_PROTEON_80MBIT = 13;
  533. /**
  534. * Constant for possible type of an interface
  535. * @see types()
  536. */
  537. const IF_TYPE_HYPERCHANNEL = 14;
  538. /**
  539. * Constant for possible type of an interface
  540. * @see types()
  541. */
  542. const IF_TYPE_FDDI = 15;
  543. /**
  544. * Constant for possible type of an interface
  545. * @see types()
  546. */
  547. const IF_TYPE_LAPB = 16;
  548. /**
  549. * Constant for possible type of an interface
  550. * @see types()
  551. */
  552. const IF_TYPE_SDLC = 17;
  553. /**
  554. * Constant for possible type of an interface
  555. * @see types()
  556. */
  557. const IF_TYPE_DSL = 18;
  558. /**
  559. * Constant for possible type of an interface
  560. * @see types()
  561. */
  562. const IF_TYPE_E1 = 19;
  563. /**
  564. * Constant for possible type of an interface
  565. * @see types()
  566. */
  567. const IF_TYPE_BASIC_ISDN = 20;
  568. /**
  569. * Constant for possible type of an interface
  570. * @see types()
  571. */
  572. const IF_TYPE_PRIMARY_ISDN = 21;
  573. /**
  574. * Constant for possible type of an interface
  575. * @see types()
  576. */
  577. const IF_TYPE_PROP_POINT_TO_POINT_SERIAL = 22;
  578. /**
  579. * Constant for possible type of an interface
  580. * @see types()
  581. */
  582. const IF_TYPE_PPP = 23;
  583. /**
  584. * Constant for possible type of an interface
  585. * @see types()
  586. */
  587. const IF_TYPE_SOFTWARE_LOOPBACK = 24;
  588. /**
  589. * Constant for possible type of an interface
  590. * @see types()
  591. */
  592. const IF_TYPE_EON = 25;
  593. /**
  594. * Constant for possible type of an interface
  595. * @see types()
  596. */
  597. const IF_TYPE_ETHERNET_3MBIT = 26;
  598. /**
  599. * Constant for possible type of an interface
  600. * @see types()
  601. */
  602. const IF_TYPE_NSIP = 27;
  603. /**
  604. * Constant for possible type of an interface
  605. * @see types()
  606. */
  607. const IF_TYPE_SLIP = 28;
  608. /**
  609. * Constant for possible type of an interface
  610. * @see types()
  611. */
  612. const IF_TYPE_ULTRA = 29;
  613. /**
  614. * Constant for possible type of an interface
  615. * @see types()
  616. */
  617. const IF_TYPE_DS3 = 30;
  618. /**
  619. * Constant for possible type of an interface
  620. * @see types()
  621. */
  622. const IF_TYPE_SIP = 31;
  623. /**
  624. * Constant for possible type of an interface
  625. * @see types()
  626. */
  627. const IF_TYPE_FRAME_RELAY = 32;
  628. /**
  629. * Text representation of interface types.
  630. *
  631. * @see types()
  632. * @var array Text representations of interface types.
  633. */
  634. public static $IF_TYPES = array(
  635. self::IF_TYPE_OTHER => 'other',
  636. self::IF_TYPE_REGULAR_1822 => 'regular1822',
  637. self::IF_TYPE_HDH_1822 => 'hdh1822',
  638. self::IF_TYPE_DDN_X25 => 'ddn-x25',
  639. self::IF_TYPE_RFC877_X25 => 'rfc877-x25',
  640. self::IF_TYPE_ETHERNET_CSMACD => 'ethernet-csmacd',
  641. self::IF_TYPE_ISO88023_CSMACD => 'iso88023-csmacd',
  642. self::IF_TYPE_ISO88024_TOKEN_BUS => 'iso88024-tokenBus',
  643. self::IF_TYPE_ISO88025_TOKEN_RING => 'iso88025-tokenRing',
  644. self::IF_TYPE_ISO88026_MAN => 'iso88026-man',
  645. self::IF_TYPE_STAR_LAN => 'starLan',
  646. self::IF_TYPE_PROTEON_10MBIT => 'proteon-10Mbit',
  647. self::IF_TYPE_PROTEON_80MBIT => 'proteon-80Mbit',
  648. self::IF_TYPE_HYPERCHANNEL => 'hyperchannel',
  649. self::IF_TYPE_FDDI => 'fddi',
  650. self::IF_TYPE_LAPB => 'lapb',
  651. self::IF_TYPE_SDLC => 'sdlc',
  652. self::IF_TYPE_DSL => 'ds1',
  653. self::IF_TYPE_E1 => 'e1',
  654. self::IF_TYPE_BASIC_ISDN => 'basicISDN',
  655. self::IF_TYPE_PRIMARY_ISDN => 'primaryISDN',
  656. self::IF_TYPE_PROP_POINT_TO_POINT_SERIAL => 'propPointToPointSerial',
  657. self::IF_TYPE_PPP => 'ppp',
  658. self::IF_TYPE_SOFTWARE_LOOPBACK => 'softwareLoopback',
  659. self::IF_TYPE_EON => 'eon',
  660. self::IF_TYPE_ETHERNET_3MBIT => 'ethernet-3Mbit',
  661. self::IF_TYPE_NSIP => 'nsip',
  662. self::IF_TYPE_SLIP => 'slip',
  663. self::IF_TYPE_ULTRA => 'ultra',
  664. self::IF_TYPE_DS3 => 'ds3',
  665. self::IF_TYPE_SIP => 'sip',
  666. self::IF_TYPE_FRAME_RELAY => 'frame-relay'
  667. );
  668. /**
  669. * Get an array of device interface types
  670. *
  671. * @see $IF_TYPES
  672. * @param boolean $translate If true, return the string representation
  673. * @return array An array of interface types
  674. */
  675. public function types( $translate = false )
  676. {
  677. $types = $this->getSNMP()->walk1d( self::OID_IF_TYPE );
  678. if( !$translate )
  679. return $types;
  680. return $this->getSNMP()->translate( $types, self::$IF_TYPES );
  681. }
  682. /**
  683. * Returns an associate array of STP port IDs (key) to interface IDs (value)
  684. *
  685. * e.g. [22] => 10122
  686. *
  687. *
  688. * @return array Associate array of STP port IDs (key) to interface IDs (value)
  689. */
  690. public function bridgeBasePortIfIndexes()
  691. {
  692. return $this->getSNMP()->walk1d( self::OID_BRIDGE_BASE_PORT_IF_INDEX );
  693. }
  694. }