Channels.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
  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\Asterisk;
  30. /**
  31. * A class for performing SNMP V2 queries on Asterisk
  32. *
  33. * @see https://wiki.asterisk.org/wiki/display/AST/Asterisk+MIB+Definitions
  34. * @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
  35. * @author Barry O'Donovan <barry@opensolutions.ie>
  36. */
  37. class Channels extends \OSS_SNMP\MIB
  38. {
  39. const OID_ASTERISK_CHANNELS_ACTIVE = '.1.3.6.1.4.1.22736.1.5.1.0';
  40. const OID_ASTERISK_CHANNELS_SUPPORTED = '.1.3.6.1.4.1.22736.1.5.3.0';
  41. const OID_ASTERISK_CHANNEL_TYPE_NAME = '.1.3.6.1.4.1.22736.1.5.4.1.2';
  42. const OID_ASTERISK_CHANNEL_TYPE_DESCRIPTION = '.1.3.6.1.4.1.22736.1.5.4.1.3';
  43. const OID_ASTERISK_CHANNEL_TYPE_STATE = '.1.3.6.1.4.1.22736.1.5.4.1.4';
  44. const OID_ASTERISK_CHANNEL_TYPE_INDICATION = '.1.3.6.1.4.1.22736.1.5.4.1.5';
  45. const OID_ASTERISK_CHANNEL_TYPE_TRANSFER = '.1.3.6.1.4.1.22736.1.5.4.1.6';
  46. const OID_ASTERISK_CHANNEL_TYPE_CHANNELS = '.1.3.6.1.4.1.22736.1.5.4.1.7';
  47. const OID_ASTERISK_CHANNEL_NAME = '.1.3.6.1.4.1.22736.1.5.2.1.2';
  48. const OID_ASTERISK_CHANNEL_LANGUAGE = '.1.3.6.1.4.1.22736.1.5.2.1.3';
  49. const OID_ASTERISK_CHANNEL_TYPE = '.1.3.6.1.4.1.22736.1.5.2.1.4';
  50. const OID_ASTERISK_CHANNEL_MUSIC_CLASS = '.1.3.6.1.4.1.22736.1.5.2.1.5';
  51. const OID_ASTERISK_CHANNEL_BRIDGE = '.1.3.6.1.4.1.22736.1.5.2.1.6';
  52. const OID_ASTERISK_CHANNEL_MASQ = '.1.3.6.1.4.1.22736.1.5.2.1.7';
  53. const OID_ASTERISK_CHANNEL_MASQR = '.1.3.6.1.4.1.22736.1.5.2.1.8';
  54. const OID_ASTERISK_CHANNEL_WHEN_HANGUP = '.1.3.6.1.4.1.22736.1.5.2.1.9';
  55. const OID_ASTERISK_CHANNEL_APP = '.1.3.6.1.4.1.22736.1.5.2.1.10';
  56. const OID_ASTERISK_CHANNEL_DATA = '.1.3.6.1.4.1.22736.1.5.2.1.11';
  57. const OID_ASTERISK_CHANNEL_CONTEXT = '.1.3.6.1.4.1.22736.1.5.2.1.12';
  58. const OID_ASTERISK_CHANNEL_MACRO_CONTEXT = '.1.3.6.1.4.1.22736.1.5.2.1.13';
  59. const OID_ASTERISK_CHANNEL_MACRO_EXTEN = '.1.3.6.1.4.1.22736.1.5.2.1.14';
  60. const OID_ASTERISK_CHANNEL_MACRO_PRI = '.1.3.6.1.4.1.22736.1.5.2.1.15';
  61. const OID_ASTERISK_CHANNEL_EXTEN = '.1.3.6.1.4.1.22736.1.5.2.1.16';
  62. const OID_ASTERISK_CHANNEL_PRI = '.1.3.6.1.4.1.22736.1.5.2.1.17';
  63. const OID_ASTERISK_CHANNEL_ACCOUNT_CODE = '.1.3.6.1.4.1.22736.1.5.2.1.18';
  64. const OID_ASTERISK_CHANNEL_FORWARD_TO = '.1.3.6.1.4.1.22736.1.5.2.1.19';
  65. const OID_ASTERISK_CHANNEL_UNQIUEID = '.1.3.6.1.4.1.22736.1.5.2.1.20';
  66. const OID_ASTERISK_CHANNEL_CALL_GROUP = '.1.3.6.1.4.1.22736.1.5.2.1.21';
  67. const OID_ASTERISK_CHANNEL_PICKUP_GROUP = '.1.3.6.1.4.1.22736.1.5.2.1.22';
  68. const OID_ASTERISK_CHANNEL_STATE = '.1.3.6.1.4.1.22736.1.5.2.1.23';
  69. const OID_ASTERISK_CHANNEL_MUTED = '.1.3.6.1.4.1.22736.1.5.2.1.24';
  70. const OID_ASTERISK_CHANNEL_RINGS = '.1.3.6.1.4.1.22736.1.5.2.1.25';
  71. const OID_ASTERISK_CHANNEL_CID_DNID = '.1.3.6.1.4.1.22736.1.5.2.1.26';
  72. const OID_ASTERISK_CHANNEL_CID_NUM = '.1.3.6.1.4.1.22736.1.5.2.1.27';
  73. const OID_ASTERISK_CHANNEL_CID_NAME = '.1.3.6.1.4.1.22736.1.5.2.1.28';
  74. const OID_ASTERISK_CHANNEL_CID_ANI = '.1.3.6.1.4.1.22736.1.5.2.1.29';
  75. const OID_ASTERISK_CHANNEL_CID_RDNIS = '.1.3.6.1.4.1.22736.1.5.2.1.30';
  76. const OID_ASTERISK_CHANNEL_CID_PRESENTATION = '.1.3.6.1.4.1.22736.1.5.2.1.31';
  77. const OID_ASTERISK_CHANNEL_CID_ANI2 = '.1.3.6.1.4.1.22736.1.5.2.1.32';
  78. const OID_ASTERISK_CHANNEL_CID_TON = '.1.3.6.1.4.1.22736.1.5.2.1.33';
  79. const OID_ASTERISK_CHANNEL_CID_TNS = '.1.3.6.1.4.1.22736.1.5.2.1.34';
  80. const OID_ASTERISK_CHANNEL_AMA_FLAGS = '.1.3.6.1.4.1.22736.1.5.2.1.35';
  81. const OID_ASTERISK_CHANNEL_ADSI = '.1.3.6.1.4.1.22736.1.5.2.1.36';
  82. const OID_ASTERISK_CHANNEL_TONE_ZONE = '.1.3.6.1.4.1.22736.1.5.2.1.37';
  83. const OID_ASTERISK_CHANNEL_HANGUP_CAUSE = '.1.3.6.1.4.1.22736.1.5.2.1.38';
  84. const OID_ASTERISK_CHANNEL_VARIABLES = '.1.3.6.1.4.1.22736.1.5.2.1.39';
  85. const OID_ASTERISK_CHANNEL_FLAGS = '.1.3.6.1.4.1.22736.1.5.2.1.40';
  86. const OID_ASTERISK_CHANNEL_TRANSFER_CAP = '.1.3.6.1.4.1.22736.1.5.2.1.41';
  87. const OID_ASTERISK_CHANNELS_BRIDGED = '.1.3.6.1.4.1.22736.1.5.5.1.0';
  88. /**
  89. * Returns the current number of active channels.
  90. *
  91. * > Current number of active channels.
  92. *
  93. * @return int The current number of active channels.
  94. */
  95. public function active()
  96. {
  97. return $this->getSNMP()->get( self::OID_ASTERISK_CHANNELS_ACTIVE );
  98. }
  99. /**
  100. * Returns the number of channel types (technologies) supported.
  101. *
  102. * > Number of channel types (technologies) supported.
  103. *
  104. * @return int The number of channel types (technologies) supported.
  105. */
  106. public function supported()
  107. {
  108. return $this->getSNMP()->get( self::OID_ASTERISK_CHANNELS_SUPPORTED );
  109. }
  110. /**
  111. * Array of supported channel type names
  112. *
  113. * > Unique name of the technology we are describing.
  114. *
  115. * @return array Supported channel type names
  116. */
  117. public function names()
  118. {
  119. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_NAME );
  120. }
  121. /**
  122. * Array of supported channel type descriptions
  123. *
  124. * > Description of the channel type (technology).
  125. *
  126. * @return array Supported channel type descriptions
  127. */
  128. public function descriptions()
  129. {
  130. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_DESCRIPTION );
  131. }
  132. /**
  133. * Array of supported channel type device state capability
  134. *
  135. * > Whether the current technology can hold device states.
  136. *
  137. * @return array Whether the current technology can hold device states.
  138. */
  139. public function deviceStates()
  140. {
  141. return $this->getSNMP()->ppTruthValue( $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_STATE ) );
  142. }
  143. /**
  144. * Array of supported channel type progress indication capability
  145. *
  146. * > Whether the current technology supports progress indication.
  147. *
  148. * @return array Whether the current technology supports progress indication.
  149. */
  150. public function progressIndications()
  151. {
  152. return $this->getSNMP()->ppTruthValue( $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_INDICATION ) );
  153. }
  154. /**
  155. * Array of supported channel type transfer capability
  156. *
  157. * > Whether the current technology supports transfers, where
  158. * > Asterisk can get out from inbetween two bridged channels.
  159. *
  160. * @return array Whether the current technology transfers
  161. */
  162. public function transfers()
  163. {
  164. return $this->getSNMP()->ppTruthValue( $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_TRANSFER ) );
  165. }
  166. /**
  167. * Array of active calls on supported channels
  168. *
  169. * > Number of active channels using the current technology.
  170. *
  171. * @return array Active calls on supported channels
  172. */
  173. public function activeCalls()
  174. {
  175. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE_CHANNELS );
  176. }
  177. /**
  178. * Number of channels currently in a bridged state.
  179. *
  180. * > Number of channels currently in a bridged state.
  181. *
  182. * @return int Array of active calls on supported channels
  183. */
  184. public function bridged()
  185. {
  186. return $this->getSNMP()->get( self::OID_ASTERISK_CHANNELS_BRIDGED );
  187. }
  188. /**
  189. * Utility function to gather channel details together in an associative array.
  190. *
  191. * Returns an array of support channel types. For example:
  192. *
  193. * Array
  194. * (
  195. * ....
  196. * [SIP] => Array
  197. * (
  198. * [name] => SIP
  199. * [index] => 5
  200. * [description] => Session Initiation Protocol (SIP)
  201. * [hasDeviceState] => 1
  202. * [hasProgressIndications] => 1
  203. * [canTransfer] => 1
  204. * [activeCalls] => 0
  205. * )
  206. * ....
  207. * )
  208. *
  209. * If you chose to index by SNMP table entries, the above element would be indexed with `5` rather than `SIP`.
  210. *
  211. * @param bool $useIndex If true, the array is indexed using the SNMP table index rather than the unique channel type name
  212. * @return array Channel details as an associative array
  213. */
  214. public function details( $useIndex = false )
  215. {
  216. $details = [];
  217. foreach( $this->names() as $index => $name )
  218. {
  219. if( $useIndex )
  220. $idx = $index;
  221. else
  222. $idx = $name;
  223. $details[ $idx ]['name'] = $name;
  224. $details[ $idx ]['index'] = $index;
  225. $details[ $idx ]['description'] = $this->descriptions()[$index];
  226. $details[ $idx ]['hasDeviceState'] = $this->deviceStates()[$index];
  227. $details[ $idx ]['hasProgressIndications'] = $this->progressIndications()[$index];
  228. $details[ $idx ]['canTransfer'] = $this->transfers()[$index];
  229. $details[ $idx ]['activeCalls'] = $this->activeCalls()[$index];
  230. }
  231. return $details;
  232. }
  233. /**
  234. * Active Channel Information: Name of the current channel.
  235. *
  236. * NB: SNMP exceptions are caught and in such cases null is returned
  237. * as not all channels have all properties.
  238. *
  239. * > Name of the current channel.
  240. *
  241. * @return array Name of the current channel.
  242. */
  243. public function chanName()
  244. {
  245. try
  246. {
  247. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_NAME );
  248. }
  249. catch( \OSS_SNMP\Exception $e )
  250. {
  251. return null;
  252. }
  253. }
  254. /**
  255. * Active Channel Information: Which language the current channel is configured to use -- used mainly for prompts.
  256. *
  257. * NB: SNMP exceptions are caught and in such cases null is returned
  258. * as not all channels have all properties.
  259. *
  260. * > Which language the current channel is configured to use -- used mainly for prompts.
  261. *
  262. * @return array Which language the current channel is configured to use -- used mainly for prompts.
  263. */
  264. public function chanLanguage()
  265. {
  266. try
  267. {
  268. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_LANGUAGE );
  269. }
  270. catch( \OSS_SNMP\Exception $e )
  271. {
  272. return null;
  273. }
  274. }
  275. /**
  276. * Active Channel Information: Underlying technology for the current channel.
  277. *
  278. * NB: SNMP exceptions are caught and in such cases null is returned
  279. * as not all channels have all properties.
  280. *
  281. * > Underlying technology for the current channel.
  282. *
  283. * @return array Underlying technology for the current channel.
  284. */
  285. public function chanType()
  286. {
  287. try
  288. {
  289. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TYPE );
  290. }
  291. catch( \OSS_SNMP\Exception $e )
  292. {
  293. return null;
  294. }
  295. }
  296. /**
  297. * Active Channel Information: Music class to be used for Music on Hold for this channel.
  298. *
  299. * NB: SNMP exceptions are caught and in such cases null is returned
  300. * as not all channels have all properties.
  301. *
  302. * > Music class to be used for Music on Hold for this channel.
  303. *
  304. * @return array Music class to be used for Music on Hold for this channel.
  305. */
  306. public function chanMusicClass()
  307. {
  308. try
  309. {
  310. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MUSIC_CLASS );
  311. }
  312. catch( \OSS_SNMP\Exception $e )
  313. {
  314. return null;
  315. }
  316. }
  317. /**
  318. * Active Channel Information: Which channel this channel is currently bridged (in a conversation) with.
  319. *
  320. * NB: SNMP exceptions are caught and in such cases null is returned
  321. * as not all channels have all properties.
  322. *
  323. * > Which channel this channel is currently bridged (in a conversation) with.
  324. *
  325. * @return array Which channel this channel is currently bridged (in a conversation) with.
  326. */
  327. public function chanBridge()
  328. {
  329. try
  330. {
  331. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_BRIDGE );
  332. }
  333. catch( \OSS_SNMP\Exception $e )
  334. {
  335. return null;
  336. }
  337. }
  338. /**
  339. * Active Channel Information: Channel masquerading for us.
  340. *
  341. * NB: SNMP exceptions are caught and in such cases null is returned
  342. * as not all channels have all properties.
  343. *
  344. * > Channel masquerading for us.
  345. *
  346. * @return array Channel masquerading for us.
  347. */
  348. public function chanMasq()
  349. {
  350. try
  351. {
  352. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MASQ );
  353. }
  354. catch( \OSS_SNMP\Exception $e )
  355. {
  356. return null;
  357. }
  358. }
  359. /**
  360. * Active Channel Information: Channel we are masquerading for.
  361. *
  362. * NB: SNMP exceptions are caught and in such cases null is returned
  363. * as not all channels have all properties.
  364. *
  365. * > Channel we are masquerading for.
  366. *
  367. * @return array Channel we are masquerading for.
  368. */
  369. public function chanMasqr()
  370. {
  371. try
  372. {
  373. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MASQR );
  374. }
  375. catch( \OSS_SNMP\Exception $e )
  376. {
  377. return null;
  378. }
  379. }
  380. /**
  381. * Active Channel Information: How long until this channel will be hung up.
  382. *
  383. * NB: SNMP exceptions are caught and in such cases null is returned
  384. * as not all channels have all properties.
  385. *
  386. * > How long until this channel will be hung up.
  387. *
  388. * @return array How long until this channel will be hung up.
  389. */
  390. public function chanWhenHangup()
  391. {
  392. try
  393. {
  394. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_WHEN_HANGUP );
  395. }
  396. catch( \OSS_SNMP\Exception $e )
  397. {
  398. return null;
  399. }
  400. }
  401. /**
  402. * Active Channel Information: Current application for the channel.
  403. *
  404. * NB: SNMP exceptions are caught and in such cases null is returned
  405. * as not all channels have all properties.
  406. *
  407. * > Current application for the channel.
  408. *
  409. * @return array Current application for the channel.
  410. */
  411. public function chanApp()
  412. {
  413. try
  414. {
  415. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_APP );
  416. }
  417. catch( \OSS_SNMP\Exception $e )
  418. {
  419. return null;
  420. }
  421. }
  422. /**
  423. * Active Channel Information: Arguments passed to the current application.
  424. *
  425. * NB: SNMP exceptions are caught and in such cases null is returned
  426. * as not all channels have all properties.
  427. *
  428. * > Arguments passed to the current application.
  429. *
  430. * @return array Arguments passed to the current application.
  431. */
  432. public function chanData()
  433. {
  434. try
  435. {
  436. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_DATA );
  437. }
  438. catch( \OSS_SNMP\Exception $e )
  439. {
  440. return null;
  441. }
  442. }
  443. /**
  444. * Active Channel Information: Current extension context.
  445. *
  446. * NB: SNMP exceptions are caught and in such cases null is returned
  447. * as not all channels have all properties.
  448. *
  449. * > Current extension context.
  450. *
  451. * @return array Current extension context.
  452. */
  453. public function chanContext()
  454. {
  455. try
  456. {
  457. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CONTEXT );
  458. }
  459. catch( \OSS_SNMP\Exception $e )
  460. {
  461. return null;
  462. }
  463. }
  464. /**
  465. * Active Channel Information: Current macro context.
  466. *
  467. * NB: SNMP exceptions are caught and in such cases null is returned
  468. * as not all channels have all properties.
  469. *
  470. * > Current macro context.
  471. *
  472. * @return array Current macro context.
  473. */
  474. public function chanMacroContext()
  475. {
  476. try
  477. {
  478. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MACRO_CONTEXT );
  479. }
  480. catch( \OSS_SNMP\Exception $e )
  481. {
  482. return null;
  483. }
  484. }
  485. /**
  486. * Active Channel Information: Current macro extension.
  487. *
  488. * NB: SNMP exceptions are caught and in such cases null is returned
  489. * as not all channels have all properties.
  490. *
  491. * > Current macro extension.
  492. *
  493. * @return array Current macro extension.
  494. */
  495. public function chanMacroExten()
  496. {
  497. try
  498. {
  499. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MACRO_EXTEN );
  500. }
  501. catch( \OSS_SNMP\Exception $e )
  502. {
  503. return null;
  504. }
  505. }
  506. /**
  507. * Active Channel Information: Current macro priority.
  508. *
  509. * NB: SNMP exceptions are caught and in such cases null is returned
  510. * as not all channels have all properties.
  511. *
  512. * > Current macro priority.
  513. *
  514. * @return array Current macro priority.
  515. */
  516. public function chanMacroPri()
  517. {
  518. try
  519. {
  520. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MACRO_PRI );
  521. }
  522. catch( \OSS_SNMP\Exception $e )
  523. {
  524. return null;
  525. }
  526. }
  527. /**
  528. * Active Channel Information: Current extension.
  529. *
  530. * NB: SNMP exceptions are caught and in such cases null is returned
  531. * as not all channels have all properties.
  532. *
  533. * > Current extension.
  534. *
  535. * @return array Current extension.
  536. */
  537. public function chanExten()
  538. {
  539. try
  540. {
  541. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_EXTEN );
  542. }
  543. catch( \OSS_SNMP\Exception $e )
  544. {
  545. return null;
  546. }
  547. }
  548. /**
  549. * Active Channel Information: Current priority.
  550. *
  551. * NB: SNMP exceptions are caught and in such cases null is returned
  552. * as not all channels have all properties.
  553. *
  554. * > Current priority.
  555. *
  556. * @return array Current priority.
  557. */
  558. public function chanPri()
  559. {
  560. try
  561. {
  562. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_PRI );
  563. }
  564. catch( \OSS_SNMP\Exception $e )
  565. {
  566. return null;
  567. }
  568. }
  569. /**
  570. * Active Channel Information: Account Code for billing.
  571. *
  572. * NB: SNMP exceptions are caught and in such cases null is returned
  573. * as not all channels have all properties.
  574. *
  575. * > Account Code for billing.
  576. *
  577. * @return array Account Code for billing.
  578. */
  579. public function chanAccountCode()
  580. {
  581. try
  582. {
  583. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_ACCOUNT_CODE );
  584. }
  585. catch( \OSS_SNMP\Exception $e )
  586. {
  587. return null;
  588. }
  589. }
  590. /**
  591. * Active Channel Information: Where to forward to if asked to dial on this interface.
  592. *
  593. * NB: SNMP exceptions are caught and in such cases null is returned
  594. * as not all channels have all properties.
  595. *
  596. * > Where to forward to if asked to dial on this interface.
  597. *
  598. * @return array Where to forward to if asked to dial on this interface.
  599. */
  600. public function chanForwardTo()
  601. {
  602. try
  603. {
  604. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_FORWARD_TO );
  605. }
  606. catch( \OSS_SNMP\Exception $e )
  607. {
  608. return null;
  609. }
  610. }
  611. /**
  612. * Active Channel Information: Unique Channel Identifier.
  613. *
  614. * NB: SNMP exceptions are caught and in such cases null is returned
  615. * as not all channels have all properties.
  616. *
  617. * > Unique Channel Identifier.
  618. *
  619. * @return array Unique Channel Identifier.
  620. */
  621. public function chanUniqueId()
  622. {
  623. try
  624. {
  625. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_UNQIUEID );
  626. }
  627. catch( \OSS_SNMP\Exception $e )
  628. {
  629. return null;
  630. }
  631. }
  632. /**
  633. * Active Channel Information: Call Group.
  634. *
  635. * NB: SNMP exceptions are caught and in such cases null is returned
  636. * as not all channels have all properties.
  637. *
  638. * > Call Group.
  639. *
  640. * @return array Call Group.
  641. */
  642. public function chanCallGroup()
  643. {
  644. try
  645. {
  646. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CALL_GROUP );
  647. }
  648. catch( \OSS_SNMP\Exception $e )
  649. {
  650. return null;
  651. }
  652. }
  653. /**
  654. * Active Channel Information: Pickup Group.
  655. *
  656. * NB: SNMP exceptions are caught and in such cases null is returned
  657. * as not all channels have all properties.
  658. *
  659. * > Pickup Group.
  660. *
  661. * @return array Pickup Group.
  662. */
  663. public function chanPickupGroup()
  664. {
  665. try
  666. {
  667. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_PICKUP_GROUP );
  668. }
  669. catch( \OSS_SNMP\Exception $e )
  670. {
  671. return null;
  672. }
  673. }
  674. /**
  675. * Possible state of an Asterisk channel as returned by `chanState()`
  676. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  677. */
  678. const CHANNEL_STATE_DOWN = 0;
  679. /**
  680. * Possible state of an Asterisk channel as returned by `chanState()`
  681. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  682. */
  683. const CHANNEL_STATE_RESERVED = 1;
  684. /**
  685. * Possible state of an Asterisk channel as returned by `chanState()`
  686. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  687. */
  688. const CHANNEL_STATE_OFF_HOOK = 2;
  689. /**
  690. * Possible state of an Asterisk channel as returned by `chanState()`
  691. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  692. */
  693. const CHANNEL_STATE_DIALING = 3;
  694. /**
  695. * Possible state of an Asterisk channel as returned by `chanState()`
  696. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  697. */
  698. const CHANNEL_STATE_RING = 4;
  699. /**
  700. * Possible state of an Asterisk channel as returned by `chanState()`
  701. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  702. */
  703. const CHANNEL_STATE_RINGING = 5;
  704. /**
  705. * Possible state of an Asterisk channel as returned by `chanState()`
  706. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  707. */
  708. const CHANNEL_STATE_UP = 6;
  709. /**
  710. * Possible state of an Asterisk channel as returned by `chanState()`
  711. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  712. */
  713. const CHANNEL_STATE_BUSY = 7;
  714. /**
  715. * Possible state of an Asterisk channel as returned by `chanState()`
  716. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  717. */
  718. const CHANNEL_STATE_DIALING_OFF_HOOK = 8;
  719. /**
  720. * Possible state of an Asterisk channel as returned by `chanState()`
  721. * @var int Possible state of an Asterisk channel as returned by `chanState()`
  722. */
  723. const CHANNEL_STATE_PRE_RING = 9;
  724. public static $CHANNEL_STATES = [
  725. self::CHANNEL_STATE_DOWN => 'down',
  726. self::CHANNEL_STATE_RESERVED => 'reserved',
  727. self::CHANNEL_STATE_OFF_HOOK => 'offHook',
  728. self::CHANNEL_STATE_DIALING => 'dialing',
  729. self::CHANNEL_STATE_RING => 'ring',
  730. self::CHANNEL_STATE_RINGING => 'ringing',
  731. self::CHANNEL_STATE_UP => 'up',
  732. self::CHANNEL_STATE_BUSY => 'busy',
  733. self::CHANNEL_STATE_DIALING_OFF_HOOK => 'dialingOffHook',
  734. self::CHANNEL_STATE_PRE_RING => 'preRing'
  735. ];
  736. /**
  737. * Active Channel Information: Channel state (see channel state constants).
  738. *
  739. * NB: SNMP exceptions are caught and in such cases null is returned
  740. * as not all channels have all properties.
  741. *
  742. * > Channel state (see channel state constants).
  743. *
  744. * @param bool $translate If true, use the `$CHANNEL_STATES` array to return textual representation
  745. * @return array Channel state (see channel state constants).
  746. */
  747. public function chanState( $translate = false )
  748. {
  749. try
  750. {
  751. $s = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_STATE );
  752. if( !$translate )
  753. return $s;
  754. return $this->getSNMP()->translate( $s, self::$CHANNEL_STATES );
  755. }
  756. catch( \OSS_SNMP\Exception $e )
  757. {
  758. return null;
  759. }
  760. }
  761. /**
  762. * Active Channel Information: Transmission of voice data has been muted.
  763. *
  764. * NB: SNMP exceptions are caught and in such cases null is returned
  765. * as not all channels have all properties.
  766. *
  767. * > Transmission of voice data has been muted.
  768. *
  769. * @return array Transmission of voice data has been muted.
  770. */
  771. public function chanMuted()
  772. {
  773. try
  774. {
  775. return $this->getSNMP()->ppTruthValue( $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_MUTED ) );
  776. }
  777. catch( \OSS_SNMP\Exception $e )
  778. {
  779. return null;
  780. }
  781. }
  782. /**
  783. * Active Channel Information: Number of rings so far.
  784. *
  785. * NB: SNMP exceptions are caught and in such cases null is returned
  786. * as not all channels have all properties.
  787. *
  788. * > Number of rings so far.
  789. *
  790. * @return array Number of rings so far.
  791. */
  792. public function chanRings()
  793. {
  794. try
  795. {
  796. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_RINGS );
  797. }
  798. catch( \OSS_SNMP\Exception $e )
  799. {
  800. return null;
  801. }
  802. }
  803. /**
  804. * Active Channel Information: Dialled Number ID.
  805. *
  806. * NB: SNMP exceptions are caught and in such cases null is returned
  807. * as not all channels have all properties.
  808. *
  809. * > Dialled Number ID.
  810. *
  811. * @return array Dialled Number ID.
  812. */
  813. public function chanCidDNID()
  814. {
  815. try
  816. {
  817. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_DNID );
  818. }
  819. catch( \OSS_SNMP\Exception $e )
  820. {
  821. return null;
  822. }
  823. }
  824. /**
  825. * Active Channel Information: Caller Number.
  826. *
  827. * NB: SNMP exceptions are caught and in such cases null is returned
  828. * as not all channels have all properties.
  829. *
  830. * > Caller Number.
  831. *
  832. * @return array Caller Number.
  833. */
  834. public function chanCidNum()
  835. {
  836. try
  837. {
  838. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_NUM );
  839. }
  840. catch( \OSS_SNMP\Exception $e )
  841. {
  842. return null;
  843. }
  844. }
  845. /**
  846. * Active Channel Information: Caller Name.
  847. *
  848. * NB: SNMP exceptions are caught and in such cases null is returned
  849. * as not all channels have all properties.
  850. *
  851. * > Caller Name.
  852. *
  853. * @return array Caller Name.
  854. */
  855. public function chanCidName()
  856. {
  857. try
  858. {
  859. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_NAME );
  860. }
  861. catch( \OSS_SNMP\Exception $e )
  862. {
  863. return null;
  864. }
  865. }
  866. /**
  867. * Active Channel Information: ANI
  868. *
  869. * NB: SNMP exceptions are caught and in such cases null is returned
  870. * as not all channels have all properties.
  871. *
  872. * > ANI
  873. *
  874. * @return array ANI
  875. */
  876. public function chanCidANI()
  877. {
  878. try
  879. {
  880. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_ANI );
  881. }
  882. catch( \OSS_SNMP\Exception $e )
  883. {
  884. return null;
  885. }
  886. }
  887. /**
  888. * Active Channel Information: Redirected Dialled Number Service.
  889. *
  890. * NB: SNMP exceptions are caught and in such cases null is returned
  891. * as not all channels have all properties.
  892. *
  893. * > Redirected Dialled Number Service.
  894. *
  895. * @return array Redirected Dialled Number Service.
  896. */
  897. public function chanCidRDNIS()
  898. {
  899. try
  900. {
  901. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_RDNIS );
  902. }
  903. catch( \OSS_SNMP\Exception $e )
  904. {
  905. return null;
  906. }
  907. }
  908. /**
  909. * Active Channel Information: Number Presentation/Screening.
  910. *
  911. * NB: SNMP exceptions are caught and in such cases null is returned
  912. * as not all channels have all properties.
  913. *
  914. * > Number Presentation/Screening.
  915. *
  916. * @return array Number Presentation/Screening.
  917. */
  918. public function chanCidPresentation()
  919. {
  920. try
  921. {
  922. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_PRESENTATION );
  923. }
  924. catch( \OSS_SNMP\Exception $e )
  925. {
  926. return null;
  927. }
  928. }
  929. /**
  930. * Active Channel Information: ANI 2 (info digit).
  931. *
  932. * NB: SNMP exceptions are caught and in such cases null is returned
  933. * as not all channels have all properties.
  934. *
  935. * > ANI 2 (info digit).
  936. *
  937. * @return array ANI 2 (info digit).
  938. */
  939. public function chanCidANI2()
  940. {
  941. try
  942. {
  943. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_ANI2 );
  944. }
  945. catch( \OSS_SNMP\Exception $e )
  946. {
  947. return null;
  948. }
  949. }
  950. /**
  951. * Active Channel Information: Type of Number.
  952. *
  953. * NB: SNMP exceptions are caught and in such cases null is returned
  954. * as not all channels have all properties.
  955. *
  956. * > Type of Number.
  957. *
  958. * @return array Type of Number.
  959. */
  960. public function chanCidTON()
  961. {
  962. try
  963. {
  964. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_TON );
  965. }
  966. catch( \OSS_SNMP\Exception $e )
  967. {
  968. return null;
  969. }
  970. }
  971. /**
  972. * Active Channel Information: Transit Network Select.
  973. *
  974. * NB: SNMP exceptions are caught and in such cases null is returned
  975. * as not all channels have all properties.
  976. *
  977. * > Transit Network Select.
  978. *
  979. * @return array Transit Network Select.
  980. */
  981. public function chanCidTNS()
  982. {
  983. try
  984. {
  985. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_CID_TNS );
  986. }
  987. catch( \OSS_SNMP\Exception $e )
  988. {
  989. return null;
  990. }
  991. }
  992. /**
  993. * Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  994. * @var int Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  995. */
  996. const CHANNEL_AMA_FLAG_DEFAULT = 0;
  997. /**
  998. * Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  999. * @var int Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  1000. */
  1001. const CHANNEL_AMA_FLAG_OMIT = 1;
  1002. /**
  1003. * Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  1004. * @var int Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  1005. */
  1006. const CHANNEL_AMA_FLAG_BILLING = 2;
  1007. /**
  1008. * Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  1009. * @var int Possible AMA flag of an Asterisk channel as returned by `chanAMAFlags()`
  1010. */
  1011. const CHANNEL_AMA_FLAG_DOCUMENTATION = 3;
  1012. public static $CHANNEL_AMA_FLAGS = [
  1013. self::CHANNEL_AMA_FLAG_DEFAULT => 'default',
  1014. self::CHANNEL_AMA_FLAG_OMIT => 'omit',
  1015. self::CHANNEL_AMA_FLAG_BILLING => 'billing',
  1016. self::CHANNEL_AMA_FLAG_DOCUMENTATION => 'documentation'
  1017. ];
  1018. /**
  1019. * Active Channel Information: AMA Flags. (See constants)
  1020. *
  1021. * NB: SNMP exceptions are caught and in such cases null is returned
  1022. * as not all channels have all properties.
  1023. *
  1024. * > AMA Flags. (See constants)
  1025. *
  1026. * @param bool $translate If true, use the `$CHANNEL_AMA_FLAGS` array to return textual representation
  1027. * @return array AMA Flags. (See constants)
  1028. */
  1029. public function chanAMAFlags( $translate = false )
  1030. {
  1031. try
  1032. {
  1033. $s = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_AMA_FLAGS );
  1034. if( !$translate )
  1035. return $s;
  1036. return $this->getSNMP()->translate( $s, self::$CHANNEL_AMA_FLAGS );
  1037. }
  1038. catch( \OSS_SNMP\Exception $e )
  1039. {
  1040. return null;
  1041. }
  1042. }
  1043. /**
  1044. * Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1045. * @var int Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1046. */
  1047. const CHANNEL_ADSI_UNKNOWN = 0;
  1048. /**
  1049. * Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1050. * @var int Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1051. */
  1052. const CHANNEL_ADSI_AVAILABLE = 1;
  1053. /**
  1054. * Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1055. * @var int Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1056. */
  1057. const CHANNEL_ADSI_UNAVAILABLE = 2;
  1058. /**
  1059. * Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1060. * @var int Possible ADSI of an Asterisk channel as returned by `chanADSI()`
  1061. */
  1062. const CHANNEL_ADSI_OFF_HOOK_ONLY = 3;
  1063. public static $CHANNEL_ADSIs = [
  1064. self::CHANNEL_ADSI_UNKNOWN => 'unknown',
  1065. self::CHANNEL_ADSI_AVAILABLE => 'available',
  1066. self::CHANNEL_ADSI_UNAVAILABLE => 'unavailable',
  1067. self::CHANNEL_ADSI_OFF_HOOK_ONLY => 'offHookOnly'
  1068. ];
  1069. /**
  1070. * Active Channel Information: Whether or not ADSI is detected on CPE. (see constants)
  1071. *
  1072. * NB: SNMP exceptions are caught and in such cases null is returned
  1073. * as not all channels have all properties.
  1074. *
  1075. * > Whether or not ADSI is detected on CPE. (see constants)
  1076. *
  1077. * @param bool $translate If true, use the `$CHANNEL_ADSIs` array to return textual representation
  1078. * @return array Whether or not ADSI is detected on CPE. (see constants)
  1079. */
  1080. public function chanADSI( $translate = false )
  1081. {
  1082. try
  1083. {
  1084. $s = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_ADSI );
  1085. if( !$translate )
  1086. return $s;
  1087. return $this->getSNMP()->translate( $s, self::$CHANNEL_ADSIs );
  1088. }
  1089. catch( \OSS_SNMP\Exception $e )
  1090. {
  1091. return null;
  1092. }
  1093. }
  1094. /**
  1095. * Active Channel Information: Indication zone to use for channel.
  1096. *
  1097. * NB: SNMP exceptions are caught and in such cases null is returned
  1098. * as not all channels have all properties.
  1099. *
  1100. * > Indication zone to use for channel.
  1101. *
  1102. * @return array Indication zone to use for channel.
  1103. */
  1104. public function chanToneZone()
  1105. {
  1106. try
  1107. {
  1108. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TONE_ZONE );
  1109. }
  1110. catch( \OSS_SNMP\Exception $e )
  1111. {
  1112. return null;
  1113. }
  1114. }
  1115. /**
  1116. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1117. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1118. */
  1119. const CHANNEL_HANGUP_CAUSE_NOT_DEFINED = 0;
  1120. /**
  1121. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1122. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1123. */
  1124. const CHANNEL_HANGUP_CAUSE_UNREGISTERED = 3;
  1125. /**
  1126. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1127. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1128. */
  1129. const CHANNEL_HANGUP_CAUSE_NORMAL = 16;
  1130. /**
  1131. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1132. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1133. */
  1134. const CHANNEL_HANGUP_CAUSE_BUSY = 17;
  1135. /**
  1136. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1137. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1138. */
  1139. const CHANNEL_HANGUP_CAUSE_NO_ANSWER = 19;
  1140. /**
  1141. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1142. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1143. */
  1144. const CHANNEL_HANGUP_CAUSE_CONGESTION = 34;
  1145. /**
  1146. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1147. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1148. */
  1149. const CHANNEL_HANGUP_CAUSE_FAILURE = 38;
  1150. /**
  1151. * Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1152. * @var int Possible hangup cause of an Asterisk channel as returned by `chanHangupCause()`
  1153. */
  1154. const CHANNEL_HANGUP_CAUSE_NO_SUCH_DRIVER = 66;
  1155. public static $CHANNEL_HANGUP_CAUSES = [
  1156. self::CHANNEL_HANGUP_CAUSE_NOT_DEFINED => 'notDefined',
  1157. self::CHANNEL_HANGUP_CAUSE_UNREGISTERED => 'unregistered',
  1158. self::CHANNEL_HANGUP_CAUSE_NORMAL => 'normal',
  1159. self::CHANNEL_HANGUP_CAUSE_BUSY => 'busy',
  1160. self::CHANNEL_HANGUP_CAUSE_NO_ANSWER => 'noAnswer',
  1161. self::CHANNEL_HANGUP_CAUSE_CONGESTION => 'congestion',
  1162. self::CHANNEL_HANGUP_CAUSE_FAILURE => 'failure',
  1163. self::CHANNEL_HANGUP_CAUSE_NO_SUCH_DRIVER => 'noSuchDriver'
  1164. ];
  1165. /**
  1166. * Active Channel Information: Why is the channel hung up. (see constants)
  1167. *
  1168. * NB: SNMP exceptions are caught and in such cases null is returned
  1169. * as not all channels have all properties.
  1170. *
  1171. * > Why is the channel hung up. (see constants)
  1172. *
  1173. * @param bool $translate If true, use the `$CHANNEL_HANGUP_CAUSES` array to return textual representation
  1174. * @return array Why is the channel hung up. (see constants)
  1175. */
  1176. public function chanHangupCause( $translate = false )
  1177. {
  1178. try
  1179. {
  1180. $s = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_HANGUP_CAUSE );
  1181. if( !$translate )
  1182. return $s;
  1183. return $this->getSNMP()->translate( $s, self::$CHANNEL_HANGUP_CAUSES );
  1184. }
  1185. catch( \OSS_SNMP\Exception $e )
  1186. {
  1187. return null;
  1188. }
  1189. }
  1190. /**
  1191. * Active Channel Information: Channel Variables defined for this channel.
  1192. *
  1193. * Returns an array of arrays where the inner array is key/value pairs
  1194. * of channel variables for that channel: `[varName] => [varValue]`
  1195. *
  1196. * NB: SNMP exceptions are caught and in such cases null is returned
  1197. * as not all channels have all properties.
  1198. *
  1199. * > Channel Variables defined for this channel.
  1200. *
  1201. * @return array Channel Variables defined for this channel.
  1202. */
  1203. public function chanVariables()
  1204. {
  1205. try
  1206. {
  1207. $vars = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_VARIABLES );
  1208. }
  1209. catch( \OSS_SNMP\Exception $e )
  1210. {
  1211. return null;
  1212. }
  1213. foreach( $vars as $idx => $var )
  1214. $vars[ $idx ] = $this->_chanVarsToArray( $var );
  1215. return $vars;
  1216. }
  1217. /**
  1218. * Utility function for `chanVariables()` to break the string returned by
  1219. * OID_ASTERISK_CHANNEL_VARIABLES into an array of key / value pairs
  1220. *
  1221. * @param string $str String containing channel variables (from `chanVariables()`
  1222. * @return Array An array of `[varName] => [varValue]` pairs for the channel
  1223. */
  1224. protected function _chanVarsToArray( $str )
  1225. {
  1226. $arr = [];
  1227. foreach( explode( "\n", $str ) as $s )
  1228. {
  1229. $arr[ substr( $s, 0, strpos( $s, '=' ) ) ] = substr( $s, strpos( $s, '=' ) + 1 );
  1230. }
  1231. return $arr;
  1232. }
  1233. /**
  1234. * Active Channel Information: Flags set on this channel.
  1235. *
  1236. * Returns a HEX number - but I could not map it to the following from Asterisk docs:
  1237. *
  1238. * > BITS {
  1239. * > wantsJitter(0),
  1240. * > deferDTMF(1),
  1241. * > writeInterrupt(2),
  1242. * > blocking(3),
  1243. * > zombie(4),
  1244. * > exception(5),
  1245. * > musicOnHold(6),
  1246. * > spying(7),
  1247. * > nativeBridge(8),
  1248. * > autoIncrementingLoop(9)
  1249. * > }
  1250. *
  1251. * NB: SNMP exceptions are caught and in such cases null is returned
  1252. * as not all channels have all properties.
  1253. *
  1254. * > Flags set on this channel. (see constants)
  1255. *
  1256. * @return array Flags set on this channel. (see constants)
  1257. */
  1258. public function chanFlags()
  1259. {
  1260. try
  1261. {
  1262. return $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_FLAGS );
  1263. }
  1264. catch( \OSS_SNMP\Exception $e )
  1265. {
  1266. return null;
  1267. }
  1268. }
  1269. /**
  1270. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1271. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1272. */
  1273. const CHANNEL_TRANSFER_CAPABILITY_SPEECH = 0;
  1274. /**
  1275. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1276. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1277. */
  1278. const CHANNEL_TRANSFER_CAPABILITY_DIGITAL = 8;
  1279. /**
  1280. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1281. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1282. */
  1283. const CHANNEL_TRANSFER_CAPABILITY_RESTRICTED_DIGITAL = 9;
  1284. /**
  1285. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1286. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1287. */
  1288. const CHANNEL_TRANSFER_CAPABILITY_AUDIO_3K = 16;
  1289. /**
  1290. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1291. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1292. */
  1293. const CHANNEL_TRANSFER_CAPABILITY_DIGITAL_WITH_TONES = 17;
  1294. /**
  1295. * Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1296. * @var int Possible channel transfer capabilities of an Asterisk channel as returned by `chanTransferCap()`
  1297. */
  1298. const CHANNEL_TRANSFER_CAPABILITY_VIDEO = 24;
  1299. public static $CHANNEL_TRANSFER_CAPABILITIES = [
  1300. self::CHANNEL_TRANSFER_CAPABILITY_SPEECH => 'speech',
  1301. self::CHANNEL_TRANSFER_CAPABILITY_DIGITAL => 'digital',
  1302. self::CHANNEL_TRANSFER_CAPABILITY_RESTRICTED_DIGITAL => 'restrictedDigital',
  1303. self::CHANNEL_TRANSFER_CAPABILITY_AUDIO_3K => 'audio3k',
  1304. self::CHANNEL_TRANSFER_CAPABILITY_DIGITAL_WITH_TONES => 'digitalWithTones',
  1305. self::CHANNEL_TRANSFER_CAPABILITY_VIDEO => 'video'
  1306. ];
  1307. /**
  1308. * Active Channel Information: Transfer Capabilities for this channel. (see constants)
  1309. *
  1310. * NB: SNMP exceptions are caught and in such cases null is returned
  1311. * as not all channels have all properties.
  1312. *
  1313. * > Transfer Capabilities for this channel. (see constants)
  1314. *
  1315. * @param bool $translate If true, use the `$CHANNEL_TRANSFER_CAPABILITIES` array to return textual representation
  1316. * @return array Transfer Capabilities for this channel. (see constants)
  1317. */
  1318. public function chanTransferCap( $translate = false )
  1319. {
  1320. try
  1321. {
  1322. $s = $this->getSNMP()->walk1d( self::OID_ASTERISK_CHANNEL_TRANSFER_CAP );
  1323. if( !$translate )
  1324. return $s;
  1325. return $this->getSNMP()->translate( $s, self::$CHANNEL_TRANSFER_CAPABILITIES );
  1326. }
  1327. catch( \OSS_SNMP\Exception $e )
  1328. {
  1329. return null;
  1330. }
  1331. }
  1332. }