GNUnet  0.10.x
Data Structures | Functions | Variables
gnunet-service-ats_connectivity.c File Reference

ats service, interaction with 'connecivity' API More...

#include "platform.h"
#include "gnunet-service-ats.h"
#include "gnunet-service-ats_addresses.h"
#include "gnunet-service-ats_connectivity.h"
#include "gnunet-service-ats_plugins.h"
#include "ats.h"
Include dependency graph for gnunet-service-ats_connectivity.c:

Go to the source code of this file.

Data Structures

struct  ConnectionRequest
 Active connection requests. More...
 

Functions

unsigned int GAS_connectivity_has_peer (void *cls, const struct GNUNET_PeerIdentity *peer)
 Is the given peer in the list of peers for which we have an address request? More...
 
void GAS_handle_request_address (struct GNUNET_SERVICE_Client *client, const struct RequestAddressMessage *msg)
 Handle GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS messages from clients. More...
 
static int free_matching_requests (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free the connection request from the map if the closure matches the client. More...
 
void GAS_handle_request_address_cancel (struct GNUNET_SERVICE_Client *client, const struct RequestAddressMessage *msg)
 Handle GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL messages from clients. More...
 
void GAS_connectivity_remove_client (struct GNUNET_SERVICE_Client *client)
 Unregister a client (which may have been a connectivity client, but this is not assured). More...
 
void GAS_connectivity_init ()
 Shutdown connectivity subsystem. More...
 
static int free_request (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free the connection request from the map. More...
 
void GAS_connectivity_done ()
 Shutdown connectivity subsystem. More...
 

Variables

static struct GNUNET_CONTAINER_MultiPeerMapconnection_requests
 Address suggestion requests by peer. More...
 

Detailed Description

ats service, interaction with 'connecivity' API

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats_connectivity.c.

Function Documentation

◆ GAS_connectivity_has_peer()

unsigned int GAS_connectivity_has_peer ( void *  cls,
const struct GNUNET_PeerIdentity peer 
)

Is the given peer in the list of peers for which we have an address request?

Parameters
clsunused, NULL
peerpeer to query for
Returns
GNUNET_YES if so, GNUNET_NO if not

Definition at line 63 of file gnunet-service-ats_connectivity.c.

References GNUNET_CONTAINER_multipeermap_contains().

Referenced by GAS_plugin_init().

65 {
66  if (NULL == connection_requests)
67  return 0;
68  /* TODO: return sum of 'strength's of connectivity requests */
70  peer);
71 }
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
int GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL)...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_handle_request_address()

void GAS_handle_request_address ( struct GNUNET_SERVICE_Client client,
const struct RequestAddressMessage msg 
)

Handle GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS messages from clients.

Handle 'request address' messages from clients.

Parameters
clientclient that sent the request
messagethe request message

Definition at line 81 of file gnunet-service-ats_connectivity.c.

References ConnectionRequest::client, GAS_plugin_request_connect_start(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, and RequestAddressMessage::peer.

Referenced by handle_request_address().

83 {
84  struct ConnectionRequest *cr;
85 
87  "Received `%s' message\n",
88  "GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS");
89  /* FIXME: should not ignore "msg->strength" */
90  cr = GNUNET_new(struct ConnectionRequest);
91  cr->client = client;
93  &msg->peer,
94  cr,
97 }
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Active connection requests.
void GAS_plugin_request_connect_start(const struct GNUNET_PeerIdentity *pid)
Notify the plugin that a request to connect to a particular peer was given to us. ...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_log(kind,...)
struct GNUNET_SERVICE_Client * client
Client that made the request.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats.h:101
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_matching_requests()

static int free_matching_requests ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Free the connection request from the map if the closure matches the client.

Parameters
clsthe client to match
pidpeer for which the request was made
valuethe struct ConnectionRequest
Returns
GNUNET_OK (continue to iterate)

Definition at line 110 of file gnunet-service-ats_connectivity.c.

References ConnectionRequest::client, GAS_plugin_request_connect_stop(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_YES, and value.

Referenced by free_request(), GAS_connectivity_remove_client(), and GAS_handle_request_address_cancel().

113 {
114  struct GNUNET_SERVICE_Client *client = cls;
115  struct ConnectionRequest *cr = value;
116 
117  if (cr->client == client)
118  {
121  "Removed request pending for peer `%s\n",
122  GNUNET_i2s(pid));
125  pid,
126  cr));
127  GNUNET_free(cr);
128  }
129  return GNUNET_OK;
130 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Handle to a client that is connected to a service.
Definition: service.c:246
Active connection requests.
static char * value
Value of the record to add/remove.
#define GNUNET_log(kind,...)
struct GNUNET_SERVICE_Client * client
Client that made the request.
void GAS_plugin_request_connect_stop(const struct GNUNET_PeerIdentity *pid)
Notify the plugin that a request to connect to a particular peer was dropped.
#define GNUNET_YES
Definition: gnunet_common.h:77
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_handle_request_address_cancel()

void GAS_handle_request_address_cancel ( struct GNUNET_SERVICE_Client client,
const struct RequestAddressMessage msg 
)

Handle GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL messages from clients.

Cancel 'request address' messages from clients.

Parameters
clientthe client that sent the request
msgthe request message

Definition at line 141 of file gnunet-service-ats_connectivity.c.

References free_matching_requests(), GNUNET_break, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, RequestAddressMessage::peer, and RequestAddressMessage::strength.

Referenced by handle_request_address_cancel().

143 {
145  "Received GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL message for peer %s\n",
146  GNUNET_i2s(&msg->peer));
147  GNUNET_break(0 == ntohl(msg->strength));
149  &msg->peer,
151  client);
152 }
static int free_matching_requests(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free the connection request from the map if the closure matches the client.
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
uint32_t strength
How "strong" is our need for an address for this peer?
Definition: ats.h:96
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats.h:101
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_connectivity_remove_client()

void GAS_connectivity_remove_client ( struct GNUNET_SERVICE_Client client)

Unregister a client (which may have been a connectivity client, but this is not assured).

Parameters
clienthandle of the (now dead) client

Definition at line 162 of file gnunet-service-ats_connectivity.c.

References free_matching_requests(), and GNUNET_CONTAINER_multipeermap_iterate().

Referenced by client_disconnect_cb().

163 {
166  client);
167 }
static int free_matching_requests(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free the connection request from the map if the closure matches the client.
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_connectivity_init()

void GAS_connectivity_init ( void  )

Shutdown connectivity subsystem.

Initialize connectivity subsystem.

Definition at line 174 of file gnunet-service-ats_connectivity.c.

References GNUNET_CONTAINER_multipeermap_create(), and GNUNET_NO.

Referenced by run().

175 {
178  GNUNET_NO);
179 }
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_request()

static int free_request ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Free the connection request from the map.

Parameters
clsNULL
pidpeer for which the request was made
valuethe struct ConnectionRequest
Returns
GNUNET_OK (continue to iterate)

Definition at line 191 of file gnunet-service-ats_connectivity.c.

References ConnectionRequest::client, free_matching_requests(), GNUNET_OK, and value.

Referenced by GAS_connectivity_done().

194 {
195  struct ConnectionRequest *cr = value;
196 
198  pid,
199  cr);
200  return GNUNET_OK;
201 }
static int free_matching_requests(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free the connection request from the map if the closure matches the client.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Active connection requests.
static char * value
Value of the record to add/remove.
struct GNUNET_SERVICE_Client * client
Client that made the request.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_connectivity_done()

void GAS_connectivity_done ( void  )

Shutdown connectivity subsystem.

Definition at line 208 of file gnunet-service-ats_connectivity.c.

References free_request(), GAS_plugin_solver_lock(), GAS_plugin_solver_unlock(), GNUNET_CONTAINER_multipeermap_destroy(), and GNUNET_CONTAINER_multipeermap_iterate().

Referenced by cleanup_task(), and run().

209 {
212  &free_request,
213  NULL);
216  connection_requests = NULL;
217 }
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static int free_request(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free the connection request from the map.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ connection_requests

struct GNUNET_CONTAINER_MultiPeerMap* connection_requests
static

Address suggestion requests by peer.

Definition at line 51 of file gnunet-service-ats_connectivity.c.