1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

support: Provide a way to reorder responses within the DNS test server

This commit is contained in:
Florian Weimer
2020-10-14 10:54:39 +02:00
parent 880a12e96d
commit 873e239a4c
5 changed files with 135 additions and 28 deletions

View File

@@ -35,25 +35,36 @@ struct resolv_edns_info
uint16_t payload_size;
};
/* This opaque struct collects information about the resolver testing
currently in progress. */
struct resolv_test;
/* This struct provides context information when the response callback
specified in struct resolv_redirect_config is invoked. */
struct resolv_response_context
{
const unsigned char *query_buffer;
struct resolv_test *test;
void *client_address;
size_t client_address_length;
unsigned char *query_buffer;
size_t query_length;
int server_index;
bool tcp;
struct resolv_edns_info edns;
};
/* Produces a deep copy of the context. */
struct resolv_response_context *
resolv_response_context_duplicate (const struct resolv_response_context *);
/* Frees the copy. For the context passed to the response function,
this happens implicitly. */
void resolv_response_context_free (struct resolv_response_context *);
/* This opaque struct is used to construct responses from within the
response callback function. */
struct resolv_response_builder;
/* This opaque struct collects information about the resolver testing
currently in progress. */
struct resolv_test;
enum
{
/* Maximum number of test servers supported by the framework. */
@@ -188,6 +199,22 @@ void resolv_response_close (struct resolv_response_builder *);
/* The size of the response packet built so far. */
size_t resolv_response_length (const struct resolv_response_builder *);
/* Allocates a response builder tied to a specific query packet,
starting at QUERY_BUFFER, containing QUERY_LENGTH bytes. */
struct resolv_response_builder *
resolv_response_builder_allocate (const unsigned char *query_buffer,
size_t query_length);
/* Deallocates a response buffer. */
void resolv_response_builder_free (struct resolv_response_builder *);
/* Sends a UDP response using a specific context. This can be used to
reorder or duplicate responses, along with
resolv_response_context_duplicate and
response_builder_allocate. */
void resolv_response_send_udp (const struct resolv_response_context *,
struct resolv_response_builder *);
__END_DECLS
#endif /* SUPPORT_RESOLV_TEST_H */