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 101 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().

102 {
103  struct GNUNET_MQ_Envelope *env;
104  struct AnnounceMessage *am;
105  size_t slen;
106 
107  a->mq = GNUNET_CLIENT_connect (a->cfg,
108  "regex",
109  NULL,
111  a);
112  if (NULL == a->mq)
113  return;
114  slen = strlen (a->regex) + 1;
115  env = GNUNET_MQ_msg_extra (am,
116  slen,
118  am->compression = htons (a->compression);
119  am->reserved = htons (0);
121  GNUNET_memcpy (&am[1],
122  a->regex,
123  slen);
124  GNUNET_MQ_send (a->mq,
125  env);
126 }
uint16_t compression
How many characters can we squeeze per edge?
Definition: regex_ipc.h:45
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:901
static void announce_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We got a disconnect after asking regex to do the announcement.
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
#define GNUNET_memcpy(dst, src, n)
uint16_t reserved
Always zero.
Definition: regex_ipc.h:50
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:622
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:353
struct GNUNET_TIME_RelativeNBO refresh_delay
Delay between repeated announcements.
Definition: regex_ipc.h:55
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 84 of file regex_api_announce.c.

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

Referenced by announce_reconnect().

86 {
87  struct GNUNET_REGEX_Announcement *a = cls;
88 
89  GNUNET_MQ_destroy (a->mq);
90  a->mq = NULL;
92 }
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:824
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: