32const char DNS_HEADER[] = {
 
   64static int generate_dns_header(
unsigned short num_records, 
char *
buf)
 
   66    unsigned short net_num_records = htons(num_records);
 
   70    memcpy(&
buf[6], &net_num_records, 
sizeof(num_records));
 
   75const char DNS_QUESTION [] = {
 
   77    0x05, 0x67, 0x6f, 0x6f, 0x73, 0x65,
 
   79    0x08, 0x66, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x73,
 
  102static int generate_dns_question(
char *
buf)
 
  108const char NAPTR_ANSWER [] = {
 
  116    0x00, 0x00, 0x30, 0x39,
 
  136static int generate_dns_answer(
int ttl, 
char *
buf)
 
  138    int net_ttl = htonl(ttl);
 
  143        memcpy(&
buf[6], &net_ttl, 
sizeof(
int));
 
  151    uint8_t 
len = 
string->len;
 
  152    size_t actual_len = strlen(
string->val);
 
  163    return actual_len + 1;
 
  182        dns_str.len = strlen(part);
 
  193        size_t record_size, 
record_fn generate, 
char *buffer)
 
  198    ptr += generate_dns_header(num_records, ptr);
 
  199    ptr += generate_dns_question(ptr);
 
  201    for (record_iter = 
records; record_iter < (
char *) 
records + num_records * record_size; record_iter += record_size) {
 
  202        unsigned short rdlength;
 
  203        unsigned short net_rdlength;
 
  206        ptr += generate_dns_answer(0, ptr);
 
  207        rdlength = generate(record_iter, ptr + 2);
 
  208        net_rdlength = htons(rdlength);
 
  209        memcpy(ptr, &net_rdlength, 2);
 
  230        size_t record_size, 
record_fn generate, 
char *buffer)
 
 
static int copy(char *infile, char *outfile)
Utility function to copy a file.
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_dns_test_write_domain(const char *string, char *buf)
Write a DNS domain to a buffer.
int ast_dns_test_generate_result(struct ast_dns_query *query, void *records, size_t num_records, size_t record_size, record_fn generate, char *buffer)
Generate a full DNS response for the given DNS records.
int ast_dns_test_write_string(const struct ast_dns_test_string *string, char *buf)
Write a DNS string to a buffer.
int(* record_fn)(void *record, char *buf)
Callback to write specific DNS record to an answer.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Representation of a string in DNS.