<commit_before>#ifndef DNSMESSAGE_H
#define DNSMESSAGE_H

/**
 * This file holds the definition for the dnsmsg_t struct, structs for its 
 * components (dnsmsg_header and dnsmsg_query), as well as function 
 * prototypes used in junction with these structs.
 *
 * @author <NAME>
 * @version 03/19/2016 
 */

#include <stdint.h>
#include <stdlib.h>

#include "dnsrecord.h"

#define DNSMSG_OPT_QR 0x8000
#define DNSMSG_OPT_AA 0x400
#define DNSMSG_OPT_TC 0x200
#define DNSMSG_OPT_RD 0x100
#define DNSMSG_OPT_RA 0x80

/** 
 * This struct holds information found in the DNS packet header all specified
 * in RFC 1035. 
 */
struct dnsmsg_header {
    /** The ID of the DNS message. When being created,this is random */
    uint16_t id;
    
    /** Whether this DNS message is a query or not (1 or 0 respectively) */
    uint8_t qr;
    
    /** 
     * This is the opcode for the DNS message. Opcodes can be found in the
     * "dnstypes.h" file.
     */
    uint8_t opcode;
    
    /** Whether this query is an authoritative answer or not (1 or 0) */
    uint8_t aa;
    
    /** Whether this DNS message has truncated data */
    uint8_t tc;
    
    /** Whether recursion is desired if this is a query */
    uint8_t rd;
    
    /** Whether recursion is available if this is a repsonse */
    uint8_t ra;
    
    /** 
     * The z code (3 bits) for this query (usually 000). Only the least 
     * significant bits of this field are used. 
     */
    uint8_t z;
    
    /**
     * This is the response code of the DNS message (if it was a response).
     * Only the least 4 sig bits are used.
     */
    uint8_t rcode;
    
    /**
     * 2 octet number showing the number of questions associated with this 
     * message
     */
    uint16_t qdcount;
    
    /**
     * 2 octet number showing the number of answers associated with this
     * message.
     */
    uint16_t ancount;
    
    /** 
     * 2 octet field showing the number of authoritative records associated 
     * with this message.
     */
    uint16_t nscount;
    
    /** 
     * 2 octet field showing the number of additional records associated 
     * with this message.
     */
    uint16_t arcount;
};

/** 
 * This struct holds information found in the question section of DNS 
 * messages as specified in RFC 1035.
 */
struct dnsmsg_query {
    /**
     * This is the byte buffer holding the name in question
     */
    uint8_t *qname;
    
    /**
     * This is the query type which can be specified through the "dnstypes.h"
     * file macros.
     */<commit_msg>Made qname a readable string instead of DNS formatted bytes<commit_after>#ifndef DNSMESSAGE_H
#define DNSMESSAGE_H

/**
 * This file holds the definition for the dnsmsg_t struct, structs for its 
 * components (dnsmsg_header and dnsmsg_query), as well as function 
 * prototypes used in junction with these structs.
 *
 * @author <NAME>
 * @version 03/19/2016 
 */

#include <stdint.h>
#include <stdlib.h>

#include "dnsrecord.h"

#define DNSMSG_OPT_QR 0x8000
#define DNSMSG_OPT_AA 0x400
#define DNSMSG_OPT_TC 0x200
#define DNSMSG_OPT_RD 0x100
#define DNSMSG_OPT_RA 0x80

/** 
 * This struct holds information found in the DNS packet header all specified
 * in RFC 1035. 
 */
struct dnsmsg_header {
    /** The ID of the DNS message. When being created,this is random */
    uint16_t id;
    
    /** Whether this DNS message is a query or not (1 or 0 respectively) */
    uint8_t qr;
    
    /** 
     * This is the opcode for the DNS message. Opcodes can be found in the
     * "dnstypes.h" file.
     */
    uint8_t opcode;
    
    /** Whether this query is an authoritative answer or not (1 or 0) */
    uint8_t aa;
    
    /** Whether this DNS message has truncated data */
    uint8_t tc;
    
    /** Whether recursion is desired if this is a query */
    uint8_t rd;
    
    /** Whether recursion is available if this is a repsonse */
    uint8_t ra;
    
    /** 
     * The z code (3 bits) for this query (usually 000). Only the least 
     * significant bits of this field are used. 
     */
    uint8_t z;
    
    /**
     * This is the response code of the DNS message (if it was a response).
     * Only the least 4 sig bits are used.
     */
    uint8_t rcode;
    
    /**
     * 2 octet number showing the number of questions associated with this 
     * message
     */
    uint16_t qdcount;
    
    /**
     * 2 octet number showing the number of answers associated with this
     * message.
     */
    uint16_t ancount;
    
    /** 
     * 2 octet field showing the number of authoritative records associated 
     * with this message.
     */
    uint16_t nscount;
    
    /** 
     * 2 octet field showing the number of additional records associated 
     * with this message.
     */
    uint16_t arcount;
};

/** 
 * This struct holds information found in the question section of DNS 
 * messages as specified in RFC 1035.
 */
struct dnsmsg_query {
    /**
     * This is the byte buffer holding the name in question
     */
    char *qname;
    
    /**
     * This is the query type which can be specified through the "dnstypes.h"
     * file macros.
     */
{'fraction_non_alphanumeric': 0.07738673925724285, 'fraction_numerical': 0.0262492708535874, 'mean_word_length': 2.272264631043257, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6564350', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1553, 'n_words': 635}