}
/*
- * Determine the nested type and call the appropriate encoder
+ * Encode fixed-size octets fields so that they
+ * are exactly the fixed size, UNLESS the entire
+ * output is truncated.
*/
- len = fr_value_box_to_network(NULL, p, outlen, &vp->data);
- if (len <= 0) return -1;
+ if ((vp->da->type == FR_TYPE_OCTETS) && vp->da->flags.length) {
+ size_t mylen = vp->da->flags.length;
+
+ if (mylen > outlen) mylen = outlen;
+
+ if (vp->vp_length < mylen) {
+ memcpy(p, vp->vp_ptr, vp->vp_length);
+ memset(p + vp->vp_length, 0, mylen - vp->vp_length);
+ } else {
+ memcpy(p, vp->vp_ptr, mylen);
+ }
+ len = mylen;
+
+ } else {
+ /*
+ * Determine the nested type and call the appropriate encoder
+ */
+ len = fr_value_box_to_network(NULL, p, outlen, &vp->data);
+ if (len <= 0) return -1;
+ }
if (child->flags.extra) {
key_da = child;
encode-pair BCMCS-Server-Domain-Name-List = "www.example.com", BCMCS-Server-Domain-Name-List = "ftp.example.com", BCMCS-Server-Domain-Name-List = "ns.example.com"
match 00 21 00 32 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 03 66 74 70 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 02 6e 73 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00
+encode-pair Client-ID-DUID = Client-ID-DUID-UUID, Client-ID-DUID-UUID-Value = 0x000102030405060708090a0b0c0d0e0f
+match 00 01 00 12 00 04 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
+
+#
+# UUID-Value field is 16 octets. So we truncate if if it's too long, and pad it with zeros if it's too short.
+#
+encode-pair Client-ID-DUID = Client-ID-DUID-UUID, Client-ID-DUID-UUID-Value = 0x000102030405060708090a0b0c0d0e0f1112
+match 00 01 00 12 00 04 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
+
+encode-pair Client-ID-DUID = Client-ID-DUID-UUID, Client-ID-DUID-UUID-Value = 0x000102030405060708090a0b0c0d
+match 00 01 00 12 00 04 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 00 00
+
count
-match 80
+match 86