Using API

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:

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();
        }
 
        public long WriteError(LogEvent le, long ErrorID)
        {
            throw new NotImplementedException();
        }
    }
}

API Details

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 -:

  1. . Create a new Class Library Project and name it BusLayer
  2. . In Solution Explorer, right click on References and select “Add Reference”
  3. . On Browse tab, select “Evolynx.RADIUS.Common.dll” which is located in Evolynx RADIUS directory, and click ok
  4. . Copy the code from the box above (which is in C#, modify for your target language) to your project
  5. . Add code to any of the methods you need to implement
  6. . When you are finished debugging your DLL, Build and copy your bug free DLL to Evolynx RADIUS directory (RADIUS Service should be stopped)

How to debug BusLayer.dll
In order to debug your DLL in Visual Studio .NET environment follow these steps:

  1. . Set the “Output Path” of your DLL project to the Evolynx RADIUS directory
  2. . Make sure EvolynxRADIUS service is stopped
  3. . Build your DLL in Debug mode
  4. . Start the EvolynxRADIUS service
  5. . From Debug menu select Processes
  6. . In the list of available Processes select EvolynxRadius.exe and then Click on Attach button
  7. . On the next window make sure “Common Language Runtime” is selected then click OK
  8. . Close the Processes window
  9. . Use breakpoints to stop execution in any part of your code
  10. . Use a RADIUS client (or Evolynx RADIUS Load Test Tool) to send requests to RADIUS Server and test your DLL

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 2019, 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: