return d_params.size() > 0;
}
+bool SVCBBaseRecordContent::hasParam(const SvcParam::SvcParamKey &key) const {
+ auto p = std::find_if(d_params.begin(), d_params.end(),
+ [&key](const SvcParam ¶m) {
+ return param.getKey() == key;
+ });
+ return p != d_params.end();
+}
+
+SvcParam SVCBBaseRecordContent::getParam(const SvcParam::SvcParamKey &key) const {
+ auto p = std::find_if(d_params.begin(), d_params.end(),
+ [&key](const SvcParam ¶m) {
+ return param.getKey() == key;
+ });
+ if (p == d_params.end()) {
+ throw std::out_of_range("No param with key " + SvcParam::keyToString(key));
+ }
+ return *p;
+}
+
/* SVCB end */
boilerplate_conv(TKEY,
void removeParam(const SvcParam::SvcParamKey &key);
// Whether or not there are any param
bool hasParams() const;
+ // Whether or not the param of |key| exists
+ bool hasParam(const SvcParam::SvcParamKey &key) const;
+ // Get the parameter with |key|, will throw out_of_range if param isn't there
+ SvcParam getParam(const SvcParam::SvcParamKey &key) const;
protected:
uint16_t d_priority;
numwarnings++;
}
+ if(svcbrc->getPriority() != 0) {
+ // Service Form
+ if (svcbrc->hasParam(SvcParam::no_default_alpn) && !svcbrc->hasParam(SvcParam::alpn)) {
+ /* draft-ietf-dnsop-svcb-https-03 section 6.1
+ * When "no-default-alpn" is specified in an RR, "alpn" must
+ * also be specified in order for the RR to be "self-consistent
+ * (Section 2.4.3).
+ */
+ cout<<"[Warning] "<<rr.qname<<"|"<<rr.qtype.getName()<<" is not self-consistent: 'no-default-alpn' parameter without 'alpn' parameter"<<endl;
+ numwarnings++;
+ }
+ if (svcbrc->hasParam(SvcParam::mandatory)) {
+ auto keys = svcbrc->getParam(SvcParam::mandatory).getMandatory();
+ for (auto const &k: keys) {
+ if (!svcbrc->hasParam(k)) {
+ cout<<"[Warning] "<<rr.qname<<"|"<<rr.qtype.getName()<<" is not self-consistent: 'mandatory' parameter lists '"+ SvcParam::keyToString(k) +"', but that parameter does not exist"<<endl;
+ numwarnings++;
+ }
+ }
+ }
+ }
+
switch (rr.qtype.getCode()) {
case QType::SVCB:
if (svcbrc->getPriority() == 0) {