#
# ALLNET.ITALIA - Patton BRI SmartWare
# Template per connessione di un centralino IP
# a 4 borchie punto-multipunto del provider con una I/F SIP
# e ricerca automatica della prima BRI libera in uscita
#
# IP Patton 		192.168.1.100
# IP GW rete e DNS 	192.168.1.1
# IP Centralino 	192.168.1.50
#
# Configurazione PBX
# IF_ISDN_X (IF_SIP_0 - no reg)	IP_PATTON:5060
#

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 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
  fax transmission 1 relay t38-udp
  fax transmission 2 bypass g711alaw64k 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 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
  national-prefix 0
  international-prefix 00
  
  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
	route call 3 dest-interface IF_ISDN_2
	route call 4 dest-interface IF_ISDN_3

  interface isdn IF_ISDN_0
    route call dest-interface IF_SIP_0
    call-reroute emit
	diversion emit
	caller-name
	
  interface isdn IF_ISDN_1
    route call dest-interface IF_SIP_0
    call-reroute emit
	diversion emit
	caller-name
	
  interface isdn IF_ISDN_2
    route call dest-interface IF_SIP_0
    call-reroute emit
	diversion emit
	caller-name
	
  interface isdn IF_ISDN_3
    route call dest-interface IF_SIP_0
    call-reroute emit
	diversion emit
	caller-name

  interface sip IF_SIP_0
    bind context sip-gateway GW_5060
    route call dest-service HG_TO_ISDN
    remote 192.168.1.50
	early-connect
    early-disconnect

context cs switch
  no shutdown

context sip-gateway GW_5060

  interface IF_GW_5060
    bind interface WAN context router port 5060

context sip-gateway GW_5060
  no shutdown

port ethernet 0 0
  medium auto
  encapsulation ip
  bind interface 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 user
      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 user
      bchan-number-order ascending
      encapsulation cc-isdn
      bind interface IF_ISDN_1 switch

port bri 0 1
  no shutdown
  
port bri 0 2
  clock auto
  encapsulation q921

  q921
    protocol pmp
    uni-side auto
    encapsulation q931

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

port bri 0 2
  no shutdown
  
port bri 0 3
  clock auto
  encapsulation q921

  q921
    protocol pmp
    uni-side auto
    encapsulation q931

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

port bri 0 3
  no shutdown