text
stringlengths
0
234
Function Definition: function To_RData is new Ada.Unchecked_Conversion
Function Body: (Source => Stream_Element_Array, Target => RData);
begin
Parsed_Response.RData := To_Unbounded_String (To_RData (Raw_Data
(Offset .. Stream_Element_Offset (RData_Length))));
Offset := Offset + Stream_Element_Offset (RData_Length);
Function Definition: procedure Start_Server is
Function Body: -- Input and Output Sockets
Capture_Config : DNSCatcher.Config.Configuration;
DNS_Transactions : DNSCatcher.DNS.Transaction_Manager
.DNS_Transaction_Manager_Task;
Receiver_Interface : DNSCatcher.Network.UDP.Receiver
.UDP_Receiver_Interface;
Sender_Interface : DNSCatcher.Network.UDP.Sender.UDP_Sender_Interface;
Logger_Task : DNSCatcher.Utils.Logger.Logger;
Transaction_Manager_Ptr : DNS_Transaction_Manager_Task_Ptr;
Socket : Socket_Type;
Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr;
procedure Free_Transaction_Manager is new Ada.Unchecked_Deallocation
(Object => DNS_Transaction_Manager_Task,
Name => DNS_Transaction_Manager_Task_Ptr);
begin
-- Load the config file from disk
DNSCatcher.Config.Initialize (Capture_Config);
DNSCatcher.Config.Read_Cfg_File
(Capture_Config, "conf/dnscatcherd.conf");
-- Configure the logger
Capture_Config.Logger_Config.Log_Level := DEBUG;
Capture_Config.Logger_Config.Use_Color := True;
Logger_Task.Initialize (Capture_Config.Logger_Config);
Transaction_Manager_Ptr := new DNS_Transaction_Manager_Task;
-- Connect the packet queue and start it all up
Logger_Task.Start;
Logger_Packet := new DNSCatcher.Utils.Logger.Logger_Message_Packet;
Logger_Packet.Log_Message (NOTICE, "DNSCatcher starting up ...");
DNSCatcher.Utils.Logger.Logger_Queue.Add_Packet (Logger_Packet);
-- Socket has to be shared between receiver and sender. This likely needs
-- to move to to a higher level class
begin
Create_Socket
(Socket => Socket,
Mode => Socket_Datagram);
Set_Socket_Option
(Socket => Socket,
Level => IP_Protocol_For_IP_Level,
Option => (GNAT.Sockets.Receive_Timeout, Timeout => 1.0));
Bind_Socket
(Socket => Socket,
Address =>
(Family => Family_Inet, Addr => Any_Inet_Addr,
Port => Capture_Config.Local_Listen_Port));
exception
when Exp_Error : GNAT.Sockets.Socket_Error =>
begin
Logger_Packet :=
new DNSCatcher.Utils.Logger.Logger_Message_Packet;
Logger_Packet.Log_Message
(ERROR, "Socket error: " & Exception_Information (Exp_Error));
Logger_Packet.Log_Message (ERROR, "Refusing to start!");
Logger_Queue.Add_Packet (Logger_Packet);
goto Shutdown_Procedure;
Function Definition: function Uint8_To_Character is new Ada.Unchecked_Conversion
Function Body: (Source => Unsigned_8, Target => Character);
function Uint16_To_String is new Ada.Unchecked_Conversion
(Source => Unsigned_16, Target => QAttributes);
-- Actually does the dirty work of creating a question
function Create_QName_Record
(Domain_Section : String)
return String
is
Label : String (1 .. Domain_Section'Length + 1);
begin
if Domain_Section /= "."
then
Label (1) :=
Uint8_To_Character (Unsigned_8 (Domain_Section'Length));
Label
(2 .. Domain_Section'Length + 1) := Domain_Section;
else
-- If this is a "." by itself, it's the terminator, and we need to
-- do special handling
declare
Empty_Label : String (1 .. 1);
begin
Empty_Label (1) := Uint8_To_Character (Unsigned_8 (0));
return Empty_Label;
Function Definition: function String_To_Packet is new Ada.Unchecked_Conversion
Function Body: (Source => String, Target => QData_SEA);
begin