#
# ALLNET.ITALIA - Patton FXO SmartWare
# Template per connessione di un centralino IP
# a 4 linee analogiche del provider (FXS) con I/F SIP separate
#
# IP Patton 		192.168.1.100
# IP GW rete e DNS 	192.168.1.1
# IP Centralino 	192.168.1.50
#
# Configurazione PBX
# IF_FXO_0 (IF_SIP_0 - no reg)	IP_PATTON:5060
# IF_FXO_1 (IF_SIP_1 - no reg)	IP_PATTON:5062
# IF_FXO_2 (IF_SIP_2 - no reg)	IP_PATTON:5064
# IF_FXO_3 (IF_SIP_3 - no reg)	IP_PATTON:5066
#

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

system

  ic voice 0
    low-bitrate-codec g729

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
  map cause to-sip user-busy to 404
  no autonomous-transitioning

profile aaa default
  method 1 local
  method 2 none

context ip router

  interface eth0
    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

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

  interface sip IF_SIP_1
    bind context sip-gateway GW_5062
    route call dest-interface IF_FXO_1
    remote 192.168.1.50
	early-connect
    early-disconnect
	
  interface sip IF_SIP_2
    bind context sip-gateway GW_5064
    route call dest-interface IF_FXO_2
    remote 192.168.1.50
	early-connect
    early-disconnect
	
  interface sip IF_SIP_3
    bind context sip-gateway GW_5066
    route call dest-interface IF_FXO_3
    remote 192.168.1.50
	early-connect
    early-disconnect
 
  interface fxo IF_FXO_0
    route call dest-interface IF_SIP_0
    disconnect-signal busy-tone
    ring-number on-caller-id
    dial-after timeout 1

  interface fxo IF_FXO_1
    route call dest-interface IF_SIP_1
    disconnect-signal busy-tone
    ring-number on-caller-id
    dial-after timeout 1

interface fxo IF_FXO_2
    route call dest-interface IF_SIP_2
    disconnect-signal busy-tone
    ring-number on-caller-id
    dial-after timeout 1

interface fxo IF_FXO_3
    route call dest-interface IF_SIP_3
    disconnect-signal busy-tone
    ring-number on-caller-id
    dial-after timeout 1


context cs switch
  no shutdown

context sip-gateway GW_5060

  interface IF_GW_5060
    bind interface eth0 context router port 5060

context sip-gateway GW_5060
  no shutdown
  
context sip-gateway GW_5062

  interface IF_GW_5062
    bind interface eth0 context router port 5062

context sip-gateway GW_5062
  no shutdown

context sip-gateway GW_5064

  interface IF_GW_5064
    bind interface eth0 context router port 5064

context sip-gateway GW_5064
  no shutdown
  
context sip-gateway GW_5066

  interface IF_GW_5066
    bind interface eth0 context router port 5066

context sip-gateway GW_5066
  no shutdown

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

port fxo 0 0
  encapsulation cc-fxo
  bind interface IF_FXO_0 switch
  no shutdown

port fxo 0 1
  encapsulation cc-fxo
  bind interface IF_FXO_1 switch
  no shutdown


port fxo 0 2
  encapsulation cc-fxo
  bind interface IF_FXO_2 switch
  no shutdown


port fxo 0 3
  encapsulation cc-fxo
  bind interface IF_FXO_3 switch
  no shutdown

