aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-28 15:43:23 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-28 15:43:23 +0000
commit91140caa33349036934b5b86238c0ec6265e0a13 (patch)
tree7340da5a8452a12588be643e59458f2f0a6891e1 /src/transport
parenta55b2de0863937cfe9c0fcbf41882b81f4c82c9c (diff)
downloadgnunet-91140caa33349036934b5b86238c0ec6265e0a13.tar.gz
gnunet-91140caa33349036934b5b86238c0ec6265e0a13.zip
support for FRIEND_HELLO messages
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c7
-rw-r--r--src/transport/gnunet-service-transport_clients.c2
-rw-r--r--src/transport/gnunet-service-transport_hello.c5
-rw-r--r--src/transport/gnunet-service-transport_hello.h3
-rw-r--r--src/transport/gnunet-service-transport_validation.c18
-rw-r--r--src/transport/plugin_transport_wlan.c1
-rw-r--r--src/transport/transport_api.c4
7 files changed, 34 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index be0371a6a..63b2ced88 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -242,6 +242,7 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
242 switch (type) 242 switch (type)
243 { 243 {
244 case GNUNET_MESSAGE_TYPE_HELLO: 244 case GNUNET_MESSAGE_TYPE_HELLO:
245 case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
245 GST_validation_handle_hello (message); 246 GST_validation_handle_hello (message);
246 return ret; 247 return ret;
247 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 248 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
@@ -630,6 +631,7 @@ key_generation_cb (void *cls,
630 long long unsigned int max_fd_cfg; 631 long long unsigned int max_fd_cfg;
631 int max_fd_rlimit; 632 int max_fd_rlimit;
632 int max_fd; 633 int max_fd;
634 int friend_only;
633 635
634 GST_keygen = NULL; 636 GST_keygen = NULL;
635 if (NULL == pk) 637 if (NULL == pk)
@@ -686,8 +688,11 @@ key_generation_cb (void *cls,
686 "Limiting number of sockets to %u: validation %u, neighbors: %u\n", 688 "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
687 max_fd, (max_fd / 3) , (max_fd / 3) * 2); 689 max_fd, (max_fd / 3) , (max_fd / 3) * 2);
688 690
691 friend_only = GNUNET_CONFIGURATION_get_value_yesno(GST_cfg, "topology","FRIENDS-ONLY");
692 if (GNUNET_SYSERR == friend_only)
693 friend_only = GNUNET_NO; /* According to topology defaults */
689 /* start subsystems */ 694 /* start subsystems */
690 GST_hello_start (&process_hello_update, NULL); 695 GST_hello_start (friend_only, &process_hello_update, NULL);
691 GNUNET_assert (NULL != GST_hello_get()); 696 GNUNET_assert (NULL != GST_hello_get());
692 GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity); 697 GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity);
693 GST_ats = 698 GST_ats =
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index db2718f4e..be05e027a 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -978,6 +978,8 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server)
978 GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)}, 978 GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)},
979 {&clients_handle_hello, NULL, 979 {&clients_handle_hello, NULL,
980 GNUNET_MESSAGE_TYPE_HELLO, 0}, 980 GNUNET_MESSAGE_TYPE_HELLO, 0},
981 {&clients_handle_hello, NULL,
982 GNUNET_MESSAGE_TYPE_FRIEND_HELLO, 0},
981 {&clients_handle_send, NULL, 983 {&clients_handle_send, NULL,
982 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0}, 984 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0},
983 {&clients_handle_request_connect, NULL, 985 {&clients_handle_request_connect, NULL,
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index 78968ae77..d9f7e2e4e 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -200,15 +200,16 @@ refresh_hello ()
200/** 200/**
201 * Initialize the HELLO module. 201 * Initialize the HELLO module.
202 * 202 *
203 * @param friend_only use a friend only hello
203 * @param cb function to call whenever our HELLO changes 204 * @param cb function to call whenever our HELLO changes
204 * @param cb_cls closure for cb 205 * @param cb_cls closure for cb
205 */ 206 */
206void 207void
207GST_hello_start (GST_HelloCallback cb, void *cb_cls) 208GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls)
208{ 209{
209 hello_cb = cb; 210 hello_cb = cb;
210 hello_cb_cls = cb_cls; 211 hello_cb_cls = cb_cls;
211 our_hello = GNUNET_HELLO_create (&GST_my_public_key, NULL, NULL, GNUNET_NO); 212 our_hello = GNUNET_HELLO_create (&GST_my_public_key, NULL, NULL, friend_only);
212 GNUNET_assert (NULL != our_hello); 213 GNUNET_assert (NULL != our_hello);
213 refresh_hello (); 214 refresh_hello ();
214} 215}
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h
index 9927408d2..2aefbe300 100644
--- a/src/transport/gnunet-service-transport_hello.h
+++ b/src/transport/gnunet-service-transport_hello.h
@@ -46,11 +46,12 @@ typedef void (*GST_HelloCallback) (void *cls,
46/** 46/**
47 * Initialize the HELLO module. 47 * Initialize the HELLO module.
48 * 48 *
49 * @param friend_only use a friend only hello
49 * @param cb function to call whenever our HELLO changes 50 * @param cb function to call whenever our HELLO changes
50 * @param cb_cls closure for cb 51 * @param cb_cls closure for cb
51 */ 52 */
52void 53void
53GST_hello_start (GST_HelloCallback cb, void *cb_cls); 54GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls);
54 55
55 56
56/** 57/**
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index f5c57d864..dbe5adf4f 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -1283,6 +1283,9 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1283 (const struct GNUNET_HELLO_Message *) hello; 1283 (const struct GNUNET_HELLO_Message *) hello;
1284 struct ValidateAddressContext vac; 1284 struct ValidateAddressContext vac;
1285 struct GNUNET_HELLO_Message *h; 1285 struct GNUNET_HELLO_Message *h;
1286 int type;
1287 int friend;
1288
1286 1289
1287 if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) || 1290 if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
1288 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key))) 1291 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
@@ -1295,7 +1298,20 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1295 memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) 1298 memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
1296 return; 1299 return;
1297 /* Add peer identity without addresses to peerinfo service */ 1300 /* Add peer identity without addresses to peerinfo service */
1298 h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, GNUNET_NO); 1301 type = ntohs(hello->type);
1302 switch (type) {
1303 case GNUNET_MESSAGE_TYPE_HELLO:
1304 friend = GNUNET_NO;
1305 break;
1306 case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
1307 friend = GNUNET_YES;
1308 break;
1309 default:
1310 GNUNET_break (0);
1311 friend = GNUNET_NO;
1312 break;
1313 }
1314 h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
1299 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL); 1315 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
1300 1316
1301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index e1201eb2b..ecf1efb86 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -1152,6 +1152,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1152 1152
1153 switch (ntohs (hdr->type)) 1153 switch (ntohs (hdr->type))
1154 { 1154 {
1155 case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
1155 case GNUNET_MESSAGE_TYPE_HELLO: 1156 case GNUNET_MESSAGE_TYPE_HELLO:
1156 if (GNUNET_OK != 1157 if (GNUNET_OK !=
1157 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) 1158 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 8dc4c7a42..d8fb7d520 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -497,6 +497,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
497 switch (ntohs (msg->type)) 497 switch (ntohs (msg->type))
498 { 498 {
499 case GNUNET_MESSAGE_TYPE_HELLO: 499 case GNUNET_MESSAGE_TYPE_HELLO:
500 case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
500 if (GNUNET_OK != 501 if (GNUNET_OK !=
501 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, &me)) 502 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, &me))
502 { 503 {
@@ -1292,7 +1293,8 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1292 if (NULL == handle->client) 1293 if (NULL == handle->client)
1293 return NULL; 1294 return NULL;
1294 1295
1295 GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO); 1296 GNUNET_break ((ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO) ||
1297 (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_FRIEND_HELLO));
1296 size = ntohs (hello->size); 1298 size = ntohs (hello->size);
1297 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader)); 1299 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader));
1298 if (GNUNET_OK != 1300 if (GNUNET_OK !=