GNUnet  0.10.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 220 of file transport_api2_application.c.

References GNUNET_TRANSPORT_ApplicationHandle::cfg, cfg, GNUNET_TRANSPORT_ApplicationSuggestHandle::ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, reconnect(), and GNUNET_TRANSPORT_ApplicationHandle::sug_requests.

Referenced by run().

222 {
224 
226  ch->cfg = cfg;
228  reconnect (ch);
229  return ch;
230 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_YES
Definition: gnunet_common.h:80
static void reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Re-establish the connection to the TRANSPORT service.
Handle to the TRANSPORT subsystem for application management.
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 258 of file transport_api2_application.c.

References free_sug_handle(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_ApplicationHandle::mq, GNUNET_TRANSPORT_ApplicationHandle::sug_requests, and GNUNET_TRANSPORT_ApplicationHandle::task.

Referenced by do_shutdown().

260 {
261  if (NULL != ch->mq)
262  {
263  GNUNET_MQ_destroy (ch->mq);
264  ch->mq = NULL;
265  }
266  if (NULL != ch->task)
267  {
269  ch->task = NULL;
270  }
273  NULL);
275  GNUNET_free (ch);
276 }
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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...
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
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 bandwith, can be zero (we will still try to connect)
Returns
suggest handle, NULL if a request is already pending

Definition at line 290 of file transport_api2_application.c.

References GNUNET_TRANSPORT_ApplicationSuggestHandle::bw, 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_TRANSPORT_ApplicationHandle::mq, peer, GNUNET_TRANSPORT_ApplicationSuggestHandle::pk, GNUNET_TRANSPORT_ApplicationHandle::sug_requests, and transmit_suggestion().

295 {
297 
299  s->ch = ch;
300  s->id = *peer;
301  s->pk = pk;
302  s->bw = bw;
304  ch->sug_requests,
305  &s->id,
306  s,
309  "Requesting TRANSPORT to suggest address for `%s'\n",
310  GNUNET_i2s (peer));
311  if (NULL == ch->mq)
312  return s;
313  GNUNET_assert (GNUNET_OK == transmit_suggestion (ch, &s->id, s));
314  return s;
315 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct GNUNET_BIO_WriteHandle * bw
hanlde to the file to write the load statistics to
struct GNUNET_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Handle for TRANSPORT address suggestion requests.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define LOG(kind,...)
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
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.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 324 of file transport_api2_application.c.

References GNUNET_TRANSPORT_ApplicationSuggestHandle::bw, ExpressPreferenceMessage::bw, GNUNET_TRANSPORT_ApplicationSuggestHandle::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, GNUNET_TRANSPORT_ApplicationSuggestHandle::id, LOG, m, GNUNET_TRANSPORT_ApplicationHandle::mq, ExpressPreferenceMessage::peer, GNUNET_TRANSPORT_ApplicationSuggestHandle::pk, ExpressPreferenceMessage::pk, and GNUNET_TRANSPORT_ApplicationHandle::sug_requests.

326 {
328  struct GNUNET_MQ_Envelope *ev;
329  struct ExpressPreferenceMessage *m;
330 
332  "Telling TRANSPORT we no longer care for an address for `%s'\n",
333  GNUNET_i2s (&sh->id));
334  GNUNET_assert (
335  GNUNET_OK ==
337  if (NULL == ch->mq)
338  {
339  GNUNET_free (sh);
340  return;
341  }
343  m->pk = htonl ((uint32_t) sh->pk);
344  m->bw = sh->bw;
345  m->peer = sh->id;
346  GNUNET_MQ_send (ch->mq, ev);
347  GNUNET_free (sh);
348 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
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:78
#define LOG(kind,...)
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
uint32_t pk
What type of performance preference does the client have? A enum GNUNET_MQ_PreferenceKind in NBO...
Definition: ats2.h:125
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL
Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT to abandon bandwidth prefe...
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
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
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
Definition: ats2.h:135
Application client to ATS service: we would like to have address suggestions for this peer...
Definition: ats2.h:112
Handle to the TRANSPORT subsystem for application management.
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.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats2.h:130
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 missmatches
addraddress to validate

Definition at line 367 of file transport_api2_application.c.

References GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), m, GNUNET_TRANSPORT_ApplicationHandle::mq, and peer.

Referenced by sock_read().

372 {
373  struct GNUNET_MQ_Envelope *ev;
374  struct RequestHelloValidationMessage *m;
375  size_t alen;
376 
377  if (NULL == ch->mq)
378  {
379  GNUNET_log (
381  "Address validation for %s:%s skipped as transport is not connected\n",
382  GNUNET_i2s (peer),
383  addr);
384  return;
385  }
386  alen = strlen (addr) + 1;
387  ev =
389  alen,
391  m->peer = *peer;
392  m->nt = htonl ((uint32_t) nt);
393  memcpy (&m[1], addr, alen);
394  GNUNET_MQ_send (ch->mq, ev);
395 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION
Type of the 'struct RequestHelloValidationMessage' send by clients to TRANSPORT to trigger validation...
#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
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_log(kind,...)
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
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function: