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 Ada.Text_IO, Ada.Integer_Text_IO; 19WITH Rr_Type.Dnskey_Record_Type; 20with Rr_Type.NSEC_Record_Type; 21 22package body Error_Msgs is 23--# hide error_msgs 24 package M_IO is new Ada.Text_IO.Modular_IO (Unsigned_Types.Unsigned32); 25 26procedure printUnsupportedRecordWarning(currentLine : in rr_type.LineFromFileType; 27 Length : IN Natural; LineCount : in Unsigned_Types.Unsigned32) is 28begin 29 Ada.Text_Io.Put("Warning: Unsupported record type at line # "); 30 m_io.put(item => lineCount, width => 1); 31 Ada.Text_IO.Put(" in zone file: "); 32 Ada.Text_Io.New_Line; 33 Ada.Text_Io.New_Line; 34 Ada.Text_Io.Put(" "); 35 Ada.Text_Io.Put(currentLine(1..length)); 36 Ada.Text_Io.New_Line; 37 Ada.Text_Io.New_Line; 38 Ada.Text_Io.Put("Record ignored "); 39 Ada.Text_IO.New_Line; 40 41end PrintUnsupportedRecordWarning; 42 43procedure printZeroTTLWarning(currentLine : in rr_type.LineFromFileType; 44 Length : IN Natural; LineCount : in Unsigned_Types.Unsigned32) is 45begin 46 Ada.Text_Io.Put("Warning: Default TTL of zero implied at line # "); 47 m_io.put(item => lineCount, width => 1); 48 Ada.Text_IO.Put(" in zone file: "); 49 Ada.Text_Io.New_Line; 50 Ada.Text_Io.New_Line; 51 Ada.Text_Io.Put(" "); 52 Ada.Text_Io.Put(currentLine(1..length)); 53 Ada.Text_Io.New_Line; 54 Ada.Text_Io.New_Line; 55 Ada.Text_Io.Put("Possible missing $TTL control statement "); 56 Ada.Text_IO.New_Line; 57end PrintZeroTTLWarning; 58 59procedure printBlankOriginWarning(currentLine : in rr_type.LineFromFileType; 60 Length : IN Natural; LineCount : in Unsigned_Types.Unsigned32) is 61begin 62 Ada.Text_Io.Put("Warning: Default blank ORIGIN appended"); 63 Ada.Text_IO.New_Line; 64 Ada.Text_IO.put("to domain name at line # "); 65 m_io.put(item => lineCount, width => 1); 66 Ada.Text_IO.Put(" in zone file: "); 67 Ada.Text_Io.New_Line; 68 Ada.Text_Io.New_Line; 69 Ada.Text_Io.Put(" "); 70 Ada.Text_Io.Put(currentLine(1..length)); 71 Ada.Text_Io.New_Line; 72 Ada.Text_Io.New_Line; 73 Ada.Text_Io.Put("Possible missing $ORIGIN control statement "); 74 Ada.Text_IO.New_Line; 75 Ada.Text_Io.Put("or missing period at end of domain name "); 76 Ada.Text_IO.New_Line; 77end PrintBlankOriginWarning; 78 79procedure printTooManyRecordTypesInNSECRecordWarning(LineCount : in Unsigned_Types.Unsigned32) is 80begin 81 Ada.Text_Io.Put("Warning: Maximum supported number of record types exceeded "); 82 Ada.Text_IO.New_Line; 83 Ada.Text_IO.put("in NSEC record at line # "); 84 m_io.put(item => lineCount, width => 1); 85 Ada.Text_IO.New_Line; 86 Ada.Text_Io.Put("Maximum number is "); 87 Ada.Text_IO.put(item => integer'image(rr_type.nsec_record_type.maxNumberOfRecordTypes)); 88 Ada.Text_Io.Put(". Further record types ignored."); 89 Ada.Text_IO.New_Line; 90 Ada.Text_IO.Put("To process the entire NSEC record, source code must be recompiled "); 91 Ada.Text_IO.New_Line; 92 Ada.Text_IO.Put("with larger value of rr_type.nsec_record_type.maxNumberOfRecordTypes and revalidated."); 93 Ada.Text_Io.New_Line; 94end printTooManyRecordTypesInNSECRecordWarning; 95 96procedure printParseErrorInfo(currentLine : in rr_type.LineFromFileType; 97 Length : in Natural; LineCount : in Unsigned_Types.Unsigned32) is 98begin 99 100 Ada.Text_Io.Put("Invalid or unsupported record on line # "); 101 m_io.put(item => lineCount, width => 1); 102 Ada.Text_IO.Put(" in zone file: "); 103 Ada.Text_Io.New_Line; 104 Ada.Text_Io.New_Line; 105 Ada.Text_Io.Put(" "); 106 Ada.Text_Io.Put(currentLine(1..length)); 107 Ada.Text_Io.New_Line; 108 Ada.Text_Io.New_Line; 109 Ada.text_io.Put("Remaining lines in zone file ignored."); 110 Ada.Text_Io.New_Line; 111END PrintParseErrorInfo; 112 113procedure printMissingRecordTypeErrorInfo(currentLine : in rr_type.LineFromFileType; 114 Length : in Natural; LineCount : in Unsigned_Types.Unsigned32) is 115begin 116 117 Ada.Text_Io.Put("Invalid NSEC record on line # "); 118 m_io.put(item => lineCount, width => 1); 119 Ada.Text_IO.Put(" of zone file: "); 120 Ada.Text_Io.New_Line; 121 Ada.Text_Io.New_Line; 122 Ada.Text_Io.Put(" "); 123 Ada.Text_Io.Put(currentLine(1..length)); 124 Ada.Text_Io.New_Line; 125 Ada.Text_Io.New_Line; 126 Ada.text_io.Put("NSEC record must contain at least one record type"); 127 Ada.Text_Io.New_Line; 128 Ada.text_io.Put("Remaining lines in zone file ignored."); 129 Ada.Text_Io.New_Line; 130END printMissingRecordTypeErrorInfo; 131 132procedure printSOARecordErrorInfo(currentLine : in rr_type.LineFromFileType; 133 Length : in Natural; LineCount : in Unsigned_Types.Unsigned32) is 134begin 135 136 Ada.Text_Io.Put("Disallowed SOA record on line # "); 137 m_io.put(item => lineCount, width => 1); 138 Ada.Text_IO.Put(" of zone file: "); 139 Ada.Text_Io.New_Line; 140 Ada.Text_Io.New_Line; 141 Ada.Text_Io.Put(" "); 142 Ada.Text_Io.Put(currentLine(1..length)); 143 Ada.Text_Io.New_Line; 144 Ada.Text_Io.New_Line; 145 Ada.text_io.Put("Only one SOA record is permitted in a zone file (RFC 1035)"); 146 Ada.Text_Io.New_Line; 147 Ada.text_io.Put("Remaining lines in zone file ignored."); 148 Ada.Text_Io.New_Line; 149END PrintSOARecordErrorInfo; 150 151procedure printAppendDomainLengthErrorInfo(currentLine : in rr_type.LineFromFileType; 152 Length : IN Natural; LineCount : IN unsigned_types.Unsigned32) IS 153begin 154 Ada.Text_IO.Put("ERROR IN ZONE FILE on line # " & Unsigned_Types.Unsigned32'Image(LineCount)); 155 Ada.Text_IO.Put(" of zone file:"); 156 Ada.Text_Io.New_Line; 157 Ada.Text_Io.New_Line; 158 Ada.Text_Io.Put(" "); 159 Ada.Text_Io.Put(currentLine(1..length)); 160 Ada.Text_IO.New_Line; 161 Ada.Text_IO.new_line; 162 Ada.Text_IO.Put("domain name after appending with $ORIGIN is too long "); 163 Ada.Text_IO.new_line; 164 Ada.Text_IO.Put("(maximum length is "); 165 Ada.Integer_Text_IO.Put(Item => Rr_Type.MaxDomainNameLength-1, Width => 1); 166 Ada.Text_IO.Put(" chars)"); 167 Ada.Text_Io.New_Line; 168 Ada.Text_Io.New_Line; 169 Ada.Text_Io.Put("Domain name must either be changed, or source code recompiled "); 170 Ada.Text_IO.New_Line; 171 Ada.Text_IO.Put("(with larger value of rr_type.MaxDomainNameLength) and revalidated."); 172 Ada.Text_Io.New_Line; 173 Ada.text_io.Put("Remaining lines in zone file ignored."); 174 Ada.Text_Io.New_Line; 175end printAppendDomainLengthErrorInfo; 176 177procedure printLineLengthErrorInfo(currentLine : in rr_type.LineFromFileType; 178 Length : IN Natural; LineCount : IN unsigned_types.Unsigned32) IS 179BEGIN 180 Ada.Text_IO.Put("ERROR: Line #"); 181 m_IO.Put(Item => LineCount, Width => 1); 182 Ada.Text_IO.put(" in zone file is too long ("); 183 Ada.Integer_Text_IO.Put(item => length, width => 1); 184 Ada.Text_IO.Put(" chars, maximum length is "); 185 Ada.Integer_Text_IO.Put(Item => Rr_Type.MaxLineLength-1, Width => 1); 186 Ada.Text_IO.Put(")"); 187 Ada.Text_Io.New_Line; 188 Ada.Text_Io.New_Line; 189 Ada.Text_Io.Put(" "); 190 Ada.Text_Io.Put(currentLine(1..length)); 191 Ada.Text_Io.New_Line; 192 Ada.Text_Io.New_Line; 193 Ada.Text_Io.Put("Line must either be broken up, or source code recompiled "); 194 Ada.Text_IO.Put("(with larger value of rr_type.MaxLineLength) and revalidated."); 195 Ada.Text_Io.New_Line; 196 Ada.text_io.Put("Remaining lines in zone file ignored."); 197 Ada.Text_Io.New_Line; 198END PrintLineLengthErrorInfo; 199 200PROCEDURE printDomainLengthErrorInfo(CurrentLine : IN Rr_Type.LineFromFileType; 201 BegIdx: IN Natural; EndIdx : IN Natural) IS 202BEGIN 203 Ada.Text_IO.put("ERROR IN ZONE FILE: domain name is too long ("); 204 Ada.Integer_Text_IO.Put(item => endIdx-begIdx+1, width => 1); 205 Ada.Text_IO.Put(" chars, maximum length is "); 206 Ada.Integer_Text_IO.Put(Item => Rr_Type.MaxDomainNameLength-1, Width => 1); 207 Ada.Text_IO.Put(")"); 208 Ada.Text_Io.New_Line; 209 Ada.Text_Io.New_Line; 210 Ada.Text_Io.Put(" "); 211 Ada.Text_Io.Put(currentLine(begIdx..endIdx)); 212 Ada.Text_Io.New_Line; 213 Ada.Text_Io.New_Line; 214 Ada.Text_Io.Put("Domain name must either be changed, or source code recompiled "); 215 Ada.Text_IO.Put("(with larger value of rr_type.MaxDomainNameLength) and revalidated."); 216 Ada.Text_Io.New_Line; 217 Ada.text_io.Put("Remaining lines in zone file ignored."); 218 Ada.Text_Io.New_Line; 219END PrintDomainLengthErrorInfo; 220 221PROCEDURE printRRStringLengthErrorInfo(CurrentLine : IN Rr_Type.LineFromFileType; 222 BegIdx: IN Natural; EndIdx : IN Natural) IS 223BEGIN 224 Ada.Text_IO.put("ERROR IN ZONE FILE: resource record string is too long ("); 225 Ada.Integer_Text_IO.Put(item => endIdx-begIdx+1, width => 1); 226 Ada.Text_IO.Put(" chars, maximum length is "); 227 Ada.Integer_Text_IO.Put(Item => Rr_Type.MaxDomainNameLength-1, Width => 1); 228 Ada.Text_IO.Put(")"); 229 Ada.Text_Io.New_Line; 230 Ada.Text_Io.New_Line; 231 Ada.Text_Io.Put(" "); 232 Ada.Text_Io.Put(currentLine(begIdx..endIdx)); 233 Ada.Text_Io.New_Line; 234 Ada.Text_Io.New_Line; 235 Ada.Text_Io.Put("Either NSEC record must be changed, or source code recompiled "); 236 Ada.Text_IO.Put("(with redefinition of rr_type.nsec_record_type.recordListType) and revalidated."); 237 Ada.Text_Io.New_Line; 238 Ada.text_io.Put("Remaining lines in zone file ignored."); 239 Ada.Text_Io.New_Line; 240END PrintRRStringLengthErrorInfo; 241 242procedure printKeyLengthErrorInfo(currentLine : in rr_type.LineFromFileType; 243 Length : IN Natural; LineCount : IN unsigned_types.Unsigned32) IS 244BEGIN 245 Ada.Text_IO.Put("ERROR: Key fragment at line #"); 246 m_IO.Put(Item => LineCount, Width => 1); 247 Ada.Text_IO.put(" in zone file makes key too long (maximum length is "); 248 Ada.Integer_Text_IO.Put(Item => Rr_Type.dnskey_record_type.maxDNSKeyLength, Width => 1); 249 Ada.Text_IO.Put(")"); 250 Ada.Text_Io.New_Line; 251 Ada.Text_Io.New_Line; 252 Ada.Text_Io.Put(" "); 253 Ada.Text_Io.Put(currentLine(1..length)); 254 Ada.Text_Io.New_Line; 255 Ada.Text_Io.New_Line; 256 Ada.Text_Io.Put("Server source code must be recompiled "); 257 Ada.Text_IO.Put("(with larger value of Rr_Type.dnskey_record_type.maxDNSKeyLength or "); 258 Ada.Text_IO.New_Line; 259 ada.Text_IO.put("Rr_Type.dnskey_record_type.maxRRSIGLength as appropriate) and revalidated."); 260 Ada.Text_Io.New_Line; 261 Ada.text_io.Put("Remaining lines in zone file ignored."); 262 Ada.Text_Io.New_Line; 263END PrintKeyLengthErrorInfo; 264 265 266PROCEDURE printDNSTableFullInfo(CurrentLine : IN Rr_Type.LineFromFileType; 267 LineCount : IN Unsigned_Types.Unsigned32) is 268begin 269 Ada.Text_IO.Put("ERROR: Zone file contains too many records,"); 270 Ada.Text_IO.New_Line; 271 Ada.Text_IO.Put("or more than one SOA record for a given domain."); 272 ada.Text_IO.New_Line; 273 ada.Text_IO.put("There is no room for the record at line # "); 274 m_IO.Put(Item => LineCount, Width => 1); 275 Ada.Text_Io.New_Line; 276 Ada.Text_Io.New_Line; 277 Ada.Text_Io.Put(" "); 278 Ada.Text_Io.Put(currentLine); 279 Ada.Text_Io.New_Line; 280 Ada.Text_Io.New_Line; 281 Ada.Text_IO.Put("If the problem is due to multiple SOA records for a given domain,"); 282 Ada.Text_IO.new_Line; 283 Ada.Text_IO.Put("you will need to remove the extra SOA records from the zone file."); 284 Ada.Text_IO.new_Line; 285 Ada.Text_Io.Put("Otherwise, shut down and rebuild the server, with source code recompiled "); 286 Ada.Text_IO.new_Line; 287 Ada.Text_IO.Put("(use larger value(s) of rr_type.MaxNumRecords and/or rr_type.NumBuckets) and revalidated."); 288 Ada.Text_Io.New_Line; 289 Ada.text_io.Put("Remaining lines in zone file ignored."); 290 Ada.Text_Io.New_Line; 291end PrintDNSTableFullInfo; 292 293--should only be called in conjunction with file reading "Success" variable set to false 294PROCEDURE PrintMissingSOARecordInfo is 295begin 296 Ada.Text_IO.Put("ERROR: First record in zone file must be an SOA record."); 297 Ada.Text_IO.New_Line; 298 Ada.Text_IO.Put("Remaining lines in zone file ignored."); 299 ada.Text_IO.New_Line; 300end PrintMissingSOARecordInfo; 301 302end error_msgs; 303