This is an old revision of the document!
If you are a .NET programmer, you can easily use a simple API to create your own database backend and billing software. Just create a .NET DLL with a specific name, which exposes a required Class. Evolynx RADIUS server expects to find a Class Library DLL file, named “BusLayer.dll”, in the same directory as “EvolynxRadius.exe” is located. This DLL should expose a Public Class name “Business” which implements the “IBusiness” interface. This interface is defined in the “Common.dll” and is used to make sure that you create a Business class which has all methods required by Evolynx RADIUS.
Business Class
When creating the DLL, you must at least create one class named Business. This Class is the bridge between Evolynx RADIUS and your billing software. Evolynx RADIUS will call specific methods of this Class to exchange information with database. A typical Business Class will look like this:
Imports System Imports Evolynx.RADIUS.Common Public Class Business Implements IBusiness Public Sub AccountingOther(ByVal Packet As RadiusPacket) Implements IBusiness.AccountingOther Throw New NotImplementedException() End Sub Public Sub AccountingStart(ByVal Packet As RadiusPacket) Implements IBusiness.AccountingStart Throw New NotImplementedException() End Sub Public Sub AccountingStop(ByVal Packet As RadiusPacket) Implements IBusiness.AccountingStop Throw New NotImplementedException() End Sub Public Function Authenticate(ByVal Packet As RadiusPacket) As Integer Implements IBusiness.Authenticate Throw New NotImplementedException() End Function Public Function LoadClients() As ClientCollection Implements IBusiness.LoadClients Throw New NotImplementedException() End Function Public Sub NotifyByEmail(ByVal State As Object) Implements IBusiness.NotifyByEmail Throw New NotImplementedException() End Sub Public Sub OnForwardAccounting(ByVal Packet As RadiusPacket, ByVal TargetIP As String) Implements IBusiness.OnForwardAccounting Throw New NotImplementedException() End Sub Public Sub OnForwardRequest(ByVal Packet As RadiusPacket, ByVal TargetIP As String) Implements IBusiness.OnForwardRequest Throw New NotImplementedException() End Sub Public Sub OnForwardToNAS(ByVal Packet As RadiusPacket, ByVal TargetIP As String) Implements IBusiness.OnForwardToNAS Throw New NotImplementedException() End Sub Public Sub ScheduledMaintenance(ByVal State As Object) Implements IBusiness.ScheduledMaintenance Throw New NotImplementedException() End Sub Public Function WriteError(ByVal Message As String, ByVal ErrorID As Long) As Long Implements IBusiness.WriteError Throw New NotImplementedException() End Function End Class
using System; using Evolynx.RADIUS.Common; namespace BusLayer { public class Business : IBusiness { public void AccountingOther(RadiusPacket Packet) { throw new NotImplementedException(); } public void AccountingStart(RadiusPacket Packet) { throw new NotImplementedException(); } public void AccountingStop(RadiusPacket Packet) { throw new NotImplementedException(); } public int Authenticate(RadiusPacket Packet) { throw new NotImplementedException(); } public ClientCollection LoadClients() { throw new NotImplementedException(); } public void NotifyByEmail(object State) { throw new NotImplementedException(); } public void OnForwardAccounting(RadiusPacket Packet, string TargetIP) { throw new NotImplementedException(); } public void OnForwardRequest(RadiusPacket Packet, string TargetIP) { throw new NotImplementedException(); } public void OnForwardToNAS(RadiusPacket Packet, string TargetIP) { throw new NotImplementedException(); } public void ScheduledMaintenance(object State) { throw new NotImplementedException(); } public long WriteError(string Message, long ErrorID) { throw new NotImplementedException(); } } }
Step by Step: How to create BusLayer.dll
Now that we know what we need to create, lets see how it should be created. The following steps summarize how you can create the DLL using Visual Studio 2008 and C -:
How to debug BusLayer.dll
In order to debug your DLL in Visual Studio .NET environment follow these steps:
Note:
Set the “Output Path” of your DLL project to the Evolynx RADIUS directory:
Sample Code
We have prepared a very simple example with minimum functionality to show how you can use the Evolynx API to create a DLL which authenticates users with a MS-Access database. In order to run this example, you need to re-define the Reference to “Definitions.dll” and set the “Output Path” in Project Properties. The mdb file must be placed in Evolynx RADIUS directory.
API Example (Visual Studio 2008, C - source code)
How to control Evolynx RADIUS Service
Evolynx RADIUS runs as a Windows service. With some .NET programming you can control some of the internal functions of this service. To do this, you need to create a ServiceController object and connect it to Evolynx Service. Then you can start and Stop the service or run a Custom command. The following sample code shows how to Start the service and run a Custom Command:
DIM myService As New ServiceProcess.ServiceController() myService.MachineName = "server-1" myService.ServiceName = "EvolynxRADIUS" myService.Start() myService.ExecuteCommand(131)
Currently there are 4 custom commands defined. These commands are used to reload settings and information without re-starting the service: