#
# ALLNET.ITALIA - Patton BRI SmartWare
# Template per connessione di un centralino 2 BRI punto-multipunto
# ad un provider VoIP con due account (emulazione BRI)
# separati per BRI (una porta per account)
#
# IP Patton 		192.168.1.100
# IP GW rete e DNS 	192.168.1.1
# IP Centralino 	res.sip.twt.it
#
# Configurazione provider VoIP
# Esempio con trunk TWT
#

cli version 3.20
clock local default-offset +01:00
clock local dst-rule DST_ON +02:00 from 02:00 mar last sunday until 03:00 oct last sunday
webserver port 80 language en
sntp-client
sntp-client server primary 0.patton.pool.ntp.org port 123 version 4
sntp-client server secondary 1.patton.pool.ntp.org port 123 version 4
dns-client server 192.168.1.1

system

  ic voice 0
    low-bitrate-codec g729

system
  clock-source 1 bri 0 0
  clock-source 2 bri 0 1

profile ppp default

profile call-progress-tone defaultAlertingtone
  play 1 1000 425 -12
  pause 2 4000
  play 3 1000 425 -12
  pause 4 4000
  
profile call-progress-tone defaultBusytone
  play 1 500 425 -12
  pause 2 500
  play 3 500 425 -12
  pause 4 500

profile call-progress-tone defaultDialtone
  play 1 200 425 -12
  pause 2 200
  play 3 600 425 -12
  pause 4 1000

profile call-progress-tone defaultReleasetone
  play 1 200 425 -12
  pause 2 200
  play 3 200 425 -12
  pause 4 200

profile tone-set default
  map call-progress-tone dial-tone defaultDialtone
  map call-progress-tone ringback-tone defaultAlertingtone
  map call-progress-tone busy-tone defaultBusytone
  map call-progress-tone congestion-tone defaultReleasetone
  map call-progress-tone release-tone defaultReleasetone

profile voip default
  codec 1 g711alaw64k rx-length 20 tx-length 20
  codec 2 g711ulaw64k rx-length 20 tx-length 20

profile pstn default

profile sip default
  no autonomous-transitioning

profile aaa default
  method 1 local
  method 2 none

context ip router

  interface IF_IP_WAN
    ipaddress 192.168.1.100 255.255.255.0
    tcp adjust-mss rx mtu
    tcp adjust-mss tx mtu

context ip router

	route 0.0.0.0 0.0.0.0 192.168.1.1 0
	
context cs switch
  international-prefix 00
  
  routing-table called-e164 RT_DIG_COL_TO_SIP_0
  route .T dest-interface IF_SIP_0
  
  routing-table called-e164 RT_DIG_COL_TO_SIP_1
  route .T dest-interface IF_SIP_1

  interface isdn IF_ISDN_0
    route call dest-table RT_DIG_COL_TO_SIP_0
	
  interface isdn IF_ISDN_1
    route call dest-table RT_DIG_COL_TO_SIP_1

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

  interface sip IF_SIP_1
    bind context sip-gateway GW_5062
    route call dest-interface IF_ISDN_1
    remote res.sip.twt.it
    early-disconnect
    address-translation outgoing-call from-header user-part fix 5678 host-part fix res.sip.twt.it
	address-translation incoming-call called-e164 to-header

context cs switch
  no shutdown

authentication-service AS_SIP
  username 1234 password 1234
  username 5678 password 5678

location-service LS_SIP_0
  domain 1 res.sip.twt.it

  identity 1234

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 1234

    registration outbound
      registrar res.sip.twt.it
      lifetime 300
      register auto

location-service LS_SIP_1
  domain 1 res.sip.twt.it

  identity 5678

    authentication outbound
      authenticate 1 authentication-service AS_SIP username 5678

    registration outbound
      registrar res.sip.twt.it
      lifetime 300
      register auto

context sip-gateway GW_5060

  interface IF_GW_5060
    bind interface IF_IP_WAN context router port 5060

context sip-gateway GW_5060
  bind location-service LS_SIP_0
  no shutdown
  
context sip-gateway GW_5062

  interface IF_GW_5062
    bind interface IF_IP_WAN context router port 5062

context sip-gateway GW_5062
  bind location-service LS_SIP_1
  no shutdown

port ethernet 0 0
  medium auto
  encapsulation ip
  bind interface IF_IP_WAN router
  no shutdown

port bri 0 0
  clock auto
  encapsulation q921

  q921
    protocol pmp
    uni-side auto
    encapsulation q931

    q931
      protocol dss1
      uni-side net
      bchan-number-order ascending
      encapsulation cc-isdn
      bind interface IF_ISDN_0 switch

port bri 0 0
  no shutdown

port bri 0 1
  clock auto
  encapsulation q921

  q921
    protocol pmp
    uni-side auto
    encapsulation q931

    q931
      protocol dss1
      uni-side net
      bchan-number-order ascending
      encapsulation cc-isdn
      bind interface IF_ISDN_1 switch

port bri 0 1
  no shutdown