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 dns_types;
19use type dns_types.packet_length_range;
20
21package body Dns_Network_Receive is
22   ----------------------------
23   -- Receive_DNS_Packet_TCP --
24   ----------------------------
25
26   procedure Receive_DNS_Packet_TCP
27     (Packet : out DNS_Types.DNS_Tcp_Packet;
28      Number_Bytes   : out DNS_Types.Packet_Length_Range;
29      Socket : in DNS_Network.DNS_Socket;
30      Failure : out Boolean)
31   IS
32   begin
33      DNS_Network.Receive_DNS_Packet_TCP(
34         Packet       => Packet,
35         Number_Bytes => Number_Bytes,
36         Socket       => Socket,
37         Failure      => Failure);
38      if not Failure then
39         Failure := (Number_Bytes < DNS_Types.Packet_Length_Range(1+DNS_Types.Header_Bits/8))
40            OR (Number_Bytes > DNS_Network.MAX_QUERY_SIZE);
41      end if;
42   end Receive_DNS_Packet_TCP;
43
44   ------------------------
45   -- Receive_DNS_Packet --
46   ------------------------
47
48   procedure Receive_DNS_Packet
49     (Packet : out DNS_Types.DNS_Packet;
50      Number_Bytes  : out DNS_Types.Packet_Length_Range;
51      Reply_Address : out DNS_Network.Network_Address_and_Port;
52      Failure : out Boolean)
53   IS
54   begin
55      DNS_Network.Receive_DNS_Packet(
56         Packet        => Packet,
57         Number_Bytes  => Number_Bytes,
58         Reply_Address => Reply_Address,
59         Failure       => Failure);
60      if not Failure then
61         Failure := (Number_Bytes < DNS_Types.Packet_Length_Range(1+DNS_Types.Header_Bits/8))
62            OR (Number_Bytes > DNS_Network.MAX_QUERY_SIZE);
63      end if;
64   end Receive_DNS_Packet;
65
66end Dns_Network_Receive;
67