[RADIATOR] Replacing the Operator-Name with a modified version

Stefan Paetow (OpenSource) oss at eons.net
Fri Mar 10 15:39:10 UTC 2023


Hi Heikki,

Thanks for checking that over. Yes, the regex was a quick thing I chucked
together (forgetting that ^ would do the trick). I've created a ForwardHook
(before sending things to our national roaming servers), and a
PreProcessingHook in the Handler that handles the DNSROAM Auth (so anything
our national roaming servers wouldn't handle, like the Cisco OpenRoaming,
Samsung OpenRoaming and Android internal OpenRoaming client realms).

So far that seems to work now, thank you! :-)

With kind regards

Stefan


On Fri, 10 Mar 2023 at 14:33, Heikki Vatiainen via radiator <
radiator at lists.open.com.au> wrote:

> On 10.3.2023 6.12, Stefan Paetow (OpenSource) via radiator wrote:
>
> > Currently, we get "1<domain>", which is the 'old' (or 'correct') format
> > for Wi-Fi networks, so I'm looking at a hook to replace the 1 with a 4
> > as a first step. I assume I do that in the PreClientHook or the
> > PreProcessingHook?
> >
> > I was thinking that this code would work:
> >
> > sub {\
> > my $p = ${$_[0]}; my $oname=$p->get_attr('Operator-Name');\
> > $oname =~ s/1(.*)$/4\1/g; $p->change_attr('Operator-Name',$oname);\
> > &main::log($main::LOG_DEBUG,"Operator-Name:$oname, ");\
> > }
> >
> > Do I have that right?
>
> Looks good. See below for a slightly updated regexp.
>
> You can use that hook as global PreClientHook, global ClientHook,
> ClientHook within a <Client ...> clause and as a PreProcessingHook
> within a <Handler>. They all use reference to the current request as
> their first argument. PreProcessingHook also gets current reply which
> can be ignored in this case.
>
> I'd simplify the regexp a little if it only needs to swap a leading 1 to
> 4. Here's an idea of a tester:
>
> <Client DEFAULT>
>          Secret  mysecret
> </Client>
>
> <Handler>
>          PreProcessingHook sub {\
>               my $p = ${$_[0]}; my $oname=$p->get_attr('Operator-Name');\
>               $oname =~ s/^1/4/s; $p->change_attr('Operator-Name',$oname);\
>               main::log($main::LOG_DEBUG,"Operator-Name:$oname, ");\
>               }
>          <AuthBy INTERNAL>
>                  DefaultResult REJECT
>          </AuthBy>
>          AddToReply Reply-Message=%{Request:Operator-Name}
> </Handler>
>
>
>
> Testing with radpwtst:
> % radpwtst -trace 4 -noacct Operator-Name=1operator:country
>
> Should return a reply with the default and additional Reply-Message:
>
>
> Fri Mar 10 16:28:31 2023: DEBUG: Packet dump:
> *** Received from 127.0.0.1 port 1645 ....
> Code:       Access-Reject
> Identifier: 233
> Authentic:  <243>2<235>H<17>!7<254>><15>W<0>_c}<185>
> Attributes:
>         Reply-Message = "Request Denied"
>         Reply-Message = "4operator:country"
>
> Rejected: Request Denied
>
>
> Note that only PreClientHook runs before log level 4 packet dump.
> Therefore the updated Operator-Name is not visible in the log with the
> other hooks.
>
> Thanks,
> Heikki
>
> --
> Heikki Vatiainen
> OSC, makers of Radiator
> Visit radiatorsoftware.com for Radiator AAA server software
> _______________________________________________
> radiator mailing list
> radiator at lists.open.com.au
> https://lists.open.com.au/mailman/listinfo/radiator
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.open.com.au/pipermail/radiator/attachments/20230310/665ae172/attachment.html>


More information about the radiator mailing list