Changeset 7577

Show
Ignore:
Timestamp:
04/11/09 15:29:16 (4 years ago)
Author:
pnlarsson
Message:

Added support for iax peers as well

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/extcfg/astman.inc

    r7575 r7577  
    103103    return FALSE; 
    104104  }  
    105    
    106    
     105     
    107106  function GetFamilyDB($family){ 
    108107    $wrets = $this->Query("Action: Command\r\nCommand: database show $family\r\n\r\n"); 
     
    130129    $account_s = "Account: " . $account; 
    131130    $callerid_s = "CallerID: " . $callerid; 
    132     mdebug("astman", "GetChannel", "callerid_s: $callerid_s, account_s: $account_s"); 
    133131    $value_stop = 0; 
    134132     
     
    141139        if (($value_stop - $value_start) > 0){ 
    142140          $status = substr($wrets, $value_start, $value_stop - $value_start); 
    143           mdebug("astman", "GetChannel", "status: $status"); 
    144141          if (strpos($status, $account_s) !== false){ 
    145             mdebug("astman", "GetChannel", "account: $account_s"); 
    146142            if (strpos($status, $callerid_s) !== false){ 
    147               mdebug("astman", "GetChannel", "callerid: $callerid_s"); 
    148143              $channel_start = strpos($status, "Channel: ") + 9; 
    149144              $channel_slut = strpos($status, "\r\n", $channel_start); 
    150145              $channel = substr($status, $channel_start, $channel_slut - $channel_start); 
    151               mdebug("astman", "GetChannel", "channel: $channel"); 
    152146              return $channel; 
    153147            } 
     
    163157  function GetAllChannel($account, $callerid, $cid_name){ 
    164158    $account_s = "Account: " . $account; 
    165     $callerid_s = "CallerID: " . $callerid;  // Anvᅵnds ej... 
     159    $callerid_s = "CallerID: " . $callerid;  // Not in use 
    166160    $cid_name_s = "CallerIDName: " . $cid_name; 
    167     mdebug("astman", "GetChannel", "account_s: $account_s, cid_name_s: $cid_name_s"); 
    168161    $value_stop = 0; 
    169162    $res = array(); 
     
    177170        if (($value_stop - $value_start) > 0){ 
    178171          $status = substr($wrets, $value_start, $value_stop - $value_start); 
    179           mdebug("astman", "GetChannel", "status: $status"); 
    180172          if (strpos($status, $account_s) !== false || strpos($status, $cid_name_s) !== false){ 
    181173            $channel_start = strpos($status, "Channel: ") + 9; 
    182174            $channel_slut = strpos($status, "\r\n", $channel_start); 
    183175            $channel = substr($status, $channel_start, $channel_slut - $channel_start); 
    184             mdebug("astman", "GetChannel", "channel: $channel"); 
    185176            $res[] = $channel; 
    186177          } 
     
    192183    return $res;     
    193184  } 
    194    
    195 /* 
    196 Utgᅵende samtal frᅵn 8546 till 90510: 
    197  
    198 Event: Status 
    199 Privilege: Call 
    200 Channel: Zap/66-1 
    201 CallerID: 90510 
    202 CallerIDName: <unknown> 
    203 Account: 
    204 State: Up 
    205 Link: SIP/8546-b6021068 
    206 Uniqueid: 1179482286.131672 
    207  
    208 Event: Status 
    209 Privilege: Call 
    210 Channel: SIP/8546-b6021068 
    211 CallerID: 607010154 
    212 CallerIDName: <unknown> 
    213 Account: 
    214 State: Up 
    215 Context: macro-dialout-trunk 
    216 Extension: s 
    217 Priority: 26 
    218 Seconds: 53 
    219 Link: Zap/66-1 
    220 Uniqueid: 1179482286.131671 
    221  
    222 Inkommande samtal frᅵn 031-487410 till 8541: 
    223  
    224 Event: Status 
    225 Privilege: Call 
    226 Channel: IAX2/8541-5 
    227 CallerID: 010154 
    228 CallerIDName: <unknown> 
    229 Account: 
    230 State: Up 
    231 Link: Zap/65-1 
    232 Uniqueid: 1179482461.131714 
    233  
    234 Event: Status 
    235 Privilege: Call 
    236 Channel: Zap/65-1 
    237 CallerID: 031487410 
    238 CallerIDName: <unknown> 
    239 Account: 
    240 State: Up 
    241 Context: macro-dial 
    242 Extension: s 
    243 Priority: 10 
    244 Seconds: 31 
    245 Link: IAX2/8541-5 
    246 Uniqueid: 1179482461.131713 
    247  
    248 Inkommand samtal frᅵn 031-487410 till 7010100 (lucent, mimmi svarade) 
    249  
    250 Event: Status 
    251 Privilege: Call 
    252 Channel: Zap/32-1 
    253 CallerID: 010100 
    254 CallerIDName: <unknown> 
    255 Account: 
    256 State: Up 
    257 Link: Zap/63-1 
    258 Uniqueid: 1179485122.131799 
    259  
    260 Event: Status 
    261 Privilege: Call 
    262 Channel: Zap/63-1 
    263 CallerID: 031487410 
    264 CallerIDName: <unknown> 
    265 Account: 
    266 State: Up 
    267 Context: macro-dial 
    268 Extension: s 
    269 Priority: 10 
    270 Seconds: 19 
    271 Link: Zap/32-1 
    272 Uniqueid: 1179485121.131798 
    273  
    274 Inkommande samtal till bengt via x antal local: 
    275  
    276 Event: Status  
    277 Privilege: Call  
    278 Channel: SIP/8511-084719f8  
    279 CallerID: 8511  
    280 CallerIDName: <unknown>  
    281 Account:  
    282 State: Up  
    283 Link: Local/8511@from-internal-a1ae,2  
    284 Uniqueid: 1179487795.132088 
    285  
    286 Event: Status  
    287 Privilege: Call  
    288 Channel: Local/8511@from-internal-a1ae,2  
    289 CallerID: 0703201583  
    290 CallerIDName: 8510  
    291 Account:  
    292 State: Up  
    293 Context: macro-dial  
    294 Extension: s  
    295 Priority: 10  
    296 Seconds: 10  
    297 Link: SIP/8511-084719f8  
    298 Uniqueid: 1179487794.132083 
    299  
    300 Event: Status  
    301 Privilege: Call  
    302 Channel: Local/8511@from-internal-a1ae,1  
    303 CallerID: 8510  
    304 CallerIDName: <unknown>  
    305 Account:  
    306 State: Up  
    307 Link: Local/8510@from-internal-d204,2  
    308 Uniqueid: 1179487794.132082 
    309  
    310 Event: Status  
    311 Privilege: Call  
    312 Channel: Local/8510@from-internal-d204,2  
    313 CallerID: 0703201583  
    314 CallerIDName: 8510  
    315 Account:  
    316 State: Up  
    317 Context: macro-dial  
    318 Extension: s  
    319 Priority: 10  
    320 Seconds: 10  
    321 Link: Local/8511@from-internal-a1ae,1  
    322 Uniqueid: 1179487794.132081 
    323  
    324 Event: Status  
    325 Privilege: Call  
    326 Channel: Local/8510@from-internal-d204,1  
    327 CallerID: 010151  
    328 CallerIDName: <unknown>  
    329 Account:  
    330 State: Up  
    331 Link: Zap/64-1  
    332 Uniqueid: 1179487794.132080 
    333  
    334 Event: Status  
    335 Privilege: Call  
    336 Channel: Zap/64-1  
    337 CallerID: 0703201583  
    338 CallerIDName: 8510  
    339 Account:  
    340 State: Up  
    341 Context: macro-dial  
    342 Extension: s  
    343 Priority: 10  
    344 Seconds: 10  
    345 Link: Local/8510@from-internal-d204,1  
    346 Uniqueid: 1179487794.132079 
    347  
    348 Hur redirect ska se ut: 
    349  
    350 Action: Redirect 
    351 Channel: Zap/65-1 
    352 Exten: 8546 
    353 Context: from-internal 
    354 Priority: 1 
    355  
    356 Svar: 
    357  
    358 Response: Success 
    359 Message: Redirect successful 
    360  
    361 */ 
    362    
    363   function GetChannelLink($exten, $lucent = false){ 
    364     $value_stop = 0; 
    365     $res = array(); 
    366     $i = 0; 
    367      
    368     $wrets = $this->Query2("Action: Status\r\n\r\n", "Event: StatusComplete\r\n"); 
    369     if ($wrets){ 
    370       $w_len = strlen($wrets); 
    371       while ($value_stop <= $w_len){ 
    372         $value_start = strpos($wrets, "Event: Status", $value_stop); 
    373         $value_stop = strpos($wrets, "Event:", $value_start + 6); 
    374         if (($value_stop - $value_start) > 0){ 
    375           $status = substr($wrets, $value_start, $value_stop - $value_start); 
    376           mdebug("astman", "GetChannelLink", "status: $status"); 
    377           $channel = $this->get_my_stuff($status, 'Channel: ', "\r\n"); 
    378           if ($channel != ""){ 
    379             mdebug("astman", "GetChannelLink", "Got Channel: $channel"); 
    380           } 
    381           $link = $this->get_my_stuff($status, 'Link: ', "\r\n"); 
    382           if ($link != ""){ 
    383             mdebug("astman", "GetChannelLink", "Got Link: $link"); 
    384           } 
    385           if ($lucent){  // Zap/65-1             
    386             $chan_nr = 0; 
    387             $link_nr = 0; 
    388             if (strtoupper($this->get_my_stuff($channel, false, '/')) == 'ZAP'){ 
    389               $chan_nr = $this->get_my_stuff($channel, '/', '-'); 
    390               mdebug("astman", "GetChannelLink", "Zap chan_nr: $chan_nr");               
    391             } 
    392             if (strtoupper($this->get_my_stuff($link, false, '/')) == 'ZAP'){ 
    393               $link_nr = $this->get_my_stuff($link, '/', '-'); 
    394               mdebug("astman", "GetChannelLink", "Zap link_nr: $link_nr");               
    395             } 
    396              
    397             if (($chan_nr >= 32 && $chan_nr <= 62) || ($link_nr >= 32 && $link_nr <= 62)){ 
    398               mdebug("astman", "GetChannelLink", "Zap OK");              
    399               if(($start = strpos($status, 'CallerID: ') + 10) > 10){ 
    400                 $callerid = substr($status, $start, strpos($status, "\r\n", $start) - $start); 
    401                 mdebug("astman", "GetChannelLink", "Zap Got CallerID: $callerid");               
    402                 $res[$i]['channel'] = $channel; 
    403                 $res[$i]['link'] = $link; 
    404                 $res[$i]['callerid'] = $callerid; 
    405                 $res[$i]['seconds'] = $this->get_my_stuff($status, 'Seconds: ', "\r\n"); 
    406                 $i++; 
    407               } 
    408             } 
    409           }else{ 
    410             if (strpos($channel, $exten) || strpos($link, $exten)){ 
    411               if(($start = strpos($status, 'CallerID: ') + 10) > 10){ 
    412                 $callerid = substr($status, $start, strpos($status, "\r\n", $start) - $start); 
    413                 mdebug("astman", "GetChannelLink", "Got CallerID: $callerid");               
    414                 $res[$i]['channel'] = $channel; 
    415                 $res[$i]['link'] = $link; 
    416                 $res[$i]['callerid'] = $callerid; 
    417                 $res[$i]['seconds'] = $this->get_my_stuff($status, 'Seconds: ', "\r\n"); 
    418                 $i++; 
    419               } 
    420             } 
    421           } 
    422         }else{ 
    423           return $res; 
    424         } 
    425       } 
    426     } 
    427     return $res;     
    428   } 
    429  
     185     
    430186  function Redirect($channel, $exten, $context = 'from-internal', $priority = 1){ 
    431     mdebug("astman", "Redirect", "channel: $channel till exten: $exten"); 
    432187    $wrets = $this->Query2("Action: Redirect\r\nChannel: $channel\r\nExten: $exten\r\nContext: $context\r\nPriority: $priority\r\n\r\n", "Message: Redirect successful\r\n"); 
    433188    if (strpos('Redirect successful', $wrets) !== false) 
  • contributed_modules/modules/extcfg/functions.inc.php

    r7575 r7577  
    1717} 
    1818 
    19 /*  Generates dialplan for conferences 
    20   We call this with retrieve_conf 
    21 */ 
    2219function extcfg_get_config($engine) { 
    2320 
     
    283280      if ($arr[$extension]['ip'] != '-none-' && $arr[$extension]['status'] != 'UNREACHABLE') 
    284281        $arr[$extension]['ok'] = true; 
     282    } 
     283  } 
     284   
     285  // IAX 
     286   
     287  $iax_res = $astman->Query2("Action: IAXpeerlist\r\n\r\n", 'PeerlistComplete'); 
     288 
     289  $iax_peers = explode("\r\n\r\n", $iax_res); 
     290     
     291  foreach ($iax_peers as $iax_peer) { 
     292    if (strpos($iax_peer, 'ObjectName')){ 
     293      $extension = $astman->get_my_stuff($iax_peer, 'ObjectName: ', "\r\n"); 
     294       
     295      $arr[$extension] = array( 
     296        'ip' => $astman->get_my_stuff($iax_peer, 'IPaddress: ', "\r\n"),  
     297        'port' => $astman->get_my_stuff($iax_peer, 'Port: ', "\r\n"), 
     298        'status' => $astman->get_my_stuff($iax_peer, 'Status: '), 
     299        'type' => 'IAX2', 
     300        'device' => '', 
     301        'ok' => false 
     302      );     
     303      if ($arr[$extension]['ip'] != '-none-' && $arr[$extension]['status'] != 'UNREACHABLE') 
     304        $arr[$extension]['ok'] = true;         
    285305    } 
    286306  }