Пример #1
0
size_t
LsdbStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
  size_t totalLength = 0;

  for (std::list<NameLsa>::const_reverse_iterator it = m_nameLsas.rbegin();
       it != m_nameLsas.rend(); ++it) {
    totalLength += it->wireEncode(block);
  }

  for (std::list<CoordinateLsa>::const_reverse_iterator it = m_coordinateLsas.rbegin();
       it != m_coordinateLsas.rend(); ++it) {
    totalLength += it->wireEncode(block);
  }

  for (std::list<AdjacencyLsa>::const_reverse_iterator it = m_adjacencyLsas.rbegin();
       it != m_adjacencyLsas.rend(); ++it) {
    totalLength += it->wireEncode(block);
  }

  totalLength += block.prependVarNumber(totalLength);
  totalLength += block.prependVarNumber(ndn::tlv::nlsr::LsdbStatus);

  return totalLength;
}
Пример #2
0
size_t
EndorseExtension::wireEncode(ndn::EncodingImpl<T>& block) const
{
  size_t totalLength = 0;

  // EndorseExtension := ENDORSE-EXTENSION-TYPE TLV-LENGTH
  //                       EntryData+
  //
  // EntryData := ENTRYDATA-TYPE TLV-LENGTH
  //                String
  //

  // EntryData
  for (std::list<std::string>::const_reverse_iterator it = m_entries.rbegin();
       it != m_entries.rend(); it++) {
    const uint8_t *entryWire = reinterpret_cast<const uint8_t*>(it->c_str());
    totalLength += block.prependByteArrayBlock(tlv::EntryData, entryWire, it->length());
  }

  // EndorseExtension
  totalLength += block.prependVarNumber(totalLength);
  totalLength += block.prependVarNumber(tlv::EndorseExtension);

  return totalLength;
}
Пример #3
0
size_t
CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
  size_t totalLength = 0;
  size_t doubleLength = 10;

  const uint8_t* doubleBytes1;
  for (auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
    doubleBytes1 = reinterpret_cast<const uint8_t*>(&*it);

    totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes1, 8);
    totalLength += block.prependVarNumber(doubleLength);
    totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicAngle);
  }

  const uint8_t* doubleBytes2 = reinterpret_cast<const uint8_t*>(&m_hyperbolicRadius);
  totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes2, 8);
  totalLength += block.prependVarNumber(doubleLength);
  totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicRadius);

  totalLength += m_lsaInfo.wireEncode(block);

  totalLength += block.prependVarNumber(totalLength);
  totalLength += block.prependVarNumber(ndn::tlv::nlsr::CoordinateLsa);

  return totalLength;
}
Пример #4
0
size_t
RoutingTable::wireEncode(ndn::EncodingImpl<TAG>& block) const
{
  size_t totalLength = 0;

  for (std::list<NextHop>::const_reverse_iterator it = m_nexthops.rbegin();
       it != m_nexthops.rend(); ++it) {
    totalLength += it->wireEncode(block);
  }

  totalLength += m_des.wireEncode(block);

  totalLength += block.prependVarNumber(totalLength);
  totalLength += block.prependVarNumber(ndn::tlv::nlsr::RouteTableEntry);

  return totalLength;
}
Пример #5
0
size_t
AdjacencyLsa::wireEncode(ndn::EncodingImpl<T>& block) const
{
  size_t totalLength = 0;

  for (std::list<Adjacency>::const_reverse_iterator it = m_adjacencies.rbegin();
       it != m_adjacencies.rend(); ++it) {
    totalLength += it->wireEncode(block);
  }

  totalLength += m_lsaInfo.wireEncode(block);

  totalLength += block.prependVarNumber(totalLength);
  totalLength += block.prependVarNumber(ndn::tlv::nlsr::AdjacencyLsa);

  return totalLength;
}
Пример #6
0
size_t
Adjacency::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
{
  size_t totalLength = 0;

  totalLength += prependNonNegativeIntegerBlock(encoder, ndn::tlv::nlsr::Cost, m_cost);

  totalLength += encoder.prependByteArrayBlock(
    ndn::tlv::nlsr::Uri, reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());

  totalLength += m_name.wireEncode(encoder);

  totalLength += encoder.prependVarNumber(totalLength);
  totalLength += encoder.prependVarNumber(ndn::tlv::nlsr::Adjacency);

  return totalLength;
}
Пример #7
0
size_t
LsaInfo::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
{
  size_t totalLength = 0;

  // Absence of an ExpirationPeriod signifies non-expiration
  if (!m_hasInfiniteExpirationPeriod) {
    totalLength += prependNonNegativeIntegerBlock(encoder,
                                                  ndn::tlv::nlsr::ExpirationPeriod,
                                                  m_expirationPeriod.count());
  }

  totalLength += prependNonNegativeIntegerBlock(encoder,
                                                ndn::tlv::nlsr::SequenceNumber,
                                                m_sequenceNumber);

  totalLength += prependNestedBlock(encoder, ndn::tlv::nlsr::OriginRouter, m_originRouter);

  totalLength += encoder.prependVarNumber(totalLength);
  totalLength += encoder.prependVarNumber(ndn::tlv::nlsr::LsaInfo);

  return totalLength;
}
Пример #8
0
size_t
ChatroomInfo::wireEncode(ndn::EncodingImpl<T>& encoder) const
{
  size_t totalLength = 0;

  // ChatroomInfo := CHATROOM-INFO-TYPE TLV-LENGTH
  //                   ChatroomName
  //                   TrustModel
  //                   ChatroomPrefix
  //                   ManagerPrefix
  //                   Participants
  //
  // ChatroomName := CHATROOM-NAME-TYPE TLV-LENGTH
  //                   NameComponent
  //
  // TrustModel := TRUST-MODEL-TYPE TLV-LENGTH
  //                 nonNegativeInteger
  //
  // ChatroomPrefix := CHATROOM-PREFIX-TYPE TLV-LENGTH
  //                     Name
  //
  // ManagerPrefix := MANAGER-PREFIX-TYPE TLV-LENGTH
  //                    Name
  //
  // Participants := PARTICIPANTS-TYPE TLV-LENGTH
  //                   Name+

  // Participants
  size_t participantsLength = 0;
  for (std::list<Name>::const_reverse_iterator it = m_participants.rbegin();
       it != m_participants.rend(); ++it) {
    participantsLength += it->wireEncode(encoder);
  }
  participantsLength += encoder.prependVarNumber(participantsLength);
  participantsLength += encoder.prependVarNumber(tlv::Participants);
  totalLength += participantsLength;

  // Manager Prefix
  size_t managerLength = m_manager.wireEncode(encoder);
  totalLength += managerLength;
  totalLength += encoder.prependVarNumber(managerLength);
  totalLength += encoder.prependVarNumber(tlv::ManagerPrefix);

  // Chatroom Sync Prefix
  size_t chatroomSyncPrefixLength = m_syncPrefix.wireEncode(encoder);
  totalLength += chatroomSyncPrefixLength;
  totalLength += encoder.prependVarNumber(chatroomSyncPrefixLength);
  totalLength += encoder.prependVarNumber(tlv::ChatroomPrefix);

  // Trust Model
  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::TrustModel, m_trustModel);

  // Chatroom Name
  size_t chatroomNameLength = m_chatroomName.wireEncode(encoder);
  totalLength += chatroomNameLength;
  totalLength += encoder.prependVarNumber(chatroomNameLength);
  totalLength += encoder.prependVarNumber(tlv::ChatroomName);

  // Chatroom Info
  totalLength += encoder.prependVarNumber(totalLength);
  totalLength += encoder.prependVarNumber(tlv::ChatroomInfo);

  return totalLength;
}