GNUnet  0.11.x
Functions
service

Bandwidth allocation. More...

Functions

struct GNUNET_TRANSPORT_ApplicationHandleGNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the TRANSPORT application client handle. More...
 
void GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
 Shutdown TRANSPORT application client. More...
 
struct GNUNET_TRANSPORT_ApplicationSuggestHandleGNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MQ_PriorityPreferences pk, struct GNUNET_BANDWIDTH_Value32NBO bw)
 An application would like TRANSPORT to connect to a peer. More...
 
void GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh)
 We no longer care about being connected to a peer. More...
 
void GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_NetworkType nt, const char *addr)
 An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct. More...
 

Detailed Description

Bandwidth allocation.

Function Documentation

◆ GNUNET_TRANSPORT_application_init()

struct GNUNET_TRANSPORT_ApplicationHandle* GNUNET_TRANSPORT_application_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the TRANSPORT application client handle.

Parameters
cfgconfiguration to use
Returns
ats application handle, NULL on error

Initialize the TRANSPORT application client handle.

Parameters
cfgconfiguration to use
Returns
transport application handle, NULL on error

Definition at line 219 of file transport_api2_application.c.

221 {
223 
225  ch->cfg = cfg;
226  ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
227  reconnect (ch);
228  return ch;
229 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
@ GNUNET_YES
Definition: gnunet_common.h:97
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).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle to the TRANSPORT subsystem for application management.
static void reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Re-establish the connection to the TRANSPORT service.

References cfg, ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, and reconnect().

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), run(), and start_peer_run().

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

◆ GNUNET_TRANSPORT_application_done()

void GNUNET_TRANSPORT_application_done ( struct GNUNET_TRANSPORT_ApplicationHandle ch)

Shutdown TRANSPORT application client.

Parameters
chhandle to destroy

Shutdown TRANSPORT application client.

Parameters
chhandle to release

Definition at line 257 of file transport_api2_application.c.

259 {
260  if (NULL != ch->mq)
261  {
263  ch->mq = NULL;
264  }
265  if (NULL != ch->task)
266  {
267  GNUNET_SCHEDULER_cancel (ch->task);
268  ch->task = NULL;
269  }
272  NULL);
274  GNUNET_free (ch);
275 }
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:143
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_TRANSPORT_ApplicationSuggestHandles in the map.

References ch, free_sug_handle(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), and GNUNET_CADET_Channel::mq.

Referenced by do_shutdown(), GNUNET_TRANSPORT_TESTING_stop_peer(), and stop_peer_run().

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

◆ GNUNET_TRANSPORT_application_suggest()

struct GNUNET_TRANSPORT_ApplicationSuggestHandle* GNUNET_TRANSPORT_application_suggest ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_MQ_PriorityPreferences  pk,
struct GNUNET_BANDWIDTH_Value32NBO  bw 
)

An application would like TRANSPORT to connect to a peer.

Parameters
chhandle
peeridentity of the peer we need an address for
pkwhat kind of application will the application require (can be GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
bwdesired bandwidth, can be zero (we will still try to connect)
Returns
suggest handle, NULL if a request is already pending

Definition at line 289 of file transport_api2_application.c.

294 {
296 
298  s->ch = ch;
299  s->id = *peer;
300  s->pk = pk;
301  s->bw = bw;
303  ch->sug_requests,
304  &s->id,
305  s,
308  "Requesting TRANSPORT to suggest address for `%s'\n",
309  GNUNET_i2s (peer));
310  if (NULL == ch->mq)
311  return s;
313  return s;
314 }
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
struct GNUNET_BIO_WriteHandle * bw
handle to the file to write the load statistics to
@ GNUNET_OK
Definition: gnunet_common.h:95
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.
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.
@ GNUNET_ERROR_TYPE_DEBUG
Handle for TRANSPORT address suggestion requests.
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
struct GNUNET_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
#define LOG(kind,...)

References bw, GNUNET_TRANSPORT_ApplicationSuggestHandle::bw, ch, GNUNET_TRANSPORT_ApplicationSuggestHandle::ch, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_new, GNUNET_OK, GNUNET_TRANSPORT_ApplicationSuggestHandle::id, LOG, GNUNET_CADET_Channel::mq, peer, pk, GNUNET_TRANSPORT_ApplicationSuggestHandle::pk, and transmit_suggestion().

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_application_suggest_cancel()

void GNUNET_TRANSPORT_application_suggest_cancel ( struct GNUNET_TRANSPORT_ApplicationSuggestHandle sh)

We no longer care about being connected to a peer.

Parameters
shhandle to stop

Definition at line 323 of file transport_api2_application.c.

325 {
327  struct GNUNET_MQ_Envelope *ev;
328  struct ExpressPreferenceMessage *m;
329 
331  "Telling TRANSPORT we no longer care for an address for `%s'\n",
332  GNUNET_i2s (&sh->id));
333  GNUNET_assert (
334  GNUNET_OK ==
335  GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, &sh->id, sh));
336  if (NULL == ch->mq)
337  {
338  GNUNET_free (sh);
339  return;
340  }
342  m->pk = htonl ((uint32_t) sh->pk);
343  m->bw = sh->bw;
344  m->peer = sh->id;
345  GNUNET_MQ_send (ch->mq, ev);
346  GNUNET_free (sh);
347 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
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.
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_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL
Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT to abandon bandwidth prefe...

References ch, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, LOG, m, GNUNET_CADET_Channel::mq, and sh.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_application_validate()

void GNUNET_TRANSPORT_application_validate ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_NetworkType  nt,
const char *  addr 
)

An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct.

The result is NOT returned, in fact TRANSPORT may do nothing (i.e. if it has too many active validations or recently tried this one already). If the addr validates, TRANSPORT will persist the address with PEERSTORE.

Parameters
chhandle
peeridentity of the peer we have an address for
ntnetwork type of addr (as claimed by the other peer); used by TRANSPORT to avoid trying addr's that really cannot work due to network type mismatches
addraddress to validate

Definition at line 366 of file transport_api2_application.c.

371 {
372  struct GNUNET_MQ_Envelope *ev;
373  struct RequestHelloValidationMessage *m;
374  size_t alen;
375 
376  if (NULL == ch->mq)
377  {
378  GNUNET_log (
380  "Address validation for %s:%s skipped as transport is not connected\n",
381  GNUNET_i2s (peer),
382  addr);
383  return;
384  }
385  alen = strlen (addr) + 1;
386  ev =
388  alen,
390  m->peer = *peer;
391  m->nt = htonl ((uint32_t) nt);
392  memcpy (&m[1], addr, alen);
393  GNUNET_MQ_send (ch->mq, ev);
394 }
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
#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
#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION
Type of the 'struct RequestHelloValidationMessage' send by clients to TRANSPORT to trigger validation...

Referenced by connect_peers_run(), offer_hello(), and sock_read().

Here is the caller graph for this function: