]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add API for querying / manipulating value box secret flag
authorNick Porter <nick@portercomputing.co.uk>
Wed, 26 Jul 2023 10:02:10 +0000 (11:02 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 26 Jul 2023 13:39:18 +0000 (14:39 +0100)
In anticipation of the flags moving to a structure.

src/lib/util/value.h

index d2b60745f59f2a89a7976f74a10fb2b08787d06b..da727fca499706e1cdcc02da4bfbf09ae4611304 100644 (file)
@@ -954,6 +954,31 @@ int                fr_value_box_mark_safe(fr_value_box_t *box, uint16_t safe)
 void           fr_value_box_mark_unsafe(fr_value_box_t *box)
                CC_HINT(nonnull);
 
+static inline CC_HINT(nonnull, always_inline)
+bool fr_value_box_is_secret(fr_value_box_t const *box)
+{
+       return box->secret;
+}
+
+static inline CC_HINT(nonnull)
+bool fr_value_box_contains_secret(fr_value_box_t const *box)
+{
+       fr_value_box_t const *vb = NULL;
+
+       if (box->secret) return true;
+       if (box->type == FR_TYPE_GROUP) {
+               while ((vb = fr_value_box_list_next(&box->vb_group, vb))) {
+                       if (fr_value_box_contains_secret(vb)) return true;
+               }
+       }
+       return false;
+}
+
+static inline CC_HINT(nonnull, always_inline)
+void fr_value_box_set_secret(fr_value_box_t *box, bool secret)
+{
+       box->secret = secret;
+}
 
 
 /** @name Assign and manipulate binary-unsafe C strings