Update A record. An update operation is not available, an IP update must be done...
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 13:30:53 +0000 (15:30 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 13:30:53 +0000 (15:30 +0200)
src/service_ods.cpp

index e69abd8..a586c0b 100644 (file)
@@ -115,20 +115,39 @@ int ServiceOds::perform_update(const std::string& ip)
 
     // Successfully loged in, status_code should be 225
 
+    // Perform delete operation until there is no RR or we have performed it 10 times.
+    int count = 0;
+    string delete_reply, reply_code;
+    ostringstream delete_request;
+    delete_request << "DELRR " << get_hostname() << " A " << endl;
+    do
+    {
+        // Send delete request
+        if (connection->send_data(delete_request.str()))
+            return -1;
+        // Get delete reply
+        delete_reply = connection->receive_data();
+        if ( delete_reply.empty() )
+            return -1;
+        count++;
+        reply_code = Util::parse_status_code(delete_reply);
+    }while ( (count < 10) && (reply_code != "300") );
+
+
     // Send update request
     ostringstream update_request;
-    update_request << "ADDRR " << get_hostname() << " NS " << ip << endl;
+    update_request << "ADDRR " << get_hostname() << " A " << ip << endl;
     if (connection->send_data(update_request.str()))
         return -1;
 
     // Receive update request server reply
     string update_reply = connection->receive_data();
-    if ( server_greeting.empty() )
+    if ( update_reply.empty() )
         return -1;
     else
     {
         // Get the return code out of the received data
-        string status_code = Util::parse_status_code(login_reply);
+        string status_code = Util::parse_status_code(update_reply);
         if ( status_code != "795" )
         {
             get_logger()->print_undefined_protocol_error("ODS",update_reply);