#include "gnunet_common.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
-#include <gnunet_mesh_service_new.h>
+#include <gnunet_mesh_service.h>
#include "gnunet_client_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_constants.h"
/* FIXME! GNUNET_MESH_close_tunnel(me->tunnel); */
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (hashmap, &me->hash, me));
+ GNUNET_CONTAINER_multihashmap_remove (hashmap, &me->hash, me));
GNUNET_free (me);
}
{
struct GNUNET_MESH_Tunnel **tunnel = cls;
- struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data (*tunnel);
+
ts->th = NULL;
if (NULL != buf)
- {
- struct GNUNET_MessageHeader *hdr =
+ {
+ struct GNUNET_MessageHeader *hdr =
(struct GNUNET_MessageHeader *) (tunnel + 1);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf,
- size);
- GNUNET_assert (size >= ntohs (hdr->size));
- memcpy (buf, hdr, ntohs (hdr->size));
- size = ntohs (hdr->size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n");
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf,
+ size);
+ GNUNET_assert (size >= ntohs (hdr->size));
+ memcpy (buf, hdr, ntohs (hdr->size));
+ size = ntohs (hdr->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n");
+ }
else
size = 0;
if (NULL != ts->head)
{
struct tunnel_notify_queue *element = ts->head;
- struct tunnel_notify_queue *head = ts->head;
- struct tunnel_notify_queue *tail = ts->tail;
- GNUNET_CONTAINER_DLL_remove (head, tail, element);
+ GNUNET_CONTAINER_DLL_remove (ts->head, ts->tail, element);
ts->th =
- GNUNET_MESH_notify_transmit_ready (*tunnel,
- GNUNET_NO,
- 42,
+ GNUNET_MESH_notify_transmit_ready (*tunnel, GNUNET_NO, 42,
GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
(const struct GNUNET_PeerIdentity *)
{
uint16_t *ps = (uint16_t *) & ports;
- return ports == 0 || ps[0] == port || ps[1] == port || ps[2] == port || ps[3] == port;
+ return ports == 0 || ps[0] == port || ps[1] == port || ps[2] == port ||
+ ps[3] == port;
}
void
send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi
+ __attribute__ ((unused)))
{
/* peer == NULL means that all peers in this request are connected */
if (peer == NULL)
GNUNET_assert (NULL != tunnel);
GNUNET_assert (NULL != *tunnel);
- struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data (*tunnel);
+
if (NULL == ts->th)
{
ts->th =
- GNUNET_MESH_notify_transmit_ready (*tunnel,
- GNUNET_NO,
- 42,
+ GNUNET_MESH_notify_transmit_ready (*tunnel, GNUNET_NO, 42,
GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
(const struct GNUNET_PeerIdentity *)
- NULL,
- ntohs (hdr->size),
+ NULL, ntohs (hdr->size),
send_pkt_to_peer_notify_callback,
cls);
}
else
{
- struct tunnel_notify_queue *head = ts->head;
- struct tunnel_notify_queue *tail = ts->tail;
struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element);
element->cls = cls;
element->len = ntohs (hdr->size);
- GNUNET_CONTAINER_DLL_insert_tail (head, tail, element);
+ GNUNET_CONTAINER_DLL_insert_tail (ts->head, ts->tail, element);
}
}
list =
GNUNET_malloc (htons (pkt->hdr.size) +
- 2 * sizeof (struct answer_packet_list *));
+ sizeof (struct answer_packet_list) -
+ sizeof (struct answer_packet));
memcpy (&list->pkt, pkt, htons (pkt->hdr.size));
char *name = (char *) (map_entry + 1);
list =
- GNUNET_malloc (2 * sizeof (struct answer_packet_list *) + offset + 2 +
+ GNUNET_malloc (sizeof (struct answer_packet_list) -
+ sizeof (struct answer_packet) + offset + 2 +
ntohs (namelen));
struct answer_packet *rpkt = &list->pkt;
{
list =
GNUNET_malloc (htons (pkt->hdr.size) +
- 2 * sizeof (struct answer_packet_list *));
+ sizeof (struct answer_packet_list) -
+ sizeof (struct answer_packet));
memcpy (&list->pkt, pkt, htons (pkt->hdr.size));
}
else if (pkt->subtype == GNUNET_DNS_ANSWER_TYPE_REMOTE_AAAA)
list =
GNUNET_malloc (htons (pkt->hdr.size) +
- 2 * sizeof (struct answer_packet_list *));
+ sizeof (struct answer_packet_list) -
+ sizeof (struct answer_packet));
memcpy (&list->pkt, pkt, htons (pkt->hdr.size));
}
list =
GNUNET_malloc (htons (pkt->hdr.size) +
- 2 * sizeof (struct answer_packet_list *));
+ sizeof (struct answer_packet_list) -
+ sizeof (struct answer_packet));
memcpy (&list->pkt, pkt, htons (pkt->hdr.size));
}
}
static int
-receive_udp_back (void *cls __attribute__ ((unused)),
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender,
+receive_udp_back (void *cls
+ __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi
+ __attribute__ ((unused)))
{
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct remote_addr *s = (struct remote_addr *) desc;
}
static int
-receive_tcp_back (void *cls __attribute__ ((unused)),
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)),
+receive_tcp_back (void *cls
+ __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender
+ __attribute__ ((unused)),
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi
+ __attribute__ ((unused)))
{
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct remote_addr *s = (struct remote_addr *) desc;
ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
sizeof (GNUNET_HashCode);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet back, addrlen = %d\n", s->addrlen);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received TCP-Packet back, addrlen = %d\n", s->addrlen);
- if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK ||
+ if (ntohs (message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK ||
ts->addrlen == 16)
{
size_t size = pktlen + sizeof (struct ip6_tcp) - 1;
tmp = pkt4->ip_hdr.dadr;
sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
- tmp = (0x06 << 16) | (0xffff & pktlen); // 0x06 for TCP?
+ tmp = (0x06 << 16) | (0xffff & pktlen); // 0x06 for TCP?
tmp = htonl (tmp);
return GNUNET_OK;
}
-static void* new_tunnel(void* cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- const struct GNUNET_PeerIdentity *initiator,
- const struct GNUNET_ATS_Information *atsi)
+static void *
+new_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
+ const struct GNUNET_PeerIdentity *initiator,
+ const struct GNUNET_ATS_Information *atsi)
{
/* Why should anyone open an inbound tunnel to vpn? */
- GNUNET_break(0);
+ GNUNET_break (0);
return NULL;
}
-static void cleaner(void *cls,
- const struct GNUNET_MESH_Tunnel *tunnel,
- void *tunnel_ctx)
+static void
+cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx)
{
/* Why should anyone open an inbound tunnel to vpn? */
- GNUNET_break(0);
+ GNUNET_break (0);
}
/**
GNUNET_APPLICATION_TYPE_END
};
- mesh_handle = GNUNET_MESH_connect (cfg_, 42, NULL, new_tunnel, cleaner, handlers, types);
+ mesh_handle =
+ GNUNET_MESH_connect (cfg_, 42, NULL, new_tunnel, cleaner, handlers,
+ types);
cfg = cfg_;
restart_hijack = 0;
hashmap = GNUNET_CONTAINER_multihashmap_create (65536);