#
# nas_dnis_check.cfg
#

# ZON DNISs
sub { 
    my $p = ${$_[0]};

    my $dnis = $p->get_attr('Called-Station-Id');
    my $cli  = $p->get_attr('Calling-Station-Id');
    my $port = $p->get_attr('Cisco-NAS-Port');
    my $user_name = $p->get_attr('User-Name');
    my $service_type = $p->get_attr('Service-Type');

    #------------------------------------------
    # Customer1 DNISs
    #------------------------------------------
    if (${dnis} =~ /207500370/) {
        $p->add_attr('customer1_dnis','true'); 
    }

    #------------------------------------------
    # zon DNIS
    #------------------------------------------
    if (${dnis} =~ /107500300|113750030|137500300|167750030|183750030|207500300|223750030|223750030|229750030|237500300|307500300|314750030|337500300|341750030|387500300|412750030|467500300|488750030|493750030|513750030|528750030|546750030|547750030|562750030|578750030|587500300|592750030|596750030|707500300|717500300|767500300/) {
        $p->add_attr('zon_dnis','true'); 
    }

    #------------------------------------------
    # tunneling or pre-authentication
    #------------------------------------------
    if (${service_type} =~ /Outbound-User/) {
        if (${user_name} =~ /dnis:/) {
            $p->add_attr('tunnel','true'); 
        }
        else {
            $p->add_attr('preauth','true'); 
        }
    }

    #------------------------------------------
    # Bad DNIS
    #------------------------------------------
    if (${dnis} =~ /888888888/) {
        $p->add_attr('bad_dnis','true'); 
    }

    #------------------------------------------
    # Bad CLI
    #------------------------------------------
    if (${cli} =~ /888888888/) {
        $p->add_attr('bad_cli','true'); 
    }
} 
