[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10147 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10147 - gnunet/src/transport |
Date: |
Tue, 26 Jan 2010 14:40:14 +0100 |
Author: nevans
Date: 2010-01-26 14:40:14 +0100 (Tue, 26 Jan 2010)
New Revision: 10147
Modified:
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/plugin_transport.h
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/plugin_transport_template.c
gnunet/src/transport/plugin_transport_udp.c
Log:
transport plugin change from single MessageHeader to message buffer and size...
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2010-01-26 13:29:45 UTC
(rev 10146)
+++ gnunet/src/transport/gnunet-service-transport.c 2010-01-26 13:40:14 UTC
(rev 10147)
@@ -1110,9 +1110,11 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("try_transmission_to_peer
pre-send: at this point rl->neighbor->addr is NOT NULL, addrlen is %d\n"),
rl->neighbor->addr_len);
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("try_transmission_to_peer pre-send:
at this point rl->neighbor->addr is NULL\n"));
+ /* FIXME: Change MessageQueue to hold message buffer and size? */
rl->plugin->api->send (rl->plugin->api->cls,
&neighbor->id,
- mq->message,
+ (char *)mq->message,
+ ntohs(mq->message->size),
mq->priority,
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
rl->neighbor->addr,
@@ -1556,7 +1558,9 @@
GNUNET_PEERINFO_add_peer (cfg, sched, &pid, hello);
n = find_neighbor (&pid, NULL, 0);
if (NULL != n)
- try_transmission_to_peer (n);
+ {
+ try_transmission_to_peer (n);
+ }
GNUNET_free (hello);
while (NULL != (va = pos->addresses))
{
@@ -1593,21 +1597,6 @@
}
-static struct GNUNET_MessageHeader *
-createPingMessage (struct GNUNET_PeerIdentity * target, struct
ValidationAddress *va)
-{
-
- struct TransportPingMessage *ping;
- ping = GNUNET_malloc(sizeof(struct TransportPingMessage));
-
- ping->challenge = htonl(va->challenge);
- ping->header.size = sizeof(struct TransportPingMessage);
- ping->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
- memcpy(&ping->target, target, sizeof(struct GNUNET_PeerIdentity));
-
- return &ping->header;
-}
-
/**
* Function that will be called if we receive a validation
* of an address challenge that we transmitted to another
@@ -1757,8 +1746,12 @@
struct TransportPlugin *tp;
struct ValidationAddress *va;
struct GNUNET_PeerIdentity id;
- struct GNUNET_MessageHeader *pingMessage;
+ char *pingMessage;
int sent;
+ struct TransportPingMessage *ping;
+ char * message_buf;
+ int hello_size;
+
tp = find_transport (tname);
if (tp == NULL)
{
@@ -1786,13 +1779,22 @@
(unsigned int) -1);
memcpy (&va[1], addr, addrlen);
- pingMessage = createPingMessage(&id, va);
+ hello_size = GNUNET_HELLO_size(our_hello);
+ message_buf = GNUNET_malloc(sizeof(struct TransportPingMessage) +
hello_size);
+ memcpy(message_buf, &our_hello, hello_size);
+ ping = GNUNET_malloc(sizeof(struct TransportPingMessage));
+ ping->challenge = htonl(va->challenge);
+ ping->header.size = htons(sizeof(struct TransportPingMessage));
+ ping->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
+ memcpy(&ping->target, &id, sizeof(struct GNUNET_PeerIdentity));
+ memcpy(&message_buf[hello_size], ping, sizeof(struct TransportPingMessage));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ping message to address `%s'
via `%s' for `%4s'\n",
GNUNET_a2s (addr, addrlen), tname, GNUNET_i2s (&id));
- sent = tp->api->send(tp->api->cls, &id, pingMessage,
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ sent = tp->api->send(tp->api->cls, &id, message_buf, sizeof(struct
TransportPingMessage) + hello_size, GNUNET_SCHEDULER_PRIORITY_DEFAULT,
TRANSPORT_DEFAULT_TIMEOUT, addr, addrlen, GNUNET_YES, NULL,
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport returned %d from send!\n",
sent);
@@ -1814,6 +1816,8 @@
* the address via the transport plugin. If not validated, then
* do not count this as a good peer/address...
*
+ * Currently this function is not used, ping/pongs get sent from the
+ * run_validation function. Haven't decided yet how to do this.
*/
static void
validate_address (void *cls, struct ValidationAddress *va,
Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h 2010-01-26 13:29:45 UTC (rev
10146)
+++ gnunet/src/transport/plugin_transport.h 2010-01-26 13:40:14 UTC (rev
10147)
@@ -197,7 +197,8 @@
(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
const struct GNUNET_PeerIdentity *
target,
- const struct GNUNET_MessageHeader *msg,
+ char *msgbuf,
+ size_t msgbuf_size,
uint32_t priority,
struct GNUNET_TIME_Relative timeout,
const void *addr,
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-01-26 13:29:45 UTC (rev
10146)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-01-26 13:40:14 UTC (rev
10147)
@@ -566,7 +566,8 @@
static ssize_t
tcp_plugin_send (void *cls,
const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_MessageHeader *msg,
+ char *msg,
+ size_t msgbuf_size,
uint32_t priority,
struct GNUNET_TIME_Relative timeout,
const void *addr,
@@ -582,7 +583,7 @@
int af;
uint16_t mlen;
- mlen = ntohs (msg->size);
+ mlen = msgbuf_size;
session = find_session_by_target (plugin, target);
if ( (session != NULL) && ((GNUNET_YES == force_address) &&
( (session->connect_alen != addrlen) ||
Modified: gnunet/src/transport/plugin_transport_template.c
===================================================================
--- gnunet/src/transport/plugin_transport_template.c 2010-01-26 13:29:45 UTC
(rev 10146)
+++ gnunet/src/transport/plugin_transport_template.c 2010-01-26 13:40:14 UTC
(rev 10147)
@@ -148,7 +148,8 @@
template_plugin_send (void *cls,
const struct GNUNET_PeerIdentity *
target,
- const struct GNUNET_MessageHeader *msg,
+ char *msgbuf,
+ size_t msgbuf_size,
unsigned int priority,
struct GNUNET_TIME_Relative timeout,
const void *addr,
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2010-01-26 13:29:45 UTC (rev
10146)
+++ gnunet/src/transport/plugin_transport_udp.c 2010-01-26 13:40:14 UTC (rev
10147)
@@ -183,7 +183,8 @@
*
* @param cls closure
* @param target who should receive this message (ignored by UDP)
- * @param msg the message to transmit
+ * @param msgbuf one or more GNUNET_MessageHeader(s) strung together
+ * @param msgbufsize the size of the msgbuf to send
* @param priority how important is the message (ignored by UDP)
* @param timeout when should we time out (give up) if we can not transmit?
* @param addr the addr to send the message to, needs to be a sockaddr for us
@@ -202,7 +203,8 @@
static ssize_t
udp_plugin_send (void *cls,
const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_MessageHeader *msg,
+ char *msgbuf,
+ size_t msgbuf_size,
unsigned int priority,
struct GNUNET_TIME_Relative timeout,
const void *addr,
@@ -228,8 +230,8 @@
}
/* Build the message to be sent */
- message = GNUNET_malloc (sizeof (struct UDPMessage) + ntohs (msg->size));
- ssize = sizeof (struct UDPMessage) + ntohs (msg->size);
+ message = GNUNET_malloc (sizeof (struct UDPMessage) + msgbuf_size);
+ ssize = sizeof (struct UDPMessage) + msgbuf_size;
#if DEBUG_UDP
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _
@@ -239,7 +241,7 @@
message->header.type = htons (0);
memcpy (&message->sender, plugin->env->my_identity,
sizeof (struct GNUNET_PeerIdentity));
- memcpy (&message[1], msg, ntohs (msg->size));
+ memcpy (&message[1], msgbuf, msgbuf_size);
/* Actually send the message */
sent =
@@ -353,6 +355,9 @@
socklen_t fromlen;
struct sockaddr_storage addr;
ssize_t ret;
+ int offset;
+ int count;
+ const struct GNUNET_MessageHeader *currhdr;
do
{
@@ -419,8 +424,20 @@
("msg reports message type of %d\n"),
ntohs (hdr->type));
#endif
- plugin->env->receive (plugin->env->cls,
- sender, hdr, UDP_DIRECT_DISTANCE, (char *)&addr, fromlen);
+ offset = 0;
+ count = 0;
+ while (offset < (ntohs (msg->header.size) - sizeof(struct UDPMessage)))
+ {
+ currhdr = &hdr[offset];
+#if DEBUG_UDP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _
+ ("processing msg %d: type %d, size %d at offset %d\n"),
+ count, offset, ntohs(currhdr->size),
ntohs(currhdr->type));
+#endif
+ plugin->env->receive (plugin->env->cls,
+ sender, currhdr, UDP_DIRECT_DISTANCE, (char *)&addr, fromlen);
+ offset += ntohs(currhdr->size);
+ }
GNUNET_free (sender);
GNUNET_free (buf);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10147 - gnunet/src/transport,
gnunet <=