GNUnet  0.10.x
plugin_transport_udp_broadcasting.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2010, 2011 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
27 #include "platform.h"
28 #include "plugin_transport_udp.h"
29 #include "gnunet_hello_lib.h"
30 #include "gnunet_util_lib.h"
32 #include "gnunet_protocols.h"
34 #include "gnunet_signatures.h"
35 #include "gnunet_constants.h"
39 #include "transport.h"
40 
41 #define LOG(kind, ...) GNUNET_log_from(kind, "transport-udp", __VA_ARGS__)
42 
43 /* *********** Cryogenic ********** */
44 #if LINUX
45 #include <sys/stat.h>
46 #include <fcntl.h>
47 
48 #include <sys/ioctl.h>
49 #include <sys/select.h>
50 #include <sys/time.h>
51 
52 #define PM_MAGIC 'k'
53 #define PM_SET_DELAY_AND_TIMEOUT _IOW(PM_MAGIC, 1, struct pm_times)
54 
55 struct pm_times {
56  unsigned long delay_msecs;
57  unsigned long timeout_msecs;
58 };
59 #endif
60 /************************************/
61 
62 
67  struct GNUNET_MessageHeader header;
68 
72  struct GNUNET_PeerIdentity sender;
73 };
74 
75 
78 
80 
85 
86  struct Plugin *plugin;
87 
88  struct sockaddr *addr;
89 
90  socklen_t addrlen;
91 
92 #if LINUX
93 
96  struct GNUNET_DISK_FileHandle *cryogenic_fd;
97 
101  struct pm_times cryogenic_times;
102 #endif
103 };
104 
105 
109 struct MstContext {
110  struct Plugin *plugin;
111 
112  const union UdpAddress *udp_addr;
113 
114  size_t udp_addr_len;
115 
119  enum GNUNET_NetworkType ats_address_network_type;
120 };
121 
122 
131 static int
133  const struct GNUNET_MessageHeader *message)
134 {
135  struct MstContext *mc = cls;
136  struct Plugin *plugin = mc->plugin;
138  const struct GNUNET_MessageHeader *hello;
139  const struct UDP_Beacon_Message *msg;
140 
141  msg = (const struct UDP_Beacon_Message *)message;
142 
144  ntohs(msg->header.type))
145  return GNUNET_OK;
147  "Received beacon with %u bytes from peer `%s' via address `%s'\n",
148  ntohs(msg->header.size),
149  GNUNET_i2s(&msg->sender),
151  mc->udp_addr,
152  mc->udp_addr_len));
153  hello = (struct GNUNET_MessageHeader *)&msg[1];
154  address = GNUNET_HELLO_address_allocate(&msg->sender,
155  PLUGIN_NAME,
156  mc->udp_addr,
157  mc->udp_addr_len,
159  plugin->env->receive(plugin->env->cls,
160  address,
161  NULL,
162  hello);
163  GNUNET_HELLO_address_free(address);
164  GNUNET_STATISTICS_update(plugin->env->stats,
165  _("# Multicast HELLO beacons received via UDP"),
166  1, GNUNET_NO);
167  return GNUNET_OK;
168 }
169 
170 
182 void
184  const char *buf,
185  ssize_t size,
186  const union UdpAddress *udp_addr,
187  size_t udp_addr_len,
188  enum GNUNET_NetworkType network_type)
189 {
190  struct GNUNET_MessageStreamTokenizer *broadcast_mst;
191  struct MstContext mc;
192 
193  broadcast_mst = GNUNET_MST_create(&broadcast_mst_cb,
194  &mc);
195  mc.plugin = plugin;
196  mc.udp_addr = udp_addr;
198  mc.ats_address_network_type = network_type;
199  GNUNET_MST_from_buffer(broadcast_mst,
200  buf, size,
201  GNUNET_NO,
202  GNUNET_NO);
203  GNUNET_MST_destroy(broadcast_mst);
204 }
205 
206 
207 static unsigned int
209  struct UDP_Beacon_Message *msg)
210 {
211  uint16_t hello_size;
212  uint16_t msg_size;
213 
214  const struct GNUNET_MessageHeader *hello;
215 
216  hello = plugin->env->get_our_hello();
217  if (NULL == hello)
218  return 0;
219  hello_size = GNUNET_HELLO_size((struct GNUNET_HELLO_Message *)hello);
220  msg_size = hello_size + sizeof(struct UDP_Beacon_Message);
221 
222  if (hello_size < (sizeof(struct GNUNET_MessageHeader)) ||
223  (msg_size > (UDP_MTU)))
224  return 0;
225 
226  msg->sender = *(plugin->env->my_identity);
227  msg->header.size = htons(msg_size);
229  GNUNET_memcpy(&msg[1], hello, hello_size);
230  return msg_size;
231 }
232 
233 
234 static void
236 {
237  struct BroadcastAddress *baddr = cls;
238  struct Plugin *plugin = baddr->plugin;
239  int sent;
240  uint16_t msg_size;
241  char buf[65536] GNUNET_ALIGN;
242 
243  baddr->broadcast_task = NULL;
244 
245  msg_size = prepare_beacon(plugin, (struct UDP_Beacon_Message *)&buf);
246  if (0 != msg_size)
247  {
248  struct sockaddr_in *addr = (struct sockaddr_in *)baddr->addr;
249 
250  addr->sin_port = htons(plugin->port);
251  sent = GNUNET_NETWORK_socket_sendto(plugin->sockv4, &buf, msg_size,
252  (const struct sockaddr *)addr,
253  baddr->addrlen);
254  if (sent == GNUNET_SYSERR)
255  {
256  if ((ENETUNREACH == errno) || (ENETDOWN == errno))
257  {
258  /* "Network unreachable" or "Network down"
259  *
260  * This indicates that we just do not have network connectivity
261  */
263  "Network connectivity is down, cannot send beacon!\n");
264  }
265  else
267  }
268  else
269  {
271  "Sent HELLO beacon broadcast with %i bytes to address %s\n", sent,
272  GNUNET_a2s(baddr->addr, baddr->addrlen));
273  }
274  }
275 
276 #if LINUX
277  /*
278  * Cryogenic
279  */
280  if (NULL != baddr->cryogenic_fd)
281  {
282  baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us / 1000.0) * 0.5;
283  baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us / 1000.0) * 1.5;
284 
285  if (ioctl(baddr->cryogenic_fd->fd,
286  PM_SET_DELAY_AND_TIMEOUT,
287  &baddr->cryogenic_times) < 0)
288  {
290  baddr->broadcast_task =
292  &udp_ipv4_broadcast_send, baddr);
293  }
294  else
296  baddr->cryogenic_fd,
298  baddr);
299  }
300  else
301 #endif
302  baddr->broadcast_task =
304  &udp_ipv4_broadcast_send, baddr);
305 }
306 
307 
308 static void
310 {
311  struct BroadcastAddress *baddr = cls;
312  struct Plugin *plugin = baddr->plugin;
313  ssize_t sent;
314  uint16_t msg_size;
315  char buf[65536] GNUNET_ALIGN;
316  const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *)baddr->addr;
317 
318  baddr->broadcast_task = NULL;
319 
320  msg_size = prepare_beacon(plugin, (struct UDP_Beacon_Message *)&buf);
321  /* Note: unclear if this actually works to limit the multicast to
322  the specified interface as we're not (necessarily) using a
323  link-local multicast group and the kernel suggests that the
324  scope ID is only respected for link-local addresses; however,
325  if the scope ID is ignored, the kernel should just multicast
326  on ALL interfaces, which is merely slightly less efficient;
327  in that case, we might want to revert to only doing this
328  once, and not per interface (hard to test...) */
329  plugin->ipv6_multicast_address.sin6_scope_id = s6->sin6_scope_id;
330  sent = GNUNET_NETWORK_socket_sendto(plugin->sockv6, &buf, msg_size,
331  (const struct sockaddr *)
332  &plugin->ipv6_multicast_address,
333  sizeof(struct sockaddr_in6));
334  plugin->ipv6_multicast_address.sin6_scope_id = 0;
335  if (sent == GNUNET_SYSERR)
336  {
337  if ((ENETUNREACH == errno) || (ENETDOWN == errno))
338  {
339  /* "Network unreachable" or "Network down"
340  *
341  * This indicates that this system is IPv6 enabled, but does not
342  * have a valid global IPv6 address assigned
343  */
345  "Network connectivity is down, cannot send beacon!\n");
346  }
347  else
349  }
350  else
351  {
353  "Sending IPv6 HELLO beacon broadcast with %d bytes to address %s\n",
354  (int)sent,
355  GNUNET_a2s((const struct sockaddr *)&plugin->ipv6_multicast_address,
356  sizeof(struct sockaddr_in6)));
357  }
358 #if LINUX
359  /*
360  * Cryogenic
361  */
362  if (NULL != baddr->cryogenic_fd)
363  {
364  baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us / 1000.0) * 0.5;
365  baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us / 1000.0) * 1.5;
366 
367  if (ioctl(baddr->cryogenic_fd->fd,
368  PM_SET_DELAY_AND_TIMEOUT,
369  &baddr->cryogenic_times) < 0)
370  {
372  baddr->broadcast_task =
374  &udp_ipv6_broadcast_send, baddr);
375  }
376  else
378  baddr->cryogenic_fd,
380  baddr);
381  }
382  else
383 #endif
384  baddr->broadcast_task =
386  &udp_ipv6_broadcast_send, baddr);
387 }
388 
389 
402 static int
403 iface_proc(void *cls,
404  const char *name,
405  int isDefault,
406  const struct sockaddr *addr,
407  const struct sockaddr *broadcast_addr,
408  const struct sockaddr *netmask, socklen_t addrlen)
409 {
410  struct Plugin *plugin = cls;
411  struct BroadcastAddress *ba;
412  enum GNUNET_NetworkType network;
413 
414  if (NULL == addr)
415  return GNUNET_OK;
417  "address %s for interface %s %p\n ",
418  GNUNET_a2s(addr, addrlen), name, addr);
419  if (NULL == broadcast_addr)
420  return GNUNET_OK;
422  "broadcast address %s for interface %s %p\n ",
423  GNUNET_a2s(broadcast_addr, addrlen), name, broadcast_addr);
424  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
425  GNUNET_a2s(netmask, addrlen), name, netmask);
426 
427  network = plugin->env->get_address_type(plugin->env->cls, broadcast_addr, addrlen);
428  if (GNUNET_NT_LOOPBACK == network)
429  {
430  /* Broadcasting on loopback does not make sense */
431  return GNUNET_YES;
432  }
433 
434  ba = GNUNET_new(struct BroadcastAddress);
435  ba->plugin = plugin;
436  ba->addr = GNUNET_malloc(addrlen);
437  GNUNET_memcpy(ba->addr, broadcast_addr, addrlen);
438  ba->addrlen = addrlen;
439 
440  if ((GNUNET_YES == plugin->enable_ipv4) &&
441  (NULL != plugin->sockv4) &&
442  (addrlen == sizeof(struct sockaddr_in)))
443  {
444 #if LINUX
445  /*
446  * setup Cryogenic FD for ipv4 broadcasting
447  */
448  char *filename;
449 
450  GNUNET_asprintf(&filename,
451  "/dev/cryogenic/%s",
452  name);
453  if (0 == access(name, R_OK))
454  {
455  ba->cryogenic_fd =
456  GNUNET_DISK_file_open(filename,
459  }
460  GNUNET_free(filename);
461 #endif
462  ba->broadcast_task =
464  }
465  if ((GNUNET_YES == plugin->enable_ipv6) &&
466  (NULL != plugin->sockv6) &&
467  (addrlen == sizeof(struct sockaddr_in6)))
468  {
469  /* Create IPv6 multicast request */
470  struct ipv6_mreq multicastRequest;
471  const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *)broadcast_addr;
472 
473  multicastRequest.ipv6mr_multiaddr =
474  plugin->ipv6_multicast_address.sin6_addr;
475  /* http://tools.ietf.org/html/rfc2553#section-5.2:
476  *
477  * IPV6_JOIN_GROUP
478  *
479  * Join a multicast group on a specified local interface. If the
480  * interface index is specified as 0, the kernel chooses the local
481  * interface. For example, some kernels look up the multicast
482  * group in the normal IPv6 routing table and using the resulting
483  * interface; we do this for each interface, so no need to use
484  * zero (anymore...).
485  */
486  multicastRequest.ipv6mr_interface = s6->sin6_scope_id;
487 
488  /* Join the multicast group */
489  if (GNUNET_OK !=
491  (plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP,
492  &multicastRequest, sizeof(multicastRequest)))
493  {
495  "Failed to join IPv6 multicast group: IPv6 broadcasting not running\n");
496  }
497  else
498  {
499 #if LINUX
500  /*
501  * setup Cryogenic FD for ipv6 broadcasting
502  */
503  char *filename;
504 
505  GNUNET_asprintf(&filename,
506  "/dev/cryogenic/%s",
507  name);
508  if (0 == access(name, R_OK))
509  {
510  ba->cryogenic_fd =
511  GNUNET_DISK_file_open(filename,
514  }
515  GNUNET_free(filename);
516 #endif
517  ba->broadcast_task =
519  }
520  }
522  plugin->broadcast_tail, ba);
523  return GNUNET_OK;
524 }
525 
526 
534 void
536  struct sockaddr_in6 *server_addrv6,
537  struct sockaddr_in *server_addrv4)
538 {
539  if (GNUNET_YES ==
541  "topology",
542  "FRIENDS-ONLY"))
543  {
545  _("Disabling HELLO broadcasting due to friend-to-friend only configuration!\n"));
546  return;
547  }
548 
549  if (GNUNET_YES != plugin->enable_broadcasting)
550  return; /* We do not send, just receive */
551 
552  /* create IPv4 broadcast socket */
553  if ((GNUNET_YES == plugin->enable_ipv4) && (NULL != plugin->sockv4))
554  {
555  static int yes = 1;
556 
558  (plugin->sockv4, SOL_SOCKET, SO_BROADCAST, &yes,
559  sizeof(int)) != GNUNET_OK)
560  {
562  _("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"),
563  ntohs(server_addrv4->sin_port));
564  }
565  }
566  /* create IPv6 multicast socket */
567  if ((GNUNET_YES == plugin->enable_ipv6) && (plugin->sockv6 != NULL))
568  {
569  memset(&plugin->ipv6_multicast_address, 0, sizeof(struct sockaddr_in6));
570  GNUNET_assert(1 ==
571  inet_pton(AF_INET6, "FF05::13B",
572  &plugin->ipv6_multicast_address.sin6_addr));
573  plugin->ipv6_multicast_address.sin6_family = AF_INET6;
574  plugin->ipv6_multicast_address.sin6_port = htons(plugin->port);
575  }
577 }
578 
579 
585 void
587 {
588  if (GNUNET_YES == plugin->enable_broadcasting)
589  {
590  /* Disable broadcasting */
591  while (plugin->broadcast_head != NULL)
592  {
593  struct BroadcastAddress *p = plugin->broadcast_head;
594 
595  if (p->broadcast_task != NULL)
596  {
598  p->broadcast_task = NULL;
599  }
600  if ((GNUNET_YES == plugin->enable_ipv6) &&
601  (NULL != plugin->sockv6) &&
602  (p->addrlen == sizeof(struct sockaddr_in6)))
603  {
604  /* Create IPv6 multicast request */
605  struct ipv6_mreq multicastRequest;
606  const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *)p->addr;
607 
608  multicastRequest.ipv6mr_multiaddr =
609  plugin->ipv6_multicast_address.sin6_addr;
610  multicastRequest.ipv6mr_interface = s6->sin6_scope_id;
611 
612  /* Leave the multicast group */
613  if (GNUNET_OK ==
615  (plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
616  &multicastRequest, sizeof(multicastRequest)))
617  {
619  }
620  else
621  {
622  LOG(GNUNET_ERROR_TYPE_DEBUG, "IPv6 multicasting stopped\n");
623  }
624  }
625 
626 #if LINUX
627  GNUNET_DISK_file_close(p->cryogenic_fd);
628 #endif
630  plugin->broadcast_tail, p);
631  GNUNET_free(p->addr);
632  GNUNET_free(p);
633  }
634  }
635 }
636 
637 /* end of plugin_transport_udp_broadcasting.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_NETWORK_socket_setsockopt(struct GNUNET_NETWORK_Handle *fd, int level, int option_name, const void *option_value, socklen_t option_len)
Set socket option.
Definition: network.c:871
void udp_broadcast_receive(struct Plugin *plugin, const char *buf, ssize_t size, const union UdpAddress *udp_addr, size_t udp_addr_len, enum GNUNET_NetworkType network_type)
We received a broadcast message.
A HELLO message is used to exchange information about transports with other peers.
int enable_broadcasting
Is broadcasting enabled: GNUNET_YES or GNUNET_NO.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_allocate(const struct GNUNET_PeerIdentity *peer, const char *transport_name, const void *address, size_t address_length, enum GNUNET_HELLO_AddressInfo local_info)
Allocate an address struct.
Definition: address.c:73
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1339
uint64_t rel_value_us
The actual value.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Implementation of the UDP transport protocol.
common internal definitions for transport service
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
int enable_ipv4
Is IPv4 enabled: GNUNET_YES or GNUNET_NO.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void setup_broadcast(struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4)
Setup broadcasting subsystem.
struct BroadcastAddress * next
Nobody is allowed to do anything to the file.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_write_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1647
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls)
Enumerate all network interfaces.
Definition: os_network.c:388
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_NETWORK_Handle * sockv4
The read socket for IPv4.
struct GNUNET_PeerIdentity sender
What is the identity of the sender.
Client-specific context for broadcast_mst_cb().
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define UDP_MTU
MTU for fragmentation subsystem.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
enum GNUNET_NetworkType ats_address_network_type
ATS network type.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define LOG(kind,...)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
Definition: mst.c:410
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
Handle to a message stream tokenizer.
Definition: mst.c:43
ssize_t GNUNET_NETWORK_socket_sendto(const struct GNUNET_NETWORK_Handle *desc, const void *message, size_t length, const struct sockaddr *dest_addr, socklen_t dest_len)
Send data to a particular destination (always non-blocking).
Definition: network.c:838
static char buf[2048]
static char * filename
static unsigned int prepare_beacon(struct Plugin *plugin, struct UDP_Beacon_Message *msg)
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
Definition: mst.c:84
static int broadcast_mst_cb(void *cls, const struct GNUNET_MessageHeader *message)
Parse broadcast message received.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages)...
int GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
Definition: mst.c:113
static void udp_ipv4_broadcast_send(void *cls)
struct GNUNET_SCHEDULER_Task * broadcast_task
ID of select broadcast task.
struct BroadcastAddress * broadcast_head
Tail of DLL of broadcast addresses.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
struct GNUNET_TIME_Relative broadcast_interval
Broadcast interval.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
struct GNUNET_MessageHeader header
Message header.
Open the file for writing.
const char * name
Loopback (same host).
Definition: gnunet_nt_lib.h:44
The identity of the host (wraps the signing key of the peer).
struct BroadcastAddress * prev
No additional information.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to &#39;struct&#39;s...
Handle for a plugin.
Definition: block.c:37
#define PLUGIN_NAME
Either an IPv4 or IPv6 UDP address.
An address for communicating with a peer.
const char * udp_address_to_string(void *cls, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
struct GNUNET_NETWORK_Handle * sockv6
The read socket for IPv6.
uint16_t port
Port used.
void stop_broadcast(struct Plugin *plugin)
Stop broadcasting subsystem.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:643
static int iface_proc(void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen)
Callback function invoked for each interface found.
void * cls
Closure to use for callbacks.
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
static void udp_ipv6_broadcast_send(void *cls)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON
Message send by a peer to notify the other to keep the session alive.
struct BroadcastAddress * broadcast_tail
Head of DLL of broadcast addresses.
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1262
struct sockaddr_in6 ipv6_multicast_address
IPv6 multicast address.
static char * address
GNS address for this phone.
Handle used to access files (and pipes).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_malloc(size)
Wrapper around malloc.
int enable_ipv6
Is IPv6 enabled: GNUNET_YES or GNUNET_NO.
const union UdpAddress * udp_addr
#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:956