Neighbour discovery with UDP. More...
#include "platform.h"
#include "plugin_transport_udp.h"
#include "gnunet_hello_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_fragmentation_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
#include "gnunet_signatures.h"
#include "gnunet_constants.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "transport.h"
Go to the source code of this file.
Data Structures | |
struct | UDP_Beacon_Message |
struct | BroadcastAddress |
struct | MstContext |
Client-specific context for broadcast_mst_cb(). More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
Functions | |
static int | broadcast_mst_cb (void *cls, const struct GNUNET_MessageHeader *message) |
Parse broadcast message received. More... | |
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. More... | |
static unsigned int | prepare_beacon (struct Plugin *plugin, struct UDP_Beacon_Message *msg) |
static void | udp_ipv4_broadcast_send (void *cls) |
static void | udp_ipv6_broadcast_send (void *cls) |
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. More... | |
void | setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4) |
Setup broadcasting subsystem. More... | |
void | stop_broadcast (struct Plugin *plugin) |
Stop broadcasting subsystem. More... | |
Neighbour discovery with UDP.
Definition in file plugin_transport_udp_broadcasting.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
Definition at line 41 of file plugin_transport_udp_broadcasting.c.
|
static |
Parse broadcast message received.
cls | the struct Plugin |
client | the struct MstContext with sender address |
message | the message we received |
Definition at line 136 of file plugin_transport_udp_broadcasting.c.
References _, address, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), LOG, mc, msg, plugin, PLUGIN_NAME, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and udp_address_to_string().
Referenced by udp_broadcast_receive().
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.
Process it and all subsequent messages in the same packet.
plugin | the UDP plugin |
buf | the buffer with the message(s) |
size | number of bytes in buf |
udp_addr | address of the sender |
udp_addr_len | number of bytes in udp_addr |
network_type | network type of the sender's address |
Definition at line 187 of file plugin_transport_udp_broadcasting.c.
References broadcast_mst_cb(), buf, GNUNET_MST_create(), GNUNET_MST_destroy(), GNUNET_MST_from_buffer(), GNUNET_NO, mc, plugin, size, MstContext::udp_addr, and MstContext::udp_addr_len.
Referenced by udp_select_read().
|
static |
Definition at line 212 of file plugin_transport_udp_broadcasting.c.
References GNUNET_HELLO_size(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON, msg, plugin, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and UDP_MTU.
Referenced by udp_ipv4_broadcast_send(), and udp_ipv6_broadcast_send().
|
static |
Definition at line 239 of file plugin_transport_udp_broadcasting.c.
References BroadcastAddress::addr, BroadcastAddress::addrlen, BroadcastAddress::broadcast_task, buf, GNUNET_a2s(), GNUNET_ALIGN, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_sendto(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_write_file(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, LOG, plugin, BroadcastAddress::plugin, and prepare_beacon().
Referenced by iface_proc().
|
static |
Definition at line 315 of file plugin_transport_udp_broadcasting.c.
References BroadcastAddress::addr, BroadcastAddress::broadcast_task, buf, GNUNET_a2s(), GNUNET_ALIGN, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_sendto(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_write_file(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, LOG, plugin, BroadcastAddress::plugin, and prepare_beacon().
Referenced by iface_proc().
|
static |
Callback function invoked for each interface found.
cls | closure with the struct Plugin |
name | name of the interface (can be NULL for unknown) |
isDefault | is this presumably the default interface |
addr | address of this interface (can be NULL for unknown or unassigned) |
broadcast_addr | the broadcast address (can be NULL for unknown or unassigned) |
netmask | the network mask (can be NULL for unknown or unassigned) |
addrlen | length of the address |
Definition at line 409 of file plugin_transport_udp_broadcasting.c.
References BroadcastAddress::addr, BroadcastAddress::addrlen, BroadcastAddress::broadcast_task, filename, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_setsockopt(), GNUNET_new, GNUNET_NT_LOOPBACK, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_YES, LOG, name, plugin, BroadcastAddress::plugin, udp_ipv4_broadcast_send(), and udp_ipv6_broadcast_send().
Referenced by setup_broadcast().
void setup_broadcast | ( | struct Plugin * | plugin, |
struct sockaddr_in6 * | server_addrv6, | ||
struct sockaddr_in * | server_addrv4 | ||
) |
Setup broadcasting subsystem.
plugin | |
server_addrv6 | |
server_addrv4 |
Definition at line 542 of file plugin_transport_udp_broadcasting.c.
References _, GNUNET_assert, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_WARNING, GNUNET_NETWORK_socket_setsockopt(), GNUNET_OK, GNUNET_OS_network_interfaces_list(), GNUNET_YES, iface_proc(), LOG, and plugin.
Referenced by libgnunet_plugin_transport_udp_init().
void stop_broadcast | ( | struct Plugin * | plugin | ) |
Stop broadcasting subsystem.
plugin |
Definition at line 595 of file plugin_transport_udp_broadcasting.c.