Skip to content

Commit

Permalink
Merge pull request sipcapture#125 from sipcapture/gv/callflow_aliases
Browse files Browse the repository at this point in the history
Search - Correctly match hosts with aliases in call flows
  • Loading branch information
adubovikov authored Oct 5, 2016
2 parents 8c9dd71 + aa86646 commit 1b9e759
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions api/RestApi/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -1800,8 +1800,11 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes
$src_id = $data->source_ip.":".$data->source_port;
$dst_id = $data->destination_ip.":".$data->destination_port;

if(!isset($hosts[$src_id])) { $hosts[$src_id] = $hostcount; $hostcount+=$host_step; }
if(!isset($hosts[$dst_id])) { $hosts[$dst_id] = $hostcount; $hostcount+=$host_step; }
$src_id_complete = $data->source_ip.":".$data->source_port."-".$data->node;
$dst_id_complete = $data->destination_ip.":".$data->destination_port."-".$data->node;

if(!isset($hosts[$src_id_complete])) { $hosts[$src_id_complete] = $hostcount; $hostcount+=$host_step; }
if(!isset($hosts[$dst_id_complete])) { $hosts[$dst_id_complete] = $hostcount; $hostcount+=$host_step; }

$ssrc = ":".$data->source_port;

Expand Down Expand Up @@ -1973,7 +1976,7 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes
$calldata["msg_color"] = $msgcol;

/*IF */
if($hosts[$src_id] > $hosts[$dst_id]) $calldata["destination"] = 2;
if($hosts[$src_id_complete] > $hosts[$dst_id_complete]) $calldata["destination"] = 2;
else $calldata["destination"] = 1;

return $calldata;
Expand Down Expand Up @@ -2540,8 +2543,46 @@ private function applyHostsAliases(&$data) {
// Apply source_alias
if (isset($alias_cache[$key])) $alias = $alias_cache[$key];
else {
if (preg_match('/(.*):(.*)-(.*)/', $key, $matches)) {
$key_ip_address = $matches[1];
$key_port = $matches[2];
$key_node = $matches[3];

if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node];
}
else if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-*"])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port . "-*"];
}
else if (isset($alias_cache[$key_ip_address . ":" . $key_port])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port];
}
else if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
}
else {
$alias = $key_ip_address.":".$key_port;
}
}
// port was omitted in alias:
else if (preg_match('/(.*)-(.*)/', $key, $matches)) {
$key_ip_address = $matches[1];
$key_node = $matches[2];
if (isset($alias_cache[$key_ip_address . "-" . $key_node])) {
$alias = $alias_cache[$key_ip_address . "-" . $key_node];
}
else if (isset($alias_cache[$key_ip_address . "-*"])) {
$alias = $alias_cache[$key_ip_address . "-*"];
}
else if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
}
else {
$alias = $key_ip_address;
}
}
// extract IP address from $key:
if (preg_match('/(.*):.*/', $key, $matches)) {
else if (preg_match('/(.*):.*/', $key, $matches)) {
$key_ip_address = $matches[1];
if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
Expand Down

0 comments on commit 1b9e759

Please sign in to comment.