]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add packet && src/dst IP to xlat tests
authorAlan T. DeKok <aland@freeradius.org>
Wed, 1 Jun 2022 14:23:39 +0000 (10:23 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 3 Jun 2022 11:15:57 +0000 (07:15 -0400)
src/bin/unit_test_module.c

index b7963c52c7f840f801e62e1c25cacaa5c4d8c8f2..7ed41424d6a4859fe756bcc4e57bcf58710b11d3 100644 (file)
@@ -137,6 +137,7 @@ static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, RADCLIENT *client
         *      Create and initialize the new request.
         */
        request = request_local_alloc_external(ctx, NULL);
+
        /*
         *      FIXME - Should be less RADIUS centric, but everything
         *      else assumes RADIUS at the moment so we can fix this later.
@@ -340,6 +341,34 @@ static bool do_xlats(fr_event_list_t *el, char const *filename, FILE *fp)
         *      Create and initialize the new request.
         */
        request = request_alloc_internal(NULL, NULL);
+       if (!request->packet) request->packet = fr_radius_packet_alloc(request, false);
+       if (!request->reply) request->reply = fr_radius_packet_alloc(request, false);
+
+       request->packet->socket = (fr_socket_t){
+               .proto = IPPROTO_UDP,
+               .inet = {
+                       .src_ipaddr = {
+                               .af = AF_INET,
+                               .prefix = 32,
+                               .addr = {
+                                       .v4 = {
+                                               .s_addr = htonl(INADDR_LOOPBACK)
+                                       }
+                               }
+                       },
+                       .src_port = 18120,
+                       .dst_ipaddr = {
+                               .af = AF_INET,
+                               .prefix = 32,
+                               .addr = {
+                                       .v4 = {
+                                               .s_addr = htonl(INADDR_LOOPBACK)
+                                       }
+                               }
+                       },
+                       .dst_port = 1812
+               }
+       };
 
        request->log.dst = talloc_zero(request, log_dst_t);
        request->log.dst->func = vlog_request;