GNUnet  0.11.x
Data Structures | Functions
transport_api_blacklist.c File Reference

library to access the blacklisting functions of the transport service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_transport_service.h"
#include "transport.h"
Include dependency graph for transport_api_blacklist.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_TRANSPORT_Blacklist
 Handle for blacklisting requests. More...
 

Functions

static void reconnect (struct GNUNET_TRANSPORT_Blacklist *br)
 Establish blacklist connection to transport service. More...
 
static void handle_query (void *cls, const struct BlacklistMessage *bm)
 Handle blacklist queries. 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_TRANSPORT_BlacklistGNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls)
 Install a blacklist callback. More...
 
void GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br)
 Abort the blacklist. More...
 

Detailed Description

library to access the blacklisting functions of the transport service

Author
Christian Grothoff

Definition in file transport_api_blacklist.c.

Function Documentation

◆ reconnect()

static void reconnect ( struct GNUNET_TRANSPORT_Blacklist br)
static

Establish blacklist connection to transport service.

Parameters
broverall handle

Definition at line 120 of file transport_api_blacklist.c.

121 {
125  struct BlacklistMessage,
126  br),
128  };
129  struct GNUNET_MQ_Envelope *env;
130  struct GNUNET_MessageHeader *req;
131 
132  if (NULL != br->mq)
133  GNUNET_MQ_destroy (br->mq);
134  br->mq = GNUNET_CLIENT_connect (br->cfg,
135  "transport",
136  handlers,
138  br);
139  if (NULL == br->mq)
140  return;
141  env = GNUNET_MQ_msg (req,
143  GNUNET_MQ_send (br->mq,
144  env);
145 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
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:1064
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:355
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT
Register a client that wants to do blacklisting.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY
Query to a blacklisting client (is this peer blacklisted)?
Change in blacklisting (either request or notification, depending on which direction it is going).
Definition: transport.h:586
Message handler for a specific message type.
Header for all communications.
struct GNUNET_MQ_Handle * mq
Connection to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
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...

References GNUNET_TRANSPORT_Blacklist::cfg, env, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY, GNUNET_MQ_destroy(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handlers, GNUNET_TRANSPORT_Blacklist::mq, and mq_error_handler().

Referenced by GNUNET_TRANSPORT_blacklist(), and mq_error_handler().

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

◆ handle_query()

static void handle_query ( void *  cls,
const struct BlacklistMessage bm 
)
static

Handle blacklist queries.

Parameters
clsour overall handle
bmquery

Definition at line 78 of file transport_api_blacklist.c.

80 {
81  struct GNUNET_TRANSPORT_Blacklist *br = cls;
82  struct GNUNET_MQ_Envelope *env;
83  struct BlacklistMessage *res;
84 
85  GNUNET_break (0 == ntohl (bm->is_allowed));
88  res->is_allowed = htonl (br->cb (br->cb_cls,
89  &bm->peer));
90  res->peer = bm->peer;
91  GNUNET_MQ_send (br->mq,
92  env);
93 }
static int res
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY
Reply from blacklisting client (answer to blacklist query).
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
Handle for blacklisting requests.
GNUNET_TRANSPORT_BlacklistCallback cb
Function to call for determining if a peer is allowed to communicate with us.

References GNUNET_TRANSPORT_Blacklist::cb, GNUNET_TRANSPORT_Blacklist::cb_cls, env, GNUNET_break, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY, GNUNET_MQ_msg, GNUNET_MQ_send(), BlacklistMessage::is_allowed, GNUNET_TRANSPORT_Blacklist::mq, BlacklistMessage::peer, and res.

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_TRANSPORT_Blacklist *
errorerror code

Definition at line 105 of file transport_api_blacklist.c.

107 {
108  struct GNUNET_TRANSPORT_Blacklist *br = cls;
109 
110  reconnect (br);
111 }
static void reconnect(struct GNUNET_TRANSPORT_Blacklist *br)
Establish blacklist connection to transport service.

References reconnect().

Referenced by reconnect().

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