{%- set tun_ipv6_addr    = slap_configuration.get('tun-ipv6-addr', '2001:db8::1') %}
{%- set tun_ipv6_network = slap_configuration.get('tun-ipv6-network', '2001:db8::/55') %}
{%- set tun_ipv4_addr    = slap_configuration.get('tun-ipv4-addr', '172.17.0.1') %}
{%- set tun_ipv4_network = slap_configuration.get('tun-ipv4-network', '172.17.0.0/17') %}
{%- set tun_name         = slap_configuration.get('tun-name', 'slaptun0') %}
{%- set tun_ipv6_start   = int(netaddr.IPAddress(tun_ipv6_addr)) %}
{%- set tun_ipv6_end     = netaddr.IPNetwork(tun_ipv6_network).last  %}
{%- set tun_ipv4_start   = int(netaddr.IPAddress(tun_ipv4_addr)) %}
{%- set tun_ipv4_end     = netaddr.IPNetwork(tun_ipv4_network).last  %}

{%- set internet_ipv4 = netaddr.IPAddress( tun_ipv4_start                         ) %}
{%- set ims_ipv4      = netaddr.IPAddress((tun_ipv4_start + tun_ipv4_end) // 2 + 1) %}
{%- set ims_ipv6      = netaddr.IPAddress((tun_ipv6_start + tun_ipv6_end) // 2    ) %}

{
    log_options: "all.level=debug,all.max_size=32",
    log_filename: "{{ directory['log'] }}/ims.log",

    sip_addr: [
        {addr: "{{ ims_ipv4 }}", bind_addr: "{{ ims_ipv4 }}", port_min: 10000, port_max: 20000},
        "{{ ims_ipv6 }}",
    ],

    mms_server_bind_addr: "{{ internet_ipv4 }}:1111",
    sctp_addr: "{{ slapparameter_dict.ims_addr }}",

    
    cx_server_addr: "127.0.1.100",
    cx_bind_addr: "{{ slapparameter_dict.ims_addr }}",

    rx_server_addr: "127.0.1.100",

    domain: "{{ slapparameter_dict.get('ims_domain', 'rapid.space') }}",

    include "{{ slap_configuration['ue_db_path'] }}",

    echo: [
        "tel:666",
        "tel:+666",
        {impu: "tel:404", code: 404},     
        {impu: "urn:service:sos", anonymous: true, authentication: false}, 
        {impu: "urn:service:sos.police", anonymous: true, authentication: false}, 
    ],
    
    precondition: "on",
    "100rel": true,
    
    ipsec_aalg_list: ["hmac-md5-96", "hmac-sha-1-96"],
    ipsec_ealg_list: ["null", "aes-cbc", "des-cbc", "des-ede3-cbc"],

    ipsec_ifname: "{{ tun_name }}-ims",
    ipsec_netns: "{{ tun_name }}-ims-netns",

    mt_call_sdp_file: "{{ directory['etc'] }}/mt_call_qos.sdp",

    ue_db_filename: "{{ directory['var'] }}/lte_ue_ims.db",
}
