diff --git a/DataItem.h b/DataItem.h index 9fa2036..1aac8d7 100644 --- a/DataItem.h +++ b/DataItem.h @@ -488,7 +488,8 @@ class DataItem const ProtocolConfig * protocfg; }; - +///shorthand for a vector of DataItem +typedef std::vector DataItems; } // namespace LLDLEP diff --git a/DestAdvert.cpp b/DestAdvert.cpp index 09b9203..c2cad77 100644 --- a/DestAdvert.cpp +++ b/DestAdvert.cpp @@ -62,7 +62,11 @@ DlepMessageBuffer DestAdvert::get_message_to_send(unsigned int * msg_len) time(NULL) - begin_time, // uptime ++seq_num, // seqnum local_rfid, // our radio id - destinations); // advertised destinations + destinations, // advertised destinations + localPeerIpv4DataItems, // advertised ipv4 dataitems + localPeerIpv4SnDataItems, // advertised ipv4 subnet dataitems + localPeerIpv6DataItems, // advertised ipv6 dataitems + localPeerIpv6SnDataItems);// advertised ipv6 subnet dataitems auto result = build_destination_advert(info); @@ -106,7 +110,7 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, return; } - auto result = unbuild_destination_advert(msg_buffer.get(), msg_buffer_len); + auto result = unbuild_destination_advert(msg_buffer.get(), msg_buffer_len, dlep); if (! result.first) { @@ -132,14 +136,19 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, LOG(DLEP_LOG_INFO, std::ostringstream("new destination advertisement entry!")); - DataItems empty_data_items; + // insert the ip data items to DataItems + DataItems dataItems = dainfo.ipv4DataItems; + dataItems.insert(dataItems.end(), dainfo.ipv4SnDataItems.begin(), dainfo.ipv4SnDataItems.end()); + dataItems.insert(dataItems.end(), dainfo.ipv6DataItems.begin(), dainfo.ipv6DataItems.end()); + dataItems.insert(dataItems.end(), dainfo.ipv6SnDataItems.begin(), dainfo.ipv6SnDataItems.end()); + // new entry, save timestamp and advertisement info dest_advert_db[dainfo.rfId] = DestAdvertDBEntry {time(NULL), DestAdvertDBEntry::EntryState::down, false, dainfo, - empty_data_items + dataItems }; } else @@ -152,7 +161,6 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, // update timestamp entry.timestamp = time(NULL); - if (entry.estate == DestAdvertDBEntry::EntryState::up) { DlepMacAddrs added, deleted; @@ -163,6 +171,17 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, getDifference(dainfo.destinations, entry.info.destinations, added); + msg << "added size " << added.size(); + for (auto it = dainfo.destinations.begin(); it != dainfo.destinations.end(); ++it) + { + msg << " dainfo.destinations" << *it; + } + for (auto it = entry.info.destinations.begin(); it != entry.info.destinations.end(); ++it) + { + msg << " entry.info.destinations" << *it; + } + LOG(DLEP_LOG_DEBUG, msg); + for (const DlepMac & mac : added) { if (! dlep->local_pdp->addDestination(mac, entry.data_items, @@ -173,14 +192,62 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, } } + //update the entry info dataitems with ip dataitems that were just received + std::vector ipParameters = {dainfo.ipv4DataItems, dainfo.ipv4SnDataItems, dainfo.ipv6DataItems, dainfo.ipv6SnDataItems}; + for (auto dataItems : ipParameters) + { + DataItems ipdisAdd, ipdisRemove; + for (auto ipdi : dataItems) + { + DataItem::IPFlags ipAdded = ipdi.ip_flags(); + //if ip add, then we need to add all new and unique id data items + if (ipAdded == DataItem::IPFlags::add) + { + bool isNewIpDi = true; + for (auto di : entry.data_items) + { + if (di == ipdi) + { + isNewIpDi = false; + } + } + if (isNewIpDi) + { + //add only new ip dataitems + ipdisAdd.push_back(ipdi); + } + } + else //if ip drop remove this ip data item + { + for (auto di : entry.data_items) + { + if (ipdi.ip_equal(di)) + { + ipdisRemove.push_back(di); + } + } + } + } + entry.data_items.insert(entry.data_items.end(), ipdisAdd.begin(), ipdisAdd.end()); + for (auto ipdir : ipdisRemove) + { + entry.data_items.erase(std::remove(entry.data_items.begin(), entry.data_items.end(), ipdir), entry.data_items.end()); + } + } + // handle destinations that were deleted by this advertisement // old - new = deleted getDifference(entry.info.destinations, dainfo.destinations, deleted); + msg << "deleted size " << deleted.size(); + LOG(DLEP_LOG_DEBUG, msg); + + for (const DlepMac & mac : deleted) { + entry.data_items.clear(); if (! dlep->local_pdp->removeDestination(mac, true)) { msg << "destination " << mac << " does not exist"; @@ -188,7 +255,6 @@ void DestAdvert::handle_message(DlepMessageBuffer msg_buffer, } } } - // update the entry info to what was just received entry.info = dainfo; } @@ -207,6 +273,47 @@ void DestAdvert::add_destination(const LLDLEP::DlepMac & mac) destinations.insert(mac); } +void DestAdvert::add_dataitem(const LLDLEP::DataItem & di) +{ + LOG(DLEP_LOG_INFO, std::ostringstream(di.to_string())); + + DataItems* selfDataItems(nullptr); + if (di.name() == ProtocolStrings::IPv4_Address) + { + selfDataItems = &localPeerIpv4DataItems; + }else if (di.name() == ProtocolStrings::IPv4_Attached_Subnet) + { + selfDataItems = &localPeerIpv4SnDataItems; + }else if (di.name() == ProtocolStrings::IPv6_Address) + { + selfDataItems = &localPeerIpv6DataItems; + }else if (di.name() == ProtocolStrings::IPv6_Attached_Subnet) + { + selfDataItems = &localPeerIpv6SnDataItems; + } + + DataItems ipdisRemove; + for (auto diRemove : *selfDataItems) + { + if (diRemove.ip_equal(di)) + { + ipdisRemove.push_back(diRemove); + } + } + for (auto diRemove : ipdisRemove) + { + selfDataItems->erase(std::remove(selfDataItems->begin(), selfDataItems->end(), diRemove), selfDataItems->end()); + } + selfDataItems->push_back(di); +} + +void DestAdvert::clear_ipdataitems() +{ + localPeerIpv4DataItems.erase(localPeerIpv4DataItems.begin(), localPeerIpv4DataItems.end()); + localPeerIpv4SnDataItems.erase(localPeerIpv4SnDataItems.begin(), localPeerIpv4SnDataItems.end()); + localPeerIpv6DataItems.erase(localPeerIpv6DataItems.begin(), localPeerIpv6DataItems.end()); + localPeerIpv6SnDataItems.erase(localPeerIpv6SnDataItems.begin(), localPeerIpv6SnDataItems.end()); +} void DestAdvert::del_destination(const LLDLEP::DlepMac & mac) { @@ -289,7 +396,38 @@ DestAdvert::update_advert_entry_data_items(const DlepMac & rfId, if (iter != dest_advert_db.end()) { DestAdvertDBEntry & entry = iter->second; - entry.data_items = data_items; + DataItems ip_data_items; + //save aside all ip data items + for (auto di : entry.data_items) + { + if (di.name() == ProtocolStrings::IPv4_Address + || di.name() == ProtocolStrings::IPv4_Attached_Subnet + || di.name() == ProtocolStrings::IPv6_Address + || di.name() == ProtocolStrings::IPv6_Attached_Subnet) + { + ip_data_items.push_back(di); + msg << "updating ipdataitems=" << di.to_string(); + LOG(DLEP_LOG_INFO, msg); + } + } + + //clean entry + entry.data_items.erase(entry.data_items.begin(), entry.data_items.end()); + + //add all new data items wich are not ip + for (auto di : data_items) + { + if (di.name() != ProtocolStrings::IPv4_Address + && di.name() != ProtocolStrings::IPv4_Attached_Subnet + && di.name() != ProtocolStrings::IPv6_Address + && di.name() != ProtocolStrings::IPv6_Attached_Subnet) + { + entry.data_items.push_back(di); + } + } + + //add ip data items that we saved aside + entry.data_items.insert(entry.data_items.end(), ip_data_items.begin(), ip_data_items.end()); } else { diff --git a/DestAdvert.h b/DestAdvert.h index bc065e4..498672c 100644 --- a/DestAdvert.h +++ b/DestAdvert.h @@ -58,6 +58,16 @@ class DestAdvert : public PeriodicMcastSendRcv /// @param[in] dest the destination to add void add_destination(const LLDLEP::DlepMac & dest); + /// Add a data item to future dataitems advertisements + /// sent by this process. + /// + /// @param[in] di the dataitem to add + void add_dataitem(const LLDLEP::DataItem & di); + + /// Remove all ipdataitems from future destination advertisements + /// sent by this process. + void clear_ipdataitems(); + /// Remove a destination from future destination advertisements /// sent by this process. /// @@ -134,6 +144,22 @@ class DestAdvert : public PeriodicMcastSendRcv /// including the peer router mac LLDLEP::DlepMacAddrs destinations; + /// any local ipv4 to put in destination advertisments, + /// including the peer router ipv4 + LLDLEP::DataItems localPeerIpv4DataItems; + + /// any local ipv4 subnet to put in destination advertisments, + /// including the peer router ipv4 subnet + LLDLEP::DataItems localPeerIpv4SnDataItems; + + /// any local ipv6 to put in destination advertisments, + /// including the peer router ipv6 + LLDLEP::DataItems localPeerIpv6DataItems; + + /// any local ipv6 subnet to put in destination advertisments, + /// including the peer router ipv6 subnet + LLDLEP::DataItems localPeerIpv6SnDataItems; + /// mutex that should be locked whenever dest_advert_db is accessed boost::recursive_mutex dest_advert_mutex; diff --git a/DestAdvertInfo.h b/DestAdvertInfo.h index a5edfd5..96ee7ae 100644 --- a/DestAdvertInfo.h +++ b/DestAdvertInfo.h @@ -30,6 +30,10 @@ struct DestAdvertInfo std::uint32_t sequenceNumber; LLDLEP::DlepMac rfId; LLDLEP::DlepMacAddrs destinations; + LLDLEP::DataItems ipv4DataItems; + LLDLEP::DataItems ipv4SnDataItems; + LLDLEP::DataItems ipv6DataItems; + LLDLEP::DataItems ipv6SnDataItems; DestAdvertInfo() : reportInterval {}, @@ -41,12 +45,20 @@ struct DestAdvertInfo time_t uptm, std::uint32_t seq, const LLDLEP::DlepMac & id, - const LLDLEP::DlepMacAddrs & dests) : + const LLDLEP::DlepMacAddrs & dests, + const LLDLEP::DataItems & ipv4Dest, + const LLDLEP::DataItems & ipv4SnDest, + const LLDLEP::DataItems & ipv6Dest, + const LLDLEP::DataItems & ipv6SnDest) : reportInterval {interval}, uptime {uptm}, sequenceNumber {seq}, rfId(id), - destinations(dests) + destinations(dests), + ipv4DataItems(ipv4Dest), + ipv4SnDataItems(ipv4SnDest), + ipv6DataItems(ipv6Dest), + ipv6SnDataItems(ipv6SnDest) { } std::string to_string() const @@ -64,6 +76,26 @@ struct DestAdvertInfo ss << dest.to_string() << ", "; } + for (auto ipdi : ipv4DataItems) + { + ss << ipdi.to_string() << ", "; + } + + for (auto ipdi : ipv4SnDataItems) + { + ss << ipdi.to_string() << ", "; + } + + for (auto ipdi : ipv6DataItems) + { + ss << ipdi.to_string() << ", "; + } + + for (auto ipdi : ipv6SnDataItems) + { + ss << ipdi.to_string() << ", "; + } + return ss.str(); } }; diff --git a/DestAdvertMessage.h b/DestAdvertMessage.h index 472e8cc..44e6f88 100644 --- a/DestAdvertMessage.h +++ b/DestAdvertMessage.h @@ -38,6 +38,30 @@ void doCopyMacToSTR(const LLDLEP::DlepMac & mac, std::string & str) str[i] = static_cast(mac.mac_addr[i]); } } + +void doCopyStrToIpdi(const std::string & str, LLDLEP::DataItem & ipdi) +{ + std::vector ipdi_ser; + ipdi_ser.resize(str.size()); + for (size_t i = 0; i < str.size(); i++) + { + ipdi_ser[i] = str[i]; + } + std::vector::const_iterator it = ipdi_ser.begin(); + std::vector::const_iterator it_end = ipdi_ser.end(); + + ipdi.deserialize(it, it_end); +} + +void doCopyIpdiToSTR(const LLDLEP::DataItem & ipdi, std::string & str) +{ + std::vector ipdi_ser = ipdi.serialize(); + str.resize(ipdi_ser.size()); + for (size_t i = 0; i < ipdi_ser.size(); ++i) + { + str[i] = static_cast(ipdi_ser[i]); + } +} } @@ -71,6 +95,34 @@ inline std::pair build_destination_advert( da.add_destinations(s); } + for (auto ipdi : info.ipv4DataItems) + { + std::string s; + doCopyIpdiToSTR(ipdi, s); + da.add_ipv4dataitems(s); + } + + for (auto ipdi : info.ipv4SnDataItems) + { + std::string s; + doCopyIpdiToSTR(ipdi, s); + da.add_ipv4sndataitems(s); + } + + for (auto ipdi : info.ipv6DataItems) + { + std::string s; + doCopyIpdiToSTR(ipdi, s); + da.add_ipv6dataitems(s); + } + + for (auto ipdi : info.ipv6SnDataItems) + { + std::string s; + doCopyIpdiToSTR(ipdi, s); + da.add_ipv6sndataitems(s); + } + const bool rc = da.SerializeToString(&str); return std::pair(rc, str); @@ -78,8 +130,10 @@ inline std::pair build_destination_advert( // un-build/de-serialize for reading +// need to transfer DlepPtr parameter for getting the protocfg, +// for construct the dataitem. inline std::pair unbuild_destination_advert( - const uint8_t * buff, size_t len) + const uint8_t * buff, size_t len, DlepPtr dlep) { DestAdvertInfo info; @@ -105,6 +159,34 @@ inline std::pair unbuild_destination_advert( info.destinations.insert(mac); } + + for (int i = 0; i < da.ipv4dataitems_size(); ++i) + { + DataItem ipdi(ProtocolStrings::IPv4_Address, dlep->protocfg); + doCopyStrToIpdi(da.ipv4dataitems(i), ipdi); + info.ipv4DataItems.push_back(ipdi); + } + + for (int i = 0; i < da.ipv4sndataitems_size(); ++i) + { + DataItem ipdi(ProtocolStrings::IPv4_Attached_Subnet, dlep->protocfg); + doCopyStrToIpdi(da.ipv4sndataitems(i), ipdi); + info.ipv4SnDataItems.push_back(ipdi); + } + + for (int i = 0; i < da.ipv6dataitems_size(); ++i) + { + DataItem ipdi(ProtocolStrings::IPv6_Address, dlep->protocfg); + doCopyStrToIpdi(da.ipv6dataitems(i), ipdi); + info.ipv6DataItems.push_back(ipdi); + } + + for (int i = 0; i < da.ipv6sndataitems_size(); ++i) + { + DataItem ipdi(ProtocolStrings::IPv6_Attached_Subnet, dlep->protocfg); + doCopyStrToIpdi(da.ipv6sndataitems(i), ipdi); + info.ipv6SnDataItems.push_back(ipdi); + } } return std::pair(rc, info); diff --git a/Dlep.cpp b/Dlep.cpp index c7b3a28..51cfedf 100644 --- a/Dlep.cpp +++ b/Dlep.cpp @@ -255,11 +255,17 @@ Dlep::initialize() } } catch (LLDLEP::DlepClient::BadParameterName & bpn) - { + { msg << bpn.what(); LOG(DLEP_LOG_FATAL, msg); notify_initialization_done(false); - } + } + catch (std::exception & exp) + { + msg << exp.what(); + LOG(DLEP_LOG_FATAL, msg); + notify_initialization_done(false); + } } void @@ -465,6 +471,21 @@ Dlep::start_dlep() session_acceptor = new boost::asio::ip::tcp::acceptor(io_service_, boost::asio::ip::tcp::endpoint(session_address, session_port)); + + // Set the socket's TTL to the session-ttl config parameter + // if it exists. + + try + { + unsigned int ttl; + dlep_client.get_config_parameter("session-ttl", &ttl); + session_acceptor->set_option(boost::asio::ip::unicast::hops(ttl)); + } + catch (LLDLEP::DlepClient::BadParameterName) + { + // Let the default TTL take effect. + } + start_async_accept(); } else // we're the router diff --git a/DlepLogger.cpp b/DlepLogger.cpp index 6d437fd..49db93b 100644 --- a/DlepLogger.cpp +++ b/DlepLogger.cpp @@ -6,11 +6,13 @@ #include "DlepLogger.h" #include #include +#include using namespace std; using namespace LLDLEP::internal; -DlepLogger::DlepLogger() +DlepLogger::DlepLogger(): + pstream(&std::cout) { this->run_level = DLEP_LOG_INFO; //this->run_level = DEBUG; @@ -19,13 +21,10 @@ DlepLogger::DlepLogger() level_name[3] = string("NOTICE: "); level_name[4] = string("ERROR: "); level_name[5] = string("FATAL: "); - - file_name = "/tmp/dlep_log.txt"; - - logfile.open("/tmp/dlep_log.txt"); } -DlepLogger::DlepLogger(int run_level) +DlepLogger::DlepLogger(int run_level): + pstream(&std::cout) { if (run_level < DLEP_LOG_DEBUG) { @@ -39,12 +38,14 @@ DlepLogger::DlepLogger(int run_level) { this->run_level = run_level; } - logfile.open("dlep_log.txt"); } DlepLogger::~DlepLogger() { - logfile.close(); + if (logfile.is_open()) + { + logfile.close(); + } } void @@ -53,7 +54,7 @@ DlepLogger::log(int level, std::string str) boost::mutex::scoped_lock lock(mutex); if (level >= run_level) { - logfile << level_name[level] << str << endl; + *pstream << level_name[level] << str << endl; } } @@ -70,7 +71,7 @@ DlepLogger::log_time(int level, std::string str) boost::mutex::scoped_lock lock(mutex); if (level >= run_level) { - logfile << time_string_get() << level_name[level] << str << endl; + *pstream << time_string_get() << level_name[level] << str << endl; } } @@ -101,9 +102,26 @@ DlepLogger::set_run_level(int run_level) void DlepLogger::set_log_file(const char * name) { - file_name = name; - logfile.close(); + if (logfile.is_open()) + { + logfile.close(); + } logfile.open(name); + + if (!logfile.fail()) + { + file_name = name; + pstream = &logfile; + } + else + { + file_name.clear(); + pstream = &std::cout; + ostringstream msg; + msg << "Unable to open log file: " << name; + DlepLogger * logger(this); + LOG(DLEP_LOG_ERROR, msg); + } } string diff --git a/DlepLogger.h b/DlepLogger.h index e4257ab..083e18a 100644 --- a/DlepLogger.h +++ b/DlepLogger.h @@ -60,6 +60,7 @@ class DlepLogger std::string file_name; int run_level; std::ofstream logfile; + std::ostream * pstream; std::string time_string_get(); std::map level_name; boost::mutex mutex; diff --git a/DlepServiceImpl.cpp b/DlepServiceImpl.cpp index 83b157a..d7d026f 100644 --- a/DlepServiceImpl.cpp +++ b/DlepServiceImpl.cpp @@ -136,9 +136,11 @@ DlepServiceImpl::destination_update(const DlepMac & mac_address, data_items); if (entry.estate == DestAdvertDBEntry::EntryState::up) { + // entry dataitems include not only dataitems that we got as a parametar, + // but some additional data items. (e.g ip data item). for (const DlepMac & dest : entry.info.destinations) { - dlep->local_pdp->updateDestination(dest, data_items, true); + dlep->local_pdp->updateDestination(dest, entry.data_items, true); } } } diff --git a/Peer.cpp b/Peer.cpp index c9e19ef..abde7d0 100644 --- a/Peer.cpp +++ b/Peer.cpp @@ -595,7 +595,7 @@ Peer::destination_down(const DlepMac & destination_mac) msg << "to peer=" << peer_id << " destination mac=" << destination_mac; LOG(DLEP_LOG_INFO, msg); - + ProtocolMessage pm {dlep->protocfg, dlep->logger}; pm.add_header(ProtocolStrings::Destination_Down); @@ -826,6 +826,7 @@ Peer::terminate(const std::string & status_name, const std::string & reason) return; } + dlep->dest_advert->clear_ipdataitems(); stop_peer(); // Create and serialize a Termination message @@ -1122,7 +1123,11 @@ Peer::handle_peer_initialization(ProtocolMessage & pm) if (status_message != "") { - terminate(ProtocolStrings::Inconsistent_Data, status_message); + // following the RFC 8175 protocol (13.8.1), + // the receiver of inconsistent inforamtion MUST issue a Session + // Termination Message containing a Status Data Item with status set + // to 'Invalid Data' and transition to the Session Termination state. + terminate(ProtocolStrings::Invalid_Data, status_message); return; } @@ -1315,7 +1320,11 @@ Peer::handle_peer_update(ProtocolMessage & pm) if (status_message != "") { - terminate(ProtocolStrings::Inconsistent_Data, status_message); + // following the RFC 8175 protocol (13.8.1), + // the receiver of inconsistent inforamtion MUST issue a Session + // Termination Message containing a Status Data Item with status set + // to 'Invalid Data' and transition to the Session Termination state. + terminate(ProtocolStrings::Invalid_Data, status_message); return; } @@ -1324,6 +1333,14 @@ Peer::handle_peer_update(ProtocolMessage & pm) // We always send the update to the client, even if there was an error. // Is that OK? dlep->dlep_client.peer_update(peer_id, data_items); + if(dlep->dest_advert_enabled) + { + //when there is peer update, publish the dataitems to the others modems + for (auto di : data_items) + { + dlep->dest_advert->add_dataitem(di); + } + } send_simple_response(ProtocolStrings::Session_Update_Response, update_status, ""); @@ -1389,8 +1406,17 @@ Peer::handle_destination_up(ProtocolMessage & pm) if (status_message != "") { - terminate(ProtocolStrings::Inconsistent_Data, status_message); - return; + // following the RFC 8175 protocol (13.8.1), + // MAY issue the appropriate response message containing Status Data Item + + ostringstream msg; + msg << "peer=" << peer_id << " status=" << ProtocolStrings::Destination_Up_Response + << " reason=" << status_message; + LOG(DLEP_LOG_DEBUG, msg); + + // following the RFC 8175 protocol, + // the receiver of inconsistent meesage MUST continue with session processing, + // therefore there is no place for 'return' } // If the peer had previously expressed Not Interested in @@ -1519,6 +1545,10 @@ Peer::handle_destination_announce(ProtocolMessage & pm) std::string response_name = dlep->protocfg->get_message_response_name(pm.get_signal_name()); + + msg << response_name; + LOG(DLEP_LOG_DEBUG, msg); + assert(response_name != ""); // already_have_this_dest will be true if we've already gotten a @@ -1528,6 +1558,12 @@ Peer::handle_destination_announce(ProtocolMessage & pm) bool already_have_this_dest = peer_pdp->validDestination(destination_mac); + msg << response_name << " response name"; + LOG(DLEP_LOG_DEBUG, msg); + + msg << already_have_this_dest << " already have this dest"; + LOG(DLEP_LOG_DEBUG, msg); + std::string statusname; if (! already_have_this_dest) { @@ -1559,8 +1595,15 @@ Peer::handle_destination_announce(ProtocolMessage & pm) // interacting with the client, and we're done. DestinationDataPtr ddp; + + msg << "gettting destination data"; + LOG(DLEP_LOG_DEBUG, msg); + if (dlep->local_pdp->getDestinationData(destination_mac, &ddp)) { + msg << " getting destination data YES"; + LOG(DLEP_LOG_DEBUG, msg); + DataItems response_data_items; ddp->get_all_data_items(response_data_items); @@ -1578,6 +1621,8 @@ Peer::handle_destination_announce(ProtocolMessage & pm) statusname = dlep->dlep_client.destination_up(peer_id, destination_mac, data_items); + msg << statusname << " status name"; + LOG(DLEP_LOG_DEBUG, msg); // convert empty status name to Success if (statusname == "") @@ -1587,6 +1632,10 @@ Peer::handle_destination_announce(ProtocolMessage & pm) } // destination did not already exist from this peer else { + msg << " What's the right status for a redudant Destination Announce?"; + msg << " destination already exists from this peer"; + LOG(DLEP_LOG_DEBUG, msg); + // What's the right status for a redundant Destination Announce? statusname = ProtocolStrings::Invalid_Message; } // destination already exists from this peer @@ -1632,8 +1681,17 @@ Peer::handle_destination_update(ProtocolMessage & pm) validate_ip_data_items(update_data_items, ddp->get_ip_data_items()); if (status_message != "") { - terminate(ProtocolStrings::Inconsistent_Data, status_message); - return; + // following the RFC 8175 protocol (13.8.1), + // MAY issue the appropriate response message containing Status Data Item + + ostringstream msg; + msg << "peer=" << peer_id << " status=" << ProtocolStrings::Session_Update_Response + << " reason=" << status_message; + LOG(DLEP_LOG_DEBUG, msg); + + // following the RFC 8175 protocol, + // the receiver of inconsistent meesage MUST continue with session processing, + // therefore there is no place for 'return' } ddp->update(update_data_items, false); @@ -2013,8 +2071,9 @@ Peer::set_state_terminating() if (dlep->dest_advert_enabled) { - // clear all destinations associated with this peer + // clear all destinations and ipdataitems associated with this peer dlep->dest_advert->clear_destinations(); + dlep->dest_advert->clear_ipdataitems(); } } } diff --git a/PeerDiscovery.cpp b/PeerDiscovery.cpp index 24395bc..ac06c10 100644 --- a/PeerDiscovery.cpp +++ b/PeerDiscovery.cpp @@ -593,7 +593,7 @@ PeerDiscovery::send_peer_offer(boost::asio::ip::udp::endpoint to_endpoint) } boost::asio::ip::udp::endpoint send_endpoint(to_endpoint.address(), - udp_port); + to_endpoint.port()); msg << "Sending signal to " << send_endpoint; LOG(DLEP_LOG_INFO, msg); diff --git a/config/modem.xml b/config/modem.xml index 9232108..352e573 100644 --- a/config/modem.xml +++ b/config/modem.xml @@ -8,17 +8,18 @@ as a modem. modem 1 - + eth0 - - + 255 + 255 + 4854 - + 225.0.0.117 60 - + 4854 60 2 diff --git a/config/protocol/dlep-rfc-8175.xml b/config/protocol/dlep-rfc-8175.xml index 62cee80..e78a64e 100644 --- a/config/protocol/dlep-rfc-8175.xml +++ b/config/protocol/dlep-rfc-8175.xml @@ -593,7 +593,7 @@ This protocol configuration file conforms to DLEP RFC 8175. 0-1 - + Relative_Link_Quality_Receive 0-1 @@ -654,6 +654,16 @@ This protocol configuration file conforms to DLEP RFC 8175. IPv6_Address 0+ + + + IPv4_Attached_Subnet + 0+ + + + + IPv6_Attached_Subnet + 0+ + diff --git a/destadvert.proto b/destadvert.proto index ecaf51f..54165e0 100644 --- a/destadvert.proto +++ b/destadvert.proto @@ -1,8 +1,14 @@ +syntax = "proto2"; + message DestinationAdvertisement { required uint32 reportinterval = 1; // report interval in seconds required uint32 sequencenumber = 2; // sequence number required uint64 uptimeinseconds = 3; // application up time in seconds required bytes localid = 4; // our local modem/radio id repeated bytes destinations = 5; // destinations to advertise + repeated bytes ipv4dataitems = 6; // ipv4 data items to advertise + repeated bytes ipv4sndataitems = 7; // ipv4 subnet data items to advertise + repeated bytes ipv6dataitems = 8; // ipv6 data items to advertise + repeated bytes ipv6sndataitems = 9; // ipv6 subnet data items to advertise }