Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Data Structures | Typedefs | Functions
dns_test.h File Reference
This graph shows which files directly or indirectly include this file:

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 Documentation

◆ record_fn

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.

Parameters
recordPointer to test-specific DNS record data
bufThe buffer into which to write the DNS record
Returns
The number of bytes written to the buffer

Definition at line 85 of file dns_test.h.

Function Documentation

◆ ast_dns_test_generate_result()

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.

Parameters
queryThe DNS query that is being processed
recordsAn array of test-specific representations of DNS records
num_recordsThe number of elements in the records array
record_sizeThe size of each element in the records array
generateThe test-specific encoder for DNS records
bufferThe buffer into which to write the DNS response

Definition at line 229 of file dns_test.c.

231{
232 return 0;
233}

Referenced by naptr_thread(), and srv_thread().

◆ ast_dns_test_write_domain()

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.

Parameters
stringThe DNS domain to write
bufThe buffer to write the domain into
Returns
The number of bytes written to the buffer

Definition at line 224 of file dns_test.c.

225{
226 return 0;
227}

Referenced by generate_naptr_record(), and generate_srv_record().

◆ ast_dns_test_write_string()

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.

Parameters
stringThe string to write
bufThe buffer to write the string into
Returns
The number of bytes written to the buffer

Definition at line 219 of file dns_test.c.

220{
221 return 0;
222}

Referenced by generate_naptr_record().