GNUnet 0.22.2
config_plugin.h File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_rest_plugin.h"
Include dependency graph for config_plugin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

enum GNUNET_GenericReturnValue REST_config_process_request (void *plugin, struct GNUNET_REST_RequestHandle *conndata_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
 Function processing the REST call. More...
 
void * REST_config_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Entry point for the plugin. More...
 
void REST_config_done (struct GNUNET_REST_Plugin *api)
 Exit point from the plugin. More...
 

Function Documentation

◆ REST_config_process_request()

enum GNUNET_GenericReturnValue REST_config_process_request ( void *  plugin,
struct GNUNET_REST_RequestHandle conndata_handle,
GNUNET_REST_ResultProcessor  proc,
void *  proc_cls 
)

Function processing the REST call.

Parameters
methodHTTP method
urlURL of the HTTP request
databody of the HTTP request (optional)
data_sizelength of the body
proccallback function for the result
proc_clsclosure for proc
Returns
GNUNET_OK if request accepted

Definition at line 371 of file config_plugin.c.

375{
376 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
378 static const struct GNUNET_REST_RequestHandler handlers[] = {
379 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_CONFIG, &get_cont },
380 { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_CONFIG, &set_cont },
381 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_CONFIG, &options_cont },
383 };
384 (void) plugin;
385
386 handle->proc_cls = proc_cls;
387 handle->proc = proc;
388 handle->rest_handle = conndata_handle;
389 handle->url = GNUNET_strdup (conndata_handle->url);
390 if (handle->url[strlen (handle->url) - 1] == '/')
391 handle->url[strlen (handle->url) - 1] = '\0';
394 handle);
395 if (GNUNET_NO ==
396 GNUNET_REST_handle_request (conndata_handle, handlers, &err, handle))
397 {
399 return GNUNET_NO;
400 }
401 return GNUNET_YES;
402}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static struct RequestHandle * requests_head
DLL.
Definition: config_plugin.c:88
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle rest request.
static void set_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle REST POST request.
static void cleanup_handle(struct RequestHandle *handle)
Cleanup request handle.
#define GNUNET_REST_API_NS_CONFIG
Definition: config_plugin.c:34
static struct RequestHandle * requests_tail
DLL.
Definition: config_plugin.c:93
static void get_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle rest request.
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, const struct GNUNET_REST_RequestHandler *handlers, struct GNUNET_REST_RequestHandlerError *err, void *cls)
Definition: rest.c:64
#define GNUNET_REST_HANDLER_END
const char * url
The url as string.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.
The request handle.
Definition: config_plugin.c:47

References cleanup_handle(), get_cont(), GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_NO, GNUNET_REST_API_NS_CONFIG, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_strdup, GNUNET_YES, handle, handlers, options_cont(), plugin, GNUNET_REST_RequestHandler::proc, requests_head, requests_tail, set_cont(), and GNUNET_REST_RequestHandle::url.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ REST_config_init()

void * REST_config_init ( const struct GNUNET_CONFIGURATION_Handle c)

Entry point for the plugin.

Parameters
clsthe "struct GNUNET_NAMESTORE_PluginEnvironment*"
Returns
NULL on error, otherwise the plugin context

Definition at line 426 of file config_plugin.c.

427{
428 static struct Plugin plugin;
429 struct GNUNET_REST_Plugin *api;
430
431 config_cfg = c;
432
433 memset (&plugin, 0, sizeof(struct Plugin));
434 plugin.cfg = c;
435 api = GNUNET_new (struct GNUNET_REST_Plugin);
436 api->cls = &plugin;
438 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("CONFIG REST API initialized\n"));
439 return api;
440}
const struct GNUNET_CONFIGURATION_Handle * config_cfg
Definition: config_plugin.c:44
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_INFO
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct returned by the initialization function of the plugin
void * cls
The closure of the plugin.
const char * name
Plugin name.
Handle for a plugin.
Definition: block.c:38

References _, GNUNET_REST_Plugin::cls, config_cfg, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_REST_API_NS_CONFIG, GNUNET_REST_Plugin::name, and plugin.

Referenced by run().

Here is the caller graph for this function:

◆ REST_config_done()

void REST_config_done ( struct GNUNET_REST_Plugin api)

Exit point from the plugin.

Parameters
clsthe plugin context (as returned by "init")
Returns
always NULL

Definition at line 406 of file config_plugin.c.

407{
408 struct Plugin *plugin;
409
410 while (NULL != requests_head)
412 plugin = api->cls;
413 plugin->cfg = NULL;
415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONFIG REST plugin is finished\n");
416}
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
void * cls
Closure for all of the callbacks.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47

References Plugin::api, cleanup_handle(), GNUNET_BLOCK_PluginFunctions::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, plugin, and requests_head.

Referenced by do_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function: