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

access regex service to advertise capabilities via regex More...

#include "platform.h"
#include "gnunet_protocols.h"
#include "gnunet_util_lib.h"
#include "gnunet_regex_service.h"
#include "regex_ipc.h"
Include dependency graph for regex_api_announce.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_REGEX_Announcement
 Handle to store cached data about a regex announce. More...
 

Macros

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

Functions

static void announce_reconnect (struct GNUNET_REGEX_Announcement *a)
 (Re)connect to the REGEX service with the given announcement a. More...
 
static void announce_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 We got a disconnect after asking regex to do the announcement. More...
 
struct GNUNET_REGEX_AnnouncementGNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *regex, struct GNUNET_TIME_Relative refresh_delay, uint16_t compression)
 Announce the given peer under the given regular expression. More...
 
void GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a)
 Stop announcing the regex specified by the given handle. More...
 

Detailed Description

access regex service to advertise capabilities via regex

Author
Maximilian Szengel
Christian Grothoff

Definition in file regex_api_announce.c.

Macro Definition Documentation

◆ LOG

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

Definition at line 32 of file regex_api_announce.c.

Function Documentation

◆ announce_reconnect()

static void announce_reconnect ( struct GNUNET_REGEX_Announcement a)
static

(Re)connect to the REGEX service with the given announcement a.

Parameters
aREGEX to announce.

Definition at line 100 of file regex_api_announce.c.

References announce_mq_error_handler(), GNUNET_REGEX_Announcement::cfg, AnnounceMessage::compression, GNUNET_REGEX_Announcement::compression, env, GNUNET_CLIENT_connect(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), GNUNET_REGEX_Announcement::mq, AnnounceMessage::refresh_delay, GNUNET_REGEX_Announcement::refresh_delay, GNUNET_REGEX_Announcement::regex, and AnnounceMessage::reserved.

Referenced by announce_mq_error_handler(), and GNUNET_REGEX_announce().

101 {
102  struct GNUNET_MQ_Envelope *env;
103  struct AnnounceMessage *am;
104  size_t slen;
105 
106  a->mq = GNUNET_CLIENT_connect(a->cfg,
107  "regex",
108  NULL,
110  a);
111  if (NULL == a->mq)
112  return;
113  slen = strlen(a->regex) + 1;
114  env = GNUNET_MQ_msg_extra(am,
115  slen,
117  am->compression = htons(a->compression);
118  am->reserved = htons(0);
120  GNUNET_memcpy(&am[1],
121  a->regex,
122  slen);
123  GNUNET_MQ_send(a->mq,
124  env);
125 }
uint16_t compression
How many characters can we squeeze per edge?
Definition: regex_ipc.h:43
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.
Definition: client.c:900
static void announce_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We got a disconnect after asking regex to do the announcement.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t compression
Number of characters per edge.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Request for regex service to announce capability.
Definition: regex_ipc.h:34
uint16_t reserved
Always zero.
Definition: regex_ipc.h:48
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:623
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
char * regex
Message we're sending to the service.
#define GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE
Advertise regex capability.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
struct GNUNET_TIME_RelativeNBO refresh_delay
Delay between repeated announcements.
Definition: regex_ipc.h:53
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_TIME_Relative refresh_delay
Frequency of announcements.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ announce_mq_error_handler()

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

We got a disconnect after asking regex to do the announcement.

Retry.

Parameters
clsthe struct GNUNET_REGEX_Announcement to retry
errorerror code

Definition at line 83 of file regex_api_announce.c.

References announce_reconnect(), GNUNET_MQ_destroy(), and GNUNET_REGEX_Announcement::mq.

Referenced by announce_reconnect().

85 {
86  struct GNUNET_REGEX_Announcement *a = cls;
87 
89  a->mq = NULL;
91 }
static void announce_reconnect(struct GNUNET_REGEX_Announcement *a)
(Re)connect to the REGEX service with the given announcement a.
Handle to store cached data about a regex announce.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
Here is the call graph for this function:
Here is the caller graph for this function: