GNUnet  0.10.x
Data Structures | Macros | Functions
identity_api_suffix_lookup.c File Reference

api to lookup an ego More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "identity.h"
Include dependency graph for identity_api_suffix_lookup.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_IDENTITY_EgoSuffixLookup
 Handle for ego lookup. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
 

Functions

static int check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
 We received a result code from the service. More...
 
static void handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
 We received a result code from the service. More...
 
static int check_identity_update (void *cls, const struct UpdateMessage *um)
 Check validity of identity update message. More...
 
static void handle_identity_update (void *cls, const struct UpdateMessage *um)
 Handle identity update message. More...
 
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 creation of the message queue. More...
 
struct GNUNET_IDENTITY_EgoSuffixLookupGNUNET_IDENTITY_ego_lookup_by_suffix (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *suffix, GNUNET_IDENTITY_EgoSuffixCallback cb, void *cb_cls)
 Lookup an ego by name. More...
 
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (struct GNUNET_IDENTITY_EgoSuffixLookup *el)
 Abort ego lookup attempt. More...
 

Detailed Description

api to lookup an ego

Author
Christian Grothoff

Definition in file identity_api_suffix_lookup.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "identity-api", __VA_ARGS__)

Definition at line 31 of file identity_api_suffix_lookup.c.

Function Documentation

◆ check_identity_result_code()

static int check_identity_result_code ( void *  cls,
const struct ResultCodeMessage rcm 
)
static

We received a result code from the service.

Check the message is well-formed.

Parameters
clsclosure
rcmresult message received
Returns
GNUNET_OK if the message is well-formed

Definition at line 71 of file identity_api_suffix_lookup.c.

References GNUNET_MQ_check_zero_termination, GNUNET_OK, ResultCodeMessage::header, and GNUNET_MessageHeader::size.

72 {
73  (void) cls;
74  if (sizeof (*rcm) != htons (rcm->header.size))
76  return GNUNET_OK;
77 }
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE.
Definition: identity.h:47
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_identity_result_code()

static void handle_identity_result_code ( void *  cls,
const struct ResultCodeMessage rcm 
)
static

We received a result code from the service.

Parameters
clsclosure
rcmresult message received

Definition at line 87 of file identity_api_suffix_lookup.c.

References GNUNET_IDENTITY_EgoSuffixLookup::cb, GNUNET_IDENTITY_EgoSuffixLookup::cb_cls, el, and GNUNET_IDENTITY_ego_lookup_by_suffix_cancel().

88 {
89  struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
90 
91  (void) rcm;
92  el->cb (el->cb_cls, NULL, NULL);
94 }
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el)
Abort ego lookup attempt.
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
Here is the call graph for this function:

◆ check_identity_update()

static int check_identity_update ( void *  cls,
const struct UpdateMessage um 
)
static

Check validity of identity update message.

Parameters
clsclosure
ummessage received
Returns
GNUNET_OK if the message is well-formed

Definition at line 105 of file identity_api_suffix_lookup.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, UpdateMessage::header, UpdateMessage::name_len, size, and GNUNET_MessageHeader::size.

106 {
107  uint16_t size = ntohs (um->header.size);
108  uint16_t name_len = ntohs (um->name_len);
109  const char *str = (const char *) &um[1];
110 
111  (void) cls;
112  if ((size != name_len + sizeof (struct UpdateMessage)) ||
113  ((0 != name_len) && ('\0' != str[name_len - 1])))
114  {
115  GNUNET_break (0);
116  return GNUNET_SYSERR;
117  }
118  return GNUNET_OK;
119 }
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:82
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted...
Definition: identity.h:88
Service informs client about status of a pseudonym.
Definition: identity.h:77

◆ handle_identity_update()

static void handle_identity_update ( void *  cls,
const struct UpdateMessage um 
)
static

Handle identity update message.

Parameters
clsclosure
ummessage received

Definition at line 129 of file identity_api_suffix_lookup.c.

References GNUNET_IDENTITY_EgoSuffixLookup::cb, GNUNET_IDENTITY_EgoSuffixLookup::cb_cls, el, GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(), UpdateMessage::name_len, and UpdateMessage::private_key.

130 {
131  struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
132  uint16_t name_len = ntohs (um->name_len);
133  const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
134 
135  el->cb (el->cb_cls, &um->private_key, str);
137 }
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:98
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el)
Abort ego lookup attempt.
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted...
Definition: identity.h:88
Here is the call graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_IDENTITY_EgoSuffixLookup *
errorerror code

Definition at line 149 of file identity_api_suffix_lookup.c.

References GNUNET_IDENTITY_EgoSuffixLookup::cb, GNUNET_IDENTITY_EgoSuffixLookup::cb_cls, el, and GNUNET_IDENTITY_ego_lookup_by_suffix_cancel().

Referenced by GNUNET_IDENTITY_ego_lookup_by_suffix().

150 {
151  struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
152 
153  (void) error;
154  el->cb (el->cb_cls, NULL, NULL);
156 }
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
void GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el)
Abort ego lookup attempt.
GNUNET_IDENTITY_EgoSuffixCallback cb
Function to call with the result.
Here is the call graph for this function:
Here is the caller graph for this function: