From: Bjoern Sikora Date: Thu, 17 Sep 2009 13:30:53 +0000 (+0200) Subject: Update A record. An update operation is not available, an IP update must be done... X-Git-Tag: v1.1~183 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=c12475373cf9038e60831ba05918a1820aa26930;p=bpdyndnsd Update A record. An update operation is not available, an IP update must be done through DELRR and ADDRR. --- diff --git a/src/service_ods.cpp b/src/service_ods.cpp index e69abd8..a586c0b 100644 --- a/src/service_ods.cpp +++ b/src/service_ods.cpp @@ -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);