- Fix SCCP
- Fix SIP
This commit is contained in:
parent
1905431be4
commit
b6bc649758
BIN
.dok/image/sip_model.jpg
Normal file
BIN
.dok/image/sip_model.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
|
@ -1930,18 +1930,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
if (!empty($dev_config['type'])) {
|
if (!empty($dev_config['type'])) {
|
||||||
if (strpos($dev_config['type'],'sip') !== false) {
|
if (strpos($dev_config['type'],'sip') !== false) {
|
||||||
$sccp_native = false;
|
$sccp_native = false;
|
||||||
$data_tmp =$this->sipconfigs->getSipConfig();
|
$tmp_bind =$this->sipconfigs->getSipConfig();
|
||||||
$dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext'));
|
$dev_ext_config = $this->dbinterface->get_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields'=>'sip_ext'));
|
||||||
$data_value = array_merge($data_value, $dev_ext_config, $data_tmp);
|
$data_value = array_merge($data_value, $dev_ext_config);
|
||||||
$data_tmp = explode(';',$dev_ext_config['sip_lines']);
|
$data_tmp = explode(';',$dev_ext_config['sip_lines']);
|
||||||
foreach ($data_tmp as $value) {
|
foreach ($data_tmp as $value) {
|
||||||
$tmp_line = explode(',',$value);
|
$tmp_line = explode(',',$value);
|
||||||
switch ($tmp_line[0]) {
|
switch ($tmp_line[0]) {
|
||||||
case 'line':
|
case 'line':
|
||||||
$dev_line_data= $this->sipconfigs->get_db_sip_TableData('DeviceById',array('id'=>$tmp_line[1]));
|
$dev_line_data= $this->sipconfigs->get_db_sip_TableData('DeviceById',array('id'=>$tmp_line[1]));
|
||||||
|
$f_linetype = ($dev_line_data['dial'] == 'PJSIP')? 'pjsip':'sip';
|
||||||
|
$dev_line_data['sbind'] = $tmp_bind[$f_linetype];
|
||||||
if (!empty($dev_line_data)) {
|
if (!empty($dev_line_data)) {
|
||||||
$data_value['siplines'][] = $dev_line_data;
|
$data_value['siplines'][] = $dev_line_data;
|
||||||
}
|
}
|
||||||
|
if ($tmp_line[2] =='default') {
|
||||||
|
$data_value['sbind']=$tmp_bind[$f_linetype];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'speeddial':
|
case 'speeddial':
|
||||||
$data_value['speeddial'][] = array("name"=>$tmp_line[1],"dial"=>$tmp_line[2]);
|
$data_value['speeddial'][] = array("name"=>$tmp_line[1],"dial"=>$tmp_line[2]);
|
||||||
|
@ -1951,10 +1956,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return print_r($data_tmp ,true);
|
// return print_r($data_value ,true);
|
||||||
// return print_r($dev_line_data,true);
|
// return print_r($dev_line_data,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// return print_r($dev_config ,true);
|
||||||
|
|
||||||
foreach ($this->sccpvalues as $key => $value) {
|
foreach ($this->sccpvalues as $key => $value) {
|
||||||
$data_value[$key] = $value['data'];
|
$data_value[$key] = $value['data'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,23 +64,45 @@ class sipconfigs {
|
||||||
|
|
||||||
public function getSipConfig() {
|
public function getSipConfig() {
|
||||||
$result = array();
|
$result = array();
|
||||||
$def_sip_proto = 'sip';
|
// $def_sip_proto = 'sip';
|
||||||
$def_proto = 'tcp';
|
// $def_proto = 'tcp';
|
||||||
$supp_proto = '';
|
// $supp_proto = '';
|
||||||
|
|
||||||
$result['sipport'] = \FreePBX::Sipsettings()->getConfig('bindport');
|
// $result['sipport'] = \FreePBX::Sipsettings()->getConfig('bindport');
|
||||||
$result['tlsport'] = \FreePBX::Sipsettings()->getConfig('tlsbindport');
|
// $result['tlsport'] = \FreePBX::Sipsettings()->getConfig('tlsbindport');
|
||||||
$tmp_sipsetigs = \FreePBX::Sipsettings()->getChanSipSettings();
|
// $tmp_sipsetigs = \FreePBX::Sipsettings()->getChanSipSettings();
|
||||||
$tmp_sip_binds = \FreePBX::Sipsettings()->getBinds();
|
$tmp_binds = \FreePBX::Sipsettings()->getBinds();
|
||||||
|
$if_list = $this->paren_class ->getIP_information2('ip4');
|
||||||
|
|
||||||
|
/*
|
||||||
$tmp_bind_ip = !empty($tmp_sipsetigs['externhost_val']) ? $tmp_sipsetigs['externhost_val'] : '';
|
$tmp_bind_ip = !empty($tmp_sipsetigs['externhost_val']) ? $tmp_sipsetigs['externhost_val'] : '';
|
||||||
$tmp_bind_ip = !empty($tmp_sipsetigs['externip_val']) ? $tmp_sipsetigs['externip_val'] : $tmp_bind_ip;
|
$tmp_bind_ip = !empty($tmp_sipsetigs['externip_val']) ? $tmp_sipsetigs['externip_val'] : $tmp_bind_ip;
|
||||||
$tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip;
|
$tmp_bind_ip = !empty($tmp_sipsetigs['bindaddr']) ? $tmp_sipsetigs['bindaddr'] : $tmp_bind_ip;
|
||||||
|
*/
|
||||||
|
$tmp_binds = is_array($tmp_binds) ? $tmp_binds: array();
|
||||||
|
foreach($tmp_binds as $f_protocol => $f_bind) {
|
||||||
|
foreach($f_bind as $f_ip => $f_port) {
|
||||||
|
if (($f_ip == '0.0.0.0') || ($f_ip == '[::]')) {
|
||||||
|
foreach($if_list as $f_if => $f_data) {
|
||||||
|
if ($f_data['ip'] == "127.0.0.1") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$result[$f_protocol][$f_data['ip']]=$f_port;
|
||||||
|
$result[$f_protocol][$f_data['ip']]['ip']=$f_data['ip'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result[$f_protocol][$f_ip]=$f_port;
|
||||||
|
$result[$f_protocol][$f_ip]['ip']=$f_ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
/*
|
||||||
// $result['sipbind'] = $tmp_bind_ip;
|
// $result['sipbind'] = $tmp_bind_ip;
|
||||||
if (empty($tmp_sip_binds[$def_sip_proto])){
|
if (empty($tmp_sip_binds[$def_sip_proto])){
|
||||||
$def_proto = 'pjsip';
|
$def_proto = 'pjsip';
|
||||||
}
|
}
|
||||||
|
return $result;
|
||||||
|
|
||||||
foreach ($tmp_sip_binds[$def_sip_proto] as $key => $value) {
|
foreach ($tmp_sip_binds[$def_sip_proto] as $key => $value) {
|
||||||
if (empty($value[$def_proto])) {
|
if (empty($value[$def_proto])) {
|
||||||
|
@ -99,6 +121,36 @@ class sipconfigs {
|
||||||
}
|
}
|
||||||
$result['sipbind'] = $tmp_bind_ip;
|
$result['sipbind'] = $tmp_bind_ip;
|
||||||
$result['sipsuportproto'] = $supp_proto;
|
$result['sipsuportproto'] = $supp_proto;
|
||||||
|
|
||||||
|
$binds= array();
|
||||||
|
$driver = \FreePBX::Config()->get_conf_setting('ASTSIPDRIVER');
|
||||||
|
if ($driver == "both" || $driver == "chan_pjsip") {
|
||||||
|
$b = \FreePBX::Sipsettings()->getConfig("binds");
|
||||||
|
$b = is_array($b) ? $b : array();
|
||||||
|
foreach($b as $protocol => $bind) {
|
||||||
|
foreach($bind as $ip => $state) {
|
||||||
|
if($state != "on") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$p = \FreePBX::Sipsettings()->getConfig($protocol."port-".$ip);
|
||||||
|
$result['nb3'.$protocol] = $p;
|
||||||
|
if ($flatten) {
|
||||||
|
$binds['pjsip']['[::]'][$protocol] = $p;
|
||||||
|
} else {
|
||||||
|
$binds['pjsip'][$ip][$protocol] = $p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$binds['pjsip'] = array("0.0.0.0" => array());
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['nd'] = $driver;
|
||||||
|
|
||||||
|
$result['nb'] = $binds;
|
||||||
|
$result['nb2'] = $b;
|
||||||
return $result;
|
return $result;
|
||||||
|
*
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,6 +417,7 @@ class xmlinterface {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private function get_server_sip_bind($data_values = array()) {
|
private function get_server_sip_bind($data_values = array()) {
|
||||||
$res = array();
|
$res = array();
|
||||||
|
|
||||||
|
@ -444,6 +445,8 @@ class xmlinterface {
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) {
|
function create_SEP_SIP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) {
|
||||||
|
|
||||||
|
@ -481,7 +484,16 @@ class xmlinterface {
|
||||||
$xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template';
|
$xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_sip_template';
|
||||||
}
|
}
|
||||||
$xml_name = $store_path . '/' . $dev_id . '.cnf.xml';
|
$xml_name = $store_path . '/' . $dev_id . '.cnf.xml';
|
||||||
$sip_bind = $this->get_server_sip_bind($data_values);
|
//$sip_bind = $this->get_server_sip_bind($data_values);
|
||||||
|
$sip_bind = $data_values['sbind'];
|
||||||
|
$bind_proto = 'tcp';
|
||||||
|
$bind_ip_def = '';
|
||||||
|
foreach($sip_bind as $key => $value) {
|
||||||
|
if (empty($bind_ip_def)) {
|
||||||
|
$bind_ip_def = $key;
|
||||||
|
$bind_proto = (isset($value['tcp'])) ? 'tcp' : 'udp';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists($xml_template)) {
|
if (file_exists($xml_template)) {
|
||||||
$xml_work = simplexml_load_file($xml_template);
|
$xml_work = simplexml_load_file($xml_template);
|
||||||
|
@ -569,13 +581,13 @@ class xmlinterface {
|
||||||
case 'callManagerGroup':
|
case 'callManagerGroup':
|
||||||
$xnode = &$xml_node->$dkey->members;
|
$xnode = &$xml_node->$dkey->members;
|
||||||
$ifc = 0;
|
$ifc = 0;
|
||||||
foreach ($sip_bind as $bind_value) {
|
foreach ($sip_bind as $bind_ip => $bind_value) {
|
||||||
$xnode_obj = clone $xnode->member;
|
$xnode_obj = clone $xnode->member;
|
||||||
$xnode_obj['priority'] = $ifc;
|
$xnode_obj['priority'] = $ifc;
|
||||||
$xnode_obj->callManager->name = $data_values['servername'];
|
$xnode_obj->callManager->name = $data_values['servername'];
|
||||||
$xnode_obj->callManager->ports->sipPort = $bind_value['port'];
|
$xnode_obj->callManager->ports->sipPort = $bind_value[$bind_proto];
|
||||||
$xnode_obj->callManager->ports->securedSipPort = $bind_value['tlsport'];
|
// $xnode_obj->callManager->ports->securedSipPort = $bind_value['tlsport'];
|
||||||
$xnode_obj->callManager->processNodeName = $bind_value['ip'];
|
$xnode_obj->callManager->processNodeName = $bind_ip;
|
||||||
if ($ifc === 0) {
|
if ($ifc === 0) {
|
||||||
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
$this->replaceSimpleXmlNode($xnode->member, $xnode_obj);
|
||||||
} else {
|
} else {
|
||||||
|
@ -600,12 +612,12 @@ class xmlinterface {
|
||||||
switch ($dkey) {
|
switch ($dkey) {
|
||||||
case 'sipProxies':
|
case 'sipProxies':
|
||||||
$xnode = &$xml_node->$dkey;
|
$xnode = &$xml_node->$dkey;
|
||||||
$xnode->backupProxy = $sip_bind[0]['ip'];
|
$xnode->backupProxy = $bind_ip_def;
|
||||||
$xnode->backupProxyPort = $sip_bind[0]['port'];
|
$xnode->backupProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||||
$xnode->emergencyProxy = $sip_bind[0]['ip'];
|
$xnode->emergencyProxy = $bind_proto;
|
||||||
$xnode->emergencyProxyPort = $sip_bind[0]['port'];
|
$xnode->emergencyProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||||
$xnode->outboundProxy = $sip_bind[0]['ip'];
|
$xnode->outboundProxy = $bind_proto;
|
||||||
$xnode->outboundProxyPort = $sip_bind[0]['port'];
|
$xnode->outboundProxyPort = $sip_bind[$bind_ip_def][$bind_proto];
|
||||||
$xnode->registerWithProxy = "true";
|
$xnode->registerWithProxy = "true";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -621,8 +633,8 @@ class xmlinterface {
|
||||||
//$xnode_obj->proxy = $data_values['bindaddr'];
|
//$xnode_obj->proxy = $data_values['bindaddr'];
|
||||||
$xnode_obj-> featureID = "9";
|
$xnode_obj-> featureID = "9";
|
||||||
if ($xnode_obj->proxy != 'USECALLMANAGER') {
|
if ($xnode_obj->proxy != 'USECALLMANAGER') {
|
||||||
$xnode_obj->proxy = $sip_bind[0]['ip'];
|
$xnode_obj->proxy = $bind_proto;
|
||||||
$xnode_obj->port = $sip_bind[0]['port'];
|
$xnode_obj->port = $sip_bind[$bind_ip_def][$bind_proto];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($var_xml_sipline as $line_key => $line_val) {
|
foreach ($var_xml_sipline as $line_key => $line_val) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
"prettyName" => _("Sccp Custom Driver"),
|
"prettyName" => _("Sccp Custom Driver"),
|
||||||
"shortName" => "SCCP",
|
"shortName" => "SCCP",
|
||||||
"description" => _("Sccp Device"),
|
"description" => _("Sccp Device"),
|
||||||
"Version" => "11.3.v434",
|
"Version" => "11.3.v434m",
|
||||||
"about" => "Sccp mysql class Base ver: 11.3, Sccp ver: 434"
|
"about" => "Sccp mysql class Base ver: 11.3, Sccp ver: 434"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,18 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// die(print_r($settings));
|
// die(print_r($settings));
|
||||||
|
$tech = Array();
|
||||||
|
$sql = "DESCRIBE `sccpline`";
|
||||||
|
foreach ($this->database->query($sql) as $row) {
|
||||||
|
$tech[$row["Field"]]=$row["Field"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// die(print_r($tech));
|
||||||
|
|
||||||
$sql = 'REPLACE INTO sccpline (name';
|
$sql = 'REPLACE INTO sccpline (name';
|
||||||
$sqlv = 'values ("'.$id.'"';
|
$sqlv = 'values ("'.$id.'"';
|
||||||
foreach($this->data_fld as $key => $val) {
|
foreach($this->data_fld as $key => $val) {
|
||||||
|
if (isset($tech[$key])) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'incominglimit':
|
case 'incominglimit':
|
||||||
$sql .= ', '.$key;
|
$sql .= ', '.$key;
|
||||||
|
@ -113,6 +121,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sql .= ") ".$sqlv.");";
|
$sql .= ") ".$sqlv.");";
|
||||||
// die(print_r($sql));
|
// die(print_r($sql));
|
||||||
|
@ -144,7 +153,7 @@ class Sccp extends \FreePBX\modules\Core\Driver {
|
||||||
// print_r($sql);
|
// print_r($sql);
|
||||||
try {
|
try {
|
||||||
$sth->execute(array($id));
|
$sth->execute(array($id));
|
||||||
$tech = $sth->fetch();
|
$tech = $sth->fetch();
|
||||||
$tech['dial']='SCCP/'.$id;
|
$tech['dial']='SCCP/'.$id;
|
||||||
} catch(\Exception $e) {}
|
} catch(\Exception $e) {}
|
||||||
|
|
||||||
|
|
|
@ -1039,8 +1039,9 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<name>description</name>
|
<name>description</name>
|
||||||
<default>000000000</default>
|
<default>000000000</default>
|
||||||
<class>sccp-custom</class>
|
<class>sccp-custom</class>
|
||||||
|
<options pattern="[0-9a-zA-Z]+"/>
|
||||||
</input>
|
</input>
|
||||||
<help>The information in the upper right corner of the device screen</help>
|
<help>The information in the upper right corner of the device screen. Only English letters and digits !</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="SLK" id="2" seq="99">
|
<item type="SLK" id="2" seq="99">
|
||||||
<label>Soft Keyset</label>
|
<label>Soft Keyset</label>
|
||||||
|
|
|
@ -1098,8 +1098,9 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<name>_description</name>
|
<name>_description</name>
|
||||||
<default>000000000</default>
|
<default>000000000</default>
|
||||||
<class>sccp-custom</class>
|
<class>sccp-custom</class>
|
||||||
|
<options pattern="[0-9a-zA-Z]+"/>
|
||||||
</input>
|
</input>
|
||||||
<help>The information in the upper right corner of the device screen</help>
|
<help>The information in the upper right corner of the device screen. Only English letters and digits !</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="SLK" id="2" seq="99">
|
<item type="SLK" id="2" seq="99">
|
||||||
<label>Soft Keyset</label>
|
<label>Soft Keyset</label>
|
||||||
|
|
|
@ -1041,8 +1041,9 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<name>description</name>
|
<name>description</name>
|
||||||
<default>000000000</default>
|
<default>000000000</default>
|
||||||
<class>sccp-custom</class>
|
<class>sccp-custom</class>
|
||||||
|
<options pattern="[0-9a-zA-Z]+"/>
|
||||||
</input>
|
</input>
|
||||||
<help>The information in the upper right corner of the device screen</help>
|
<help>The information in the upper right corner of the device screen. Only English letters and digits !</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="SLK" id="2" seq="99">
|
<item type="SLK" id="2" seq="99">
|
||||||
<label>Soft Keyset</label>
|
<label>Soft Keyset</label>
|
||||||
|
|
|
@ -1095,8 +1095,9 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
<name>description</name>
|
<name>description</name>
|
||||||
<default>000000000</default>
|
<default>000000000</default>
|
||||||
<class>sccp-custom</class>
|
<class>sccp-custom</class>
|
||||||
|
<options pattern="[0-9a-zA-Z]+"/>
|
||||||
</input>
|
</input>
|
||||||
<help>The information in the upper right corner of the device screen</help>
|
<help>The information in the upper right corner of the device screen. Only English letters and digits !</help>
|
||||||
</item>
|
</item>
|
||||||
<item type="SLK" id="2" seq="99">
|
<item type="SLK" id="2" seq="99">
|
||||||
<label>Soft Keyset</label>
|
<label>Soft Keyset</label>
|
||||||
|
|
|
@ -105,6 +105,9 @@ if ($mysql_info['Value'] <= '2000') {
|
||||||
//$tmp_data_list = $amp_conf;
|
//$tmp_data_list = $amp_conf;
|
||||||
//$tmp_data_list=FreePBX::create()->Sipsettings->getConfig('bindport');
|
//$tmp_data_list=FreePBX::create()->Sipsettings->getConfig('bindport');
|
||||||
// $tmp_data_list=FreePBX::Sipsettings()->getChanSipSettings();
|
// $tmp_data_list=FreePBX::Sipsettings()->getChanSipSettings();
|
||||||
|
$tmp_data_list=$this->sipconfigs->getSipConfig();
|
||||||
|
//$tmp_data_list=FreePBX::Sipsettings()->getBinds();
|
||||||
|
|
||||||
// $tmp_data_list = \FreePBX::Sipsettings()->getSipPortOwner();
|
// $tmp_data_list = \FreePBX::Sipsettings()->getSipPortOwner();
|
||||||
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpExtension');
|
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||||
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpDevice', array('type'=>'cisco-sip'));
|
// $tmp_data_list=$this->dbinterface->get_db_SccpTableData('SccpDevice', array('type'=>'cisco-sip'));
|
||||||
|
|
Loading…
Reference in a new issue