Unlang Configuration Problem on Missing Attributes

classic Classic list List threaded Threaded
4 messages Options
| Threaded
Open this post in threaded view
|

Unlang Configuration Problem on Missing Attributes

StreitLeak
I have problem on unlang when I want to build SQL Query.
The Request packet is missing some attributes on VSA.
The Dictionary which I custom it have 150 attributes. But the Request only
sent 120 or 130.
So if I set all attributes in my sql query, the query will fail with
lacking some attributes in Request Packet.
-----SQL Schema---
  Ex:   The table Schema Example
create table radacct {
                 attr1   int not null default 0.
                 attr2  varchar(255) not null default '',
                 attr3  int not null default 0.
                 attr4  int not null default 0
}
--- SQL Query in sql/main/mysql/querier.conf ---
 The Query = "insert into radacct ( attr1.attr2.attr3,attr4) values
('%{attr1}', '%{attr2}','%{attr3}','%{attr4}' );"
---  Request Packet Example ---
        Acct-Delay-Time = 437
        Attr1-Log-Time = "Mon Feb  8 15:15:11 2021\n"
        Acct-Status-Type = Stop
        Acct-Session-Id = "15934598980000000296"
        Attr2-Session-Ingress-CallId = 65535
        Attr3-Session-Egress-CallId = 1
        Attr5-Session-Generic-Id = 157
        Acct-Multi-Session-Id = "1612768062157"
----
     so the real query is "insert into radacct ( attr1.attr2.attr3,attr4)
values (' Mon Feb  8 15:15:11 2021\n ', '65535','1','' )
      As you can see . the Attr4 is missing in Request Packet. And it cause
the query failed. So I need to set some rules to avoid it. But I can't
understand the foreach how to check each VSA attributes. Or any easily way
to avoid the missing attributes.
      Have any configuration Example can help me to understand it?



              星たちよ
              汝の命短き眷族の望みな聞くがよい
              我らの望み  それほ
              汝の本將ちゆく末な看取るニと
                 -------------《アーヴによる人類帝國》國歌の一節よリ
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Unlang Configuration Problem on Missing Attributes

Matthew Newton-3


On 13/02/2021 05:44, StreitLeak wrote:
>       so the real query is "insert into radacct ( attr1.attr2.attr3,attr4)
> values (' Mon Feb  8 15:15:11 2021\n ', '65535','1','' )
>        As you can see . the Attr4 is missing in Request Packet. And it cause
> the query failed. So I need to set some rules to avoid it. But I can't
> understand the foreach how to check each VSA attributes. Or any easily way
> to avoid the missing attributes.

You can use conditional expansions

e.g.  %{%{attr4}:-0}

See

https://networkradius.com/doc/current/unlang/xlat_condition.html

There are plenty of examples of this in the default config, especially
in the SQL queries.

--
Matthew
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Unlang Configuration Problem on Missing Attributes

StreitLeak
MCN:
      I tried it before. But looks its only can set string not integer (ex:
%{%{attr4}:--3} its showing error when restart radius service.). So can I
set the -3 by using %{%{attr4}:-'-3'} or not?

              星たちよ
              汝の命短き眷族の望みな聞くがよい
              我らの望み  それほ
              汝の本將ちゆく末な看取るニと
                 -------------《アーヴによる人類帝國》國歌の一節よリ


Matthew Newton <[hidden email]> 於 2021年2月13日 週六 下午5:46寫道:

>
>
> On 13/02/2021 05:44, StreitLeak wrote:
> >       so the real query is "insert into radacct (
> attr1.attr2.attr3,attr4)
> > values (' Mon Feb  8 15:15:11 2021\n ', '65535','1','' )
> >        As you can see . the Attr4 is missing in Request Packet. And it
> cause
> > the query failed. So I need to set some rules to avoid it. But I can't
> > understand the foreach how to check each VSA attributes. Or any easily
> way
> > to avoid the missing attributes.
>
> You can use conditional expansions
>
> e.g.  %{%{attr4}:-0}
>
> See
>
> https://networkradius.com/doc/current/unlang/xlat_condition.html
>
> There are plenty of examples of this in the default config, especially
> in the SQL queries.
>
> --
> Matthew
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Unlang Configuration Problem on Missing Attributes

Alan DeKok-2
On Feb 13, 2021, at 7:00 AM, StreitLeak <[hidden email]> wrote:
>      I tried it before. But looks its only can set string not integer (ex:
> %{%{attr4}:--3} its showing error when restart radius service.). So can I
> set the -3 by using %{%{attr4}:-'-3'} or not?

  Yes.

  It would help ENORMOUSLY if you posted the debug output as suggested everywhere in the documentation.

  http://wiki.freeradius.org/list-help

  Alan DeKok.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html