180 size_t payload_length = ntohs (req->
header.
size) -
sizeof(*req);
191 (
const char *) &req[1]);
297 uint16_t reply_length,
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
IPC messages between DNS API and DNS service.
static void force_reconnect(struct GNUNET_DNS_Handle *dh)
Drop the existing connection and reconnect to the DNS service.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void reconnect(void *cls)
Reconnect to the DNS service.
static int check_request(void *cls, const struct GNUNET_DNS_Request *req)
This receives packets from the DNS service and calls the application to check that the request is wel...
static void handle_request(void *cls, const struct GNUNET_DNS_Request *req)
This receives packets from the DNS service and calls the application to handle it.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
API to access the DNS service.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
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...
void GNUNET_DNS_disconnect(struct GNUNET_DNS_Handle *dh)
Disconnect from the DNS service.
void GNUNET_DNS_request_forward(struct GNUNET_DNS_RequestHandle *rh)
If a GNUNET_DNS_RequestHandler calls this function, the request is given to other clients or the glob...
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 d...
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.
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 shou...
GNUNET_DNS_Flags
Flags that specify when to call the client's handler.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST
Type of messages between the gnunet-helper-dns and the service.
#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE
Type of messages between the gnunet-helper-dns and the service.
#define GNUNET_MESSAGE_TYPE_DNS_CLIENT_INIT
Initial message from client to DNS service for registration.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
GNUNET_DNS_RequestHandler rh
Function to call to get replies.
enum GNUNET_DNS_Flags flags
Flags for events we care about.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
uint32_t generation
Re-connect counter, to make sure we did not reconnect in the meantime.
unsigned int pending_requests
Number of GNUNET_DNS_RequestHandles we have outstanding.
void * rh_cls
Closure for rh.
Message from client to DNS service to register itself.
Handle to identify an individual DNS request.
struct GNUNET_DNS_Handle * dh
Handle to DNS API.
uint32_t generation
Re-connect counter, to make sure we did not reconnect in the meantime.
uint64_t request_id
Stored in network byte order (as for us, it is just a random number).
Message from DNS service to client: please handle a request.
uint32_t reserved
Always zero.
uint64_t request_id
Unique request ID.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST.
Message from client to DNS service: here is my reply.
uint32_t drop_flag
Zero to drop, 1 for no change (no payload), 2 for update (message has payload).
uint64_t request_id
Unique request ID.
Handle to a message queue.
Message handler for a specific message type.
Entry in list of pending tasks.