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, Rr_Type, Rr_Type.Aaaa_Record_Type, Rr_Type.Dnskey_Record_Type,
19   rr_type.nsec_record_type, rr_type.rrsig_record_type, unsigned_types;
20--with Ada.Text_IO, Ada.Integer_Text_IO;
21
22--# inherit Ada.Characters.Handling, Ada.Characters.Latin_1, dns_types, error_msgs,
23--#   parser_utilities, rr_type, rr_type.aaaa_record_type, rr_type.dnskey_record_type,
24--#   rr_type.nsec_record_type,
25--#   rr_type.mx_record_type, rr_type.rrsig_record_type, rr_type.soa_record_type,
26--#   rr_type.srv_record_type, Spark.Ada.Strings.Maps, unsigned_types;
27
28PACKAGE Zone_File_Parser IS
29   TYPE Unsigned8 IS mod 2**8;
30
31   procedure ParseDNSKeyHeader(DNSKEY_Rec: out rr_type.dnskey_record_type.DNSKeyRecordType;
32      zoneFileLine : in rr_type.LineFromFileType;
33      ZLength : in Rr_Type.LineLengthIndex;
34      Success : in out Boolean);
35   --# derives DNSKEY_Rec, success from zoneFileLine, zLength, success;
36
37   procedure ParseRRSigHeader(RRSIG_Rec: out rr_type.rrsig_record_type.RRSIGRecordType;
38      zoneFileLine : in rr_type.LineFromFileType;
39      ZLength : in Rr_Type.LineLengthIndex;
40      Success : in out Boolean);
41   --# derives RRSIG_Rec, success from zoneFileLine, zLength, success;
42
43   procedure ParseRRSig2ndLine(RRSIG_Rec:  in out rr_type.rrsig_record_type.RRSIGRecordType;
44      zoneFileLine : in rr_type.LineFromFileType;
45      ZLength : in Rr_Type.LineLengthIndex;
46      Success : in out Boolean);
47   --# derives RRSIG_Rec from RRSIG_Rec, zoneFileLine, zLength, success  & success from zoneFileLine, zLength, success;
48
49   procedure ParseControlLine(newOrigin : in out rr_type.DomainNameStringType;
50                              NewTTL : in out Unsigned_Types.Unsigned32;
51                              zoneFileLine : in rr_type.LineFromFileType;
52                              ZLength : in Rr_Type.LineLengthIndex; Success : in out Boolean);
53   --# derives newOrigin from newOrigin, zoneFileLine, zLength
54   --# & newTTL from newTTL, zoneFileLine, zLength, success
55   --# & success from success, zoneFileLine, zLength;
56
57   procedure parseDomainName(newDomainName : out rr_type.DomainNameStringType;
58                             zoneFileLine : in rr_type.LineFromFileType;
59                             ZLength : IN rr_type.LineLengthIndex; Success : IN OUT Boolean);
60    --# derives newDomainName from zoneFileLine, zLength
61    --# & success from success, zoneFileLine, zLength;
62
63   procedure ParseDomainNameAndRRString(
64      newDomainName : out rr_type.DomainNameStringType;
65      RRString : out Rr_Type.LineFromFileType;
66      zoneFileLine : in rr_type.LineFromFileType;
67      ZLength : IN Rr_Type.LineLengthIndex;
68      Success : IN OUT Boolean);
69    --# derives newDomainName, RRString from zoneFileLine, zLength
70    --# & success from success, zoneFileLine, zLength;
71
72   PROCEDURE FillBlockInfo(RRString: IN Rr_Type.LineFromFileType;
73      NumberOfRecordTypes: OUT Rr_Type.Nsec_Record_Type.RecordTypeIndexValue;
74      RecordTypes: out Rr_Type.Nsec_Record_Type.recordTypeArrayType;
75      numberOfBlocks: out Rr_Type.Nsec_Record_Type.BlockNumberValue;
76      BlockNumbers: OUT Rr_Type.Nsec_Record_Type.BlockNumberArrayType;
77      BlockLengths: OUT Rr_Type.Nsec_Record_Type.BlockLengthArrayType;
78      BitMaps: OUT Rr_Type.Nsec_Record_Type.BitMapsArrayArrayType;
79      LineCount : in Unsigned_Types.Unsigned32;
80      Success: IN OUT Boolean);
81   --# derives numberOfRecordTypes from RRString
82   --# & recordTypes from RRString & numberOfBlocks from RRString & blockNumbers from RRString
83   --# & blockLengths from RRString & bitMaps from RRString & success from RRString, Success & null from LineCount;
84   --# post Success = true -> numberOfBlocks > 0;
85
86   procedure parseIpv4(newIpv4 : out unsigned_types.Unsigned32;
87                       zoneFileLine : in rr_type.LineFromFileType;
88                       zLength : in rr_type.LineLengthIndex; success : in out boolean);
89   --# derives newIpv4 from zoneFileLine, zLength
90   --# & success from success, zoneFileLine, zLength;
91
92   procedure parseIpv6(newIpv6 : out rr_type.aaaa_record_type.IPV6AddrType;
93                       zoneFileLine : in rr_type.LineFromFileType;
94                        zLength : in rr_type.LineLengthIndex; success : in out boolean);
95   --# derives newIpv6 from zoneFileLine, zLength
96   --# & success from success, zoneFileLine, zLength;
97
98   procedure parsePrefAndDomainName(newPref : out unsigned_types.Unsigned16;
99                                    newDomainName : out rr_type.DomainNameStringType;
100                                    zoneFileLine : in rr_type.LineFromFileType;
101                                    zLength : in rr_type.LineLengthIndex; success : in out boolean);
102   --# derives newPref, newDomainName from zoneFileLine, zlength
103   --# & success from success, zoneFileLine, zLength;
104
105   procedure parsePrefWeightPortAndDomainName(newPref : out unsigned_types.Unsigned16;
106                                    newWeight : out unsigned_types.Unsigned16;
107                                    newPort : out unsigned_types.Unsigned16;
108                                    newDomainName : out rr_type.DomainNameStringType;
109                                    zoneFileLine : in rr_type.LineFromFileType;
110                                    zLength : in rr_type.LineLengthIndex; success : in out boolean);
111   --# derives newPref, newWeight, newPort, newDomainName from zoneFileLine, zlength
112   --# & success from success, zoneFileLine, zLength;
113
114   procedure ParseNameServerAndEmail(newNameServer : out Rr_Type.DomainNameStringType;
115                                      newEmail : out rr_type.DomainNameStringType;
116                                      zoneFileLine : in rr_type.LineFromFileType;
117                                      ZLength : in Rr_Type.LineLengthIndex; Success : in out Boolean);
118   --# derives newNameServer, newEMail from zoneFileLine, zlength
119   --# & success from success, zoneFileLine, zLength;
120
121   procedure parseSerialNumber(newSerialNumber : out unsigned_types.Unsigned32;
122                                 zoneFileLine : in rr_type.LineFromFileType;
123                                 ZLength : in Rr_Type.LineLengthIndex; Success : in out Boolean);
124   --# derives newSerialNumber from zoneFileLine, zLength
125   --# & success from success, zoneFileLine, zLength;
126
127   procedure ParseTimeSpec(newTimeSpec : out Unsigned_Types.Unsigned32;
128      zoneFileLine : in Rr_Type.LineFromFileType;
129      ZLength : in Rr_Type.LineLengthIndex; Success : in out Boolean);
130   --# derives newTimeSpec from zoneFileLine, zLength, success
131   --# & success from success, zoneFileLine, zLength;
132
133   procedure parseOwnerTTLClassAndRecordType(newOwner : in out rr_type.DomainNameStringType;
134                              newTTL : in out unsigned_types.Unsigned32;
135                              newClass : in out rr_type.classType;
136                              newType : in out dns_types.Query_Type;
137                      	      zoneFileLine : in rr_type.LineFromFileType;
138                              zLength : in rr_type.LineLengthIndex; success : in out boolean);
139   --# derives newOwner from newOwner, zoneFileLine, zLength
140   --#  & newTTL from newTTL, zoneFileLine, zLength, success
141   --#  & newClass from newClass, zoneFileLine, zLength, success
142   --#  & newType from newType, zoneFileLine, zLength, success
143   --#  & success from success, zoneFileLine, zLength;
144
145end zone_file_parser;
146