Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Muktadir R Chowdhury | 800833b | 2016-07-29 13:43:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
| 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | **/ |
| 21 | |
| 22 | #include "lsdb-status-publisher.hpp" |
| 23 | |
| 24 | #include "lsa.hpp" |
| 25 | #include "tlv/lsdb-status.hpp" |
| 26 | |
| 27 | #include <ndn-cxx/face.hpp> |
| 28 | |
| 29 | namespace nlsr { |
| 30 | |
| 31 | const ndn::Name::Component LsdbStatusPublisher::DATASET_COMPONENT = ndn::Name::Component("list"); |
| 32 | |
| 33 | LsdbStatusPublisher::LsdbStatusPublisher(Lsdb& lsdb, |
| 34 | ndn::Face& face, |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 35 | ndn::KeyChain& keyChain, |
| 36 | AdjacencyLsaPublisher& adjacencyLsaPublisher, |
| 37 | CoordinateLsaPublisher& coordinateLsaPublisher, |
| 38 | NameLsaPublisher& nameLsaPublisher) |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 39 | : SegmentPublisher<ndn::Face>(face, keyChain) |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 40 | , m_adjacencyLsaPublisher(adjacencyLsaPublisher) |
| 41 | , m_coordinateLsaPublisher(coordinateLsaPublisher) |
| 42 | , m_nameLsaPublisher(nameLsaPublisher) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | size_t |
| 47 | LsdbStatusPublisher::generate(ndn::EncodingBuffer& outBuffer) |
| 48 | { |
| 49 | size_t totalLength = 0; |
| 50 | |
| 51 | tlv::LsdbStatus lsdbStatus; |
| 52 | for (const tlv::AdjacencyLsa& tlvLsa : m_adjacencyLsaPublisher.getTlvLsas()) { |
| 53 | lsdbStatus.addAdjacencyLsa(tlvLsa); |
| 54 | } |
| 55 | |
| 56 | for (const tlv::CoordinateLsa& tlvLsa : m_coordinateLsaPublisher.getTlvLsas()) { |
| 57 | lsdbStatus.addCoordinateLsa(tlvLsa); |
| 58 | } |
| 59 | |
| 60 | for (const tlv::NameLsa& tlvLsa : m_nameLsaPublisher.getTlvLsas()) { |
| 61 | lsdbStatus.addNameLsa(tlvLsa); |
| 62 | } |
| 63 | |
| 64 | totalLength += lsdbStatus.wireEncode(outBuffer); |
| 65 | |
| 66 | return totalLength; |
| 67 | } |
| 68 | |
| 69 | } // namespace nlsr |