Add opt record specific fields. Fix for issue #73

This commit is contained in:
Neel Goyal 2014-02-18 15:10:28 -05:00
parent 5d34d31ecc
commit c11509cf41
2 changed files with 14 additions and 5 deletions

View File

@ -156,7 +156,12 @@ static struct rdata_def sink_rdata[] = {
static struct rdata_def opt_rdata[] = {
{ "options" , t_dict },
{ "option_code" , t_int },
{ "option_data" , t_bindata }};
{ "option_data" , t_bindata },
{ "udp_payload_size" , t_int },
{ "extended_rcode" , t_int },
{ "version" , t_int },
{ "do" , t_int },
{ "z" , t_int }};
static struct rdata_def apl_rdata[] = {
{ "apitems" , t_dict },
{ "address_family" , t_int },
@ -1365,13 +1370,17 @@ getdns_return_t priv_getdns_append_opt_rr(
getdns_dict_destroy(rr_dict);
return GETDNS_RETURN_GENERIC_ERROR;
}
/* add rest of the fields */
r = getdns_dict_set_int(rr_dict, "type", GETDNS_RRTYPE_OPT);
r |= getdns_dict_set_int(rr_dict, "udp_payload_size", ldns_pkt_edns_udp_size(pkt));
r |= getdns_dict_set_int(rr_dict, "extended_rcode", ldns_pkt_edns_extended_rcode(pkt));
r |= getdns_dict_set_int(rr_dict, "version", ldns_pkt_edns_version(pkt));
r |= getdns_dict_set_int(rr_dict, "do", ldns_pkt_edns_do(pkt));
r |= getdns_dict_set_int(rr_dict, "z", ldns_pkt_edns_z(pkt));
if (r != GETDNS_RETURN_GOOD) {
getdns_dict_destroy(rr_dict);
return GETDNS_RETURN_GENERIC_ERROR;
}
/* other fields don't really make sense as they are
interpreted differently */
/* append */
r = getdns_list_set_dict(rdatas, list_len, opt_rr);

View File

@ -99,13 +99,13 @@ main(int argc, char** argv)
return (GETDNS_RETURN_GENERIC_ERROR);
}
/* Set up the getdns call */
const char *this_name = argc > 1 ? argv[1] : "mx.kitchensink.net";
const char *this_name = argc > 1 ? argv[1] : "getdnsapi.net";
char *this_userarg = "somestring"; // Could add things here to help identify this call
getdns_transaction_t this_transaction_id = 0;
/* Make the call */
getdns_return_t dns_request_return =
getdns_general(this_context, this_name, GETDNS_RRTYPE_APL,
getdns_general(this_context, this_name, GETDNS_RRTYPE_A,
NULL, this_userarg, &this_transaction_id, this_callbackfn);
if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
fprintf(stderr, "A bad domain name was used: %s. Exiting.",