1---------------------------------------------------------------- 2-- IRONSIDES - DNS SERVER 3-- 4-- By: Martin C. Carlisle and Barry S. Fagin 5-- Department of Computer Science 6-- United States Air Force Academy 7-- 8-- This is free software; you can redistribute it and/or 9-- modify without restriction. We do ask that you please keep 10-- the original author information, and clearly indicate if the 11-- software has been modified. 12-- 13-- This software is distributed in the hope that it will be useful, 14-- but WITHOUT ANY WARRANTY; without even the implied warranty 15-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16---------------------------------------------------------------- 17 18with Protected_SPARK_IO_05; 19package body Udp_Dns_Package is 20 --type task_array is array(1..10) of udp_dns_task; 21 The_Task : Udp_Dns_Task; 22 --the_tasks : task_array; 23 Startup_Suspension : Ada.Synchronous_Task_Control.Suspension_Object; 24 25 procedure Initialization_Done is 26 begin 27 Ada.Synchronous_Task_Control.Set_True(Startup_Suspension); 28 end Initialization_Done; 29 30 ------------------ 31 -- Udp_Dns_Task -- 32 ------------------ 33 34 task body Udp_Dns_Task is 35 Input_Packet : DNS_Types.DNS_Packet; 36 Input_Bytes : DNS_Types.Packet_Length_Range; 37 Reply_Address : DNS_Network.Network_Address_And_Port; 38 Output_Packet : DNS_Types.DNS_Packet; 39 Output_Bytes : DNS_Types.Packet_Length_Range; 40 Failure : Boolean; 41 Max_Transmit : DNS_Types.Packet_Length_Range; 42 begin 43 DNS_Network.Initialize_UDP; 44 Ada.Synchronous_Task_Control.Suspend_Until_True(Startup_Suspension); 45 Output_Packet.Bytes := DNS_Types.Bytes_Array_Type'(others => 0); 46 Output_Packet.Header := DNS_Types.Empty_Header; 47 loop 48 --# assert true; 49 DNS_Network_Receive.Receive_DNS_Packet( 50 Packet => Input_Packet, 51 Number_Bytes => Input_Bytes, 52 Reply_Address => Reply_Address, 53 Failure => Failure); 54 if Failure then 55 Protected_SPARK_IO_05.SPARK_IO_PO.Put_Line( 56 Protected_SPARK_IO_05.SPARK_IO_PO.Standard_Output, 57 "Receive failed",0); 58 else 59 Process_Dns_Request.Create_Response( 60 Input_Packet => Input_Packet, 61 Input_Bytes => Input_Bytes, 62 Output_Packet => Output_Packet, 63 Output_Bytes => Output_Bytes, 64 Max_Transmit => Max_Transmit); 65 -- since there is a restriction on UDP messages, cap the UDP size here 66 -- Max_Transmit will be higher if EDNS0 67 Output_Bytes := DNS_Types.Packet_Length_Range'Min(Max_Transmit,Output_Bytes); 68 69-- accept Flow, 10, Output_Packet, "don't really care that the packet is network ordered"; 70 DNS_Network.Send_DNS_Packet( 71 Packet => Output_Packet, 72 Number_Bytes => Output_Bytes, 73 To_Address => Reply_Address, 74 Failure => Failure); 75--end accept; 76 if Failure then 77 Protected_SPARK_IO_05.SPARK_IO_PO.Put_Line( 78 Protected_SPARK_IO_05.SPARK_IO_PO.Standard_Output, 79 "send failed",0); 80 end if; 81 end if; 82 end loop; 83 end Udp_Dns_Task; 84 85end Udp_Dns_Package; 86