gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26647 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r26647 - gnunet/src/transport
Date: Thu, 28 Mar 2013 16:43:23 +0100

Author: wachs
Date: 2013-03-28 16:43:23 +0100 (Thu, 28 Mar 2013)
New Revision: 26647

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_hello.c
   gnunet/src/transport/gnunet-service-transport_hello.h
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/plugin_transport_wlan.c
   gnunet/src/transport/transport_api.c
Log:
support for FRIEND_HELLO messages


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2013-03-28 15:24:59 UTC 
(rev 26646)
+++ gnunet/src/transport/gnunet-service-transport.c     2013-03-28 15:43:23 UTC 
(rev 26647)
@@ -242,6 +242,7 @@
   switch (type)
   {
   case GNUNET_MESSAGE_TYPE_HELLO:
+  case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
     GST_validation_handle_hello (message);
     return ret;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
@@ -630,6 +631,7 @@
   long long unsigned int max_fd_cfg;
   int max_fd_rlimit;
   int max_fd;
+  int friend_only;
 
   GST_keygen = NULL;
   if (NULL == pk)
@@ -686,8 +688,11 @@
               "Limiting number of sockets to %u: validation %u, neighbors: 
%u\n",
               max_fd, (max_fd / 3) , (max_fd / 3) * 2);
 
+  friend_only = GNUNET_CONFIGURATION_get_value_yesno(GST_cfg, 
"topology","FRIENDS-ONLY");
+  if (GNUNET_SYSERR == friend_only)
+       friend_only = GNUNET_NO; /* According to topology defaults */
   /* start subsystems */
-  GST_hello_start (&process_hello_update, NULL);
+  GST_hello_start (friend_only, &process_hello_update, NULL);
   GNUNET_assert (NULL != GST_hello_get());
   GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity);
   GST_ats =

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2013-03-28 
15:24:59 UTC (rev 26646)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2013-03-28 
15:43:23 UTC (rev 26647)
@@ -978,6 +978,8 @@
      GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)},
     {&clients_handle_hello, NULL,
      GNUNET_MESSAGE_TYPE_HELLO, 0},
+         {&clients_handle_hello, NULL,
+                GNUNET_MESSAGE_TYPE_FRIEND_HELLO, 0},
     {&clients_handle_send, NULL,
      GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0},
     {&clients_handle_request_connect, NULL,

Modified: gnunet/src/transport/gnunet-service-transport_hello.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_hello.c       2013-03-28 
15:24:59 UTC (rev 26646)
+++ gnunet/src/transport/gnunet-service-transport_hello.c       2013-03-28 
15:43:23 UTC (rev 26647)
@@ -200,15 +200,16 @@
 /**
  * Initialize the HELLO module.
  *
+ * @param friend_only use a friend only hello
  * @param cb function to call whenever our HELLO changes
  * @param cb_cls closure for cb
  */
 void
-GST_hello_start (GST_HelloCallback cb, void *cb_cls)
+GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls)
 {
   hello_cb = cb;
   hello_cb_cls = cb_cls;
-  our_hello = GNUNET_HELLO_create (&GST_my_public_key, NULL, NULL, GNUNET_NO);
+  our_hello = GNUNET_HELLO_create (&GST_my_public_key, NULL, NULL, 
friend_only);
   GNUNET_assert (NULL != our_hello);
   refresh_hello ();
 }

Modified: gnunet/src/transport/gnunet-service-transport_hello.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_hello.h       2013-03-28 
15:24:59 UTC (rev 26646)
+++ gnunet/src/transport/gnunet-service-transport_hello.h       2013-03-28 
15:43:23 UTC (rev 26647)
@@ -46,11 +46,12 @@
 /**
  * Initialize the HELLO module.
  *
+ * @param friend_only use a friend only hello
  * @param cb function to call whenever our HELLO changes
  * @param cb_cls closure for cb
  */
 void
-GST_hello_start (GST_HelloCallback cb, void *cb_cls);
+GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls);
 
 
 /**

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2013-03-28 
15:24:59 UTC (rev 26646)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2013-03-28 
15:43:23 UTC (rev 26647)
@@ -1283,7 +1283,10 @@
       (const struct GNUNET_HELLO_Message *) hello;
   struct ValidateAddressContext vac;
   struct GNUNET_HELLO_Message *h;
+  int type;
+  int friend;
 
+
   if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
       (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
   {
@@ -1295,7 +1298,20 @@
       memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
     return;
   /* Add peer identity without addresses to peerinfo service */
-  h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, GNUNET_NO);
+  type = ntohs(hello->type);
+  switch (type) {
+               case GNUNET_MESSAGE_TYPE_HELLO:
+                       friend = GNUNET_NO;
+                       break;
+               case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
+                       friend = GNUNET_YES;
+                       break;
+               default:
+                       GNUNET_break (0);
+                       friend = GNUNET_NO;
+                       break;
+       }
+  h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
   GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2013-03-28 15:24:59 UTC 
(rev 26646)
+++ gnunet/src/transport/plugin_transport_wlan.c        2013-03-28 15:43:23 UTC 
(rev 26647)
@@ -1152,6 +1152,7 @@
 
   switch (ntohs (hdr->type))
   {
+  case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
   case GNUNET_MESSAGE_TYPE_HELLO:
     if (GNUNET_OK != 
        GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, 
&tmpsource))

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2013-03-28 15:24:59 UTC (rev 
26646)
+++ gnunet/src/transport/transport_api.c        2013-03-28 15:43:23 UTC (rev 
26647)
@@ -497,6 +497,7 @@
   switch (ntohs (msg->type))
   {
   case GNUNET_MESSAGE_TYPE_HELLO:
+  case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
     if (GNUNET_OK !=
         GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, &me))
     {
@@ -1292,7 +1293,8 @@
   if (NULL == handle->client)
     return NULL;
 
-  GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
+  GNUNET_break ((ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO) ||
+                                                       (ntohs (hello->type) == 
GNUNET_MESSAGE_TYPE_FRIEND_HELLO));
   size = ntohs (hello->size);
   GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader));
   if (GNUNET_OK !=




reply via email to

[Prev in Thread] Current Thread [Next in Thread]