Asterisk - The Open Source Telephony Project
18.5.0
|
Go to the source code of this file.
Data Structures | |
struct | ast_dns_test_string |
Representation of a string in DNS. More... | |
Typedefs | |
typedef int(* | record_fn) (void *record, char *buf) |
Callback to write specific DNS record to an answer. More... | |
Functions | |
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. More... | |
int | ast_dns_test_write_domain (const char *string, char *buf) |
Write a DNS domain to a buffer. More... | |
int | ast_dns_test_write_string (const struct ast_dns_test_string *string, char *buf) |
Write a DNS string to a buffer. More... | |
typedef int(* record_fn) (void *record, char *buf) |
Callback to write specific DNS record to an answer.
When generating a DNS result, the type of DNS record being generated will need to be performed by individual test cases. This is a callback that tests can define to write a specific type of DNS record to the provided buffer.
There is no buffer size passed to this function. Tests are expected to use a buffer that is sufficiently large for their tests.
record | Pointer to test-specific DNS record data |
buf | The buffer into which to write the DNS record |
Definition at line 85 of file dns_test.h.
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.
This function takes care of generating the DNS header, question, and answer sections of a DNS response. In order to place test-specific record data into the DNS answers, a callback is provided as a parameter to this function so that the necessary records can be encoded properly by the tests.
There is no buffer size passed to this function. Tests are expected to use a buffer that is sufficiently large for their tests.
query | The DNS query that is being processed |
records | An array of test-specific representations of DNS records |
num_records | The number of elements in the records array |
record_size | The size of each element in the records array |
generate | The test-specific encoder for DNS records |
buffer | The buffer into which to write the DNS response |
Definition at line 222 of file dns_test.c.
References ast_dns_test_write_domain(), ast_dns_test_write_string(), buf, generate_dns_answer(), generate_dns_header(), generate_dns_question(), and records.
Referenced by naptr_thread(), and srv_thread().
int ast_dns_test_write_domain | ( | const char * | string, |
char * | buf | ||
) |
Write a DNS domain to a buffer.
A DNS domain consists of a series of labels separated by dots. Each of these labels gets written as a DNS string. A DNS domain ends with a NULL label, which is essentially a zero-length DNS string.
There is no buffer size passed to this function. Tests are expected to use a buffer that is sufficiently large for their tests.
string | The DNS domain to write |
buf | The buffer to write the domain into |
A DNS domain consists of a series of labels separated by dots. Each of these labels gets written as a DNS string. A DNS domain ends with a NULL label, which is essentially a zero-length DNS string.
There is no buffer size passed to this function since we provide the data ourselves and have sized the buffer to be way larger than necessary for the tests.
string | The DNS domain to write |
buf | The buffer to write the domain into |
Definition at line 196 of file dns_test.c.
References ast_dns_test_write_string(), ast_strdupa, ast_strlen_zero, buf, copy(), ast_dns_test_string::len, strsep(), and ast_dns_test_string::val.
Referenced by ast_dns_test_generate_result(), generate_naptr_record(), and generate_srv_record().
int ast_dns_test_write_string | ( | const struct ast_dns_test_string * | string, |
char * | buf | ||
) |
Write a DNS string to a buffer.
This writes the DNS string to the buffer and returns the total number of bytes written to the buffer.
There is no buffer size passed to this function. Tests are expected to use a buffer that is sufficiently large for their tests.
string | The string to write |
buf | The buffer to write the string into |
This writes the DNS string to the buffer and returns the total number of bytes written to the buffer.
There is no buffer size passed to this function since we provide the data ourselves and have sized the buffer to be way larger than necessary for the tests.
string | The string to write |
buf | The buffer to write the string into |
Definition at line 162 of file dns_test.c.
References len(), and ast_dns_test_string::val.
Referenced by ast_dns_test_generate_result(), ast_dns_test_write_domain(), and generate_naptr_record().