30#include "gnunet_signatures.h"
37#define LOG(kind, ...) GNUNET_log_from (kind, "abd-api", __VA_ARGS__)
154 handle->reconnect_task = NULL;
169 handle->reconnect_backoff =
219 uint32_t r_id = ntohl (vr_msg->
id);
221 size_t mlen = ntohs (vr_msg->
header.
size) -
sizeof (*vr_msg);
222 uint32_t d_count = ntohl (vr_msg->
d_count);
223 uint32_t c_count = ntohl (vr_msg->
c_count);
230 "Received verify reply from ABD service\n");
231 for (vr =
handle->request_head; NULL != vr; vr = vr->
next)
232 if (vr->
r_id == r_id)
244 (
const char *) &vr_msg[1],
251 proc (proc_cls, 0, NULL, 0,
256 proc (proc_cls, d_count, d_chain, c_count, dels);
275 uint32_t r_id = ntohl (vr_msg->
id);
276 uint32_t
size = ntohl (vr_msg->
size);
277 bool is_bw = ntohs (vr_msg->
is_bw);
285 "Received intermediate reply from ABD service\n");
287 for (vr =
handle->request_head; NULL != vr; vr = vr->
next)
288 if (vr->
r_id == r_id)
300 (
const char *) &vr_msg[1],
305 proc (proc_cls, dd, is_bw);
342 for (vr =
handle->request_head; NULL != vr; vr = vr->
next)
383 if (NULL !=
handle->reconnect_task)
386 handle->reconnect_task = NULL;
426 const char *issuer_attribute,
439 if (NULL == issuer_attribute)
447 "Trying to collect `%s' in ABD\n",
449 nlen = strlen (issuer_attribute) + 1;
464 c_msg->
id = htonl (vr->
r_id);
470 GNUNET_memcpy (&c_msg[1], issuer_attribute, strlen (issuer_attribute));
500 const char *issuer_attribute,
502 uint32_t delegate_count,
516 if ((NULL == issuer_attribute) || (NULL == delegates))
526 "Trying to verify `%s' in ABD\n",
528 nlen = strlen (issuer_attribute) + 1 + clen;
543 v_msg->
id = htonl (vr->
r_id);
545 v_msg->
d_count = htonl (delegate_count);
550 GNUNET_memcpy (&v_msg[1], issuer_attribute, strlen (issuer_attribute));
555 + strlen (issuer_attribute) + 1);
struct GNUNET_MQ_MessageHandlers handlers[]
IPC messages between ABD API and ABD service.
static void handle_intermediate(void *cls, const struct DelegationChainIntermediateMessage *vr_msg)
static void handle_result(void *cls, const struct DelegationChainResultMessage *vr_msg)
Handler for messages received from the ABD 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(struct GNUNET_ABD_Handle *handle)
Reconnect to ABD service.
static void force_reconnect(struct GNUNET_ABD_Handle *handle)
Disconnect from service and then reconnect.
static int check_intermediate(void *cls, const struct DelegationChainIntermediateMessage *vr_msg)
static int check_result(void *cls, const struct DelegationChainResultMessage *vr_msg)
Check validity of message received from the ABD service.
static void reconnect_task(void *cls)
Reconnect to ABD.
ssize_t GNUNET_ABD_delegates_serialize(unsigned int c_count, const struct GNUNET_ABD_Delegate *cd, size_t dest_size, char *dest)
Serizalize the given abds.
size_t GNUNET_ABD_delegates_get_size(unsigned int c_count, const struct GNUNET_ABD_Delegate *cd)
Calculate how many bytes we will need to serialize the abds.
int GNUNET_ABD_delegation_chain_deserialize(size_t len, const char *src, unsigned int d_count, struct GNUNET_ABD_Delegation *dd, unsigned int c_count, struct GNUNET_ABD_Delegate *cd)
Deserialize the given destination.
API to serialize and deserialize delegation chains and abds.
static char * issuer_key
Issuer pubkey string.
enum GNUNET_ABD_AlgoDirectionFlags direction
API enum, filled and passed for collect/verify.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_GNS_LookupWithTldRequest * lr
Handle to lookup request.
static int result
Global testing status.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
API to the Credential service.
Identity service; implements identity management for GNUnet.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
void(* GNUNET_ABD_IntermediateResultProcessor)(void *cls, struct GNUNET_ABD_Delegation *delegation, bool is_bw)
GNUNET_ABD_AlgoDirectionFlags
struct GNUNET_ABD_Handle * GNUNET_ABD_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the ABD service.
struct GNUNET_ABD_Request * GNUNET_ABD_verify(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_PublicKey *subject_key, uint32_t delegate_count, const struct GNUNET_ABD_Delegate *delegates, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute verification.
void GNUNET_ABD_disconnect(struct GNUNET_ABD_Handle *handle)
Shutdown connection with the ABD service.
void GNUNET_ABD_request_cancel(struct GNUNET_ABD_Request *lr)
Cancel pending verify request.
struct GNUNET_ABD_Request * GNUNET_ABD_collect(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_PrivateKey *subject_key, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute collection.
void(* GNUNET_ABD_CredentialResultProcessor)(void *cls, unsigned int d_count, struct GNUNET_ABD_Delegation *delegation_chain, unsigned int c_count, struct GNUNET_ABD_Delegate *delegte)
Iterator called on obtained result for an attribute verification.
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.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#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.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
GNUNET_MQ_Error
Error codes for the queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#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_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT
#define GNUNET_MESSAGE_TYPE_ABD_COLLECT
#define GNUNET_MESSAGE_TYPE_ABD_VERIFY
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Message from client to Credential service to collect credentials.
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.
uint16_t resolution_algo
Direction of the resolution algo.
uint16_t issuer_attribute_len
Length of the issuer attribute.
struct GNUNET_CRYPTO_PrivateKey subject_key
Subject public key.
uint32_t id
Unique identifier for this request (for key collisions).
Message from ABD service to client: new results.
uint32_t del_found
Indicates if credential has been found at all.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT.
uint32_t d_count
The number of delegations in the response.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t c_count
The number of credentials in the response.
Connection to the ABD service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Reconnect task.
struct GNUNET_ABD_Request * request_tail
Tail of linked list of active verify requests.
struct GNUNET_ABD_Request * request_head
Head of linked list of active verify requests.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
uint32_t r_id_gen
Request Id generator.
struct GNUNET_TIME_Relative reconnect_backoff
How long do we wait until we try to reconnect?
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Handle to a verify request.
void * proc_cls
verify_proc closure
GNUNET_ABD_CredentialResultProcessor verify_proc
processor to call on verify result
struct GNUNET_ABD_Handle * abd_handle
handle to abd service
GNUNET_ABD_IntermediateResultProcessor int_proc
processor to call on intermediate result
struct GNUNET_ABD_Request * next
DLL.
void * proc2_cls
verify_proc2 closure
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
struct GNUNET_ABD_Request * prev
DLL.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle to a message queue.
Message handler for a specific message type.
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Message from client to Credential service to verify attributes.
uint16_t resolution_algo
Direction of the resolution algo.
struct GNUNET_CRYPTO_PublicKey subject_key
Subject public key.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t d_count
Number of delegates.
uint16_t issuer_attribute_len
Length of the issuer attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
Trust anchor.