################################################
# CONFIGURATION OF PATTON DEVICE
################################################

#----------------------------------------------------------------#
#                                                                #
# Patton Electronics Company                                     #
# SN5531/4BIS8VRHP v1.8 (SmartNode 5531 VoIP eSBC)               #
#----------------------------------------------------------------#
#                                                                #
# Project: Spark SIP Trunk Testing                               #
# Created: 04 Apr 2019                                           #
# By: Patton Support Desk (Melbourne TAC)                        #
# For: SnapperNet New Zealand                                    #
#                                                                #
#----------------------------------------------------------------#
#                                                                #
# NOTES:                                                         #
# ------                                                         #
# - Telnet and Web HTTP are disabled in this configuration.      #
# - Web interface is available on HTTPS (443)                    #
# - The called number for outgoing calls will be mapped from     #
#   seven or eight digits to a nine-digit format.                #
# - During testing of this configuration, the incoming calls     #
#   had the called-number as 8 digit CLI and was passed as it    #
#   is to the BRI side.                                          #
# - The BRI might need reconfiguration depending on pmp or pp    #
#   mode of operation.                                           #
# - All incoming calls from SIP will be sent to hunt group to    #
#   hunt from available BRI ports starting from 0/0 until 0/3    #
#                                                                #
#----------------------------------------------------------------#

cli version 4.00
support connect LETS_CONNECT
system hostname SN_SPARK_SIP_TEST
system description "SIP Trunk Testing (Spark NZ)"
system contact "SnapperNet (+64 9 4154182)"
system location "Albany Auckland"
system provider "SnapperNet Auckland"
system subscriber "Spark SIP Trunk Validation"
system supplier "SnapperNet Auckland"
system banner "Welcome to SIP Trunking Gateway\n(Powered by SnapperNet)"
clock local default-offset +12:00
clock local dst-rule NZDT +1:00 from sep last sunday 02:00 2000 until apr 1st 03:00 2036
rtp-port-range 8000 8199

profile aaa DEFAULT
  method 1 local
  method 2 none

console
  use profile aaa DEFAULT

telnet-server
  use profile aaa DEFAULT
  shutdown

ssh-server
  use profile aaa DEFAULT
  no shutdown

snmp-server
  shutdown

web-server
  no protocol http
  protocol https port 443
  use profile aaa DEFAULT
  no shutdown

ntp
  server 122.56.252.129
  server 122.56.252.137
  no shutdown

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

profile napt NAPT_WAN

dns-server
  host 192.168.1.1 smartnode.local
  relay dns-client
  no shutdown

dns-client
  name-server 210.55.111.1
  name-server 122.56.237.1

profile dhcp-server DHCPS_LAN
  network 192.168.1.0/24
  lease 24 hours
  default-router 192.168.1.1
  domain-name-server 192.168.1.1
  include 192.168.1.10 192.168.1.99

profile tls DEFAULT
  authentication incoming
  authentication outgoing
  private-key pki:private-key/DEFAULT
  own-certificate 1 pki:certificate/DEFAULT
  diffie-hellman-parameters pki:diffie-hellman-parameters/DEFAULT-2048

profile call-progress-tone NZ_Alertingtone
  play 1 400 first-tone 400 -13 second-tone 450 -13
  pause 2 200
  play 3 400 first-tone 400 -13 second-tone 450 -13
  pause 4 2000

profile call-progress-tone NZ_Busytone
  play 1 500 first-tone 400 -13
  pause 2 500

profile call-progress-tone NZ_Callwaiting
  play 1 200 first-tone 400 -13
  pause 2 200

profile call-progress-tone NZ_Dialtone
  play 1 5000 first-tone 400 -13

profile call-progress-tone NZ_Releasetone
  play 1 250 first-tone 400 -13
  pause 2 250

profile call-progress-tone NZ_SDTone
  play 1 10000 first-tone 425 -19 second-tone 620 -19

profile tone-set DEFAULT
  map call-progress-tone dial-tone NZ_Dialtone
  map call-progress-tone ringback-tone NZ_Alertingtone
  map call-progress-tone waiting-tone NZ_Callwaiting
  map call-progress-tone busy-tone NZ_Busytone
  map call-progress-tone congestion-tone NZ_Releasetone
  map call-progress-tone release-tone NZ_Releasetone
  map call-progress-tone special-dial-tone NZ_SDTone

profile voip DEFAULT
  codec 1 g711alaw64k rx-length 20 tx-length 20
  codec 2 g711ulaw64k rx-length 20 tx-length 20
  dtmf-relay rtp
  fax transmission 1 relay t38-udp
  fax transmission 2 bypass g711alaw64k rx-length 20 tx-length 20

profile pstn DEFAULT

profile rip DEFAULT

profile sip DEFAULT

context ip ROUTER

  interface WAN
    ipaddress DHCP dhcp
    use profile napt NAPT_WAN DHCP

  interface LAN
    ipaddress LAN 192.168.1.1/24

  routing-table DEFAULT

  bgp
    shutdown

  rip
    shutdown

context ip ROUTER
  use profile dhcp-server DHCPS_LAN

nodems-client
  resource any
  shutdown

profile packetsmart DEFAULT

profile ppp DEFAULT

cwmp-client
  bind ipaddress ROUTER WAN DHCP
  session-retry-maximum 1
  no shutdown

  stun
    shutdown

context cs SWITCH
  no shutdown

  mapping-table called-e164 to called-e164 MT_SET_CLI
    map (.......)$ to 09\1
    map (........)$ to 0\1

  routing-table called-e164 RT_GET_DIGITS
    route .T dest-table RT_TO_SIP

  routing-table calling-e164 RT_TO_SIP
    route default dest-interface IF_SIP MT_SET_CLI

  interface isdn IF_BRI_00
    route call dest-table RT_GET_DIGITS
    no release-tone

  interface isdn IF_BRI_01
    route call dest-table RT_GET_DIGITS
    no release-tone

  interface isdn IF_BRI_02
    route call dest-table RT_GET_DIGITS
    no release-tone

  interface isdn IF_BRI_03
    route call dest-table RT_GET_DIGITS
    no release-tone

  interface sip IF_SIP
    bind context sip-gateway SIP
    route call dest-service HG_INC
    remote sip-net.spark.co.nz
    local sip-net.spark.co.nz
    early-disconnect
    address-translation outgoing-call to-header user-part call host-part local

  service hunt-group HG_INC
    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
    drop-cause recovery-on-timer-expiry
    route call 1 dest-interface IF_BRI_00
    route call 2 dest-interface IF_BRI_01
    route call 3 dest-interface IF_BRI_02
    route call 4 dest-interface IF_BRI_03

authentication-service AS_SPARK
  realm 1 spark.co.nz
  username 9442XXXX password PASSWORD

location-service LS_SPARK
  domain 1 sip-net.spark.co.nz
  match-any-domain

  identity-group DEFAULT

    authentication outbound
      authenticate 1 authentication-service AS_SPARK username 9442XXXX

    registration outbound
      registrar sip-net.spark.co.nz
      register auto

  identity 9442XXXX inherits DEFAULT

context sip-gateway SIP
  bind location-service LS_SPARK

  interface IF_SIP_SIP
    transport-protocol udp+tcp 5060
    no transport-protocol tls
    bind ipaddress ROUTER WAN DHCP

context sip-gateway SIP
  no shutdown

sip-survivability
  shutdown

port ethernet 0 0
  bind interface ROUTER WAN
  no shutdown

port ethernet 0 1
  bind interface ROUTER LAN
  no shutdown

port bri 0 0

  q921
    protocol pmp
    uni-side auto

    q931
      protocol dss1
      uni-side net
      max-calls 2
      channel-range 0 1
      bind interface SWITCH IF_BRI_00

port bri 0 0
  no shutdown

port bri 0 1

  q921
    protocol pmp
    uni-side auto

    q931
      protocol dss1
      uni-side net
      max-calls 2
      channel-range 0 1
      bind interface SWITCH IF_BRI_01

port bri 0 1
  no shutdown

port bri 0 2

  q921
    protocol pmp
    uni-side auto

    q931
      protocol dss1
      uni-side user
      max-calls 2
      channel-range 0 1
      bind interface SWITCH IF_BRI_02

port bri 0 2
  no shutdown

port bri 0 3

  q921
    protocol pmp
    uni-side auto

    q931
      protocol dss1
      uni-side user
      max-calls 2
      channel-range 0 1
      bind interface SWITCH IF_BRI_03

port bri 0 3
  no shutdown