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 Zone_File_Io, Dns_Table_Pkg, Rr_Type.A_Record_Type, Rr_Type.AAAA_Record_Type, Rr_Type.Cname_Record_Type, 19 Rr_Type.Dnskey_Record_Type, Rr_Type.MX_Record_Type, Rr_Type.NS_Record_Type, Rr_Type.NSEC_Record_Type, 20 Rr_Type.PTR_Record_Type, Rr_Type.RRSIG_Record_Type, Rr_Type.SOA_Record_Type, Rr_Type.srv_record_type, Unsigned_Types; 21WITH Ada.Text_IO, Spark.Ada.Text_IO; 22USE TYPE Spark.Ada.Text_IO.Exception_T; 23 24procedure Driver is 25 pragma Priority(0); 26 returnedARecords : Rr_Type.A_Record_Type.ARecordBucketType; 27 returnedAAAARecords : Rr_Type.AAAA_Record_Type.AAAARecordBucketType; 28 ReturnedCNAMERecords : Rr_Type.CNAME_Record_Type.CNAMERecordBucketType; 29 returnedDNSKEYRecords : Rr_Type.DNSKEY_Record_Type.DNSKEYRecordBucketType; 30 returnedMXRecords : Rr_Type.MX_Record_Type.MXRecordBucketType; 31 returnedSRVRecords : Rr_Type.srv_record_type.SRVRecordBucketType; 32 ReturnedNSRecords : Rr_Type.NS_Record_Type.NSRecordBucketType; 33 returnedNSECRecords : Rr_Type.NSEC_Record_Type.NSECRecordBucketType; 34 ReturnedPTRRecords : Rr_Type.PTR_Record_Type.PTRRecordBucketType; 35 returnedRRSIGRecords : Rr_Type.RRSIG_Record_Type.RRSIGRecordBucketType; 36 returnedSOARecords : Rr_Type.SOA_Record_Type.SOARecordBucketType; 37 NumFound : Natural; 38 --ZoneFileName : constant String := "tmp.zonefile"; 39 ZoneFileName : constant String := "dfcs.usafa.edu.zonefile"; 40 --ZoneFileName : constant String := "db.dfcs.usafa.edu.signed"; 41 --ZoneFileName : constant String := "DFAN/usafa.hpc.mil.zonefile"; 42 --ZoneFileName : constant String := "DFAN/wedge.hpc.mil.zonefile"; 43 --ZoneFileName : constant String := "DFAN/wedge.iita.zonefile"; 44 --ZoneFileName : constant String := "DFAN/usafa.aero.zonefile"; 45 --ZoneFileName : constant String := "DFAN/research.usafa.edu.zonefile"; 46 --ZoneFileName : constant String := "DFAN/msrc.usafa.hpc.mil.zonefile"; 47 --ZoneFileName : constant String := "DFAN/edu.usafa.hpc.mil.zonefile"; 48 --ZoneFileName : constant String := "DFAN/10.in-addr.arpa.zonefile"; 49 --ZoneFileName : constant String := "DFAN/130.32.140.in-addr.arpa.zonefile"; 50 --ZoneFileName : constant String := "DFAN/castle.zonefile"; 51 --ZoneFileName : constant String := "DFAN/alabnet.zonefile"; 52 --zoneFileName : constant String := "DFAN/ipv6.usafa.edu.zonefile"; 53 --zoneFileName : constant String := "DFAN/alabnet.zonefile"; 54 55 function openzoneFile(fileName : in String) return boolean 56 is 57 ZoneFile : Spark.Ada.Text_IO.File_Type; 58 success : boolean := true; 59 begin 60 Spark.Ada.Text_IO.Open(File => ZoneFile, Mode => Spark.Ada.Text_IO.In_File, 61 Name => FileName, Form => ""); 62 if (Spark.Ada.Text_IO.Get_Last_Exception_File(zoneFile) /= Spark.Ada.Text_IO.No_Exception) then 63 Ada.Text_IO.Put("Unable to open zone file " & ZoneFileName); 64 Ada.Text_IO.New_Line; 65 Ada.Text_IO.Put("Check spelling, path, permissions etc and retry."); 66 Ada.Text_IO.New_Line; 67 return false; 68 else 69 Zone_File_Io.ProcesszoneFile(ZoneFile, Success); 70 return success; 71 end if; 72 end OpenzoneFile; 73 74begin 75 if OpenZoneFile(ZoneFileName) then 76 Dns_Table_Pkg.DNS_Table.QueryARecords( 77 Rr_Type.ConvertStringToWire("boleng.dfcs.usafa.edu."), ReturnedARecords, NumFound); 78 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " A records returned"); 79 for i in integer range 1..numFound loop 80 Ada.Text_IO.Put("A record found, ipv4 = "); 81 Ada.Text_IO.put(unsigned_types.Unsigned32'image(returnedARecords(i).ipv4)); 82 Ada.Text_IO.New_Line; 83 END LOOP; 84 85 Dns_Table_Pkg.DNS_Table.QueryAAAARecords( 86 rr_type.convertStringToWire("iPV6.dfcs.usafa.EDu."),ReturnedAAAARecords, NumFound); 87 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " AAAA records returned"); 88 for i in integer range 1..numFound loop 89 Ada.Text_IO.Put("AAAA record found, ipv6(1) = "); 90 Ada.Text_IO.put(unsigned_types.Unsigned16'image(returnedAAAARecords(i).ipv6(1))); 91 Ada.Text_IO.New_Line; 92 END LOOP; 93 94 Dns_Table_Pkg.DNS_Table.QueryCNAMERecords( 95 rr_type.convertStringToWire("DOc.dfcs.usafa.edu."), ReturnedCNAMERecords, NumFound); 96 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " CNAME records returned"); 97 for i in integer range 1..numFound loop 98 Ada.Text_IO.Put("CNAME record found, canonical domain name = "); 99 Ada.Text_IO.put(returnedCNAMERecords(i).canonicalDomainName); 100 Ada.Text_IO.New_Line; 101 END LOOP; 102 103 Dns_Table_Pkg.DNS_Table.QueryDNSKEYRecords( 104 rr_type.convertStringToWire("dfcs.usafa.edu."), ReturnedDNSKEYRecords, NumFound); 105 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " DNSKEY records returned"); 106 for i in integer range 1..numFound loop 107 Ada.Text_IO.Put("DNSKEY record found, key = "); 108 Ada.Text_IO.put(returnedDNSKEYRecords(i).key); 109 Ada.Text_IO.New_Line; 110 END LOOP; 111 112 Dns_Table_Pkg.DNS_Table.QueryMXRecords( 113 rr_type.convertStringToWire("gibson.dfcs.USAFA.edu."), ReturnedMXRecords, NumFound); 114 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " MX records returned"); 115 for i in integer range 1..numFound loop 116 Ada.Text_IO.Put("MX record found, pref/mailExchanger = "); 117 Ada.text_io.put(unsigned_types.Unsigned16'image(ReturnedMXRecords(I).pref)); 118 Ada.Text_IO.put(" "); 119 Ada.Text_IO.Put(ReturnedMXRecords(I).MailExchanger); 120 ada.Text_IO.new_line; 121 END LOOP; 122 123 124 Dns_Table_Pkg.DNS_Table.QuerySRVRecords( 125 rr_type.convertStringToWire("_minecraft._tcp_gibson.dfcs.usafa.edu."), ReturnedSRVRecords, NumFound); 126 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " SRV records returned"); 127 for i in integer range 1..numFound loop 128 Ada.Text_IO.Put("SRV record found, pref/weight/portnum/servername= "); 129 Ada.text_io.put(unsigned_types.Unsigned16'image(ReturnedSRVRecords(I).pref)); 130 Ada.Text_IO.put(" "); 131 Ada.text_io.put(unsigned_types.Unsigned16'image(ReturnedSRVRecords(I).weight)); 132 Ada.Text_IO.put(" "); 133 Ada.text_io.put(unsigned_types.Unsigned16'image(ReturnedSRVRecords(I).portnum)); 134 Ada.Text_IO.put(" "); 135 Ada.Text_IO.Put(ReturnedSRVRecords(I).ServerName); 136 ada.Text_IO.new_line; 137 END LOOP; 138 139 Dns_Table_Pkg.DNS_Table.QueryNSECRecords( 140 rr_type.convertStringToWire("dfcs.usafa.edu."), ReturnedNSECRecords, NumFound); 141 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " NSEC records returned"); 142 for i in integer range 1..numFound loop 143 Ada.Text_IO.Put("NSEC record found, resource string = "); 144 Ada.Text_IO.put(returnedNSECRecords(i).RecordList); 145 Ada.Text_IO.New_Line; 146 END LOOP; 147 148 Dns_Table_Pkg.DNS_Table.QueryNSRecords( 149 rr_type.convertStringToWire("dfcS.Usafa.edu."), ReturnedNSRecords, NumFound); 150 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " NS records returned"); 151 for i in integer range 1..numFound loop 152 Ada.Text_IO.Put("NS record found, nameserver = "); 153 Ada.Text_IO.put(returnedNSRecords(i).nameserver); 154 Ada.Text_IO.New_Line; 155 END LOOP; 156 157 Dns_Table_Pkg.DNS_Table.QueryPTRRecords( 158 rr_type.ConvertStringToWire("15.9.236.128.IN-addr.arpa."), ReturnedPTRRecords, NumFound); 159 --Dns_Table_Pkg.DNS_Table.QueryPTRRecords( 160 --Rr_Type.ConvertStringToWire("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.IP6.ARPA."), 161 --ReturnedPTRRecords, NumFound); 162 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " PTR records returned"); 163 for i in integer range 1..numFound loop 164 Ada.Text_IO.Put("PTR record found, domain name = "); 165 Ada.Text_IO.put(returnedPTRRecords(i).domainname); 166 Ada.Text_IO.New_Line; 167 END LOOP; 168 169 Dns_Table_Pkg.DNS_Table.QueryRRSIGRecords( 170 rr_type.convertStringToWire("dfcs.usafa.edu."), ReturnedRRSIGRecords, NumFound); 171 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " RRSIG records returned"); 172 for i in integer range 1..numFound loop 173 Ada.Text_IO.Put("RRSIG record found, signature = "); 174 Ada.Text_IO.put(returnedRRSIGRecords(i).signature); 175 Ada.Text_IO.New_Line; 176 END LOOP; 177 178 Dns_Table_Pkg.DNS_Table.QuerySOARecords( 179 rr_type.ConvertStringToWire("DFCS.usafa.EDU."), ReturnedSOARecords, NumFound); 180 Ada.Text_IO.Put_Line( Integer'Image(NumFound) & " SOA records returned"); 181 for i in integer range 1..numFound loop 182 Ada.Text_IO.Put("SOA record found, nameserver = "); 183 Ada.Text_IO.put(returnedSOARecords(i).nameserver); 184 Ada.Text_IO.New_Line; 185 END LOOP; 186 end if; 187end driver; 188