|
@@ -42,12 +42,46 @@ using namespace isc::dns::Rdata::IN;
|
|
using namespace isc::dns::Rdata::Generic;
|
|
using namespace isc::dns::Rdata::Generic;
|
|
using namespace ISC::Data;
|
|
using namespace ISC::Data;
|
|
|
|
|
|
|
|
+void
|
|
|
|
+ParkingLot::addARecord(std::string data) {
|
|
|
|
+ a_records.push_back(Rdata::RdataPtr(new A(data)));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+ParkingLot::addAAAARecord(std::string data) {
|
|
|
|
+ aaaa_records.push_back(Rdata::RdataPtr(new AAAA(data)));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+ParkingLot::addNSRecord(std::string data) {
|
|
|
|
+ ns_records.push_back(Rdata::RdataPtr(new NS(data)));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+ParkingLot::setSOARecord(isc::dns::Rdata::RdataPtr soa_record) {
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+ParkingLot::setDefaultZoneData() {
|
|
|
|
+ clearARecords();
|
|
|
|
+ clearAAAARecords();
|
|
|
|
+ clearNSRecords();
|
|
|
|
+
|
|
|
|
+ addARecord("127.0.0.1");
|
|
|
|
+ addAAAARecord("::1");
|
|
|
|
+ addNSRecord("ns1.parking.example");
|
|
|
|
+ addNSRecord("ns2.parking.example");
|
|
|
|
+ addNSRecord("ns3.parking.example");
|
|
|
|
+}
|
|
|
|
+
|
|
ParkingLot::ParkingLot(int port) {
|
|
ParkingLot::ParkingLot(int port) {
|
|
- ns1 = Rdata::RdataPtr(new NS("ns1.parking.example"));
|
|
|
|
|
|
+ setDefaultZoneData();
|
|
|
|
+ /*ns1 = Rdata::RdataPtr(new NS("ns1.parking.example"));
|
|
ns2 = Rdata::RdataPtr(new NS("ns2.parking.example"));
|
|
ns2 = Rdata::RdataPtr(new NS("ns2.parking.example"));
|
|
ns3 = Rdata::RdataPtr(new NS("ns3.parking.example"));
|
|
ns3 = Rdata::RdataPtr(new NS("ns3.parking.example"));
|
|
a = Rdata::RdataPtr(new A("127.0.0.1"));
|
|
a = Rdata::RdataPtr(new A("127.0.0.1"));
|
|
aaaa = Rdata::RdataPtr(new AAAA("::1"));
|
|
aaaa = Rdata::RdataPtr(new AAAA("::1"));
|
|
|
|
+ */
|
|
soa = Rdata::RdataPtr(new SOA("parking.example", "noc.parking.example",
|
|
soa = Rdata::RdataPtr(new SOA("parking.example", "noc.parking.example",
|
|
1, 1800, 900, 604800, TTL(86400)));
|
|
1, 1800, 900, 604800, TTL(86400)));
|
|
|
|
|
|
@@ -154,23 +188,26 @@ ParkingLot::processMessage() {
|
|
msg.setRcode(Message::RCODE_NOERROR);
|
|
msg.setRcode(Message::RCODE_NOERROR);
|
|
RRset* nsset = new RRset(query->getName(), RRClass::IN,
|
|
RRset* nsset = new RRset(query->getName(), RRClass::IN,
|
|
RRType::NS, TTL(3600));
|
|
RRType::NS, TTL(3600));
|
|
-
|
|
|
|
- nsset->addRdata(ns1);
|
|
|
|
- nsset->addRdata(ns2);
|
|
|
|
- nsset->addRdata(ns3);
|
|
|
|
|
|
+ BOOST_FOREACH(isc::dns::Rdata::RdataPtr ns, ns_records) {
|
|
|
|
+ nsset->addRdata(ns);
|
|
|
|
+ }
|
|
|
|
|
|
if (query->getType() == RRType::NS)
|
|
if (query->getType() == RRType::NS)
|
|
msg.addRRset(SECTION_ANSWER, RRsetPtr(nsset));
|
|
msg.addRRset(SECTION_ANSWER, RRsetPtr(nsset));
|
|
else if (query->getType() == RRType::A) {
|
|
else if (query->getType() == RRType::A) {
|
|
msg.addRRset(SECTION_AUTHORITY, RRsetPtr(nsset));
|
|
msg.addRRset(SECTION_AUTHORITY, RRsetPtr(nsset));
|
|
- RR arr(query->getName(), RRClass::IN, RRType::A, TTL(3600), a);
|
|
|
|
|
|
|
|
- msg.addRR(SECTION_ANSWER, arr);
|
|
|
|
|
|
+ BOOST_FOREACH(isc::dns::Rdata::RdataPtr a, a_records) {
|
|
|
|
+ RR arr(query->getName(), RRClass::IN, RRType::A, TTL(3600), a);
|
|
|
|
+ msg.addRR(SECTION_ANSWER, arr);
|
|
|
|
+ }
|
|
} else if (query->getType() == RRType::AAAA) {
|
|
} else if (query->getType() == RRType::AAAA) {
|
|
msg.addRRset(SECTION_AUTHORITY, RRsetPtr(nsset));
|
|
msg.addRRset(SECTION_AUTHORITY, RRsetPtr(nsset));
|
|
- RR aaaarr(query->getName(), RRClass::IN, RRType::AAAA,
|
|
|
|
- TTL(3600), aaaa);
|
|
|
|
- msg.addRR(SECTION_ANSWER, aaaarr);
|
|
|
|
|
|
+ BOOST_FOREACH(isc::dns::Rdata::RdataPtr aaaa, aaaa_records) {
|
|
|
|
+ RR aaaarr(query->getName(), RRClass::IN, RRType::AAAA,
|
|
|
|
+ TTL(3600), aaaa);
|
|
|
|
+ msg.addRR(SECTION_ANSWER, aaaarr);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
RR soarr(query->getName(), RRClass::IN, RRType::SOA,
|
|
RR soarr(query->getName(), RRClass::IN, RRType::SOA,
|
|
TTL(3600), soa);
|
|
TTL(3600), soa);
|