diff -ur abills.orig/Abills/mysql/Acct.pm abills/Abills/mysql/Acct.pm
--- abills.orig/Abills/mysql/Acct.pm	2008-04-26 12:54:23.000000000 +0400
+++ abills/Abills/mysql/Acct.pm	2008-05-29 08:46:46.000000000 +0400
@@ -65,8 +65,8 @@
 #my $a=`echo "test $acct_status_type = $ACCT_TYPES{$RAD->{ACCT_STATUS_TYPE}}"  >> /tmp/12211 `;
  
  $RAD->{FRAMED_IP_ADDRESS} = '0.0.0.0' if(! defined($RAD->{FRAMED_IP_ADDRESS}));
- if (length($RAD->{ACCT_SESSION_ID}) > 25) {
- 	  $RAD->{ACCT_SESSION_ID} = substr($RAD->{ACCT_SESSION_ID}, 0, 1);
+ if (length($RAD->{ACCT_SESSION_ID}) > 32) {
+ 	  $RAD->{ACCT_SESSION_ID} = substr($RAD->{ACCT_SESSION_ID}, 0, 32);
   }
  
 if ($RAD->{USER_NAME} =~ /(\d+):(\S+)/) {
@@ -344,8 +344,24 @@
   	return $self;
    }
 
-#detalization for Exppp
+#If detalization on then...
 if ($conf->{s_detalization}) {
+    #detalization for MPD & OpenVPN
+    if ($NAS->{NAS_TYPE} eq 'mpd' || $NAS->{NAS_TYPE} eq 'openvpn') {
+	$RAD->{INBYTE}=0 if (! defined($RAD->{INBYTE}));
+        $RAD->{OUTBYTE}=0 if (! defined($RAD->{OUTBYTE}));
+        $RAD->{INBYTE2}=0 if (! defined($RAD->{INBYTE2}));
+	$RAD->{OUTBYTE2}=0 if (! defined($RAD->{OUTBYTE2}));
+
+	$self->query($db, "INSERT into s_detail (acct_session_id, nas_id, acct_status, last_update, 
+	    sent1, recv1, sent2, recv2, id)
+	VALUES (\"$RAD->{ACCT_SESSION_ID}\", '$NAS->{NAS_ID}',
+	'$acct_status_type', UNIX_TIMESTAMP(),
+	'$RAD->{OUTBYTE}', '$RAD->{INBYTE}', 
+	'$RAD->{OUTBYTE2}', '$RAD->{INBYTE2}', 
+	'$RAD->{USER_NAME}');", 'do');
+    #detalization for Exppp
+    } elsif ($NAS->{NAS_TYPE} eq 'exppp') {
    $RAD->{INTERIUM_INBYTE}=0 if (! defined($RAD->{INTERIUM_INBYTE}));
    $RAD->{INTERIUM_OUTBYTE}=0 if (! defined($RAD->{INTERIUM_OUTBYTE}));
    $RAD->{INTERIUM_INBYTE2}=0 if (! defined($RAD->{INTERIUM_INBYTE2}));
@@ -358,6 +374,7 @@
    '$RAD->{INTERIUM_INBYTE}', '$RAD->{INTERIUM_OUTBYTE}', 
    '$RAD->{INTERIUM_INBYTE2}', '$RAD->{INTERIUM_OUTBYTE2}', 
    '$RAD->{USER_NAME}');", 'do');
+    }
 }
diff -ur abills.orig/Abills/mysql/Auth.pm abills/Abills/mysql/Auth.pm
--- abills.orig/Abills/mysql/Auth.pm	2008-05-03 04:27:35.000000000 +0400
+++ abills/Abills/mysql/Auth.pm	2008-06-01 09:05:25.000000000 +0400
@@ -834,16 +839,20 @@
     return 1, \%RAD_PAIRS;
    }
  } 
-#If don't athorize any above methods auth PAP password
 else {
-  if(defined($RAD->{USER_PASSWORD}) && $self->{PASSWD} ne $RAD->{USER_PASSWORD}) {
+#If don't athorize any above methods auth PAP password for OpenVPN
+  if(defined($RAD->{PASSWORD}) && $self->{PASSWD} ne $RAD->{PASSWORD}) {
+    $RAD_PAIRS{'Reply-Message'}="Wrong OpenVPN password $RAD->{PASSWORD}}";
+    return 1, \%RAD_PAIRS;
+    }
+#If don't athorize any above methods auth PAP password
+  elsif(defined($RAD->{USER_PASSWORD}) && $self->{PASSWD} ne $RAD->{USER_PASSWORD}) {
     $RAD_PAIRS{'Reply-Message'}="Wrong password '$RAD->{USER_PASSWORD}'";
     return 1, \%RAD_PAIRS;
    }
 }
diff -ur abills.orig/Abills/nas.pl abills/Abills/nas.pl
--- abills.orig/Abills/nas.pl	2008-04-26 12:54:12.000000000 +0400
+++ abills/Abills/nas.pl	2008-05-25 05:01:38.000000000 +0400
@@ -62,6 +62,9 @@
  elsif ($nas_type eq 'mpd') {
    hangup_mpd($NAS, $PORT);
   }
+ elsif ($nas_type eq 'openvpn') {
+   hangup_openvpn($NAS, $PORT, $USER);
+  }
  elsif ($nas_type eq 'mpd4') {
    hangup_mpd4($NAS, $PORT, $attr);
   }
@@ -698,7 +701,18 @@
                "\]\texit");
 
  my $result = telnet_cmd("$NAS->{NAS_MNG_IP_PORT}", \@commands);
- print $result;
+# print $result;
+ return 0;
+}
+
+sub hangup_openvpn {
+ my ($NAS_IP, $PORT, $USER) = @_;
+
+ my @commands=(">INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info\tkill $USER",
+               "SUCCESS: common name '$USER' found, 1 client(s) killed\texit");
+
+ my $result = telnet_cmd("$NAS->{NAS_MNG_IP_PORT}", \@commands);
+# print $result;
  return 0;
 }
diff -ur abills.orig/cgi-bin/admin/index.cgi abills/cgi-bin/admin/index.cgi
--- abills.orig/cgi-bin/admin/index.cgi	2008-05-03 04:27:36.000000000 +0400
+++ abills/cgi-bin/admin/index.cgi	2008-05-31 23:23:45.000000000 +0400
@@ -2764,6 +2764,7 @@
   'bsr1000'   => 'CMTS Motorola BSR 1000',
   'mikrotik'  => 'Mikrotik (http://www.mikrotik.com)',
   'dlink_pb'  => 'Dlink IP-MAC-Port Binding',
+  'openvpn'   => 'OpenVPN with RadiusPlugin',
   'other'     => 'Other nas server',
   'chillispot'=> 'Chillispot (www.chillispot.org)',
   'vlan'      => 'Vlan managment',
diff -ur abills.orig/libexec/linkupdown abills/libexec/linkupdown
--- abills.orig/libexec/linkupdown	2008-04-26 12:54:35.000000000 +0400
+++ abills/libexec/linkupdown	2008-06-10 20:03:46.000000000 +0400
@@ -104,10 +104,20 @@
 
 # Arguments
 my ($ACTION, $INTERFACE, $USER, $HISADDR, $inum);
 
+require Admins;
+Admins->import();
+require Dv;
+Dv->import();
+
+my $admin = Admins->new($db, \%conf);
+$admin->info($conf{SYSTEM_ADMIN_ID}, { IP => '127.0.0.1' });
+my $Dv = Dv->new($db, $admin, \%conf); 
+
 #MPD
 if ($ARGV[0] eq 'mpd') {
   $ACTION   = $ARGV[1];
@@ -117,6 +127,26 @@
   $inum     = $INTERFACE;
   $inum     =~ s/ng//;
 }
+#OpenVPN
+elsif ($ARGV[0] eq 'openvpn') {
+  $ACTION   = $ARGV[1];
+  $INTERFACE= $ARGV[2];
+  $USER     = $ARGV[6];
+  $HISADDR  = $ARGV[5];
+
+  my $user = undef;
+
+  $user = $Dv->info(0, { LOGIN => $USER });
+  $inum = $user->{UID}+$conf{OPENVPN_FW_FIRST_RULE};
+
+#  $inum     = $INTERFACE;
+#  if(! ($inum     =~ s/tap//)) {
+#     $inum= 100+8
+#  } else {
+#     $inum     = $inum+100;
+#  }
+}
+
 #pppd
 elsif ($ARGV[0] eq 'ipn') {
   $ACTION    = $ARGV[1];
@@ -157,15 +187,6 @@
 my $via_if_in  = ($INTERFACE ne '-') ? "via $INTERFACE in" : '';
 my $via_if_out = ($INTERFACE ne '-') ? "via $INTERFACE out" : '';
 
-require Admins;
-Admins->import();
-require Dv;
-Dv->import();
-
-
-my $admin = Admins->new($db, \%conf);
-$admin->info($conf{SYSTEM_ADMIN_ID}, { IP => '127.0.0.1' });
-my $Dv = Dv->new($db, $admin, \%conf); 

 my @FW_ACTIONS = ();