GNUnet 0.22.0
identity_plugin.h File Reference
Include dependency graph for identity_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_identity_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_identity_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Entry point for the plugin. More...
 
void REST_identity_done (struct GNUNET_REST_Plugin *api)
 Exit point from the plugin. More...
 

Function Documentation

◆ REST_identity_process_request()

enum GNUNET_GenericReturnValue REST_identity_process_request ( void *  plugin,
struct GNUNET_REST_RequestHandle rest_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
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 callback function
Returns
GNUNET_OK if request accepted

Definition at line 1185 of file identity_plugin.c.

1189{
1190 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1192 static const struct GNUNET_REST_RequestHandler handlers[] =
1193 { { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1194 &ego_get_pubkey },
1195 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name },
1196 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_get_all },
1197 { MHD_HTTP_METHOD_PUT,
1199 &ego_edit_pubkey },
1200 { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name },
1201 { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create },
1202 { MHD_HTTP_METHOD_DELETE,
1205 { MHD_HTTP_METHOD_DELETE,
1207 &ego_delete_name },
1208 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont },
1209 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_SIGN, &ego_sign_data},
1211
1212
1214 handle->proc_cls = proc_cls;
1215 handle->proc = proc;
1216 handle->rest_handle = rest_handle;
1217 handle->data = rest_handle->data;
1218 handle->data_size = rest_handle->data_size;
1219
1220 handle->url = GNUNET_strdup (rest_handle->url);
1221 if (handle->url[strlen (handle->url) - 1] == '/')
1222 handle->url[strlen (handle->url) - 1] = '\0';
1223 handle->timeout_task =
1227 handle);
1228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1229 if (GNUNET_NO ==
1230 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1231 {
1233 return GNUNET_NO;
1234 }
1235
1236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1237 return GNUNET_YES;
1238}
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.
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
#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:1276
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static void ego_sign_data(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void ego_edit_pubkey(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity PUT request with public key.
static void ego_get_name(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity GET request with a name.
#define GNUNET_REST_API_NS_IDENTITY
Identity Namespace.
static void ego_create(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity POST request.
static void ego_delete_name(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity DELETE request with name.
static void ego_get_pubkey(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity GET request with a public key.
static void ego_get_all(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity GET request - responds with all identities.
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.
#define GNUNET_REST_API_NS_SIGN
Identity Namespace with sign specifier.
#define GNUNET_REST_API_NS_IDENTITY_NAME
Identity Namespace with public key specifier.
static struct RequestHandle * requests_tail
DLL.
static void ego_edit_name(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity PUT request with name.
#define GNUNET_REST_API_NS_IDENTITY_PUBKEY
Identity Namespace with public key specifier.
static void do_error(void *cls)
Task run on errors.
static void cleanup_handle(void *cls)
Cleanup lookup handle.
static void ego_delete_pubkey(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle identity DELETE request with public key.
const char * data
The POST data.
const char * url
The url as string.
size_t data_size
The POST data size.
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(), GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), ego_create(), ego_delete_name(), ego_delete_pubkey(), ego_edit_name(), ego_edit_pubkey(), ego_get_all(), ego_get_name(), ego_get_pubkey(), ego_sign_data(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_REST_API_NS_IDENTITY, GNUNET_REST_API_NS_IDENTITY_NAME, GNUNET_REST_API_NS_IDENTITY_PUBKEY, GNUNET_REST_API_NS_SIGN, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, handle, handlers, options_cont(), GNUNET_REST_RequestHandler::proc, requests_head, requests_tail, 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_identity_init()

void * REST_identity_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 1248 of file identity_plugin.c.

1249{
1250 static struct Plugin plugin;
1251 struct GNUNET_REST_Plugin *api;
1252
1253 id_cfg = c;
1254 if (NULL != plugin.cfg)
1255 return NULL; /* can only initialize once! */
1256 memset (&plugin, 0, sizeof(struct Plugin));
1257 plugin.cfg = c;
1258 api = GNUNET_new (struct GNUNET_REST_Plugin);
1259 api->cls = &plugin;
1262 "%s, %s, %s, %s, %s",
1263 MHD_HTTP_METHOD_GET,
1264 MHD_HTTP_METHOD_POST,
1265 MHD_HTTP_METHOD_PUT,
1266 MHD_HTTP_METHOD_DELETE,
1267 MHD_HTTP_METHOD_OPTIONS);
1270
1271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n"));
1272 return api;
1273}
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
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
const struct GNUNET_CONFIGURATION_Handle * id_cfg
The configuration handle.
#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)
static char * allow_methods
HTTP methods allows for this plugin.
static struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
#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 _, allow_methods, GNUNET_REST_Plugin::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_new, GNUNET_REST_API_NS_IDENTITY, id_cfg, ID_REST_STATE_INIT, identity_handle, list_ego(), GNUNET_REST_Plugin::name, plugin, and state.

Referenced by run().

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

◆ REST_identity_done()

void REST_identity_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 1283 of file identity_plugin.c.

1284{
1285 struct Plugin *plugin = api->cls;
1286 struct EgoEntry *ego_entry;
1287 struct EgoEntry *ego_tmp;
1288
1289 plugin->cfg = NULL;
1290 while (NULL != requests_head)
1292 if (NULL != identity_handle)
1294
1295 for (ego_entry = ego_head; NULL != ego_entry;)
1296 {
1297 ego_tmp = ego_entry;
1298 ego_entry = ego_entry->next;
1299 GNUNET_free (ego_tmp->identifier);
1300 GNUNET_free (ego_tmp->keystring);
1301 GNUNET_free (ego_tmp);
1302 }
1303
1305 GNUNET_free (api);
1306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n");
1307}
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.
static struct EgoEntry * ego_head
Ego list.
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, cleanup_handle(), GNUNET_BLOCK_PluginFunctions::cls, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, EgoEntry::identifier, identity_handle, EgoEntry::keystring, EgoEntry::next, plugin, and requests_head.

Referenced by do_shutdown().

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