From ea9586a4c5643917b938526b13e079c78e7f7c91 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Wed, 17 Jun 2015 00:01:31 +0300 Subject: [PATCH] Use DNSName in Oracle backend --- modules/oraclebackend/oraclebackend.cc | 82 +++++++++++++------------- modules/oraclebackend/oraclebackend.hh | 51 ++++++++-------- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/modules/oraclebackend/oraclebackend.cc b/modules/oraclebackend/oraclebackend.cc index f486c900e..d2071eb83 100644 --- a/modules/oraclebackend/oraclebackend.cc +++ b/modules/oraclebackend/oraclebackend.cc @@ -398,7 +398,7 @@ OracleBackend::~OracleBackend () } void -OracleBackend::lookup (const QType &qtype, const string &qname, +OracleBackend::lookup (const QType &qtype, const DNSName& qname, DNSPacket *p, int zoneId) { sword rc; @@ -441,7 +441,7 @@ OracleBackend::lookup (const QType &qtype, const string &qname, } } - string_to_cbuf(mQueryName, qname, sizeof(mQueryName)); + string_to_cbuf(mQueryName, qname.toStringNoDot(), sizeof(mQueryName)); string_to_cbuf(mQueryType, qtype.getName(), sizeof(mQueryType)); mQueryZoneId = zoneId; @@ -459,8 +459,8 @@ OracleBackend::lookup (const QType &qtype, const string &qname, bool OracleBackend::getBeforeAndAfterNames ( - uint32_t zoneId, const string& zone, - const string& name, string& before, string& after) + uint32_t zoneId, const DNSName& zone, + const DNSName& name, DNSName& before, DNSName& after) { if(!d_dnssecQueries) return -1; @@ -476,7 +476,7 @@ OracleBackend::getBeforeAndAfterNames ( bind_str_ind(stmt, ":prev", mResultPrevName, sizeof(mResultPrevName), &mResultPrevNameInd); bind_str_ind(stmt, ":next", mResultNextName, sizeof(mResultNextName), &mResultNextNameInd); bind_uint32(stmt, ":zoneid", &zoneId); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); mResultPrevNameInd = -1; mResultNextNameInd = -1; @@ -500,7 +500,7 @@ OracleBackend::getBeforeAndAfterNames ( bool OracleBackend::getBeforeAndAfterNamesAbsolute(uint32_t zoneId, - const string& name, string& unhashed, string& before, string& after) + const string& name, DNSName& unhashed, string& before, string& after) { if(!d_dnssecQueries) return -1; @@ -541,7 +541,7 @@ OracleBackend::getBeforeAndAfterNamesAbsolute(uint32_t zoneId, } vector -OracleBackend::getDomainMasters (const string &domain, int zoneId) +OracleBackend::getDomainMasters (const DNSName& domain, int zoneId) { sword rc; OCIStmt *stmt; @@ -587,7 +587,7 @@ OracleBackend::getDomainMasters (const string &domain, int zoneId) } bool -OracleBackend::isMaster (const string &domain, const string &master) +OracleBackend::isMaster (const DNSName& domain, const string &master) { sword rc; OCIStmt *stmt; @@ -596,7 +596,7 @@ OracleBackend::isMaster (const string &domain, const string &master) stmt = prepare_query(masterSvcCtx, isZoneMasterQuerySQL, isZoneMasterQueryKey); - string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); + string_to_cbuf(mQueryZone, domain.toStringNoDot(), sizeof(mQueryZone)); string_to_cbuf(mQueryName, master, sizeof(mQueryName)); char res_master[512]; @@ -624,7 +624,7 @@ OracleBackend::isMaster (const string &domain, const string &master) } bool -OracleBackend::getDomainInfo (const string &domain, DomainInfo &di) +OracleBackend::getDomainInfo (const DNSName& domain, DomainInfo &di) { sword rc; OCIStmt *stmt; @@ -649,7 +649,7 @@ OracleBackend::getDomainInfo (const string &domain, DomainInfo &di) define_output_uint32(stmt, 5, &serial_ind, &serial); define_output_uint32(stmt, 6, ¬ified_serial_ind, ¬ified_serial); - string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); + string_to_cbuf(mQueryZone, domain.toStringNoDot(), sizeof(mQueryZone)); bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); @@ -696,7 +696,7 @@ OracleBackend::getDomainInfo (const string &domain, DomainInfo &di) return true; } -void OracleBackend::alsoNotifies(const string &domain, set *addrs) +void OracleBackend::alsoNotifies(const DNSName& domain, set *addrs) { sword rc; OCIStmt *stmt; @@ -710,7 +710,7 @@ void OracleBackend::alsoNotifies(const string &domain, set *addrs) bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); - string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); + string_to_cbuf(mQueryZone, domain.toStringNoDot(), sizeof(mQueryZone)); define_output_str(stmt, 1, &hostaddr_ind, hostaddr, sizeof(hostaddr)); @@ -942,7 +942,7 @@ OracleBackend::setNotified (uint32_t zoneId, uint32_t serial) } bool -OracleBackend::list (const string &domain, int zoneId, bool include_disabled) +OracleBackend::list (const DNSName& domain, int zoneId, bool include_disabled) { sword rc; @@ -1020,7 +1020,7 @@ bool OracleBackend::get (DNSResourceRecord &rr) } bool -OracleBackend::startTransaction (const string &domain, int zoneId) +OracleBackend::startTransaction (const DNSName& domain, int zoneId) { sword rc; OCIStmt *stmt; @@ -1075,7 +1075,7 @@ OracleBackend::feedRecord (const DNSResourceRecord &rr, string *ordername) bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); mQueryZoneId = rr.domain_id; - string_to_cbuf(mQueryName, rr.qname, sizeof(mQueryName)); + string_to_cbuf(mQueryName, rr.qname.toStringNoDot(), sizeof(mQueryName)); ttl = rr.ttl; string_to_cbuf(mQueryType, rr.qtype.getName(), sizeof(mQueryType)); string_to_cbuf(mQueryContent, rr.content, sizeof(mQueryContent)); @@ -1137,7 +1137,7 @@ OracleBackend::abortTransaction () } bool -OracleBackend::superMasterBackend (const string &ip, const string &domain, +OracleBackend::superMasterBackend (const string &ip, const DNSName& domain, const vector &nsset, string *nameserver, string *account, DNSBackend **backend) @@ -1182,14 +1182,14 @@ OracleBackend::superMasterBackend (const string &ip, const string &domain, } bool -OracleBackend::createSlaveDomain(const string &ip, const string &domain, +OracleBackend::createSlaveDomain(const string &ip, const DNSName& domain, const string &nameserver, const string &account) { sword rc; OCIStmt *insertSlaveQueryHandle; OCIStmt *insertMasterQueryHandle; - string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); + string_to_cbuf(mQueryZone, domain.toStringNoDot(), sizeof(mQueryZone)); openMasterConnection(); @@ -1238,7 +1238,7 @@ OracleBackend::createSlaveDomain(const string &ip, const string &domain, } bool -OracleBackend::getAllDomainMetadata (const string& name, std::map >& meta) +OracleBackend::getAllDomainMetadata (const DNSName& name, std::map >& meta) { DomainInfo di; if (getDomainInfo(name, di) == false) return false; @@ -1253,7 +1253,7 @@ OracleBackend::getAllDomainMetadata (const string& name, std::map& meta) { if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) @@ -1294,7 +1294,7 @@ OracleBackend::getDomainMetadata (const string& name, const string& kind, bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); define_output_str(stmt, 1, &mResultContentInd, mResultContent, sizeof(mResultContent)); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); @@ -1317,7 +1317,7 @@ OracleBackend::getDomainMetadata (const string& name, const string& kind, } bool -OracleBackend::setDomainMetadata(const string& name, const string& kind, +OracleBackend::setDomainMetadata(const DNSName& name, const string& kind, const vector& meta) { if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) @@ -1336,7 +1336,7 @@ OracleBackend::setDomainMetadata(const string& name, const string& kind, throw OracleException("Oracle setDomainMetadata BEGIN", oraerr); } - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); stmt = prepare_query(masterSvcCtx, delZoneMetadataQuerySQL, delZoneMetadataQueryKey); @@ -1381,13 +1381,13 @@ OracleBackend::setDomainMetadata(const string& name, const string& kind, } bool -OracleBackend::getTSIGKey (const string& name, string* algorithm, string* content) +OracleBackend::getTSIGKey (const DNSName& name, DNSName* algorithm, string* content) { sword rc; OCIStmt *stmt; stmt = prepare_query(pooledSvcCtx, getTSIGKeyQuerySQL, getTSIGKeyQueryKey); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); define_output_str(stmt, 1, &mResultTypeInd, mResultType, sizeof(mResultType)); @@ -1418,7 +1418,7 @@ OracleBackend::getTSIGKey (const string& name, string* algorithm, string* conten } bool -OracleBackend::delTSIGKey(const string& name) +OracleBackend::delTSIGKey(const DNSName& name) { sword rc; OCIStmt *stmt; @@ -1427,7 +1427,7 @@ OracleBackend::delTSIGKey(const string& name) rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); stmt = prepare_query(masterSvcCtx, delTSIGKeyQuerySQL, delTSIGKeyQueryKey); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); @@ -1447,7 +1447,7 @@ OracleBackend::delTSIGKey(const string& name) } bool -OracleBackend::setTSIGKey(const string& name, const string& algorithm, const string& content) +OracleBackend::setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) { sword rc; OCIStmt *stmt; @@ -1461,7 +1461,7 @@ OracleBackend::setTSIGKey(const string& name, const string& algorithm, const str } stmt = prepare_query(masterSvcCtx, delTSIGKeyQuerySQL, delTSIGKeyQueryKey); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); @@ -1474,8 +1474,8 @@ OracleBackend::setTSIGKey(const string& name, const string& algorithm, const str release_query(stmt, delTSIGKeyQueryKey); stmt = prepare_query(masterSvcCtx, setTSIGKeyQuerySQL, setTSIGKeyQueryKey); - string_to_cbuf(mQueryName, name, sizeof(mQueryName)); - string_to_cbuf(mQueryType, algorithm, sizeof(mQueryType)); + string_to_cbuf(mQueryName, name.toStringNoDot(), sizeof(mQueryName)); + string_to_cbuf(mQueryType, algorithm.toStringNoDot(), sizeof(mQueryType)); string_to_cbuf(mQueryContent, content, sizeof(mQueryContent)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); @@ -1536,7 +1536,7 @@ OracleBackend::getTSIGKeys(std::vector< struct TSIGKey > &keys) } bool -OracleBackend::getDomainKeys (const string& name, unsigned int kind, vector& keys) +OracleBackend::getDomainKeys (const DNSName& name, unsigned int kind, vector& keys) { if(!d_dnssecQueries) return -1; @@ -1549,7 +1549,7 @@ OracleBackend::getDomainKeys (const string& name, unsigned int kind, vector getDomainMasters(const string &domain, int zoneId); - bool isMaster(const string &domain, const string &master); - bool getDomainInfo(const string &domain, DomainInfo &di); - void alsoNotifies(const string &domain, set *addrs); + vector getDomainMasters(const DNSName& domain, int zoneId); + bool isMaster(const DNSName& domain, const string &master); + bool getDomainInfo(const DNSName& domain, DomainInfo &di); + void alsoNotifies(const DNSName& domain, set *addrs); void getUnfreshSlaveInfos(vector* domains); void getUpdatedMasters(vector* domains); void setFresh(uint32_t zoneId); void setNotified(uint32_t zoneId, uint32_t serial); - bool list(const string &domain, int zoneId, bool include_disabled=false); - bool startTransaction(const string &domain, int zoneId); + bool list(const DNSName& domain, int zoneId, bool include_disabled=false); + bool startTransaction(const DNSName& domain, int zoneId); bool feedRecord(const DNSResourceRecord &rr, string* ordername); bool commitTransaction(); bool abortTransaction(); - bool superMasterBackend(const string &ip, const string &domain, + bool superMasterBackend(const string &ip, const DNSName& domain, const vector &nsset, string *account, string *nameserver, DNSBackend **backend); - bool createSlaveDomain(const string &ip, const string &domain, + bool createSlaveDomain(const string &ip, const DNSName& domain, const string &nameserver, const string &account); - bool getAllDomainMetadata(const string& name, std::map >& meta); - bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); - bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); + bool getAllDomainMetadata(const DNSName& name, std::map >& meta); + bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta); + bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta); - bool getTSIGKey(const string& name, string* algorithm, string* content); - bool delTSIGKey(const string& name); - bool setTSIGKey(const string& name, const string& algorithm, const string& content); + bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content); + bool delTSIGKey(const DNSName& name); + bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content); bool getTSIGKeys(std::vector< struct TSIGKey > &keys); - bool getDomainKeys(const string& name, unsigned int kind, vector& keys); - bool removeDomainKey(const string& name, unsigned int id); - int addDomainKey(const string& name, const KeyData& key); - bool activateDomainKey(const string& name, unsigned int id); - bool deactivateDomainKey(const string& name, unsigned int id); + bool getDomainKeys(const DNSName& name, unsigned int kind, vector& keys); + bool removeDomainKey(const DNSName& name, unsigned int id); + int addDomainKey(const DNSName& name, const KeyData& key); + bool activateDomainKey(const DNSName& name, unsigned int id); + bool deactivateDomainKey(const DNSName& name, unsigned int id); private: @@ -181,7 +182,7 @@ private: void Cleanup(); void openMasterConnection(); - bool setDomainKeyState(const string& name, unsigned int id, int active); + bool setDomainKeyState(const DNSName& name, unsigned int id, int active); OCIStmt* prepare_query (OCISvcCtx* orasvc, string& code, const char *key); void release_query (OCIStmt *stmt, const char *key); -- 2.40.0