$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/mesh/libgnunetmesh.la \
$(GN_LIBINTL)
gnunet_service_dns_SOURCES = \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/mesh/libgnunetmesh.la \
$(GN_LIBINTL)
#check_PROGRAMS = \
#include <gnunet_common.h>
#include <gnunet_program_lib.h>
#include <gnunet_protocols.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
#include <gnunet_constants.h>
#include "gnunet-vpn-packet.h"
static int ret;
/**
- * The handle to core
+ * The handle to mesh
*/
-static struct GNUNET_CORE_Handle *core_handle;
+static struct GNUNET_MESH_Handle *mesh_handle;
/**
* This hashmap contains the mapping from peer, service-descriptor,
struct udp_state
{
struct GNUNET_PeerIdentity peer;
+ struct GNUNET_MESH_Tunnel *tunnel;
GNUNET_HashCode desc;
short spt;
short dpt;
cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
- if (core_handle != NULL)
+ if (mesh_handle != NULL)
{
- GNUNET_CORE_disconnect(core_handle);
- core_handle = NULL;
+ GNUNET_MESH_disconnect(mesh_handle);
+ mesh_handle = NULL;
}
}
memcpy (desc, &data->state.desc, sizeof (GNUNET_HashCode));
memcpy (pkt + 1, buf, len);
- GNUNET_CORE_notify_transmit_ready (core_handle, 42,
+ GNUNET_MESH_notify_transmit_ready (data->state.tunnel, 42,
+ GNUNET_NO,
GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
- &data->state.peer, len_pkt,
+ len_pkt,
send_udp_service, hdr);
out:
}
+/**
+ * The messages are one GNUNET_HashCode for the service, followed by a struct udp_pkt
+ */
static int
-receive_udp_service (void *cls, const struct GNUNET_PeerIdentity *other,
+receive_udp_service (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received UDP-Packet from peer %s\n",
- GNUNET_i2s (other));
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
struct udp_state *state = &send->state;
unsigned int new = GNUNET_NO;
- memcpy (&state->peer, other, sizeof (struct GNUNET_PeerIdentity));
+ state->tunnel = tunnel;
memcpy (&state->desc, desc, sizeof (GNUNET_HashCode));
state->spt = ntohs (pkt->spt);
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg_)
{
- const static struct GNUNET_CORE_MessageHandler handlers[] = {
+ const static struct GNUNET_MESH_MessageHandler handlers[] = {
{receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
{NULL, 0, 0}
};
- core_handle = GNUNET_CORE_connect(cfg_,
- 42,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
+ mesh_handle = GNUNET_MESH_connect(cfg_,
NULL,
- 0,
+ NULL, /* FIXME */
handlers);
udp_connections = GNUNET_CONTAINER_multihashmap_create(65536);
#include <gnunet_common.h>
#include <gnunet_client_lib.h>
#include <gnunet_os_lib.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
#include <gnunet_protocols.h>
#include <gnunet_server_lib.h>
#include <gnunet_container_lib.h>
#include <gnunet_common.h>
#include <gnunet_client_lib.h>
#include <gnunet_os_lib.h>
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
#include <gnunet_protocols.h>
#include <gnunet_server_lib.h>
#include <gnunet_container_lib.h>
(port_in_ports(me->desc.ports, pkt6_udp->udp_hdr.dpt) ||
port_in_ports(me->additional_ports, pkt6_udp->udp_hdr.dpt)))
{
- size_t size = sizeof(struct GNUNET_PeerIdentity) + sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + ntohs(pkt6_udp->udp_hdr.len);
- struct GNUNET_PeerIdentity *cls = GNUNET_malloc(size);
+ size_t size = sizeof(struct GNUNET_MESH_Tunnel*) + sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + ntohs(pkt6_udp->udp_hdr.len);
+ struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc(size);
struct GNUNET_MessageHeader *hdr = (struct GNUNET_MessageHeader*)(cls+1);
GNUNET_HashCode* hc = (GNUNET_HashCode*)(hdr + 1);
- memcpy(cls, &me->desc.peer, sizeof(struct GNUNET_PeerIdentity));
+
memcpy(hc, &me->desc.service_descriptor, sizeof(GNUNET_HashCode));
memcpy(hc+1, &pkt6_udp->udp_hdr, ntohs(pkt6_udp->udp_hdr.len));
- GNUNET_CORE_peer_request_connect(core_handle,
- GNUNET_TIME_UNIT_FOREVER_REL,
- (struct GNUNET_PeerIdentity*)&me->desc.peer,
- send_udp_to_peer,
- cls);
+
+ if (me->tunnel == NULL)
+ {
+ *cls = GNUNET_MESH_peer_request_connect_all(mesh_handle,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ 1,
+ (struct GNUNET_PeerIdentity*)&me->desc.peer,
+ send_udp_to_peer,
+ NULL,
+ cls);
+ me->tunnel = *cls;
+ }
+ else
+ *cls = me->tunnel;
+ //FIXME: somehow call send_udp_to_peer
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued to send to peer %x\n", *((unsigned int*)&me->desc.peer));
}
}
#include "gnunet_common.h"
#include <gnunet_os_lib.h>
#include "gnunet_protocols.h"
-#include <gnunet_core_service.h>
+#include <gnunet_mesh_service.h>
#include "gnunet_client_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_constants.h"
dns_connection = NULL;
}
- if (core_handle != NULL)
+ if (mesh_handle != NULL)
{
- GNUNET_CORE_disconnect(core_handle);
- core_handle = NULL;
+ GNUNET_MESH_disconnect(mesh_handle);
+ mesh_handle = NULL;
}
}
/*}}}*/
void
send_udp_to_peer (void *cls,
- int success)
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
- struct GNUNET_PeerIdentity *peer = cls;
+ struct GNUNET_MESH_Tunnel **tunnel = cls;
struct GNUNET_MessageHeader *hdr =
- (struct GNUNET_MessageHeader *) (peer + 1);
+ (struct GNUNET_MessageHeader *) (tunnel + 1);
GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1);
struct udp_pkt *udp = (struct udp_pkt *) (hc + 1);
- GNUNET_CORE_notify_transmit_ready (core_handle,
+ GNUNET_MESH_notify_transmit_ready (*tunnel,
+ GNUNET_NO,
42,
GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
- peer,
htons (sizeof
(struct GNUNET_MessageHeader) +
sizeof (GNUNET_HashCode) +
}
static int
-receive_udp_back (void *cls, const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
+ void **tunnel_ctx,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
char addr[16];
+ const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel);
+
new_ip6addr(addr, &other->hashPubKey, desc);
size_t size = sizeof(struct ip6_udp) + ntohs(pkt->len) - 1 - sizeof(struct udp_pkt);
return GNUNET_OK;
}
-void init_core (void* cls, struct GNUNET_CORE_Handle* server, const struct GNUNET_PeerIdentity* my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to CORE, I am %x\n", *((unsigned long*)my_identity));
+void init_mesh (void* cls, struct GNUNET_MESH_Handle* server, const struct GNUNET_PeerIdentity* my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to MESH, I am %x\n", *((unsigned long*)my_identity));
}
-void connect_core (void* cls, const struct GNUNET_PeerIdentity* peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) {
+void connect_mesh (void* cls, const struct GNUNET_PeerIdentity* peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) {
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %x\n", *((unsigned long*)peer));
}
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg_)
{
- const static struct GNUNET_CORE_MessageHandler handlers[] = {
+ const static struct GNUNET_MESH_MessageHandler handlers[] = {
{receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
{NULL, 0, 0}
};
- core_handle = GNUNET_CORE_connect(cfg_,
- 42,
- NULL,
- init_core,
- connect_core,
- NULL,
- NULL,
+ mesh_handle = GNUNET_MESH_connect(cfg_,
NULL,
- 0,
NULL,
- 0,
handlers);
mst = GNUNET_SERVER_mst_create(&message_token, NULL);
cfg = cfg_;
unsigned int port_in_ports (uint64_t ports, uint16_t port);
void
-send_udp_to_peer (void *cls, int success);
+send_udp_to_peer (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi);
/**
* The configuration to use
const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * The handle to core
+ * The handle to mesh
*/
-struct GNUNET_CORE_Handle *core_handle;
+struct GNUNET_MESH_Handle *mesh_handle;
/**
* The hashmap containing the mappings from ipv6-addresses to gnunet-descriptors
struct map_entry {
struct GNUNET_vpn_service_descriptor desc;
+ struct GNUNET_MESH_Tunnel *tunnel;
uint16_t namelen;
uint64_t additional_ports;
/**