uint8_t *a = answer;
ssize_t resp_size;
size_t rdata_size;
- unsigned char uri_compressed[MAXDNAME];
- ssize_t compressed_len;
+ size_t uri_len;
if (rr->type != ns_t_uri) {
RWRAP_LOG(RWRAP_LOG_ERROR, "Wrong type!\n");
}
RWRAP_LOG(RWRAP_LOG_TRACE, "Adding URI RR");
rdata_size = 3 * sizeof(uint16_t);
-
- /* Prepare the data to write */
- compressed_len = ns_name_compress(rr->rrdata.uri_rec.uri,
- uri_compressed, MAXDNAME,
- NULL, NULL);
- if (compressed_len < 0) {
- return -1;
- }
- rdata_size += compressed_len;
+ uri_len = strlen(rr->rrdata.uri_rec.uri) + 1;
+ rdata_size += uri_len;
resp_size = rwrap_fake_rdata_common(ns_t_uri, rdata_size,
rr->key, anslen, &a);
NS_PUT16(rr->rrdata.uri_rec.prio, a);
NS_PUT16(rr->rrdata.uri_rec.weight, a);
- memcpy(a, uri_compressed, compressed_len);
+ memcpy(a, rr->rrdata.uri_rec.uri, uri_len);
return resp_size;
}
const uint8_t *rrdata;
int prio;
int weight;
- char uri[MAXDNAME];
(void) state; /* unused */
/*
* The query must finish w/o an error, have one answer and the answer
- * must be a parseable RR of type SRV and have the priority, weight,
- * port and hostname as in the fake hosts file
+ * must be a parseable RR of type URI and have the priority, weight, and
+ * URI string as in the hosts file.
*/
assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
assert_int_equal(ns_msg_count(handle, ns_s_an), 1);
NS_GET16(prio, rrdata);
NS_GET16(weight, rrdata);
- rv = ns_name_uncompress(ns_msg_base(handle),
- ns_msg_end(handle),
- rrdata,
- uri, MAXDNAME);
- assert_int_not_equal(rv, -1);
-
assert_int_equal(prio, 2);
assert_int_equal(weight, 5);
- assert_string_equal(uri, "https://vpn.cwrap.org/VPN");
+ assert_string_equal(rrdata, "https://vpn.cwrap.org/VPN");
}
/*
const uint8_t *rrdata;
int prio;
int weight;
- char uri[MAXDNAME];
(void) state; /* unused */
/*
* The query must finish w/o an error, have one answer and the answer
- * must be a parseable RR of type SRV and have the priority, weight,
- * port and hostname as in the fake hosts file
+ * must be a parseable RR of type URI and have the priority, weight, and
+ * URI string as in the fake hosts file
*/
assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
assert_int_equal(ns_msg_count(handle, ns_s_an), 1);
NS_GET16(prio, rrdata);
NS_GET16(weight, rrdata);
- rv = ns_name_uncompress(ns_msg_base(handle),
- ns_msg_end(handle),
- rrdata,
- uri, MAXDNAME);
- assert_int_not_equal(rv, -1);
-
assert_int_equal(prio, 1);
assert_int_equal(weight, 100);
- assert_string_equal(uri, "ftp://ftp.cwrap.org/public");
+ assert_string_equal(rrdata, "ftp://ftp.cwrap.org/public");
}
static void test_res_fake_soa_query(void **state)