Parcourir la source

[4552] Updated MySQL to insert/retrieve DHCP4 msg fields.

These fields are: siaddr, sname and file.
Marcin Siodelski il y a 8 ans
Parent
commit
fa40765e93
1 fichiers modifiés avec 73 ajouts et 3 suppressions
  1. 73 3
      src/lib/dhcpsrv/mysql_host_data_source.cc

+ 73 - 3
src/lib/dhcpsrv/mysql_host_data_source.cc

@@ -61,6 +61,12 @@ const size_t OPTION_FORMATTED_VALUE_MAX_LEN = 8192;
 /// @brief Maximum length of option space name.
 /// @brief Maximum length of option space name.
 const size_t OPTION_SPACE_MAX_LEN = 128;
 const size_t OPTION_SPACE_MAX_LEN = 128;
 
 
+/// @brief Maximum length of the server hostname.
+const size_t SERVER_HOSTNAME_MAX_LEN = 64;
+
+/// @brief Maximum length of the boot file name.
+const size_t BOOT_FILE_NAME_MAX_LEN = 128;
+
 /// @brief Numeric value representing last supported identifier.
 /// @brief Numeric value representing last supported identifier.
 ///
 ///
 /// This value is used to validate whether the identifier type stored in
 /// This value is used to validate whether the identifier type stored in
@@ -79,7 +85,7 @@ class MySqlHostExchange {
 private:
 private:
 
 
     /// @brief Number of columns returned for SELECT queries send by this class.
     /// @brief Number of columns returned for SELECT queries send by this class.
-    static const size_t HOST_COLUMNS = 9;
+    static const size_t HOST_COLUMNS = 12;
 
 
 public:
 public:
 
 
@@ -97,11 +103,17 @@ public:
           dhcp4_subnet_id_(0), dhcp6_subnet_id_(0), ipv4_address_(0),
           dhcp4_subnet_id_(0), dhcp6_subnet_id_(0), ipv4_address_(0),
           hostname_length_(0), dhcp4_client_classes_length_(0),
           hostname_length_(0), dhcp4_client_classes_length_(0),
           dhcp6_client_classes_length_(0),
           dhcp6_client_classes_length_(0),
+          dhcp4_next_server_(0),
+          dhcp4_server_hostname_length_(0),
+          dhcp4_boot_file_name_length_(0),
           dhcp4_subnet_id_null_(MLM_FALSE),
           dhcp4_subnet_id_null_(MLM_FALSE),
           dhcp6_subnet_id_null_(MLM_FALSE),
           dhcp6_subnet_id_null_(MLM_FALSE),
           ipv4_address_null_(MLM_FALSE), hostname_null_(MLM_FALSE),
           ipv4_address_null_(MLM_FALSE), hostname_null_(MLM_FALSE),
           dhcp4_client_classes_null_(MLM_FALSE),
           dhcp4_client_classes_null_(MLM_FALSE),
-          dhcp6_client_classes_null_(MLM_FALSE) {
+          dhcp6_client_classes_null_(MLM_FALSE),
+          dhcp4_next_server_null_(MLM_FALSE),
+          dhcp4_server_hostname_null_(MLM_FALSE),
+          dhcp4_boot_file_name_null_(MLM_FALSE) {
 
 
         // Fill arrays with 0 so as they don't include any garbage.
         // Fill arrays with 0 so as they don't include any garbage.
         memset(dhcp_identifier_buffer_, 0, sizeof(dhcp_identifier_buffer_));
         memset(dhcp_identifier_buffer_, 0, sizeof(dhcp_identifier_buffer_));
@@ -121,8 +133,11 @@ public:
         columns_[6] = "hostname";
         columns_[6] = "hostname";
         columns_[7] = "dhcp4_client_classes";
         columns_[7] = "dhcp4_client_classes";
         columns_[8] = "dhcp6_client_classes";
         columns_[8] = "dhcp6_client_classes";
+        columns_[9] = "dhcp4_next_server";
+        columns_[10] = "dhcp4_server_hostname";
+        columns_[11] = "dhcp4_boot_file_name";
 
 
-        BOOST_STATIC_ASSERT(8 < HOST_COLUMNS);
+        BOOST_STATIC_ASSERT(11 < HOST_COLUMNS);
     };
     };
 
 
     /// @brief Virtual destructor.
     /// @brief Virtual destructor.
@@ -397,6 +412,31 @@ public:
         bind_[8].length = &dhcp6_client_classes_length_;
         bind_[8].length = &dhcp6_client_classes_length_;
         bind_[8].is_null = &dhcp6_client_classes_null_;
         bind_[8].is_null = &dhcp6_client_classes_null_;
 
 
+        // dhcp4_next_server
+        dhcp4_next_server_null_ = MLM_FALSE;
+        bind_[9].buffer_type = MYSQL_TYPE_LONG;
+        bind_[9].buffer = reinterpret_cast<char*>(&dhcp4_next_server_);
+        bind_[9].is_unsigned = MLM_TRUE;
+        bind_[9].is_null = &dhcp4_next_server_null_;
+
+        // dhcp4_server_hostname
+        dhcp4_server_hostname_null_ = MLM_FALSE;
+        dhcp4_server_hostname_length_ = sizeof(dhcp4_server_hostname_);
+        bind_[10].buffer_type = MYSQL_TYPE_STRING;
+        bind_[10].buffer = reinterpret_cast<char*>(dhcp4_server_hostname_);
+        bind_[10].buffer_length = dhcp4_server_hostname_length_;
+        bind_[10].length = &dhcp4_server_hostname_length_;
+        bind_[10].is_null = &dhcp4_server_hostname_null_;
+
+        // dhcp4_boot_file_name
+        dhcp4_boot_file_name_null_ = MLM_FALSE;
+        dhcp4_boot_file_name_length_ = sizeof(dhcp4_boot_file_name_);
+        bind_[11].buffer_type = MYSQL_TYPE_STRING;
+        bind_[11].buffer = reinterpret_cast<char*>(dhcp4_boot_file_name_);
+        bind_[11].buffer_length = dhcp4_boot_file_name_length_;
+        bind_[11].length = &dhcp4_boot_file_name_length_;
+        bind_[11].is_null = &dhcp4_boot_file_name_null_;
+
         // Add the error flags
         // Add the error flags
         setErrorIndicators(bind_, error_);
         setErrorIndicators(bind_, error_);
 
 
@@ -578,6 +618,21 @@ private:
     /// client classes.
     /// client classes.
     unsigned long dhcp6_client_classes_length_;
     unsigned long dhcp6_client_classes_length_;
 
 
+    /// Next server address (siaddr).
+    uint32_t dhcp4_next_server_;
+
+    /// Server hostname (sname).
+    char dhcp4_server_hostname_[SERVER_HOSTNAME_MAX_LEN];
+
+    /// A length of the string holding server hostname.
+    unsigned long dhcp4_server_hostname_length_;
+
+    /// Boot file name (file).
+    char dhcp4_boot_file_name_[BOOT_FILE_NAME_MAX_LEN];
+
+    /// A length of the string holding boot file name.
+    unsigned long dhcp4_boot_file_name_length_;
+
     /// @name Boolean values indicating if values of specific columns in
     /// @name Boolean values indicating if values of specific columns in
     /// the database are NULL.
     /// the database are NULL.
     //@{
     //@{
@@ -601,6 +656,15 @@ private:
     /// NULL.
     /// NULL.
     my_bool dhcp6_client_classes_null_;
     my_bool dhcp6_client_classes_null_;
 
 
+    /// Boolean flag indicating if the value of next server is NULL.
+    my_bool dhcp4_next_server_null_;
+
+    /// Boolean flag indicating if the value of server hostname is NULL.
+    my_bool dhcp4_server_hostname_null_;
+
+    /// Boolean flag indicating if the value of boot file name is NULL.
+    my_bool dhcp4_boot_file_name_null_;
+
     //@}
     //@}
 
 
 };
 };
@@ -1817,6 +1881,7 @@ TaggedStatement tagged_statements[] = {
             "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
             "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
                 "h.dhcp4_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, "
                 "h.dhcp4_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, "
                 "h.hostname, h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.hostname, h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o4.option_id, o4.code, o4.value, o4.formatted_value, o4.space, "
                 "o4.option_id, o4.code, o4.value, o4.formatted_value, o4.space, "
                 "o4.persistent, "
                 "o4.persistent, "
                 "o6.option_id, o6.code, o6.value, o6.formatted_value, o6.space, "
                 "o6.option_id, o6.code, o6.value, o6.formatted_value, o6.space, "
@@ -1840,6 +1905,7 @@ TaggedStatement tagged_statements[] = {
             "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
             "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_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.persistent "
                 "o.persistent "
             "FROM hosts AS h "
             "FROM hosts AS h "
@@ -1855,6 +1921,7 @@ TaggedStatement tagged_statements[] = {
             "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
             "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_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.persistent "
                 "o.persistent "
             "FROM hosts AS h "
             "FROM hosts AS h "
@@ -1872,6 +1939,7 @@ TaggedStatement tagged_statements[] = {
                 "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
                 "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
                 "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.persistent, "
                 "o.persistent, "
                 "r.reservation_id, r.address, r.prefix_len, r.type, "
                 "r.reservation_id, r.address, r.prefix_len, r.type, "
@@ -1893,6 +1961,7 @@ TaggedStatement tagged_statements[] = {
             "SELECT h.host_id, h.dhcp_identifier, h.dhcp_identifier_type, "
             "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_subnet_id, h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.persistent "
                 "o.persistent "
             "FROM hosts AS h "
             "FROM hosts AS h "
@@ -1912,6 +1981,7 @@ TaggedStatement tagged_statements[] = {
                 "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
                 "h.dhcp_identifier_type, h.dhcp4_subnet_id, "
                 "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
                 "h.dhcp4_client_classes, h.dhcp6_client_classes, "
+                "h.dhcp4_next_server, h.dhcp4_server_hostname, h.dhcp4_boot_file_name, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.option_id, o.code, o.value, o.formatted_value, o.space, "
                 "o.persistent, "
                 "o.persistent, "
                 "r.reservation_id, r.address, r.prefix_len, r.type, "
                 "r.reservation_id, r.address, r.prefix_len, r.type, "