From: Alan T. DeKok Date: Fri, 25 Nov 2022 14:41:28 +0000 (-0500) Subject: preliminary code to interpret UNLANG_TYPE_VARIABLE X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83544f1618eb1897ca11f51ab0cf718de268d6fb;p=thirdparty%2Ffreeradius-server.git preliminary code to interpret UNLANG_TYPE_VARIABLE does nothing right now, but at least doesn't crash if you try to use local variables --- diff --git a/src/lib/unlang/all.mk b/src/lib/unlang/all.mk index 8a743baf81a..148748918ef 100644 --- a/src/lib/unlang/all.mk +++ b/src/lib/unlang/all.mk @@ -24,6 +24,7 @@ SOURCES := base.c \ switch.c \ timeout.c \ tmpl.c \ + variable.c \ xlat.c \ xlat_builtin.c \ xlat_eval.c \ diff --git a/src/lib/unlang/base.c b/src/lib/unlang/base.c index 043a35c3e1c..d7cb6458a5f 100644 --- a/src/lib/unlang/base.c +++ b/src/lib/unlang/base.c @@ -103,6 +103,7 @@ int unlang_init_global(void) unlang_edit_init(); unlang_timeout_init(); unlang_limit_init(); + unlang_variable_init(); instance_count++; diff --git a/src/lib/unlang/unlang_priv.h b/src/lib/unlang/unlang_priv.h index 56f26e0f940..35bbc5062d3 100644 --- a/src/lib/unlang/unlang_priv.h +++ b/src/lib/unlang/unlang_priv.h @@ -623,6 +623,8 @@ void unlang_edit_init(void); void unlang_timeout_init(void); void unlang_limit_init(void); + +void unlang_variable_init(void); /** @} */ #ifdef __cplusplus diff --git a/src/lib/unlang/variable.c b/src/lib/unlang/variable.c new file mode 100644 index 00000000000..6090222da86 --- /dev/null +++ b/src/lib/unlang/variable.c @@ -0,0 +1,49 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * $Id$ + * + * @file unlang/variable.c + * @brief Unlang local "variable"s + * + * @copyright 2022 Network RADIUS SAS (legal@networkradius.com) + */ +RCSID("$Id$") + +#include "group_priv.h" +#include "variable_priv.h" + +static unlang_action_t unlang_variable(UNUSED rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame) +{ + unlang_variable_t *var; + + var = unlang_generic_to_variable(frame->instruction); + + RDEBUG3("Creating varible max %d", var->max_attr); + + return UNLANG_ACTION_CALCULATE_RESULT; +} + + +void unlang_variable_init(void) +{ + unlang_register(UNLANG_TYPE_VARIABLE, + &(unlang_op_t){ + .name = "variable", + .interpret = unlang_variable, + }); +}