require("Core")
require("DMR")
 
function handleCallData(flavor, source, destination, tag, header)
  --[[
 
    *** This function is called from LoopBack link while processing call headers
 
    Parameters:
      flavor - set of bits that defines call type, see SESSION_TYPE_FLAG_*
      source - source ID of call
      destination - destination ID of call
      tag - route tag
      header - binary string contains FullLC, DataHeader or CSBK
 
    Returns:
      Modified DMR header
 
  ]]--
 
  -- Simple rule to replace destination ID of group voice call
  if (bit.band(flavor, SESSION_TYPE_FLAG_VOICE) ~= 0) and
     (bit.band(flavor, SESSION_TYPE_FLAG_GROUP) ~= 0) and
     (tag < 999999)
  then
    return setVoiceCallDestinationID(header, tag)
  end
 
 
  return header
end