123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674 |
- #include <config.h>
- #include <dhcpsrv/dhcpsrv_log.h>
- #include <dhcpsrv/mysql_host_data_source.h>
- #include <dhcpsrv/db_exceptions.h>
- #include <boost/pointer_cast.hpp>
- #include <boost/static_assert.hpp>
- #include <mysql.h>
- #include <mysqld_error.h>
- #include <stdint.h>
- #include <string>
- using namespace isc;
- using namespace isc::dhcp;
- using namespace isc::asiolink;
- using namespace std;
- namespace {
- const size_t ADDRESS6_TEXT_MAX_LEN = 39;
- const size_t CLIENT_CLASSES_MAX_LEN = 255;
- const size_t HOSTNAME_MAX_LEN = 255;
- TaggedStatement tagged_statements[] = {
-
- {MySqlHostDataSource::INSERT_HOST,
- "INSERT INTO hosts(host_id, dhcp_identifier, dhcp_identifier_type, "
- "dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, "
- "dhcp4_client_classes, dhcp6_client_classes) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"},
-
- {MySqlHostDataSource::INSERT_V6_RESRV,
- "INSERT INTO ipv6_reservations(address, prefix_len, type, "
- "dhcp6_iaid, host_id) "
- "VALUES (?,?,?,?,?)"},
-
-
-
-
-
- {MySqlHostDataSource::GET_HOST_DHCPID,
- "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
- "h.dhcp4_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, "
- "h.hostname, h.dhcp4_client_classes, h.dhcp6_client_classes, "
- "r.address, r.prefix_len, r.type, r.dhcp6_iaid "
- "FROM hosts AS h "
- "LEFT JOIN ipv6_reservations AS r "
- "ON h.host_id = r.host_id "
- "WHERE dhcp_identifier = ? AND dhcp_identifier_type = ?"},
-
-
-
- {MySqlHostDataSource::GET_HOST_ADDR,
- "SELECT host_id, dhcp_identifier, dhcp_identifier_type, "
- "dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, "
- "dhcp4_client_classes, dhcp6_client_classes "
- "FROM hosts "
- "WHERE ipv4_address = ?"},
-
-
- {MySqlHostDataSource::GET_HOST_SUBID4_DHCPID,
- "SELECT host_id, dhcp_identifier, dhcp_identifier_type, "
- "dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, "
- "dhcp4_client_classes, dhcp6_client_classes "
- "FROM hosts "
- "WHERE dhcp4_subnet_id = ? AND dhcp_identifier_type = ? "
- " AND dhcp_identifier = ?"},
-
-
-
-
-
-
- {MySqlHostDataSource::GET_HOST_SUBID6_DHCPID,
- "SELECT DISTINCT h.host_id, h.dhcp_identifier, "
- "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
- "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
- "h.dhcp4_client_classes, h.dhcp6_client_classes, "
- "r.address, r.prefix_len, r.type, r.dhcp6_iaid "
- "FROM hosts AS h "
- "LEFT JOIN ipv6_reservations AS r "
- "ON h.host_id = r.host_id "
- "WHERE dhcp6_subnet_id = ? AND dhcp_identifier_type = ? "
- "AND dhcp_identifier = ? "
- "ORDER BY h.host_id, r.prefix_len, r.address"},
-
-
-
- {MySqlHostDataSource::GET_HOST_SUBID_ADDR,
- "SELECT host_id, dhcp_identifier, dhcp_identifier_type, "
- "dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, "
- "dhcp4_client_classes, dhcp6_client_classes "
- "FROM hosts "
- "WHERE dhcp4_subnet_id = ? AND ipv4_address = ?"},
-
-
-
-
-
-
- {MySqlHostDataSource::GET_HOST_PREFIX,
- "SELECT DISTINCT h.host_id, h.dhcp_identifier, "
- "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
- "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
- "h.dhcp4_client_classes, h.dhcp6_client_classes, "
- "r.address, r.prefix_len, r.type, r.dhcp6_iaid "
- "FROM hosts AS h "
- "LEFT JOIN ipv6_reservations AS r "
- "ON h.host_id = r.host_id "
- "WHERE h.host_id = "
- "(SELECT host_id FROM ipv6_reservations "
- "WHERE address = ? AND prefix_len = ?) "
- "ORDER BY h.host_id, r.prefix_len, r.address"},
-
- {MySqlHostDataSource::GET_VERSION,
- "SELECT version, minor FROM schema_version"},
-
- {MySqlHostDataSource::NUM_STATEMENTS, NULL}
- };
- class MySqlHostExchange {
- private:
-
- static const size_t HOST_COLUMNS = 9;
- public:
-
-
-
-
- MySqlHostExchange()
- : bind_(HOST_COLUMNS), columns_(HOST_COLUMNS),
- error_(HOST_COLUMNS, MLM_FALSE), host_id_(0),
- dhcp_identifier_length_(0), dhcp_identifier_type_(0),
- dhcp4_subnet_id_(0), dhcp6_subnet_id_(0), ipv4_address_(0),
- hostname_length_(0), dhcp4_client_classes_length_(0),
- dhcp6_client_classes_length_(0), dhcp4_subnet_id_null_(MLM_FALSE),
- dhcp6_subnet_id_null_(MLM_FALSE), ipv4_address_null_(MLM_FALSE),
- hostname_null_(MLM_FALSE), dhcp4_client_classes_null_(MLM_FALSE),
- dhcp6_client_classes_null_(MLM_FALSE) {
-
- memset(dhcp_identifier_buffer_, 0, sizeof(dhcp_identifier_buffer_));
- memset(hostname_, 0, sizeof(hostname_));
- memset(dhcp4_client_classes_, 0, sizeof(dhcp4_client_classes_));
- memset(dhcp6_client_classes_, 0, sizeof(dhcp6_client_classes_));
-
- columns_[0] = "host_id";
- columns_[1] = "dhcp_identifier";
- columns_[2] = "dhcp_identifier_type";
- columns_[3] = "dhcp4_subnet_id";
- columns_[4] = "dhcp6_subnet_id";
- columns_[5] = "ipv4_address";
- columns_[6] = "hostname";
- columns_[7] = "dhcp4_client_classes";
- columns_[8] = "dhcp6_client_classes";
- BOOST_STATIC_ASSERT(8 < HOST_COLUMNS);
- };
-
- virtual ~MySqlHostExchange() {
- }
-
-
-
- uint64_t getHostId() const {
- return (host_id_);
- };
-
-
-
-
-
-
-
-
-
-
- static void setErrorIndicators(std::vector<MYSQL_BIND>& bind,
- std::vector<my_bool>& error) {
- for (size_t i = 0; i < error.size(); ++i) {
- error[i] = MLM_FALSE;
- bind[i].error = reinterpret_cast<char*>(&error[i]);
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
- static std::string getColumnsInError(std::vector<my_bool>& error,
- const std::vector<std::string>& names) {
- std::string result = "";
-
- for (size_t i = 0; i < names.size(); ++i) {
- if (error[i] == MLM_TRUE) {
- if (!result.empty()) {
- result += ", ";
- }
- result += names[i];
- }
- }
- if (result.empty()) {
- result = "(None)";
- }
- return (result);
- };
-
-
-
-
-
-
-
-
-
-
- std::vector<MYSQL_BIND> createBindForSend(const HostPtr& host) {
-
- host_ = host;
-
-
-
-
- memset(&bind_[0], 0, sizeof(MYSQL_BIND) * bind_.size());
-
- try {
-
-
-
- host_id_ = static_cast<uint32_t>(NULL);
- bind_[0].buffer_type = MYSQL_TYPE_LONG;
- bind_[0].buffer = reinterpret_cast<char*>(&host_id_);
- bind_[0].is_unsigned = MLM_TRUE;
-
-
- if (host->getDuid()) {
- dhcp_identifier_length_ = host->getDuid()->getDuid().size();
- memcpy(static_cast<void*>(dhcp_identifier_buffer_),
- &(host->getDuid()->getDuid()[0]),
- host->getDuid()->getDuid().size());
- bind_[1].buffer_type = MYSQL_TYPE_BLOB;
- bind_[1].buffer = dhcp_identifier_buffer_;
- bind_[1].buffer_length = dhcp_identifier_length_;
- bind_[1].length = &dhcp_identifier_length_;
- } else if (host->getHWAddress()){
- dhcp_identifier_length_ = host->getHWAddress()->hwaddr_.size();
- memcpy(static_cast<void*>(dhcp_identifier_buffer_),
- &(host->getHWAddress()->hwaddr_[0]),
- host->getHWAddress()->hwaddr_.size());
- bind_[1].buffer_type = MYSQL_TYPE_BLOB;
- bind_[1].buffer = dhcp_identifier_buffer_;
- bind_[1].buffer_length = dhcp_identifier_length_;
- bind_[1].length = &dhcp_identifier_length_;
- } else {
- isc_throw(DbOperationError, "Host object doesn't contain any"
- " identifier which can be used to retrieve information"
- " from the database about its static reservations");
- }
-
-
- if (host->getHWAddress()) {
- dhcp_identifier_type_ = BaseHostDataSource::ID_HWADDR;
- bind_[2].buffer_type = MYSQL_TYPE_TINY;
- bind_[2].buffer = reinterpret_cast<char*>(&dhcp_identifier_type_);
- bind_[2].is_unsigned = MLM_TRUE;
- } else if (host->getDuid()) {
- dhcp_identifier_type_ = BaseHostDataSource::ID_DUID;
- bind_[2].buffer_type = MYSQL_TYPE_TINY;
- bind_[2].buffer = reinterpret_cast<char*>(&dhcp_identifier_type_);
- bind_[2].is_unsigned = MLM_TRUE;
- }
-
-
-
- dhcp4_subnet_id_ = host->getIPv4SubnetID();
- bind_[3].buffer_type = MYSQL_TYPE_LONG;
- bind_[3].buffer = reinterpret_cast<char*>(&dhcp4_subnet_id_);
- bind_[3].is_unsigned = MLM_TRUE;
-
-
-
- dhcp6_subnet_id_ = host->getIPv6SubnetID();
- bind_[4].buffer_type = MYSQL_TYPE_LONG;
- bind_[4].buffer = reinterpret_cast<char*>(&dhcp6_subnet_id_);
- bind_[4].is_unsigned = MLM_TRUE;
-
-
-
- ipv4_address_ = static_cast<uint32_t>(host->getIPv4Reservation());
- bind_[5].buffer_type = MYSQL_TYPE_LONG;
- bind_[5].buffer = reinterpret_cast<char*>(&ipv4_address_);
- bind_[5].is_unsigned = MLM_TRUE;
-
-
-
- strncpy(hostname_, host->getHostname().c_str(), HOSTNAME_MAX_LEN - 1);
- hostname_length_ = host->getHostname().length();
- bind_[6].buffer_type = MYSQL_TYPE_STRING;
- bind_[6].buffer = reinterpret_cast<char*>(hostname_);
- bind_[6].buffer_length = hostname_length_;
-
- bind_[7].buffer_type = MYSQL_TYPE_STRING;
-
- string classes4_txt = host->getClientClasses4().toText(",");
- strncpy(dhcp4_client_classes_, classes4_txt.c_str(), CLIENT_CLASSES_MAX_LEN - 1);
- bind_[7].buffer = dhcp4_client_classes_;
- bind_[7].buffer_length = classes4_txt.length();
-
- bind_[8].buffer_type = MYSQL_TYPE_STRING;
-
- string classes6_txt = host->getClientClasses6().toText(",");
- strncpy(dhcp6_client_classes_, classes6_txt.c_str(), CLIENT_CLASSES_MAX_LEN - 1);
- bind_[8].buffer = dhcp6_client_classes_;
- bind_[8].buffer_length = classes6_txt.length();
- bind_[8].buffer_length = sizeof(host->getClientClasses6());
- } catch (const std::exception& ex) {
- isc_throw(DbOperationError,
- "Could not create bind array from Host: "
- << host->getHostname() << ", reason: " << ex.what());
- }
-
-
- return (std::vector<MYSQL_BIND>(&bind_[0], &bind_[HOST_COLUMNS]));
- };
-
-
-
-
-
-
-
- virtual std::vector<MYSQL_BIND> createBindForReceive() {
-
-
-
-
-
-
- memset(&bind_[0], 0, sizeof(MYSQL_BIND) * bind_.size());
-
- bind_[0].buffer_type = MYSQL_TYPE_LONG;
- bind_[0].buffer = reinterpret_cast<char*>(&host_id_);
- bind_[0].is_unsigned = MLM_TRUE;
-
- dhcp_identifier_length_ = sizeof(dhcp_identifier_buffer_);
- bind_[1].buffer_type = MYSQL_TYPE_BLOB;
- bind_[1].buffer = reinterpret_cast<char*>(dhcp_identifier_buffer_);
- bind_[1].buffer_length = dhcp_identifier_length_;
- bind_[1].length = &dhcp_identifier_length_;
-
- bind_[2].buffer_type = MYSQL_TYPE_TINY;
- bind_[2].buffer = reinterpret_cast<char*>(&dhcp_identifier_type_);
- bind_[2].is_unsigned = MLM_TRUE;
-
- dhcp4_subnet_id_null_ = MLM_FALSE;
- bind_[3].buffer_type = MYSQL_TYPE_LONG;
- bind_[3].buffer = reinterpret_cast<char*>(&dhcp4_subnet_id_);
- bind_[3].is_unsigned = MLM_TRUE;
- bind_[3].is_null = &dhcp4_subnet_id_null_;
-
- dhcp6_subnet_id_null_ = MLM_FALSE;
- bind_[4].buffer_type = MYSQL_TYPE_LONG;
- bind_[4].buffer = reinterpret_cast<char*>(&dhcp6_subnet_id_);
- bind_[4].is_unsigned = MLM_TRUE;
- bind_[4].is_null = &dhcp6_subnet_id_null_;
-
- ipv4_address_null_ = MLM_FALSE;
- bind_[5].buffer_type = MYSQL_TYPE_LONG;
- bind_[5].buffer = reinterpret_cast<char*>(&ipv4_address_);
- bind_[5].is_unsigned = MLM_TRUE;
- bind_[5].is_null = &ipv4_address_null_;
-
- hostname_null_ = MLM_FALSE;
- hostname_length_ = sizeof(hostname_);
- bind_[6].buffer_type = MYSQL_TYPE_STRING;
- bind_[6].buffer = reinterpret_cast<char*>(hostname_);
- bind_[6].buffer_length = hostname_length_;
- bind_[6].length = &hostname_length_;
- bind_[6].is_null = &hostname_null_;
-
- dhcp4_client_classes_null_ = MLM_FALSE;
- dhcp4_client_classes_length_ = sizeof(dhcp4_client_classes_);
- bind_[7].buffer_type = MYSQL_TYPE_STRING;
- bind_[7].buffer = reinterpret_cast<char*>(dhcp4_client_classes_);
- bind_[7].buffer_length = dhcp4_client_classes_length_;
- bind_[7].length = &dhcp4_client_classes_length_;
- bind_[7].is_null = &dhcp4_client_classes_null_;
-
- dhcp6_client_classes_null_ = MLM_FALSE;
- dhcp6_client_classes_length_ = sizeof(dhcp6_client_classes_);
- bind_[8].buffer_type = MYSQL_TYPE_STRING;
- bind_[8].buffer = reinterpret_cast<char*>(dhcp6_client_classes_);
- bind_[8].buffer_length = dhcp6_client_classes_length_;
- bind_[8].length = &dhcp6_client_classes_length_;
- bind_[8].is_null = &dhcp6_client_classes_null_;
-
- setErrorIndicators(bind_, error_);
-
-
- return (bind_);
- };
-
-
-
-
-
-
-
-
- HostPtr retrieveHost() {
-
-
- Host::IdentifierType type = Host::IDENT_HWADDR;
- switch (dhcp_identifier_type_) {
- case 0:
- type = Host::IDENT_HWADDR;
- break;
- case 1:
- type = Host::IDENT_DUID;
- break;
- default:
- isc_throw(BadValue, "invalid dhcp identifier type returned: "
- << static_cast<int>(dhcp_identifier_type_)
- << ". Only 0 or 1 are supported.");
- }
-
- SubnetID ipv4_subnet_id(0);
- if (dhcp4_subnet_id_null_ == MLM_FALSE) {
- ipv4_subnet_id = static_cast<SubnetID>(dhcp4_subnet_id_);
- }
-
- SubnetID ipv6_subnet_id(0);
- if (dhcp6_subnet_id_null_ == MLM_FALSE) {
- ipv6_subnet_id = static_cast<SubnetID>(dhcp6_subnet_id_);
- }
-
- asiolink::IOAddress ipv4_reservation = asiolink::IOAddress::IPV4_ZERO_ADDRESS();
- if (ipv4_address_null_ == MLM_FALSE) {
- ipv4_reservation = asiolink::IOAddress(ipv4_address_);
- }
-
- std::string hostname;
- if (hostname_null_ == MLM_FALSE) {
- hostname = std::string(hostname_, hostname_length_);
- }
-
- std::string dhcp4_client_classes;
- if (dhcp4_client_classes_null_ == MLM_FALSE) {
- dhcp4_client_classes = std::string(dhcp4_client_classes_,
- dhcp4_client_classes_length_);
- }
-
- std::string dhcp6_client_classes;
- if (dhcp6_client_classes_null_ == MLM_FALSE) {
- dhcp6_client_classes = std::string(dhcp6_client_classes_,
- dhcp6_client_classes_length_);
- }
-
- HostPtr h(new Host(dhcp_identifier_buffer_, dhcp_identifier_length_,
- type, ipv4_subnet_id, ipv6_subnet_id, ipv4_reservation,
- hostname, dhcp4_client_classes, dhcp6_client_classes));
- h->setHostId(host_id_);
- return (h);
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual void processFetchedData(ConstHostCollection& hosts) {
- HostPtr host;
-
-
-
- if (hosts.empty() || (hosts.back()->getHostId() != getHostId())) {
-
-
- host = retrieveHost();
- hosts.push_back(host);
- }
- }
-
-
-
-
-
-
-
-
-
-
- std::string getErrorColumns() {
- return (getColumnsInError(error_, columns_));
- };
- protected:
-
- std::vector<MYSQL_BIND> bind_;
-
- std::vector<std::string> columns_;
-
- std::vector<my_bool> error_;
-
-
- HostPtr host_;
- private:
-
- uint64_t host_id_;
-
-
- uint8_t dhcp_identifier_buffer_[DUID::MAX_DUID_LEN];
-
- size_t dhcp_identifier_length_;
-
-
- uint8_t dhcp_identifier_type_;
-
- uint32_t dhcp4_subnet_id_;
-
- uint32_t dhcp6_subnet_id_;
-
- uint32_t ipv4_address_;
-
- char hostname_[HOSTNAME_MAX_LEN];
-
- unsigned long hostname_length_;
-
- char dhcp4_client_classes_[CLIENT_CLASSES_MAX_LEN];
-
-
- unsigned long dhcp4_client_classes_length_;
-
- char dhcp6_client_classes_[CLIENT_CLASSES_MAX_LEN];
-
-
- unsigned long dhcp6_client_classes_length_;
-
-
-
-
- my_bool dhcp4_subnet_id_null_;
-
- my_bool dhcp6_subnet_id_null_;
-
- my_bool ipv4_address_null_;
-
- my_bool hostname_null_;
-
-
- my_bool dhcp4_client_classes_null_;
-
-
- my_bool dhcp6_client_classes_null_;
-
- };
- class MySqlHostIPv6Exchange : public MySqlHostExchange {
- private:
-
-
- static const size_t RESERVATION_COLUMNS = 13;
- public:
-
-
-
-
- MySqlHostIPv6Exchange()
- : MySqlHostExchange(), reserv_type_(0), reserv_type_null_(MLM_FALSE),
- ipv6_address_buffer_len_(0), prefix_len_(0), iaid_(0) {
- memset(ipv6_address_buffer_, 0, sizeof(ipv6_address_buffer_));
-
- columns_.push_back("address");
- columns_.push_back("prefix_len");
- columns_.push_back("type");
- columns_.push_back("dhcp6_iaid");
-
-
-
- bind_.resize(RESERVATION_COLUMNS);
-
- error_.resize(RESERVATION_COLUMNS);
- std::fill(&error_[0], &error_[RESERVATION_COLUMNS], MLM_FALSE);
- }
-
-
-
-
- bool hasReservation() const {
- return (reserv_type_null_ == MLM_FALSE);
- };
-
-
-
-
-
-
- IPv6Resrv retrieveReservation() {
-
- IPv6Resrv::Type type = IPv6Resrv::TYPE_NA;
- switch (reserv_type_) {
- case 0:
- type = IPv6Resrv::TYPE_NA;
- break;
- case 2:
- type = IPv6Resrv::TYPE_PD;
- break;
- default:
- isc_throw(BadValue,
- "invalid IPv6 reservation type returned: "
- << static_cast<int>(reserv_type_)
- << ". Only 0 or 2 are allowed.");
- }
- ipv6_address_buffer_[ipv6_address_buffer_len_] = '\0';
- std::string address = ipv6_address_buffer_;
- IPv6Resrv r(type, IOAddress(address), prefix_len_);
- return (r);
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual void processFetchedData(ConstHostCollection& hosts) {
- HostPtr host;
- HostPtr most_recent_host;
-
-
-
-
-
- if (!hosts.empty()) {
-
-
-
-
-
-
-
-
- most_recent_host = boost::const_pointer_cast<Host>(hosts.back());
- }
-
-
- if (!most_recent_host || (most_recent_host->getHostId() != getHostId())) {
- host = retrieveHost();
-
-
- if (hasReservation()) {
- host->addReservation(retrieveReservation());
- }
-
- hosts.push_back(host);
-
-
- } else if (hasReservation() && most_recent_host) {
- most_recent_host->addReservation(retrieveReservation());
- }
- }
-
-
-
-
-
-
-
-
- virtual std::vector<MYSQL_BIND> createBindForReceive() {
-
- static_cast<void>(MySqlHostExchange::createBindForReceive());
-
- ipv6_address_buffer_len_ = sizeof(ipv6_address_buffer_) - 1;
- bind_[9].buffer_type = MYSQL_TYPE_STRING;
- bind_[9].buffer = ipv6_address_buffer_;
- bind_[9].buffer_length = ipv6_address_buffer_len_;
- bind_[9].length = &ipv6_address_buffer_len_;
-
- bind_[10].buffer_type = MYSQL_TYPE_TINY;
- bind_[10].buffer = reinterpret_cast<char*>(&prefix_len_);
- bind_[10].is_unsigned = MLM_TRUE;
-
- reserv_type_null_ = MLM_FALSE;
- bind_[11].buffer_type = MYSQL_TYPE_TINY;
- bind_[11].buffer = reinterpret_cast<char*>(&reserv_type_);
- bind_[11].is_unsigned = MLM_TRUE;
- bind_[11].is_null = &reserv_type_null_;
-
- bind_[12].buffer_type = MYSQL_TYPE_LONG;
- bind_[12].buffer = reinterpret_cast<char*>(&iaid_);
- bind_[12].is_unsigned = MLM_TRUE;
-
- setErrorIndicators(bind_, error_);
-
-
- return (bind_);
- };
- private:
-
- uint8_t reserv_type_;
-
-
-
-
- my_bool reserv_type_null_;
-
- char ipv6_address_buffer_[ADDRESS6_TEXT_MAX_LEN + 1];
-
- size_t ipv6_address_buffer_len_;
-
- uint8_t prefix_len_;
-
- uint8_t iaid_;
- };
- class MySqlIPv6ReservationExchange {
- private:
-
- static const size_t RESRV_COLUMNS = 6;
- public:
-
-
-
- MySqlIPv6ReservationExchange()
- : host_id_(0), address_("::"), address_len_(0), prefix_len_(0), type_(0),
- iaid_(0), resv_(IPv6Resrv::TYPE_NA, asiolink::IOAddress("::"), 128) {
-
- std::fill(&error_[0], &error_[RESRV_COLUMNS], MLM_FALSE);
-
- columns_[0] = "host_id";
- columns_[1] = "address";
- columns_[2] = "prefix_len";
- columns_[3] = "type";
- columns_[4] = "dhcp6_iaid";
- BOOST_STATIC_ASSERT(4 < RESRV_COLUMNS);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- std::vector<MYSQL_BIND> createBindForSend(const IPv6Resrv& resv,
- const HostID& id) {
-
- resv_ = resv;
- host_id_ = id;
-
-
-
-
-
- memset(bind_, 0, sizeof(bind_));
-
- try {
-
- address_ = resv.getPrefix().toText();
- address_len_ = address_.length();
- bind_[0].buffer_type = MYSQL_TYPE_BLOB;
- bind_[0].buffer = reinterpret_cast<char*>
- (const_cast<char*>(address_.c_str()));
- bind_[0].buffer_length = address_len_;
- bind_[0].length = &address_len_;
-
- prefix_len_ = resv.getPrefixLen();
- bind_[1].buffer_type = MYSQL_TYPE_TINY;
- bind_[1].buffer = reinterpret_cast<char*>(&prefix_len_);
- bind_[1].is_unsigned = MLM_TRUE;
-
-
- type_ = resv.getType() == IPv6Resrv::TYPE_NA ? 0 : 2;
- bind_[2].buffer_type = MYSQL_TYPE_TINY;
- bind_[2].buffer = reinterpret_cast<char*>(&type_);
- bind_[2].is_unsigned = MLM_TRUE;
-
-
- iaid_ = 0;
- bind_[3].buffer_type = MYSQL_TYPE_LONG;
- bind_[3].buffer = reinterpret_cast<char*>(&iaid_);
- bind_[3].is_unsigned = MLM_TRUE;
-
- bind_[4].buffer_type = MYSQL_TYPE_LONG;
- bind_[4].buffer = reinterpret_cast<char*>(&host_id_);
- bind_[4].is_unsigned = MLM_TRUE;
- } catch (const std::exception& ex) {
- isc_throw(DbOperationError,
- "Could not create bind array from IPv6 Reservation: "
- << resv_.toText() << ", reason: " << ex.what());
- }
-
-
-
- return (std::vector<MYSQL_BIND>(&bind_[0], &bind_[RESRV_COLUMNS-1]));
- }
- private:
-
- uint64_t host_id_;
-
- std::string address_;
-
- size_t address_len_;
-
- uint8_t prefix_len_;
-
- uint8_t type_;
-
- uint8_t iaid_;
-
- IPv6Resrv resv_;
-
- MYSQL_BIND bind_[RESRV_COLUMNS];
-
- std::string columns_[RESRV_COLUMNS];
-
-
- my_bool error_[RESRV_COLUMNS];
- };
- }
- namespace isc {
- namespace dhcp {
- class MySqlHostDataSourceImpl {
- public:
-
-
-
-
- MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters);
-
- ~MySqlHostDataSourceImpl();
-
-
-
-
-
-
-
- void addQuery(MySqlHostDataSource::StatementIndex stindex,
- std::vector<MYSQL_BIND>& bind);
-
-
-
-
- void addResv(const IPv6Resrv& resv, const HostID& id);
-
-
-
-
-
-
-
-
-
-
-
-
- void checkError(const int status,
- const MySqlHostDataSource::StatementIndex index,
- const char* what) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void getHostCollection(MySqlHostDataSource::StatementIndex stindex,
- MYSQL_BIND* bind,
- boost::shared_ptr<MySqlHostExchange> exchange,
- ConstHostCollection& result, bool single) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ConstHostPtr getHost(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len,
- MySqlHostDataSource::StatementIndex stindex,
- boost::shared_ptr<MySqlHostExchange> exchange) const;
-
-
- boost::shared_ptr<MySqlHostExchange> host_exchange_;
-
-
- boost::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange_;
-
-
- boost::shared_ptr<MySqlIPv6ReservationExchange> host_ipv6_reservation_exchange_;
-
- MySqlConnection conn_;
- };
- MySqlHostDataSourceImpl::
- MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters)
- : host_exchange_(new MySqlHostExchange()),
- host_ipv6_exchange_(new MySqlHostIPv6Exchange()),
- host_ipv6_reservation_exchange_(new MySqlIPv6ReservationExchange()),
- conn_(parameters) {
-
- conn_.openDatabase();
-
-
-
-
-
- my_bool result = mysql_autocommit(conn_.mysql_, 1);
- if (result != 0) {
- isc_throw(DbOperationError, mysql_error(conn_.mysql_));
- }
-
- conn_.prepareStatements(tagged_statements,
- MySqlHostDataSource::NUM_STATEMENTS);
- }
- MySqlHostDataSourceImpl::~MySqlHostDataSourceImpl() {
-
-
-
- for (int i = 0; i < conn_.statements_.size(); ++i) {
- if (conn_.statements_[i] != NULL) {
- (void) mysql_stmt_close(conn_.statements_[i]);
- conn_.statements_[i] = NULL;
- }
- }
-
-
- }
- void
- MySqlHostDataSourceImpl::addQuery(MySqlHostDataSource::StatementIndex stindex,
- std::vector<MYSQL_BIND>& bind) {
-
- int status = mysql_stmt_bind_param(conn_.statements_[stindex], &bind[0]);
- checkError(status, stindex, "unable to bind parameters");
-
- status = mysql_stmt_execute(conn_.statements_[stindex]);
- if (status != 0) {
-
- if (mysql_errno(conn_.mysql_) == ER_DUP_ENTRY) {
- isc_throw(DuplicateEntry, "Database duplicate entry error");
- }
- checkError(status, stindex, "unable to execute");
- }
- }
- void
- MySqlHostDataSourceImpl::addResv(const IPv6Resrv& resv,
- const HostID& id) {
- std::vector<MYSQL_BIND> bind =
- host_ipv6_reservation_exchange_->createBindForSend(resv, id);
- addQuery(MySqlHostDataSource::INSERT_V6_RESRV, bind);
- }
- void
- MySqlHostDataSourceImpl::
- checkError(const int status, const MySqlHostDataSource::StatementIndex index,
- const char* what) const {
- if (status != 0) {
- isc_throw(DbOperationError, what << " for <"
- << conn_.text_statements_[index] << ">, reason: "
- << mysql_error(conn_.mysql_) << " (error code "
- << mysql_errno(conn_.mysql_) << ")");
- }
- }
- void
- MySqlHostDataSourceImpl::
- getHostCollection(MySqlHostDataSource::StatementIndex stindex,
- MYSQL_BIND* bind, boost::shared_ptr<MySqlHostExchange> exchange,
- ConstHostCollection& result, bool single) const {
-
- int status = mysql_stmt_bind_param(conn_.statements_[stindex], bind);
- checkError(status, stindex, "unable to bind WHERE clause parameter");
-
-
- std::vector<MYSQL_BIND> outbind = exchange->createBindForReceive();
- status = mysql_stmt_bind_result(conn_.statements_[stindex], &outbind[0]);
- checkError(status, stindex, "unable to bind SELECT clause parameters");
-
- status = mysql_stmt_execute(conn_.statements_[stindex]);
- checkError(status, stindex, "unable to execute");
-
-
- status = mysql_stmt_store_result(conn_.statements_[stindex]);
- checkError(status, stindex, "unable to set up for storing all results");
-
-
-
-
- MySqlFreeResult fetch_release(conn_.statements_[stindex]);
- while ((status = mysql_stmt_fetch(conn_.statements_[stindex])) ==
- MLM_MYSQL_FETCH_SUCCESS) {
- try {
- exchange->processFetchedData(result);
- } catch (const isc::BadValue& ex) {
-
- isc_throw(BadValue, ex.what() << ". Statement is <" <<
- conn_.text_statements_[stindex] << ">");
- }
- if (single && (result.size() > 1)) {
- isc_throw(MultipleRecords, "multiple records were found in the "
- "database where only one was expected for query "
- << conn_.text_statements_[stindex]);
- }
- }
-
-
- if (status == MLM_MYSQL_FETCH_FAILURE) {
-
- checkError(status, stindex, "unable to fetch results");
- } else if (status == MYSQL_DATA_TRUNCATED) {
-
- isc_throw(DataTruncated, conn_.text_statements_[stindex]
- << " returned truncated data: columns affected are "
- << exchange->getErrorColumns());
- }
- }
- ConstHostPtr
- MySqlHostDataSourceImpl::
- getHost(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len,
- MySqlHostDataSource::StatementIndex stindex,
- boost::shared_ptr<MySqlHostExchange> exchange) const {
-
- MYSQL_BIND inbind[3];
- memset(inbind, 0, sizeof(inbind));
- uint32_t subnet_buffer = static_cast<uint32_t>(subnet_id);
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
- inbind[0].is_unsigned = MLM_TRUE;
-
- std::vector<char> identifier_vec(identifier_begin,
- identifier_begin + identifier_len);
- unsigned long length = identifier_vec.size();
- inbind[2].buffer_type = MYSQL_TYPE_BLOB;
- inbind[2].buffer = &identifier_vec[0];
- inbind[2].buffer_length = length;
- inbind[2].length = &length;
-
- char identifier_type_copy = static_cast<char>(identifier_type);
- inbind[1].buffer_type = MYSQL_TYPE_TINY;
- inbind[1].buffer = reinterpret_cast<char*>(&identifier_type_copy);
- inbind[1].is_unsigned = MLM_TRUE;
- ConstHostCollection collection;
- getHostCollection(stindex, inbind, exchange, collection, true);
-
- ConstHostPtr result;
- if (!collection.empty())
- result = *collection.begin();
- return (result);
- }
- MySqlHostDataSource::
- MySqlHostDataSource(const MySqlConnection::ParameterMap& parameters)
- : impl_(new MySqlHostDataSourceImpl(parameters)) {
- }
- MySqlHostDataSource::~MySqlHostDataSource() {
- delete impl_;
- }
- void
- MySqlHostDataSource::add(const HostPtr& host) {
-
- std::vector<MYSQL_BIND> bind = impl_->host_exchange_->createBindForSend(host);
-
- impl_->addQuery(INSERT_HOST, bind);
- IPv6ResrvRange v6resv = host->getIPv6Reservations();
- if (std::distance(v6resv.first, v6resv.second) == 0) {
-
- return;
- }
-
- uint64_t host_id = mysql_insert_id(impl_->conn_.mysql_);
- for (IPv6ResrvIterator resv = v6resv.first; resv != v6resv.second;
- ++resv) {
- impl_->addResv(resv->second, host_id);
- }
- }
- ConstHostCollection
- MySqlHostDataSource::getAll(const HWAddrPtr& hwaddr,
- const DuidPtr& duid) const {
- if (duid){
- return (getAll(Host::IDENT_DUID, &duid->getDuid()[0],
- duid->getDuid().size()));
- } else if (hwaddr) {
- return (getAll(Host::IDENT_HWADDR,
- &hwaddr->hwaddr_[0],
- hwaddr->hwaddr_.size()));
- }
- return (ConstHostCollection());
- }
- ConstHostCollection
- MySqlHostDataSource::getAll(const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const {
-
- MYSQL_BIND inbind[2];
- memset(inbind, 0, sizeof(inbind));
-
- char identifier_type_copy = static_cast<char>(identifier_type);
- inbind[1].buffer = &identifier_type_copy;
- inbind[1].buffer_type = MYSQL_TYPE_TINY;
- inbind[1].is_unsigned = MLM_TRUE;
-
- std::vector<char> identifier_vec(identifier_begin,
- identifier_begin + identifier_len);
- unsigned long int length = identifier_vec.size();
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = &identifier_vec[0];
- inbind[0].buffer_length = length;
- inbind[0].length = &length;
- ConstHostCollection result;
- impl_->getHostCollection(GET_HOST_DHCPID, inbind,
- impl_->host_ipv6_exchange_,
- result, false);
- return (result);
- }
- ConstHostCollection
- MySqlHostDataSource::getAll4(const asiolink::IOAddress& address) const {
-
- MYSQL_BIND inbind[1];
- memset(inbind, 0, sizeof(inbind));
- uint32_t addr4 = static_cast<uint32_t>(address);
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&addr4);
- inbind[0].is_unsigned = MLM_TRUE;
- ConstHostCollection result;
- impl_->getHostCollection(GET_HOST_ADDR, inbind, impl_->host_exchange_,
- result, false);
- return (result);
- }
- ConstHostPtr
- MySqlHostDataSource::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
- const DuidPtr& duid) const {
-
- if (hwaddr && duid) {
- isc_throw(BadValue, "MySQL host data source get4() called with both"
- " hwaddr and duid, only one of them is allowed");
- }
- if (!hwaddr && !duid) {
- isc_throw(BadValue, "MySQL host data source get4() called with "
- "neither hwaddr or duid specified, one of them is required");
- }
-
- if (hwaddr) {
- return (get4(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
- hwaddr->hwaddr_.size()));
- } else if (duid) {
- return (get4(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
- duid->getDuid().size()));
- }
- return (ConstHostPtr());
- }
- ConstHostPtr
- MySqlHostDataSource::get4(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const {
- return (impl_->getHost(subnet_id, identifier_type, identifier_begin,
- identifier_len, GET_HOST_SUBID4_DHCPID,
- impl_->host_exchange_));
- }
- ConstHostPtr
- MySqlHostDataSource::get4(const SubnetID& subnet_id,
- const asiolink::IOAddress& address) const {
-
- MYSQL_BIND inbind[2];
- uint32_t subnet = subnet_id;
- memset(inbind, 0, sizeof(inbind));
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&subnet);
- inbind[0].is_unsigned = MLM_TRUE;
- uint32_t addr4 = static_cast<uint32_t>(address);
- inbind[1].buffer_type = MYSQL_TYPE_LONG;
- inbind[1].buffer = reinterpret_cast<char*>(&addr4);
- inbind[1].is_unsigned = MLM_TRUE;
- ConstHostCollection collection;
- impl_->getHostCollection(GET_HOST_SUBID_ADDR, inbind, impl_->host_exchange_,
- collection, true);
-
- ConstHostPtr result;
- if (!collection.empty())
- result = *collection.begin();
- return (result);
- }
- ConstHostPtr
- MySqlHostDataSource::get6(const SubnetID& subnet_id, const DuidPtr& duid,
- const HWAddrPtr& hwaddr) const {
-
- if (hwaddr && duid) {
- isc_throw(BadValue, "MySQL host data source get6() called with both"
- " hwaddr and duid, only one of them is allowed");
- }
- if (!hwaddr && !duid) {
- isc_throw(BadValue, "MySQL host data source get6() called with "
- "neither hwaddr or duid specified, one of them is required");
- }
-
- if (hwaddr) {
- return (get6(subnet_id, Host::IDENT_HWADDR, &hwaddr->hwaddr_[0],
- hwaddr->hwaddr_.size()));
- } else if (duid) {
- return (get6(subnet_id, Host::IDENT_DUID, &duid->getDuid()[0],
- duid->getDuid().size()));
- }
- return (ConstHostPtr());
- }
- ConstHostPtr
- MySqlHostDataSource::get6(const SubnetID& subnet_id,
- const Host::IdentifierType& identifier_type,
- const uint8_t* identifier_begin,
- const size_t identifier_len) const {
- return (impl_->getHost(subnet_id, identifier_type, identifier_begin,
- identifier_len, GET_HOST_SUBID6_DHCPID,
- impl_->host_ipv6_exchange_));
- }
- ConstHostPtr
- MySqlHostDataSource::get6(const asiolink::IOAddress& prefix,
- const uint8_t prefix_len) const {
-
- MYSQL_BIND inbind[2];
- memset(inbind, 0, sizeof(inbind));
- std::string addr6 = prefix.toText();
- unsigned long addr6_length = addr6.size();
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = reinterpret_cast<char*>
- (const_cast<char*>(addr6.c_str()));
- inbind[0].length = &addr6_length;
- inbind[0].buffer_length = addr6_length;
- uint8_t tmp = prefix_len;
- inbind[1].buffer_type = MYSQL_TYPE_TINY;
- inbind[1].buffer = reinterpret_cast<char*>(&tmp);
- inbind[1].is_unsigned = MLM_TRUE;
- ConstHostCollection collection;
- impl_->getHostCollection(GET_HOST_PREFIX, inbind,
- impl_->host_ipv6_exchange_,
- collection, true);
-
- ConstHostPtr result;
- if (!collection.empty()) {
- result = *collection.begin();
- }
- return (result);
- }
- std::string MySqlHostDataSource::getName() const {
- std::string name = "";
- try {
- name = impl_->conn_.getParameter("name");
- } catch (...) {
-
- }
- return (name);
- }
- std::string MySqlHostDataSource::getDescription() const {
- return (std::string("Host data source that stores host information"
- "in MySQL database"));
- }
- std::pair<uint32_t, uint32_t> MySqlHostDataSource::getVersion() const {
- const StatementIndex stindex = GET_VERSION;
- LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_MYSQL_HOST_DB_GET_VERSION);
- uint32_t major;
- uint32_t minor;
-
- int status = mysql_stmt_execute(impl_->conn_.statements_[stindex]);
- if (status != 0) {
- isc_throw(DbOperationError, "unable to execute <"
- << impl_->conn_.text_statements_[stindex]
- << "> - reason: " << mysql_error(impl_->conn_.mysql_));
- }
-
- MYSQL_BIND bind[2];
- memset(bind, 0, sizeof(bind));
- bind[0].buffer_type = MYSQL_TYPE_LONG;
- bind[0].is_unsigned = 1;
- bind[0].buffer = &major;
- bind[0].buffer_length = sizeof(major);
- bind[1].buffer_type = MYSQL_TYPE_LONG;
- bind[1].is_unsigned = 1;
- bind[1].buffer = &minor;
- bind[1].buffer_length = sizeof(minor);
- status = mysql_stmt_bind_result(impl_->conn_.statements_[stindex], bind);
- if (status != 0) {
- isc_throw(DbOperationError, "unable to bind result set: "
- << mysql_error(impl_->conn_.mysql_));
- }
-
-
-
- MySqlFreeResult fetch_release(impl_->conn_.statements_[stindex]);
- status = mysql_stmt_fetch(impl_->conn_.statements_[stindex]);
- if (status != 0) {
- isc_throw(DbOperationError, "unable to obtain result set: "
- << mysql_error(impl_->conn_.mysql_));
- }
- return (std::make_pair(major, minor));
- }
- void
- MySqlHostDataSource::commit() {
- impl_->conn_.commit();
- }
- void
- MySqlHostDataSource::rollback() {
- impl_->conn_.rollback();
- }
- };
- };
|