From: Alan T. DeKok Date: Sun, 23 Jan 2022 14:02:16 +0000 (-0500) Subject: notes for DHCPv4 encodings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fb4a75b7782f7dc37120759cb89d3dd76f1813f;p=thirdparty%2Ffreeradius-server.git notes for DHCPv4 encodings --- diff --git a/src/protocols/dhcpv4/decode.c b/src/protocols/dhcpv4/decode.c index e7973dca78..9b12ba6b33 100644 --- a/src/protocols/dhcpv4/decode.c +++ b/src/protocols/dhcpv4/decode.c @@ -548,6 +548,21 @@ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, if (da->type == FR_TYPE_VSA) return decode_vsa(ctx, out, da, data + 2, data[1]); + /* + * @todo - RFC 2131 Section 4.1 says: + * + * The client concatenates the values of multiple + * instances of the same option into a single parameter + * list for configuration. + * + * which presumably also means the same for the server on reception. + * + * TBH, it would be simplest to have a thread-local array + * for temporary work. If there are multiple options of + * the same number, then the values for those options get + * mashed into the temporary buffer. Then, that buffer + * gets used for value decoding. + */ ret = decode_value(ctx, out, da, data + 2, data[1]); if (ret < 0) { fr_dict_unknown_free(&da); diff --git a/src/protocols/dhcpv4/encode.c b/src/protocols/dhcpv4/encode.c index bc1076a9dd..1841f5c407 100644 --- a/src/protocols/dhcpv4/encode.c +++ b/src/protocols/dhcpv4/encode.c @@ -242,6 +242,24 @@ static ssize_t encode_rfc_hdr(fr_dbuff_t *dbuff, break; } + /* + * @todo - RFC 2131 Section 4.1 says: + * + * The client concatenates the values of multiple + * instances of the same option into a single parameter + * list for configuration. + * + * so if we have multiple options of the same + * number, then pack them as much as possible. + * + * TBH, it would be simplest to have a + * thread-local array for temporary work. If + * there are multiple options of the same number, + * then the values for those options get mashed + * into the temporary buffer. Then, that buffer + * gets copied to the actual packet, with headers + * being added as necessary. + */ len = encode_value(&work_dbuff, da_stack, depth, cursor, encode_ctx); if (len < -1) return len; if (len == -1) {