GNUnet  0.19.5
gnunet-service-ats_connectivity.c File Reference

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

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 64 of file gnunet-service-ats_connectivity.c.

66 {
67  if (NULL == connection_requests)
68  return 0;
69  /* TODO: return sum of 'strength's of connectivity requests */
71  peer);
72 }
static struct GNUNET_CONTAINER_MultiPeerMap * connection_requests
Address suggestion requests by peer.
enum GNUNET_GenericReturnValue 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).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References connection_requests, GNUNET_CONTAINER_multipeermap_contains(), and peer.

Referenced by GAS_plugin_init().

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
msgthe request message

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

84 {
85  struct ConnectionRequest *cr;
86 
88  "Received `%s' message\n",
89  "GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS");
90  /* FIXME: should not ignore "msg->strength" */
91  cr = GNUNET_new (struct ConnectionRequest);
92  cr->client = client;
94  &msg->peer,
95  cr,
98 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Active connection requests.
struct GNUNET_SERVICE_Client * client
Client that made the request.

References ConnectionRequest::client, connection_requests, GAS_plugin_request_connect_start(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, and msg.

Referenced by handle_request_address().

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 111 of file gnunet-service-ats_connectivity.c.

114 {
115  struct GNUNET_SERVICE_Client *client = cls;
116  struct ConnectionRequest *cr = value;
117 
118  if (cr->client == client)
119  {
122  "Removed request pending for peer `%s\n",
123  GNUNET_i2s (pid));
126  pid,
127  cr));
128  GNUNET_free (cr);
129  }
130  return GNUNET_OK;
131 }
static char * value
Value of the record to add/remove.
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.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_OK
@ GNUNET_YES
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.
Handle to a client that is connected to a service.
Definition: service.c:252

References ConnectionRequest::client, connection_requests, 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, pid, and value.

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

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 142 of file gnunet-service-ats_connectivity.c.

144 {
146  "Received GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL message for peer %s\n",
147  GNUNET_i2s (&msg->peer));
148  GNUNET_break (0 == ntohl (msg->strength));
150  &msg->peer,
152  client);
153 }
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.
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References ConnectionRequest::client, connection_requests, free_matching_requests(), GNUNET_break, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, and msg.

Referenced by handle_request_address_cancel().

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 163 of file gnunet-service-ats_connectivity.c.

164 {
165  if (NULL != connection_requests)
168  client);
169 }
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.

References ConnectionRequest::client, connection_requests, free_matching_requests(), and GNUNET_CONTAINER_multipeermap_iterate().

Referenced by client_disconnect_cb().

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 176 of file gnunet-service-ats_connectivity.c.

177 {
180  GNUNET_NO);
181 }
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).
@ GNUNET_NO

References connection_requests, GNUNET_CONTAINER_multipeermap_create(), and GNUNET_NO.

Referenced by run().

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 193 of file gnunet-service-ats_connectivity.c.

196 {
197  struct ConnectionRequest *cr = value;
198 
200  pid,
201  cr);
202  return GNUNET_OK;
203 }

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

Referenced by GAS_connectivity_done().

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 210 of file gnunet-service-ats_connectivity.c.

211 {
214  &free_request,
215  NULL);
218  connection_requests = NULL;
219 }
static int free_request(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free the connection request from the map.
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.

References connection_requests, 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().

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

Variable Documentation

◆ connection_requests