#
# ALLNET.ITALIA - Patton BRI Trinity
# Estratto di esempio per adattare TON e NP sul numero chiamato in presenza di centrali ISDN
# configurate sulla rete ISDN italiana nativa (NT1/NT1+/PRI)
#
# MP_CG_REM_PREFIX	Rimuove il previsso 0039 dal numero chiamante se presente
# MP_CDNP			Mappa in isdn-telephony / E.164 il numbering plan del numero chiamato (DID)
# MP_CD_REM_PREFIX	Rimuove i prefissi 0039 / 00390 / 0 / 50 dal numero chiamato (DID) se presenti
# MP_CDTON			Mappa su national il type of number del numero chiamato (DID)

context cs SWITCH
  national-prefix 0
  international-prefix 00

  mapping-table calling-e164 to calling-e164 MP_CG_REM_PREFIX
    map 0039(.%) to \1

  mapping-table called-numbering-plan to called-numbering-plan MP_CDNP
    map default to isdn-telephony

  mapping-table called-e164 to called-e164 MP_CD_REM_PREFIX
	map 00390(.%) to \1
	map 0(.%) to \1
	map 50(.%) to \1

  mapping-table called-type-of-number to called-type-of-number MP_CDTON
    map default to national

  routing-table called-e164 RT_DIG_COL_TO_SIP
    route .T dest-interface IF_SIP_0

  routing-table called-e164 RT_TO_ISDN
    route default dest-service HG_TO_ISDN CF_ISDN_ADAPT

  complex-function CF_ISDN_ADAPT
    execute 1 MP_CDNP
    execute 2 MP_CDTON
    execute 3 MP_CD_REM_PREFIX
    execute 4 MP_CG_REM_PREFIX

  interface isdn IF_ISDN_0
    route call dest-table RT_DIG_COL_TO_SIP
    call-reroute emit
    diversion emit
    caller-name
    isdn-date-time
    user-side-ringback-tone

  interface isdn IF_ISDN_1
    route call dest-table RT_DIG_COL_TO_SIP
    call-reroute emit
    diversion emit
    caller-name
    isdn-date-time
    user-side-ringback-tone

  interface sip IF_SIP_0
    bind context sip-gateway GW_5060
    route call dest-table RT_TO_ISDN
    remote res.sip.twt.it
    early-disconnect
    address-translation outgoing-call from-header user-part fix 50511231234 host-part fix res.sip.twt.it
	address-translation incoming-call called-e164 to-header

  service hunt-group HG_TO_ISDN
    drop-cause normal-unspecified
    drop-cause no-circuit-channel-available
    drop-cause network-out-of-order
    drop-cause temporary-failure
    drop-cause switching-equipment-congestion
    drop-cause access-info-discarded
    drop-cause circuit-channel-not-available
    drop-cause resources-unavailable
    route call 1 dest-interface IF_ISDN_0
    route call 2 dest-interface IF_ISDN_1

context cs SWITCH
  no shutdown