void StrategyChoice::wireDecode(const Block& block) { if (block.type() != tlv::nfd::StrategyChoice) { throw Error("expecting StrategyChoice block"); } m_wire = block; m_wire.parse(); Block::element_const_iterator val = m_wire.elements_begin(); if (val != m_wire.elements_end() && val->type() == tlv::Name) { m_name.wireDecode(*val); ++val; } else { throw Error("missing required Name field"); } if (val != m_wire.elements_end() && val->type() == tlv::nfd::Strategy) { val->parse(); if (val->elements().empty()) { throw Error("expecting Strategy/Name"); } else { m_strategy.wireDecode(*val->elements_begin()); } ++val; } else { throw Error("missing required Strategy field"); } }
void ControlParameters::wireDecode(const Block& block) { if (block.type() != tlv::nfd::ControlParameters) { throw Error("expecting TLV-TYPE ControlParameters"); } m_wire = block; m_wire.parse(); Block::element_const_iterator val; val = m_wire.find(tlv::Name); m_hasFields[CONTROL_PARAMETER_NAME] = val != m_wire.elements_end(); if (this->hasName()) { m_name.wireDecode(*val); } val = m_wire.find(tlv::nfd::FaceId); m_hasFields[CONTROL_PARAMETER_FACE_ID] = val != m_wire.elements_end(); if (this->hasFaceId()) { m_faceId = static_cast<uint64_t>(readNonNegativeInteger(*val)); } val = m_wire.find(tlv::nfd::Uri); m_hasFields[CONTROL_PARAMETER_URI] = val != m_wire.elements_end(); if (this->hasUri()) { m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size()); } val = m_wire.find(tlv::nfd::LocalControlFeature); m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = val != m_wire.elements_end(); if (this->hasLocalControlFeature()) { m_localControlFeature = static_cast<LocalControlFeature>(readNonNegativeInteger(*val)); } val = m_wire.find(tlv::nfd::Origin); m_hasFields[CONTROL_PARAMETER_ORIGIN] = val != m_wire.elements_end(); if (this->hasOrigin()) { m_origin = static_cast<uint64_t>(readNonNegativeInteger(*val)); } val = m_wire.find(tlv::nfd::Cost); m_hasFields[CONTROL_PARAMETER_COST] = val != m_wire.elements_end(); if (this->hasCost()) { m_cost = static_cast<uint64_t>(readNonNegativeInteger(*val)); } val = m_wire.find(tlv::nfd::Flags); m_hasFields[CONTROL_PARAMETER_FLAGS] = val != m_wire.elements_end(); if (this->hasFlags()) { m_flags = static_cast<uint64_t>(readNonNegativeInteger(*val)); } val = m_wire.find(tlv::nfd::Strategy); m_hasFields[CONTROL_PARAMETER_STRATEGY] = val != m_wire.elements_end(); if (this->hasStrategy()) { val->parse(); if (val->elements().empty()) { throw Error("expecting Strategy/Name"); } else { m_strategy.wireDecode(*val->elements_begin()); } } val = m_wire.find(tlv::nfd::ExpirationPeriod); m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = val != m_wire.elements_end(); if (this->hasExpirationPeriod()) { m_expirationPeriod = time::milliseconds(readNonNegativeInteger(*val)); } }