}
int dns_question_add(DnsQuestion *q, DnsResourceKey *key) {
+ unsigned i;
+ int r;
+
assert(q);
assert(key);
+ for (i = 0; i < q->n_keys; i++) {
+ r = dns_resource_key_equal(q->keys[i], key);
+ if (r < 0)
+ return r;
+ if (r > 0)
+ return 0;
+ }
+
if (q->n_keys >= q->n_allocated)
return -ENOSPC;
return r;
}
- return 1;
+ return 0;
}
int dns_question_is_valid(DnsQuestion *q) {
/* Check that all keys in this question bear the same name */
for (i = 1; i < q->n_keys; i++) {
+ assert(q->keys[i]);
+
r = dns_name_equal(DNS_RESOURCE_KEY_NAME(q->keys[i]), name);
if (r <= 0)
return r;
return -ENOMEM;
/* Create a new question, and patch in the new name */
- for (n->n_keys = 0; n->n_keys < q->n_keys; n->n_keys++) {
+ for (i = 0; i < q->n_keys; i++) {
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *k = NULL;
k = dns_resource_key_new(q->keys[i]->class, q->keys[i]->type, name);
return 1;
}
+
+int dns_question_endswith(DnsQuestion *q, const char *suffix) {
+ unsigned i;
+
+ assert(q);
+ assert(suffix);
+
+ for (i = 0; i < q->n_keys; i++) {
+ int k;
+
+ k = dns_name_endswith(DNS_RESOURCE_KEY_NAME(q->keys[i]), suffix);
+ if (k <= 0)
+ return k;
+ }
+
+ return 1;
+}
+
+int dns_question_extract_reverse_address(DnsQuestion *q, int *family, union in_addr_union *address) {
+ unsigned i;
+
+ assert(q);
+ assert(family);
+ assert(address);
+
+ for (i = 0; i < q->n_keys; i++) {
+ int k;
+
+ k = dns_name_address(DNS_RESOURCE_KEY_NAME(q->keys[i]), family, address);
+ if (k != 0)
+ return k;
+ }
+
+ return 0;
+}