size_t wireEncode(EncodingImpl<T>& encoder) const { size_t totalLength = 0; totalLength += prependNonNegativeIntegerBlock(encoder, ndn::statusCollector::tlv::RX, m_rx); totalLength += prependNonNegativeIntegerBlock(encoder, ndn::statusCollector::tlv::TX, m_tx); totalLength += prependNonNegativeIntegerBlock(encoder, ndn::statusCollector::tlv::FaceId, m_faceId); totalLength += encoder.prependByteArrayBlock(ndn::statusCollector::tlv::LinkIp, reinterpret_cast<const uint8_t*>(m_linkIp.c_str()), m_linkIp.size()); totalLength += encoder.prependByteArrayBlock(ndn::statusCollector::tlv::CurrentTime, reinterpret_cast<const uint8_t*>(m_timestamp.c_str()), m_timestamp.size()); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(statusCollector::tlv::FaceStatus); return totalLength; }
size_t FaceEventNotification::wireEncode(EncodingImpl<TAG>& encoder) const { size_t totalLength = 0; totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Flags, m_flags); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::LinkType, m_linkType); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FacePersistency, m_facePersistency); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceScope, m_faceScope); totalLength += encoder.prependByteArrayBlock(tlv::nfd::LocalUri, reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size()); totalLength += encoder.prependByteArrayBlock(tlv::nfd::Uri, reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size()); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceId, m_faceId); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceEventKind, m_kind); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::nfd::FaceEventNotification); return totalLength; }
size_t Interest::encode03(EncodingImpl<TAG>& encoder) const { size_t totalLength = 0; // Encode as NDN Packet Format v0.3 // Interest ::= INTEREST-TYPE TLV-LENGTH // Name // CanBePrefix? // MustBeFresh? // ForwardingHint? // Nonce? // InterestLifetime? // HopLimit? // ApplicationParameters? // (reverse encoding) // ApplicationParameters if (hasApplicationParameters()) { totalLength += encoder.prependBlock(getApplicationParameters()); } // HopLimit: not yet supported // InterestLifetime if (getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::InterestLifetime, static_cast<uint64_t>(getInterestLifetime().count())); } // Nonce uint32_t nonce = getNonce(); // if nonce was unset, getNonce generates a random nonce totalLength += encoder.prependByteArrayBlock(tlv::Nonce, reinterpret_cast<uint8_t*>(&nonce), sizeof(nonce)); // ForwardingHint if (!getForwardingHint().empty()) { totalLength += getForwardingHint().wireEncode(encoder); } // MustBeFresh if (getMustBeFresh()) { totalLength += prependEmptyBlock(encoder, tlv::MustBeFresh); } // CanBePrefix if (getCanBePrefix()) { totalLength += prependEmptyBlock(encoder, tlv::CanBePrefix); } // Name totalLength += getName().wireEncode(encoder); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::Interest); return totalLength; }
size_t FaceStatus::wireEncode(EncodingImpl<TAG>& encoder) const { size_t totalLength = 0; totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Flags, m_flags); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutBytes, m_nOutBytes); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInBytes, m_nInBytes); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutNacks, m_nOutNacks); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutDatas, m_nOutDatas); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests, m_nOutInterests); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInNacks, m_nInNacks); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInDatas, m_nInDatas); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInInterests, m_nInInterests); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::LinkType, m_linkType); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FacePersistency, m_facePersistency); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceScope, m_faceScope); if (m_hasExpirationPeriod) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::ExpirationPeriod, m_expirationPeriod.count()); } totalLength += encoder.prependByteArrayBlock(tlv::nfd::LocalUri, reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size()); totalLength += encoder.prependByteArrayBlock(tlv::nfd::Uri, reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size()); totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceId, m_faceId); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::nfd::FaceStatus); return totalLength; }
size_t FaceQueryFilter::wireEncode(EncodingImpl<TAG>& encoder) const { size_t totalLength = 0; if (m_hasLinkType) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::LinkType, m_linkType); } if (m_hasFacePersistency) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FacePersistency, m_facePersistency); } if (m_hasFaceScope) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceScope, m_faceScope); } if (m_hasLocalUri) { totalLength += encoder.prependByteArrayBlock(tlv::nfd::LocalUri, reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size()); } if (m_hasRemoteUri) { totalLength += encoder.prependByteArrayBlock(tlv::nfd::Uri, reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size()); } if (m_hasUriScheme) { totalLength += encoder.prependByteArrayBlock(tlv::nfd::UriScheme, reinterpret_cast<const uint8_t*>(m_uriScheme.c_str()), m_uriScheme.size()); } if (m_hasFaceId) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceId, m_faceId); } totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::nfd::FaceQueryFilter); return totalLength; }
size_t wireEncode(EncodingImpl<T>& encoder) const { size_t bytes_encoded = 0; bytes_encoded += encoder.prependByteArrayBlock(ndn::statusCollector::tlv::ScriptData, reinterpret_cast<const uint8_t*>(m_data.c_str()), m_data.size()); bytes_encoded += encoder.prependVarNumber(bytes_encoded); bytes_encoded += encoder.prependVarNumber(statusCollector::tlv::ScriptPacket); return bytes_encoded; }
size_t Interest::encode02(EncodingImpl<TAG>& encoder) const { size_t totalLength = 0; // Encode as NDN Packet Format v0.2 // Interest ::= INTEREST-TYPE TLV-LENGTH // Name // Selectors? // Nonce // InterestLifetime? // ForwardingHint? // (reverse encoding) // ForwardingHint if (getForwardingHint().size() > 0) { totalLength += getForwardingHint().wireEncode(encoder); } // InterestLifetime if (getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) { totalLength += prependNonNegativeIntegerBlock(encoder, tlv::InterestLifetime, static_cast<uint64_t>(getInterestLifetime().count())); } // Nonce uint32_t nonce = getNonce(); // if nonce was unset, getNonce generates a random nonce totalLength += encoder.prependByteArrayBlock(tlv::Nonce, reinterpret_cast<uint8_t*>(&nonce), sizeof(nonce)); // Selectors if (hasSelectors()) { totalLength += getSelectors().wireEncode(encoder); } // Name totalLength += getName().wireEncode(encoder); totalLength += encoder.prependVarNumber(totalLength); totalLength += encoder.prependVarNumber(tlv::Interest); return totalLength; }
inline size_t prependByteArrayBlock(EncodingImpl<TAG>& encoder, uint32_t type, const uint8_t* array, size_t arraySize) { return encoder.prependByteArrayBlock(type, array, arraySize); }