Fix for issue #43 - add additional header fields

This commit is contained in:
Neel Goyal 2013-12-12 13:59:53 -05:00
parent 0c0d5b63ae
commit 93211cc99a
2 changed files with 53 additions and 7 deletions

View File

@ -63,9 +63,6 @@ struct getdns_context;
#define GETDNS_STR_KEY_HEADER "header" #define GETDNS_STR_KEY_HEADER "header"
#define GETDNS_STR_KEY_QUESTION "question" #define GETDNS_STR_KEY_QUESTION "question"
#define GETDNS_STR_KEY_ANSWER "answer" #define GETDNS_STR_KEY_ANSWER "answer"
#define GETDNS_STR_KEY_ID "id"
#define GETDNS_STR_KEY_QR "qr"
#define GETDNS_STR_KEY_OPC "opcode"
#define GETDNS_STR_KEY_TYPE "type" #define GETDNS_STR_KEY_TYPE "type"
#define GETDNS_STR_KEY_CLASS "class" #define GETDNS_STR_KEY_CLASS "class"
#define GETDNS_STR_KEY_TTL "ttl" #define GETDNS_STR_KEY_TTL "ttl"
@ -78,6 +75,24 @@ struct getdns_context;
#define GETDNS_STR_KEY_QTYPE "qtype" #define GETDNS_STR_KEY_QTYPE "qtype"
#define GETDNS_STR_KEY_QCLASS "qclass" #define GETDNS_STR_KEY_QCLASS "qclass"
#define GETDNS_STR_KEY_QNAME "qname" #define GETDNS_STR_KEY_QNAME "qname"
#define GETDNS_STR_KEY_QR "qr"
/* header flags */
#define GETDNS_STR_KEY_ID "id"
#define GETDNS_STR_KEY_OPCODE "opcode"
#define GETDNS_STR_KEY_RCODE "rcode"
#define GETDNS_STR_KEY_AA "aa"
#define GETDNS_STR_KEY_TC "tc"
#define GETDNS_STR_KEY_RD "rd"
#define GETDNS_STR_KEY_RA "ra"
#define GETDNS_STR_KEY_AD "ad"
#define GETDNS_STR_KEY_CD "cd"
#define GETDNS_STR_KEY_Z "z"
#define GETDNS_STR_KEY_QDCOUNT "qdcount"
#define GETDNS_STR_KEY_ANCOUNT "ancount"
#define GETDNS_STR_KEY_NSCOUNT "nscount"
#define GETDNS_STR_KEY_ARCOUNT "arcount"
/** @} /** @}
*/ */

View File

@ -184,10 +184,41 @@ create_reply_header_dict(struct getdns_context *context, ldns_pkt * reply)
/* cheat since we know GETDNS_RETURN_GOOD == 0 */ /* cheat since we know GETDNS_RETURN_GOOD == 0 */
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_ID, r |= getdns_dict_set_int(result, GETDNS_STR_KEY_ID,
ldns_pkt_id(reply)); ldns_pkt_id(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_QR,
ldns_pkt_qr(reply)); /* set bits - seems like this could be macro-ified*/
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_OPC, r |= getdns_dict_set_int(result, GETDNS_STR_KEY_QR,
(int) ldns_pkt_get_opcode(reply)); (int) ldns_pkt_qr(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_AA,
(int) ldns_pkt_aa(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_TC,
(int) ldns_pkt_tc(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_RD,
(int) ldns_pkt_rd(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_CD,
(int) ldns_pkt_cd(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_RA,
(int) ldns_pkt_aa(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_AD,
(int) ldns_pkt_ad(reply));
/* codes */
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_OPCODE,
(int) ldns_pkt_get_opcode(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_RCODE,
(int) ldns_pkt_get_rcode(reply));
/* default z to 0 */
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_Z, 0);
/* counts */
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_QDCOUNT,
(int) ldns_pkt_qdcount(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_ANCOUNT,
(int) ldns_pkt_ancount(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_NSCOUNT,
(int) ldns_pkt_nscount(reply));
r |= getdns_dict_set_int(result, GETDNS_STR_KEY_ARCOUNT,
(int) ldns_pkt_arcount(reply));
if (r != 0) { if (r != 0) {
getdns_dict_destroy(result); getdns_dict_destroy(result);