ATTRIBUTE User-Class 77 octets
# Rapid Commit
-ATTRIBUTE Rapid-Commit 80 bool
+ATTRIBUTE Rapid-Commit 80 bool encode=exists
# Fully Qualified Domain Name
ATTRIBUTE Client-FQDN 81 string
# Relay Agent Information
for (c = to_eval; c; c = fr_dlist_next(list, c)) {
PAIR_VERIFY(c);
if (c->da->dict != dict || c->da->flags.internal) continue;
- if (c->da->type == FR_TYPE_BOOL && !c->vp_bool) continue;
+
+ if (c->da->type == FR_TYPE_BOOL && da_is_bool_exists(c->da) && !c->vp_bool) continue;
break;
}
{ L("dns_label"), FLAG_ENCODE_DNS_LABEL },
{ L("encode=dns_label"), FLAG_ENCODE_DNS_LABEL },
{ L("prefix=split"), FLAG_ENCODE_SPLIT_PREFIX },
+ { L("encode=exists"), FLAG_ENCODE_BOOL_EXISTS },
};
static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *parent,
return false;
}
+ if ((type != FR_TYPE_BOOL) && (flags->subtype == FLAG_ENCODE_BOOL_EXISTS)) {
+ fr_strerror_const("The 'encode=exists' flag can only be used with attributes of type 'bool'");
+ return false;
+ }
+
return true;
}
FLAG_ENCODE_NONE = 0, //!< no particular encoding for DHCPv6 strings
FLAG_ENCODE_DNS_LABEL, //!< encode as DNS label
FLAG_ENCODE_SPLIT_PREFIX, //!< encode IPv4 prefixes as Policy-Filter, split into IP/mask
+ FLAG_ENCODE_BOOL_EXISTS, //!< bool as existence checks
};
#define da_is_dns_label(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_DNS_LABEL))
#define da_is_split_prefix(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_SPLIT_PREFIX))
+#define da_is_bool_exists(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_BOOL_EXISTS))
typedef struct {
uint8_t opcode;
* Rapid-Commit does this. Options 19/20 require encoding as one byte of 0/1.
*/
case FR_TYPE_BOOL:
+ if (da_is_bool_exists(vp->da)) {
+ break;
+ }
+ fr_dbuff_in(&work_dbuff, (uint8_t) (vp->vp_bool == true));
break;
case FR_TYPE_IPV4_PREFIX:
proto-dictionary dhcpv4
fuzzer-out dhcpv4
-#
-# bools which are false don't get encoded
-#
-encode-pair IP-Forward-Enable = false
-match
-
-encode-pair IP-Forward-Enable = true
-match 13 00
-
-decode-pair -
-match IP-Forward-Enable = yes
-
#
# DHCP TLV types
#
match Relay-Agent-Information.Circuit-Id = 0x3132333435363738396131323334353637383962313233343536373839633132333435363738396431323334353637383965313233343536373839663132333435363738396731323334353637383968313233343536373839613132333435363738396131323334353637383961313233343536373839613132333435363738396131323334353637383961313233343536373839613132333435363738396131323334353637383961313233343536373839613132333435363738396131323334353637383961313233343536373839613132333435363738396131323334353637383961313233343536373839613132333435363738396178797a
count
-match 51
+match 45
--- /dev/null
+#
+# Test vectors for bools, which are shit and random.
+#
+proto dhcpv4
+proto-dictionary dhcpv4
+fuzzer-out dhcpv4
+
+encode-pair Rapid-Commit = yes
+match 50 00
+
+decode-pair -
+match Rapid-Commit = yes
+
+#
+# false is "don't encode"
+#
+encode-pair Rapid-Commit = false
+match
+
+#
+# Normal bools get encoded as 0/1
+#
+encode-pair IP-Forward-Enable = false
+match 13 01 00
+
+encode-pair IP-Forward-Enable = true
+match 13 01 01
+
+decode-pair -
+match IP-Forward-Enable = yes
+
+#
+# All non-zero values are "true"
+#
+decode-pair 13 01 88
+match IP-Forward-Enable = yes
+
+#
+# Rapid-Commit is stupid
+#
+encode-pair Rapid-Commit = yes
+match 50 00
+
+decode-pair -
+match Rapid-Commit = yes
+
+#
+# false is "don't encode"
+#
+encode-pair Rapid-Commit = false
+match
+
+#
+# We allow Rapid-Commit to be normal, if it so chooses
+#
+decode-pair 50 01 00
+match Rapid-Commit = no
+
+decode-pair 50 01 01
+match Rapid-Commit = yes
+
+
+count
+match 27