GNUnet  0.10.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 121 of file transport_api_blacklist.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(), GNUNET_TRANSPORT_Blacklist::mq, and mq_error_handler().

Referenced by GNUNET_TRANSPORT_blacklist(), and mq_error_handler().

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

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.

82 {
83  struct GNUNET_TRANSPORT_Blacklist *br = cls;
84  struct GNUNET_MQ_Envelope *env;
85  struct BlacklistMessage *res;
86 
87  GNUNET_break (0 == ntohl (bm->is_allowed));
88  env = GNUNET_MQ_msg (res,
90  res->is_allowed = htonl (br->cb (br->cb_cls,
91  &bm->peer));
92  res->peer = bm->peer;
93  GNUNET_MQ_send (br->mq,
94  env);
95 }
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:618
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:613
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Change in blacklisting (either request or notification, depending on which direction it is going)...
Definition: transport.h:600
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY
Reply from blacklisting client (answer to blacklist query).
static int res
struct GNUNET_MQ_Handle * mq
Connection to transport service.
Handle for blacklisting requests.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_TRANSPORT_BlacklistCallback cb
Function to call for determining if a peer is allowed to communicate with us.
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
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 106 of file transport_api_blacklist.c.

References reconnect().

Referenced by reconnect().

108 {
109  struct GNUNET_TRANSPORT_Blacklist *br = cls;
110 
111  reconnect (br);
112 }
Handle for blacklisting requests.
static void reconnect(struct GNUNET_TRANSPORT_Blacklist *br)
Establish blacklist connection to transport service.
Here is the call graph for this function:
Here is the caller graph for this function: