]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update comments
authorAlan T. DeKok <aland@freeradius.org>
Sun, 13 Mar 2022 11:56:36 +0000 (07:56 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 13 Mar 2022 11:56:36 +0000 (07:56 -0400)
src/protocols/dhcpv4/decode.c

index 601d99fea64eee952b7320af3fd27ef7b00dbd1b..83fe193b11f1feba72b89e03076f5e95c2d423cb 100644 (file)
@@ -569,6 +569,19 @@ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
 
        /*
         *      Check for multiple options of the same type, and concatenate their values together.
+        *
+        *      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.
+        *
+        *      We therefore peek ahead, and concatenate the values into a temporary buffer.  The buffer is
+        *      allocated only if necessary, and is re-used for the entire packet.
+        *
+        *      If the options are *not* consecutive, then we don't concatenate them.  Too bad for you!
         */
        next = data + 2 + data[1];
        if ((data[1] > 0) && (next < end) && (next[0] == data[0])) {
@@ -605,21 +618,6 @@ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
                goto done;
        }
 
-       /*
-        *      @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.
-        */
        slen = decode_value(ctx, out, da, data + 2, data[1], decode_ctx);
        if (slen < 0) {
                fr_dict_unknown_free(&da);