Skip to content

Conversation

@surfermarty
Copy link

Added support for CoA requests which meant handling accounting packets, which have a different authenticator format. Changes add support for 'CoA' and 'Disconnect' requests.

@dapphp
Copy link
Owner

dapphp commented Nov 25, 2025

Hi,

Thanks for adding this. I'm working on getting it merged in and adding tests. Can you provide any examples for how you used it?

@surfermarty
Copy link
Author

surfermarty commented Nov 25, 2025

Background:

We have PPPoE connections that come into MikroTik routers which use Radius for authentication. If a connection goes over it's data limit, we need to apply a speed throttle onto the connection. Typically PPPoE connections would set this at the time they connect but that would mean we need to force the connection to reset.

The PPPoE server allows these rate limits to be applied through a Radius 'Change of Authentication' request. This then applies the rate limit to an active connection without restarting it.

CoA is part of RFC5176 to Radius, along with the option to disconnect a session, so I've implemented both.

They use the Accounting packet format for Radius, which is different from the Authentication one; so that was also implemented.

Example of usage:

$radius=new Dapphp\Radius\Radius("nas ip");
$radius->setAccountingPort(3799);
$radius->setSecret('secret');

$radius->resetAttributes();
$radius->setUsername("username");
$radius->setVendorSpecificAttribute(Dapphp\Radius\VendorId::MIKROTIK, 8, "0/0");
if(!$radius->coaRequest()) {
echo("CoA for username @ nasip failed".PHP_EOL);
}

@dapphp
Copy link
Owner

dapphp commented Nov 25, 2025

That's super helpful, thanks. I'm making a few small changes and fixes to the code and have some other improvements I'll try to include with this release but expect to push some changes up in a day or so based on your changes for review.

dapphp added a commit that referenced this pull request Dec 6, 2025
@dapphp
Copy link
Owner

dapphp commented Dec 6, 2025

Hi @surfermarty,

I finally got these changes and other pending work merged in and pushed to the 3.0 branch. If you have the time and are able, could you test with the 3.0 branch before I tag a new release and merge into the main branch?

There are some small changes between your original PR and the merged changes but not much. There's no need to set the accounting port unless it's non-standard. I also merged generateRadiusAccountingPacket() with the existing function since they were identical, and I wanted message authenticator (type 80) support to work with accounting packets as well, but that doesn't really change how it's called. Check out example/CoA-Disconnect.php for basic usage.

Otherwise, I'll merge this in soon and greatly appreciate the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants