Typedefs | |
typedef void(* | GNUNET_DNS_RequestHandler) (void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request) |
Signature of a function that is called whenever the DNS service encounters a DNS request and needs to do something with it. More... | |
Enumerations | |
enum | GNUNET_DNS_Flags { GNUNET_DNS_FLAG_NEVER = 0 , GNUNET_DNS_FLAG_REQUEST_MONITOR = 1 , GNUNET_DNS_FLAG_PRE_RESOLUTION = 2 , GNUNET_DNS_FLAG_POST_RESOLUTION = 4 , GNUNET_DNS_FLAG_RESPONSE_MONITOR = 8 } |
Flags that specify when to call the client's handler. More... | |
Functions | |
void | GNUNET_DNS_request_forward (struct GNUNET_DNS_RequestHandle *rh) |
If a GNUNET_DNS_RequestHandler calls this function, the client has no desire to interfere with the request and it should continue to be processed normally. More... | |
void | GNUNET_DNS_request_drop (struct GNUNET_DNS_RequestHandle *rh) |
If a GNUNET_DNS_RequestHandler calls this function, the request is to be dropped and no response should be generated. More... | |
void | GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh, uint16_t reply_length, const char *reply) |
If a GNUNET_DNS_RequestHandler calls this function, the request is supposed to be answered with the data provided to this call (with the modifications the function might have made). More... | |
struct GNUNET_DNS_Handle * | GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_DNS_Flags flags, GNUNET_DNS_RequestHandler rh, void *rh_cls) |
Connect to the service-dns. More... | |
void | GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *dh) |
Disconnect from the DNS service. More... | |
typedef void(* GNUNET_DNS_RequestHandler) (void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request) |
Signature of a function that is called whenever the DNS service encounters a DNS request and needs to do something with it.
The function has then the chance to generate or modify the response by calling one of the three "GNUNET_DNS_request_*" continuations.
When a request is intercepted, this function is called first to give the client a chance to do the complete address resolution; "rdata" will be NULL for this first call for a DNS request, unless some other client has already filled in a response.
If multiple clients exist, all of them are called before the global DNS. The global DNS is only called if all of the clients' functions call GNUNET_DNS_request_forward. Functions that call GNUNET_DNS_request_forward will be called again before a final response is returned to the application. If any of the clients' functions call GNUNET_DNS_request_drop, the response is dropped.
cls | closure |
rh | request handle to user for reply |
request_length | number of bytes in request |
request | udp payload of the DNS request |
Definition at line 126 of file gnunet_dns_service.h.
enum GNUNET_DNS_Flags |
Flags that specify when to call the client's handler.
Enumerator | |
---|---|
GNUNET_DNS_FLAG_NEVER | Useless option: never call the client. |
GNUNET_DNS_FLAG_REQUEST_MONITOR | Set this flag to see all requests first prior to resolution (for monitoring). Clients that set this flag must then call "GNUNET_DNS_request_forward" when they process a request for the first time. Calling "GNUNET_DNS_request_answer" is not allowed for MONITOR peers. |
GNUNET_DNS_FLAG_PRE_RESOLUTION | This client should be called on requests that have not yet been resolved as this client provides a resolution service. Note that this does not guarantee that the client will see all requests as another client might be called first and that client might have already done the resolution, in which case other pre-resolution clients won't see the request anymore. |
GNUNET_DNS_FLAG_POST_RESOLUTION | This client wants to be called on the results of a DNS resolution (either resolved by PRE-RESOLUTION clients or the global DNS). The client then has a chance to modify the answer (or cause it to be dropped). There is no guarantee that other POST-RESOLUTION client's won't modify (or drop) the answer afterwards. |
GNUNET_DNS_FLAG_RESPONSE_MONITOR | Set this flag to see all requests just before they are returned to the network. Clients that set this flag must then call "GNUNET_DNS_request_forward" when they process a request for the last time. Calling "GNUNET_DNS_request_answer" is not allowed for MONITOR peers. |
Definition at line 56 of file gnunet_dns_service.h.
void GNUNET_DNS_request_forward | ( | struct GNUNET_DNS_RequestHandle * | rh | ) |
If a GNUNET_DNS_RequestHandler calls this function, the client has no desire to interfere with the request and it should continue to be processed normally.
rh | request that should now be forwarded |
If a GNUNET_DNS_RequestHandler calls this function, the client has no desire to interfere with the request and it should continue to be processed normally.
Once a global response has been obtained, the request handler is AGAIN called to give it a chance to observe and modify the response after the "normal" resolution. It is not legal for the request handler to call this function if a response is already present.
rh | request that should now be forwarded |
Definition at line 237 of file dns_api.c.
References GNUNET_DNS_RequestHandle::dh, GNUNET_DNS_Response::drop_flag, env, GNUNET_DNS_RequestHandle::generation, GNUNET_DNS_Handle::generation, GNUNET_assert, GNUNET_free, GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_DNS_Handle::mq, GNUNET_DNS_Handle::pending_requests, GNUNET_DNS_Response::request_id, and GNUNET_DNS_RequestHandle::request_id.
Referenced by display_request(), dns_post_request_handler(), handle_dns_request(), and modify_request().
void GNUNET_DNS_request_drop | ( | struct GNUNET_DNS_RequestHandle * | rh | ) |
If a GNUNET_DNS_RequestHandler calls this function, the request is to be dropped and no response should be generated.
rh | request that should now be dropped |
Definition at line 265 of file dns_api.c.
References GNUNET_DNS_RequestHandle::dh, GNUNET_DNS_Response::drop_flag, env, GNUNET_DNS_RequestHandle::generation, GNUNET_DNS_Handle::generation, GNUNET_assert, GNUNET_free, GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_DNS_Handle::mq, GNUNET_DNS_Handle::pending_requests, GNUNET_DNS_Response::request_id, and GNUNET_DNS_RequestHandle::request_id.
Referenced by abort_all_requests(), dns_post_request_handler(), dns_pre_request_handler(), finish_request(), GNS_interceptor_done(), timeout_request(), and vpn_allocation_callback().
void GNUNET_DNS_request_answer | ( | struct GNUNET_DNS_RequestHandle * | rh, |
uint16_t | reply_length, | ||
const char * | reply | ||
) |
If a GNUNET_DNS_RequestHandler calls this function, the request is supposed to be answered with the data provided to this call (with the modifications the function might have made).
The reply given must always be a valid DNS reply and not a mutated DNS request.
rh | request that should now be answered |
reply_length | size of reply (uint16_t to force sane size) |
reply | reply data |
rh | request that should now be answered |
reply_length | size of reply (uint16_t to force sane size) |
reply | reply data |
Definition at line 296 of file dns_api.c.
References GNUNET_DNS_RequestHandle::dh, GNUNET_DNS_Response::drop_flag, env, GNUNET_DNS_RequestHandle::generation, GNUNET_DNS_Handle::generation, GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_DNS_Handle::mq, GNUNET_DNS_Handle::pending_requests, GNUNET_DNS_Response::request_id, and GNUNET_DNS_RequestHandle::request_id.
Referenced by finish_request(), handle_dns_response(), modify_request(), and reply_to_dns().
struct GNUNET_DNS_Handle * GNUNET_DNS_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
enum GNUNET_DNS_Flags | flags, | ||
GNUNET_DNS_RequestHandler | rh, | ||
void * | rh_cls | ||
) |
Connect to the service-dns.
cfg | configuration to use |
flags | when to call rh |
rh | function to call with DNS requests |
rh_cls | closure to pass to rh |
Definition at line 340 of file dns_api.c.
References cfg, GNUNET_DNS_Handle::cfg, GNUNET_DNS_Handle::flags, GNUNET_new, GNUNET_SCHEDULER_add_now(), reconnect(), GNUNET_DNS_Handle::reconnect_task, GNUNET_DNS_Handle::rh, and GNUNET_DNS_Handle::rh_cls.
Referenced by GNS_interceptor_init(), and run().
void GNUNET_DNS_disconnect | ( | struct GNUNET_DNS_Handle * | dh | ) |
Disconnect from the DNS service.
dh | DNS handle |
Definition at line 363 of file dns_api.c.
References GNUNET_break, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_DNS_Handle::mq, GNUNET_DNS_Handle::pending_requests, and GNUNET_DNS_Handle::reconnect_task.
Referenced by cleanup(), do_disconnect(), and GNS_interceptor_done().