Modifying Transit Network Selection Filters

From TBwiki
Jump to: navigation, search

Contents

Applies to version(s): v2.6, v2.7.

Before filter

This filter is specific to SPIROU. In SPIROU, the Network Identification used for Transit Network Selection can be added at the beginning of the called number, when Nature Of Address (NOA) is set to "international number with transit network selection" or "national number with transit network selection". This example works for Network Identification of 4 digits, modify it to match the number of digits in your specific network.

  # Specific to Spirou, remaps called nature of address, removes selection prefix 
  # and uses it as the network_identification field
  # This example will work for selection prefixes of 4 digits, modify .slice!(0..3) according to 
  # the length of the selection prefixes in your network
  def transit_network_selection_before_filter params
    #Reset value to false
    @route_rejected = false

    call = params[:call]
    called_noa = call[:called_noa]

    case called_noa
      when 'international_number_with_transit_network_selection'
        call[:called_noa] = 'international_number'
        call[:network_identification] = call[:called].slice!(0..3)
      when 'national_number_with_transit_network_selection'
        call[:called_noa] = 'national_number'
        call[:network_identification] = call[:called].slice!(0..3)
    end

  params

  end 


Route match

This filter allows to match routes according to the network_identification column when Transit Network Selection (TNS) is present. Calls will be routed normally if the TNS IE is not present.

See Add Network Identification column to Routes.

  # Will only accept calls if no network identification is requested, or if 
  # the network identification of the route matches with the requested one
  def transit_network_selection_route_match( route, call, nap_list )
    requested_network_id = call[:network_identification]

    if requested_network_id.nil?
      return true
    end

    route_network_id = route[:network_identification]

    if requested_network_id != route_network_id
      #Keep track if a route was rejected because of transit network selection, to return the good release cause
      @route_rejected = true
      return false
    end

    return true
  end

After filter

This filter removes the Transit Network Selection information from the route, after the information has been used to route the call. It also makes sure the correct release reason is sent when there is no route because no route matched the requested network identification. Do not use this filter if it is required to transmit the Transit Network Selection IE from the incoming leg to the outgoing leg.

  #Test to send the good release reason if there is no route
  #Removes network identification, we do not want to transmit it in the outgoing call
  def transit_network_selection_after_filter params
    routes = params[ :routes ]
    #If no routes where found because routes were rejected for transit network selection, 
    #raise an exception with the correct error code 
    raise RoutingException, :invalid_transit_network if (routes.empty? && @route_rejected == true)
    
    call = params[:call]
    call[:network_identification] = nil

    params

  end
Personal tools