This file is part of GNUnet
Copyright (C) 2010-2017 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Affero General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
*/
struct GNUNET_PeerIdentity target;
+ /**
+ * Tokenizer for inbound messages.
+ */
+ struct GNUNET_MessageStreamTokenizer *mst;
+
/**
* Plugin this session belongs to.
*/
/**
* Network type of the address.
*/
- enum GNUNET_ATS_Network_Type scope;
+ enum GNUNET_NetworkType scope;
/**
* Is this session about to be destroyed (sometimes we cannot
/**
* Network type the address belongs to.
*/
- enum GNUNET_ATS_Network_Type network_type;
+ enum GNUNET_NetworkType network_type;
/**
* Has the @e sender field been initialized yet?
GNUNET_free (s->frag_ctx);
s->frag_ctx = NULL;
}
+ if (NULL != s->mst)
+ {
+ GNUNET_MST_destroy (s->mst);
+ s->mst = NULL;
+ }
GNUNET_free (s);
}
* @param session the session
* @return the network type
*/
-static enum GNUNET_ATS_Network_Type
+static enum GNUNET_NetworkType
udp_plugin_get_network (void *cls,
struct GNUNET_ATS_Session *session)
{
* @param address the address
* @return the network type
*/
-static enum GNUNET_ATS_Network_Type
+static enum GNUNET_NetworkType
udp_plugin_get_network_for_address (void *cls,
const struct GNUNET_HELLO_Address *address)
{
else
{
GNUNET_break (0);
- return GNUNET_ATS_NET_UNSPECIFIED;
+ return GNUNET_NT_UNSPECIFIED;
}
return plugin->env->get_address_type (plugin->env->cls,
sb,
* Our external IP address/port mapping has changed.
*
* @param cls closure, the `struct Plugin`
+ * @param app_ctx[in,out] location where the app can store stuff
+ * on add and retrieve it on remove
* @param add_remove #GNUNET_YES to mean the new public IP address,
* #GNUNET_NO to mean the previous (now invalid) one
* @param ac address class the address belongs to
*/
static void
udp_nat_port_map_callback (void *cls,
+ void **app_ctx,
int add_remove,
enum GNUNET_NAT_AddressClass ac,
const struct sockaddr *addr,
void *arg;
size_t args;
+ (void) app_ctx;
LOG (GNUNET_ERROR_TYPE_DEBUG,
(GNUNET_YES == add_remove)
? "NAT notification to add address `%s'\n"
if (GNUNET_YES == session->in_destroy)
{
GNUNET_break (0);
+ GNUNET_free (udpw);
return;
}
- if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX)
+ if (plugin->bytes_in_buffer > INT64_MAX - udpw->msg_size)
{
GNUNET_break (0);
}
udpw->qc = &qc_fragment_sent;
udpw->qc_cls = plugin;
GNUNET_memcpy (udpw->msg_buf,
- msg,
- msg_len);
+ msg,
+ msg_len);
enqueue (plugin,
udpw);
if (session->address->address_length == sizeof (struct IPv4UdpAddress))
if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) &&
(NULL == plugin->sockv4) )
return GNUNET_SYSERR;
- if (udpmlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return GNUNET_SYSERR;
* Message tokenizer has broken up an incomming message. Pass it on
* to the service.
*
- * @param cls the `struct Plugin *`
- * @param client the `struct GNUNET_ATS_Session *`
+ * @param cls the `struct GNUNET_ATS_Session *`
* @param hdr the actual message
* @return #GNUNET_OK (always)
*/
static int
process_inbound_tokenized_messages (void *cls,
- void *client,
const struct GNUNET_MessageHeader *hdr)
{
- struct Plugin *plugin = cls;
- struct GNUNET_ATS_Session *session = client;
+ struct GNUNET_ATS_Session *session = cls;
+ struct Plugin *plugin = session->plugin;
if (GNUNET_YES == session->in_destroy)
return GNUNET_OK;
static struct GNUNET_ATS_Session *
udp_plugin_create_session (void *cls,
const struct GNUNET_HELLO_Address *address,
- enum GNUNET_ATS_Network_Type network_type)
+ enum GNUNET_NetworkType network_type)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *s;
s = GNUNET_new (struct GNUNET_ATS_Session);
+ s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages,
+ s);
s->plugin = plugin;
s->address = GNUNET_HELLO_address_copy (address);
s->target = address->peer;
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *s;
- enum GNUNET_ATS_Network_Type network_type = GNUNET_ATS_NET_UNSPECIFIED;
+ enum GNUNET_NetworkType network_type = GNUNET_NT_UNSPECIFIED;
const struct IPv4UdpAddress *udp_v4;
const struct IPv6UdpAddress *udp_v6;
(const struct sockaddr *) &v6,
sizeof (v6));
}
- GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type);
+ GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
return udp_plugin_create_session (cls,
address,
network_type);
const struct UDPMessage *msg,
const union UdpAddress *udp_addr,
size_t udp_addr_len,
- enum GNUNET_ATS_Network_Type network_type)
+ enum GNUNET_NetworkType network_type)
{
struct GNUNET_ATS_Session *s;
struct GNUNET_HELLO_Address *address;
- GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type);
+ GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
if (0 != ntohl (msg->reserved))
{
GNUNET_break_op(0);
GNUNET_free (address);
s->rc++;
- GNUNET_SERVER_mst_receive (plugin->mst,
- s,
- (const char *) &msg[1],
- ntohs (msg->header.size) - sizeof(struct UDPMessage),
- GNUNET_YES,
- GNUNET_NO);
+ GNUNET_MST_from_buffer (s->mst,
+ (const char *) &msg[1],
+ ntohs (msg->header.size) - sizeof(struct UDPMessage),
+ GNUNET_YES,
+ GNUNET_NO);
s->rc--;
if ( (0 == s->rc) &&
(GNUNET_YES == s->in_destroy) )
const struct GNUNET_MessageHeader *msg,
const union UdpAddress *udp_addr,
size_t udp_addr_len,
- enum GNUNET_ATS_Network_Type network_type)
+ enum GNUNET_NetworkType network_type)
{
struct DefragContext *d_ctx;
struct GNUNET_TIME_Absolute now;
const struct sockaddr_in6 *sa6;
const union UdpAddress *int_addr;
size_t int_addr_len;
- enum GNUNET_ATS_Network_Type network_type;
+ enum GNUNET_NetworkType network_type;
fromlen = sizeof (addr);
memset (&addr,
socklen_t slen,
int error)
{
- enum GNUNET_ATS_Network_Type type;
+ enum GNUNET_NetworkType type;
type = plugin->env->get_address_type (plugin->env->cls,
sa,
slen);
- if ( ( (GNUNET_ATS_NET_LAN == type) ||
- (GNUNET_ATS_NET_WAN == type) ) &&
+ if ( ( (GNUNET_NT_LAN == type) ||
+ (GNUNET_NT_WAN == type) ) &&
( (ENETUNREACH == errno) ||
(ENETDOWN == errno) ) )
{
unsigned long long port;
unsigned long long aport;
unsigned long long udp_max_bps;
- unsigned long long enable_v6;
- unsigned long long enable_broadcasting;
- unsigned long long enable_broadcasting_recv;
+ int enable_v6;
+ int enable_broadcasting;
+ int enable_broadcasting_recv;
char *bind4_address;
char *bind6_address;
struct GNUNET_TIME_Relative interval;
p->sessions = GNUNET_CONTAINER_multipeermap_create (16,
GNUNET_NO);
p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages,
- p);
GNUNET_BANDWIDTH_tracker_init (&p->tracker,
NULL,
NULL,
_("Failed to create UDP network sockets\n"));
GNUNET_CONTAINER_multipeermap_destroy (p->sessions);
GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs);
- GNUNET_SERVER_mst_destroy (p->mst);
if (NULL != p->nat)
GNUNET_NAT_unregister (p->nat);
GNUNET_free (p);
GNUNET_CONTAINER_heap_destroy (plugin->defrag_ctxs);
plugin->defrag_ctxs = NULL;
}
- if (NULL != plugin->mst)
- {
- GNUNET_SERVER_mst_destroy (plugin->mst);
- plugin->mst = NULL;
- }
while (NULL != (udpw = plugin->ipv4_queue_head))
{
dequeue (plugin,