]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rearrange to show how to assign octets to structural members
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Dec 2021 17:38:09 +0000 (12:38 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Dec 2021 17:43:04 +0000 (12:43 -0500)
code isn't done, but it's a start of rearrangement

src/lib/unlang/edit.c

index f7fcf53b22d8f9214904d9861965e8c1098271ef..5549a155f3e0627a9b73e9cdd3e9ecd3e070fdb7 100644 (file)
@@ -299,8 +299,6 @@ static int apply_edits(request_t *request, unlang_frame_state_edit_t *state, map
                        goto leaf;
                }
 
-               fr_assert(rhs_box->type == FR_TYPE_STRING);
-
                if (map->op == T_OP_SUB_EQ) {
                        REDEBUG("Cannot remove data from a list");
                        return -1;
@@ -311,12 +309,35 @@ static int apply_edits(request_t *request, unlang_frame_state_edit_t *state, map
 
                children = &state->rhs.pair_list;
 
-               /*
-                *      @todo - keep parsing until the end.
-                */
-               token = fr_pair_list_afrom_str(state, da, rhs_box->vb_strvalue, rhs_box->length, children);
-               if (token == T_INVALID) {
-                       RPEDEBUG("Failed parsing string as attribute list");
+               switch (rhs_box->type) {
+               case FR_TYPE_STRING:
+                       /*
+                        *      @todo - keep parsing until the end.
+                        */
+                       token = fr_pair_list_afrom_str(state, da, rhs_box->vb_strvalue, rhs_box->length, children);
+                       if (token == T_INVALID) {
+                               RPEDEBUG("Failed parsing string as attribute list");
+                               return -1;
+                       }
+
+                       if (token != T_EOL) {
+                               REDEBUG("Failed to parse the entire string.");
+                               return -1;
+                       }
+
+                       break;
+
+               case FR_TYPE_OCTETS:
+                       /*
+                        *      @todo - do something like protocol_decode_xlat / xlat_decode_value_box_list(),
+                        *      except all of that requires a decode context :(
+                        */
+
+
+               default:
+                       fr_strerror_printf("Cannot assign '%s' type to structural type '%s'",
+                                          fr_table_str_by_value(fr_value_box_type_table, rhs_box->type, "<INVALID>"),
+                                          fr_table_str_by_value(fr_value_box_type_table, state->lhs.vp->vp_type, "<INVALID>"));
                        return -1;
                }