diff options
-rw-r--r-- | src/core/gnunet-service-core_sessions.c | 130 | ||||
-rw-r--r-- | src/core/gnunet-service-core_sessions.h | 51 | ||||
-rw-r--r-- | src/core/gnunet-service-core_typemap.c | 171 | ||||
-rw-r--r-- | src/core/gnunet-service-core_typemap.h | 66 |
4 files changed, 323 insertions, 95 deletions
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 0db053ff5..b72a0e0b3 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file core/gnunet-service-core_neighbours.c | 22 | * @file core/gnunet-service-core_sessions.c |
23 | * @brief code for managing of 'encrypted' sessions (key exchange done) | 23 | * @brief code for managing of 'encrypted' sessions (key exchange done) |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -33,7 +33,7 @@ | |||
33 | * Record kept for each request for transmission issued by a | 33 | * Record kept for each request for transmission issued by a |
34 | * client that is still pending. | 34 | * client that is still pending. |
35 | */ | 35 | */ |
36 | struct ClientActiveRequest; | 36 | struct GSC_ClientActiveRequest; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Data kept per session. | 39 | * Data kept per session. |
@@ -49,13 +49,13 @@ struct Session | |||
49 | * Head of list of requests from clients for transmission to | 49 | * Head of list of requests from clients for transmission to |
50 | * this peer. | 50 | * this peer. |
51 | */ | 51 | */ |
52 | struct ClientActiveRequest *active_client_request_head; | 52 | struct GSC_ClientActiveRequest *active_client_request_head; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Tail of list of requests from clients for transmission to | 55 | * Tail of list of requests from clients for transmission to |
56 | * this peer. | 56 | * this peer. |
57 | */ | 57 | */ |
58 | struct ClientActiveRequest *active_client_request_tail; | 58 | struct GSC_ClientActiveRequest *active_client_request_tail; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Performance data for the peer. | 61 | * Performance data for the peer. |
@@ -294,8 +294,8 @@ handle_peer_status_change (struct Neighbour *n) | |||
294 | static void | 294 | static void |
295 | schedule_peer_messages (struct Neighbour *n) | 295 | schedule_peer_messages (struct Neighbour *n) |
296 | { | 296 | { |
297 | struct ClientActiveRequest *car; | 297 | struct GSC_ClientActiveRequest *car; |
298 | struct ClientActiveRequest *pos; | 298 | struct GSC_ClientActiveRequest *pos; |
299 | struct Client *c; | 299 | struct Client *c; |
300 | struct MessageEntry *mqe; | 300 | struct MessageEntry *mqe; |
301 | unsigned int queue_size; | 301 | unsigned int queue_size; |
@@ -354,7 +354,7 @@ static void | |||
354 | free_neighbour (struct Neighbour *n) | 354 | free_neighbour (struct Neighbour *n) |
355 | { | 355 | { |
356 | struct MessageEntry *m; | 356 | struct MessageEntry *m; |
357 | struct ClientActiveRequest *car; | 357 | struct GSC_ClientActiveRequest *car; |
358 | 358 | ||
359 | #if DEBUG_CORE | 359 | #if DEBUG_CORE |
360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1360,6 +1360,51 @@ GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car, | |||
1360 | 1360 | ||
1361 | 1361 | ||
1362 | 1362 | ||
1363 | /** | ||
1364 | * Send a message to the neighbour. | ||
1365 | * | ||
1366 | * @param cls the message | ||
1367 | * @param key neighbour's identity | ||
1368 | * @param value 'struct Neighbour' of the target | ||
1369 | * @return always GNUNET_OK | ||
1370 | */ | ||
1371 | static int | ||
1372 | do_send_message (void *cls, const GNUNET_HashCode * key, void *value) | ||
1373 | { | ||
1374 | struct GNUNET_MessageHeader *hdr = cls; | ||
1375 | struct Neighbour *n = value; | ||
1376 | struct MessageEntry *m; | ||
1377 | uint16_t size; | ||
1378 | |||
1379 | size = ntohs (hdr->size); | ||
1380 | m = GNUNET_malloc (sizeof (struct MessageEntry) + size); | ||
1381 | memcpy (&m[1], hdr, size); | ||
1382 | m->deadline = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
1383 | m->slack_deadline = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
1384 | m->priority = UINT_MAX; | ||
1385 | m->sender_status = n->status; | ||
1386 | m->size = size; | ||
1387 | GNUNET_CONTAINER_DLL_insert (n->message_head, | ||
1388 | n->message_tail, | ||
1389 | m); | ||
1390 | return GNUNET_OK; | ||
1391 | } | ||
1392 | |||
1393 | |||
1394 | /** | ||
1395 | * Broadcast a message to all neighbours. | ||
1396 | * | ||
1397 | * @param msg message to transmit | ||
1398 | */ | ||
1399 | void | ||
1400 | GSC_SESSIONS_broadcast (const struct GNUNET_MessageHeader *msg) | ||
1401 | { | ||
1402 | if (NULL == sessions) | ||
1403 | return; | ||
1404 | GNUNET_CONTAINER_multihashmap_iterate (sessions, | ||
1405 | &do_send_message, msg); | ||
1406 | } | ||
1407 | |||
1363 | 1408 | ||
1364 | /** | 1409 | /** |
1365 | * Helper function for GSC_SESSIONS_handle_client_iterate_peers. | 1410 | * Helper function for GSC_SESSIONS_handle_client_iterate_peers. |
@@ -1413,9 +1458,60 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value) | |||
1413 | } | 1458 | } |
1414 | 1459 | ||
1415 | 1460 | ||
1461 | /** | ||
1462 | * End the session with the given peer (we are no longer | ||
1463 | * connected). | ||
1464 | * | ||
1465 | * @param pid identity of peer to kill session with | ||
1466 | */ | ||
1467 | void | ||
1468 | GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid) | ||
1469 | { | ||
1470 | } | ||
1471 | |||
1472 | |||
1473 | /** | ||
1474 | * Traffic is being solicited for the given peer. This means that the | ||
1475 | * message queue on the transport-level (NEIGHBOURS subsystem) is now | ||
1476 | * empty and it is now OK to transmit another (non-control) message. | ||
1477 | * | ||
1478 | * @param pid identity of peer ready to receive data | ||
1479 | */ | ||
1480 | void | ||
1481 | GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid) | ||
1482 | { | ||
1483 | } | ||
1484 | |||
1485 | |||
1486 | /** | ||
1487 | * Transmit a message to a particular peer. | ||
1488 | * | ||
1489 | * @param car original request that was queued and then solicited, | ||
1490 | * ownership does not change (dequeue will be called soon). | ||
1491 | * @param msg message to transmit | ||
1492 | */ | ||
1493 | void | ||
1494 | GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car, | ||
1495 | const struct GNUNET_MessageHeader *msg) | ||
1496 | { | ||
1497 | } | ||
1498 | |||
1416 | 1499 | ||
1417 | /** | 1500 | /** |
1418 | * Handle CORE_ITERATE_PEERS request. | 1501 | * We have a new client, notify it about all current sessions. |
1502 | * | ||
1503 | * @param client the new client | ||
1504 | */ | ||
1505 | void | ||
1506 | GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client) | ||
1507 | { | ||
1508 | } | ||
1509 | |||
1510 | |||
1511 | /** | ||
1512 | * Handle CORE_ITERATE_PEERS request. For this request type, the client | ||
1513 | * does not have to have transmitted an INIT request. All current peers | ||
1514 | * are returned, regardless of which message types they accept. | ||
1419 | * | 1515 | * |
1420 | * @param cls unused | 1516 | * @param cls unused |
1421 | * @param client client sending the iteration request | 1517 | * @param client client sending the iteration request |
@@ -1439,7 +1535,10 @@ GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client | |||
1439 | 1535 | ||
1440 | 1536 | ||
1441 | /** | 1537 | /** |
1442 | * Handle CORE_PEER_CONNECTED request. Notify client about existing neighbours. | 1538 | * Handle CORE_PEER_CONNECTED request. Notify client about connection |
1539 | * to the given neighbour. For this request type, the client does not | ||
1540 | * have to have transmitted an INIT request. All current peers are | ||
1541 | * returned, regardless of which message types they accept. | ||
1443 | * | 1542 | * |
1444 | * @param cls unused | 1543 | * @param cls unused |
1445 | * @param client client sending the iteration request | 1544 | * @param client client sending the iteration request |
@@ -1466,7 +1565,8 @@ GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *cl | |||
1466 | 1565 | ||
1467 | 1566 | ||
1468 | /** | 1567 | /** |
1469 | * Handle REQUEST_INFO request. | 1568 | * Handle REQUEST_INFO request. For this request type, the client must |
1569 | * have transmitted an INIT first. | ||
1470 | * | 1570 | * |
1471 | * @param cls unused | 1571 | * @param cls unused |
1472 | * @param client client sending the request | 1572 | * @param client client sending the request |
@@ -1576,8 +1676,11 @@ GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client | |||
1576 | 1676 | ||
1577 | 1677 | ||
1578 | 1678 | ||
1679 | /** | ||
1680 | * Initialize sessions subsystem. | ||
1681 | */ | ||
1579 | int | 1682 | int |
1580 | GSC_NEIGHBOURS_init () | 1683 | GSC_SESSIONS_init () |
1581 | { | 1684 | { |
1582 | neighbours = GNUNET_CONTAINER_multihashmap_create (128); | 1685 | neighbours = GNUNET_CONTAINER_multihashmap_create (128); |
1583 | self.public_key = &my_public_key; | 1686 | self.public_key = &my_public_key; |
@@ -1589,8 +1692,11 @@ GSC_NEIGHBOURS_init () | |||
1589 | } | 1692 | } |
1590 | 1693 | ||
1591 | 1694 | ||
1695 | /** | ||
1696 | * Shutdown sessions subsystem. | ||
1697 | */ | ||
1592 | void | 1698 | void |
1593 | GSC_NEIGHBOURS_done () | 1699 | GSC_SESSIONS_done () |
1594 | { | 1700 | { |
1595 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper, | 1701 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper, |
1596 | NULL); | 1702 | NULL); |
diff --git a/src/core/gnunet-service-core_sessions.h b/src/core/gnunet-service-core_sessions.h index 1898aa36a..fc5944cda 100644 --- a/src/core/gnunet-service-core_sessions.h +++ b/src/core/gnunet-service-core_sessions.h | |||
@@ -87,6 +87,15 @@ GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car, | |||
87 | 87 | ||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Broadcast a message to all neighbours. | ||
91 | * | ||
92 | * @param msg message to transmit | ||
93 | */ | ||
94 | void | ||
95 | GSC_SESSIONS_broadcast (const struct GNUNET_MessageHeader *msg); | ||
96 | |||
97 | |||
98 | /** | ||
90 | * We have a new client, notify it about all current sessions. | 99 | * We have a new client, notify it about all current sessions. |
91 | * | 100 | * |
92 | * @param client the new client | 101 | * @param client the new client |
@@ -96,6 +105,48 @@ GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client); | |||
96 | 105 | ||
97 | 106 | ||
98 | /** | 107 | /** |
108 | * Handle CORE_ITERATE_PEERS request. For this request type, the client | ||
109 | * does not have to have transmitted an INIT request. All current peers | ||
110 | * are returned, regardless of which message types they accept. | ||
111 | * | ||
112 | * @param cls unused | ||
113 | * @param client client sending the iteration request | ||
114 | * @param message iteration request message | ||
115 | */ | ||
116 | void | ||
117 | GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client, | ||
118 | const struct GNUNET_MessageHeader *message); | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Handle CORE_PEER_CONNECTED request. Notify client about connection | ||
123 | * to the given neighbour. For this request type, the client does not | ||
124 | * have to have transmitted an INIT request. All current peers are | ||
125 | * returned, regardless of which message types they accept. | ||
126 | * | ||
127 | * @param cls unused | ||
128 | * @param client client sending the iteration request | ||
129 | * @param message iteration request message | ||
130 | */ | ||
131 | void | ||
132 | GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client, | ||
133 | const struct GNUNET_MessageHeader *message); | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Handle REQUEST_INFO request. For this request type, the client must have | ||
138 | * transmitted an INIT first. | ||
139 | * | ||
140 | * @param cls unused | ||
141 | * @param client client sending the request | ||
142 | * @param message iteration request message | ||
143 | */ | ||
144 | void | ||
145 | GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, | ||
146 | const struct GNUNET_MessageHeader *message); | ||
147 | |||
148 | |||
149 | /** | ||
99 | * Initialize sessions subsystem. | 150 | * Initialize sessions subsystem. |
100 | */ | 151 | */ |
101 | void | 152 | void |
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c index dfd0b8888..5feb65a53 100644 --- a/src/core/gnunet-service-core_typemap.c +++ b/src/core/gnunet-service-core_typemap.c | |||
@@ -1,3 +1,33 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file core/gnunet-service-core_typemap.c | ||
23 | * @brief management of map that specifies which message types this peer supports | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_transport_service.h" | ||
29 | #include "gnunet_service_core.h" | ||
30 | |||
1 | 31 | ||
2 | /** | 32 | /** |
3 | * A type map describing which messages a given neighbour is able | 33 | * A type map describing which messages a given neighbour is able |
@@ -16,6 +46,58 @@ static uint32_t my_type_map[(UINT16_MAX + 1) / 32]; | |||
16 | 46 | ||
17 | 47 | ||
18 | /** | 48 | /** |
49 | * Compute a type map message for this peer. | ||
50 | * | ||
51 | * @return this peers current type map message. | ||
52 | */ | ||
53 | static struct GNUNET_MessageHeader * | ||
54 | compute_type_map_message () | ||
55 | { | ||
56 | char *tmp; | ||
57 | uLongf dlen; | ||
58 | struct GNUNET_MessageHeader *hdr; | ||
59 | |||
60 | #ifdef compressBound | ||
61 | dlen = compressBound (sizeof (my_type_map)); | ||
62 | #else | ||
63 | dlen = sizeof (my_type_map) + (sizeof (my_type_map) / 100) + 20; | ||
64 | /* documentation says 100.1% oldSize + 12 bytes, but we | ||
65 | * should be able to overshoot by more to be safe */ | ||
66 | #endif | ||
67 | hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader)); | ||
68 | hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader)); | ||
69 | tmp = (char *) &hdr[1]; | ||
70 | if ((Z_OK != | ||
71 | compress2 ((Bytef *) tmp, &dlen, (const Bytef *) my_type_map, | ||
72 | sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) | ||
73 | { | ||
74 | dlen = sizeof (my_type_map); | ||
75 | memcpy (tmp, my_type_map, sizeof (my_type_map)); | ||
76 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP); | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP); | ||
81 | } | ||
82 | return hdr; | ||
83 | } | ||
84 | |||
85 | |||
86 | /** | ||
87 | * Send my type map to all connected peers (it got changed). | ||
88 | */ | ||
89 | static void | ||
90 | broadcast_my_type_map () | ||
91 | { | ||
92 | struct GNUNET_MessageHeader *hdr; | ||
93 | |||
94 | hdr = compute_type_map_message (); | ||
95 | GSC_SESSIONS_broadcast (hdr);x | ||
96 | GNUNET_free (hdr); | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
19 | * Add a set of types to our type map. | 101 | * Add a set of types to our type map. |
20 | */ | 102 | */ |
21 | void | 103 | void |
@@ -63,97 +145,20 @@ int | |||
63 | GSC_TYPEMAP_test_match (struct GSC_TypeMap *tmap, | 145 | GSC_TYPEMAP_test_match (struct GSC_TypeMap *tmap, |
64 | const uint16_t *types, | 146 | const uint16_t *types, |
65 | unsigned int tcnt) | 147 | unsigned int tcnt) |
66 | { | 148 | { |
67 | return GNUNET_YES; /* FIXME */ | 149 | return GNUNET_YES; /* FIXME */ |
68 | } | 150 | } |
69 | 151 | ||
70 | 152 | ||
71 | /** | 153 | void |
72 | * Compute a type map message for this peer. | 154 | GSC_TYPEMAP_init () |
73 | * | ||
74 | * @return this peers current type map message. | ||
75 | */ | ||
76 | static struct GNUNET_MessageHeader * | ||
77 | compute_type_map_message () | ||
78 | { | ||
79 | char *tmp; | ||
80 | uLongf dlen; | ||
81 | struct GNUNET_MessageHeader *hdr; | ||
82 | |||
83 | #ifdef compressBound | ||
84 | dlen = compressBound (sizeof (my_type_map)); | ||
85 | #else | ||
86 | dlen = sizeof (my_type_map) + (sizeof (my_type_map) / 100) + 20; | ||
87 | /* documentation says 100.1% oldSize + 12 bytes, but we | ||
88 | * should be able to overshoot by more to be safe */ | ||
89 | #endif | ||
90 | hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader)); | ||
91 | hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader)); | ||
92 | tmp = (char *) &hdr[1]; | ||
93 | if ((Z_OK != | ||
94 | compress2 ((Bytef *) tmp, &dlen, (const Bytef *) my_type_map, | ||
95 | sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) | ||
96 | { | ||
97 | dlen = sizeof (my_type_map); | ||
98 | memcpy (tmp, my_type_map, sizeof (my_type_map)); | ||
99 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP); | ||
104 | } | ||
105 | return hdr; | ||
106 | } | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Send a type map message to the neighbour. | ||
111 | * | ||
112 | * @param cls the type map message | ||
113 | * @param key neighbour's identity | ||
114 | * @param value 'struct Neighbour' of the target | ||
115 | * @return always GNUNET_OK | ||
116 | */ | ||
117 | static int | ||
118 | send_type_map_to_neighbour (void *cls, const GNUNET_HashCode * key, void *value) | ||
119 | { | 155 | { |
120 | struct GNUNET_MessageHeader *hdr = cls; | ||
121 | struct Neighbour *n = value; | ||
122 | struct MessageEntry *m; | ||
123 | uint16_t size; | ||
124 | |||
125 | if (n == &self) | ||
126 | return GNUNET_OK; | ||
127 | size = ntohs (hdr->size); | ||
128 | m = GNUNET_malloc (sizeof (struct MessageEntry) + size); | ||
129 | memcpy (&m[1], hdr, size); | ||
130 | m->deadline = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
131 | m->slack_deadline = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
132 | m->priority = UINT_MAX; | ||
133 | m->sender_status = n->status; | ||
134 | m->size = size; | ||
135 | m->next = n->messages; | ||
136 | n->messages = m; | ||
137 | return GNUNET_OK; | ||
138 | } | 156 | } |
139 | 157 | ||
140 | 158 | ||
141 | 159 | void | |
142 | /** | 160 | GSC_TYPEMAP_done () |
143 | * Send my type map to all connected peers (it got changed). | ||
144 | */ | ||
145 | static void | ||
146 | broadcast_my_type_map () | ||
147 | { | 161 | { |
148 | struct GNUNET_MessageHeader *hdr; | ||
149 | |||
150 | if (NULL == neighbours) | ||
151 | return; | ||
152 | hdr = compute_type_map_message (); | ||
153 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, | ||
154 | &send_type_map_to_neighbour, hdr); | ||
155 | GNUNET_free (hdr); | ||
156 | } | 162 | } |
157 | 163 | ||
158 | 164 | /* end of gnunet-service-core_typemap.c */ | |
159 | |||
diff --git a/src/core/gnunet-service-core_typemap.h b/src/core/gnunet-service-core_typemap.h new file mode 100644 index 000000000..4bbd6eb29 --- /dev/null +++ b/src/core/gnunet-service-core_typemap.h | |||
@@ -0,0 +1,66 @@ | |||
1 | * | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file core/gnunet-service-core_typemap.h | ||
23 | * @brief management of map that specifies which message types this peer supports | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_CORE_TYPEMAP_H | ||
27 | #define GNUNET_SERVICE_CORE_TYPEMAP_H | ||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_transport_service.h" | ||
31 | #include "gnunet_service_core.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Add a set of types to our type map. | ||
36 | */ | ||
37 | void | ||
38 | GSC_TYPEMAP_add (const uint16_t *types, | ||
39 | unsigned int tlen); | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Remove a set of types from our type map. | ||
44 | */ | ||
45 | void | ||
46 | GSC_TYPEMAP_remove (const uint16_t *types, | ||
47 | unsigned int tlen); | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Test if any of the types from the types array is in the | ||
52 | * given type map. | ||
53 | * | ||
54 | * @param map map to test | ||
55 | * @param types array of types | ||
56 | * @param tcnt number of entries in types | ||
57 | * @return GNUNET_YES if a type is in the map, GNUNET_NO if not | ||
58 | */ | ||
59 | int | ||
60 | GSC_TYPEMAP_test_match (struct GSC_TypeMap *tmap, | ||
61 | const uint16_t *types, | ||
62 | unsigned int tcnt); | ||
63 | |||
64 | |||
65 | #endif | ||
66 | /* end of gnunet-service-core_typemap.h */ | ||