GNUnet 0.22.2
reclaim_plugin.h File Reference
Include dependency graph for reclaim_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_reclaim_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_reclaim_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Entry point for the plugin. More...
 
void REST_reclaim_done (struct GNUNET_REST_Plugin *api)
 Exit point from the plugin. More...
 

Function Documentation

◆ REST_reclaim_process_request()

enum GNUNET_GenericReturnValue REST_reclaim_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 1411 of file reclaim_plugin.c.

1415{
1416 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1418 static const struct GNUNET_REST_RequestHandler handlers[] =
1419 { { MHD_HTTP_METHOD_GET,
1421 { MHD_HTTP_METHOD_POST,
1423 { MHD_HTTP_METHOD_DELETE,
1425 { MHD_HTTP_METHOD_GET,
1427 { MHD_HTTP_METHOD_POST,
1429 { MHD_HTTP_METHOD_DELETE,
1431 { MHD_HTTP_METHOD_GET,
1433 { MHD_HTTP_METHOD_POST,
1435 { MHD_HTTP_METHOD_POST,
1437 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1439
1440 handle->response_code = 0;
1442 handle->proc_cls = proc_cls;
1443 handle->proc = proc;
1444 handle->rest_handle = rest_handle;
1445
1446 handle->url = GNUNET_strdup (rest_handle->url);
1447 if (handle->url[strlen (handle->url) - 1] == '/')
1448 handle->url[strlen (handle->url) - 1] = '\0';
1449 handle->timeout_task =
1453 handle);
1454 if (GNUNET_NO ==
1455 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1456 {
1458 return GNUNET_NO;
1459 }
1460
1461 return GNUNET_YES;
1462}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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
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.
Definition: scheduler.c:1277
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_REST_API_NS_IDENTITY_REVOKE
Revoke namespace.
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
static void do_timeout(void *cls)
Task run on timeout, sends error message.
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke namespace.
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
static void delete_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes credential from an identity.
static void revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#define GNUNET_REST_API_NS_RECLAIM
REST root namespace.
static void delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
static void list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List tickets for identity request.
static struct RequestHandle * requests_head
DLL.
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
static void list_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists credential for identity request.
static void add_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static struct RequestHandle * requests_tail
DLL.
static void add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
static void consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void cleanup_handle(void *cls)
Cleanup lookup handle.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.
The request handle.
Definition: config_plugin.c:47

References add_attribute_cont(), add_credential_cont(), cleanup_handle(), consume_ticket_cont(), delete_attribute_cont(), delete_credential_cont(), do_timeout(), GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_NO, GNUNET_REST_API_NS_IDENTITY_CONSUME, GNUNET_REST_API_NS_IDENTITY_REVOKE, GNUNET_REST_API_NS_IDENTITY_TICKETS, GNUNET_REST_API_NS_RECLAIM, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, handle, handlers, list_attribute_cont(), list_credential_cont(), list_tickets_cont(), options_cont(), GNUNET_REST_RequestHandler::proc, requests_head, requests_tail, revoke_ticket_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_reclaim_init()

void * REST_reclaim_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
Parameters
clsConfig info
Returns
NULL on error, otherwise the plugin context

Definition at line 1472 of file reclaim_plugin.c.

1473{
1474 static struct Plugin plugin;
1475 struct GNUNET_REST_Plugin *api;
1476
1477 rcfg = c;
1478 if (NULL != plugin.cfg)
1479 return NULL; /* can only initialize once! */
1480 memset (&plugin, 0, sizeof(struct Plugin));
1481 plugin.cfg = rcfg;
1482 api = GNUNET_new (struct GNUNET_REST_Plugin);
1483 api->cls = &plugin;
1486 "%s, %s, %s, %s, %s",
1487 MHD_HTTP_METHOD_GET,
1488 MHD_HTTP_METHOD_POST,
1489 MHD_HTTP_METHOD_PUT,
1490 MHD_HTTP_METHOD_DELETE,
1491 MHD_HTTP_METHOD_OPTIONS);
1496 _ ("Identity Provider REST API initialized\n"));
1497 return api;
1498}
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:487
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1118
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
#define ID_REST_STATE_INIT
State while collecting all egos.
static int state
The processing state.
static void list_ego(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
If listing is enabled, prints information about the egos.
static char * allow_methods
HTTP methods allows for this plugin.
static struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
const struct GNUNET_CONFIGURATION_Handle * rcfg
The configuration handle.
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 _, allow_methods, GNUNET_REST_Plugin::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_new, GNUNET_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM, ID_REST_STATE_INIT, identity_handle, idp, list_ego(), GNUNET_REST_Plugin::name, plugin, rcfg, and state.

Referenced by run().

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

◆ REST_reclaim_done()

void REST_reclaim_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 1508 of file reclaim_plugin.c.

1509{
1510 struct Plugin *plugin = api->cls;
1511 struct RequestHandle *request;
1512 struct EgoEntry *ego_entry;
1513 struct EgoEntry *ego_tmp;
1514
1515 plugin->cfg = NULL;
1516 while (NULL != (request = requests_head))
1517 do_error (request);
1518 if (NULL != idp)
1520 if (NULL != identity_handle)
1522 for (ego_entry = ego_head; NULL != ego_entry;)
1523 {
1524 ego_tmp = ego_entry;
1525 ego_entry = ego_entry->next;
1526 GNUNET_free (ego_tmp->identifier);
1527 GNUNET_free (ego_tmp->keystring);
1528 GNUNET_free (ego_tmp);
1529 }
1530
1532 GNUNET_free (api);
1534 "Identity Provider REST plugin is finished\n");
1535}
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1150
static struct EgoEntry * ego_head
Ego list.
static void do_error(void *cls)
Task run on error, sends error message.
The default namestore ego.
char * identifier
Ego Identifier.
char * keystring
Public key string.
struct EgoEntry * next
DLL.
void * cls
Closure for all of the callbacks.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47

References allow_methods, Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, do_error(), ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, GNUNET_RECLAIM_disconnect(), EgoEntry::identifier, identity_handle, idp, EgoEntry::keystring, EgoEntry::next, plugin, request, and requests_head.

Referenced by do_shutdown().

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