]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
start of fixes to mod_write() for dynamic clients
authorAlan T. DeKok <aland@freeradius.org>
Wed, 22 Nov 2017 20:36:06 +0000 (15:36 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 22 Nov 2017 20:36:06 +0000 (15:36 -0500)
src/modules/proto_radius/proto_radius_udp.c

index 30bd988d27a04544ac581c0dc364906d0178636c..60c83118b3c241b3281536858db1b741af9f8b25 100644 (file)
@@ -694,6 +694,51 @@ static ssize_t mod_write(void *instance, void *packet_ctx,
        fr_time_t                       reply_time;
        struct timeval                  tv;
 
+       /*
+        *      Check for the first packet back from a dynamic client
+        *      definition.  If we find it, add the client (or not),
+        *      as required.
+        */
+       if (inst->dynamic_clients_is_set && address->client->dynamic && !address->client->active) {
+               RADCLIENT *client = address->client;
+               fr_dlist_t *entry;
+
+               if (buffer_len == 1) {
+                       while ((entry = FR_DLIST_FIRST(client->packets)) != NULL) {
+                               dynamic_packet_t *saved;
+
+                               saved = fr_ptr_to_type(dynamic_packet_t, entry, entry);
+                               (void) fr_radius_tracking_entry_delete(inst->ft, saved->track);
+                               fr_dlist_remove(&saved->entry);
+                               talloc_free(saved);
+                               inst->dynamic_clients.num_pending_packets--;
+                       }
+
+                       client_delete(inst->dynamic_clients.clients, client);
+                       client_free(client); /* @todo - fix this to NOT have a FIFO */
+
+                       return buffer_len;
+               }
+
+               inst->dynamic_clients.num_pending_clients--;
+
+               // @todo - update the client definition, etc...
+               // @todo - call fr_network_read()
+               // @todo - cache 'nr' in inst, too.. like proto_detail_file / proto_detail_work
+
+               /*
+                *      Move the packets over to the pending list.
+                */
+               while ((entry = FR_DLIST_FIRST(client->packets)) != NULL) {
+                       fr_dlist_remove(entry);
+                       fr_dlist_insert_tail(&inst->dynamic_clients.pending, entry);
+                       inst->dynamic_clients.num_pending_packets--;
+               }
+
+               rad_assert(0 == 1);
+               return buffer_len;
+       }
+
        /*
         *      The original packet has changed.  Suppress the write,
         *      as the client will never accept the response.