diff options
Diffstat (limited to 'src')
87 files changed, 305 insertions, 1320 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index a61343833..56af544b1 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -753,7 +753,7 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
753 | 753 | ||
754 | slen = strlen (service_name) + 1; | 754 | slen = strlen (service_name) + 1; |
755 | if (slen + sizeof (struct GNUNET_ARM_Message) >= | 755 | if (slen + sizeof (struct GNUNET_ARM_Message) >= |
756 | GNUNET_SERVER_MAX_MESSAGE_SIZE) | 756 | GNUNET_MAX_MESSAGE_SIZE) |
757 | { | 757 | { |
758 | GNUNET_break (0); | 758 | GNUNET_break (0); |
759 | return NULL; | 759 | return NULL; |
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index cc23ef1f6..19088c5cb 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -2225,7 +2225,7 @@ main (int argc, | |||
2225 | shc_chld = | 2225 | shc_chld = |
2226 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, | 2226 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, |
2227 | &sighandler_child_death); | 2227 | &sighandler_child_death); |
2228 | ret = GNUNET_SERVICE_ruN_ (argc, | 2228 | ret = GNUNET_SERVICE_run_ (argc, |
2229 | argv, | 2229 | argv, |
2230 | "arm", | 2230 | "arm", |
2231 | GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, | 2231 | GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, |
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index faeeb6081..81ae01b6a 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -657,9 +657,9 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, | |||
657 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); | 657 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); |
658 | namelen = strlen (address->transport_name) + 1; | 658 | namelen = strlen (address->transport_name) + 1; |
659 | msize = address->address_length + namelen; | 659 | msize = address->address_length + namelen; |
660 | if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 660 | if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) || |
661 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 661 | (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) || |
662 | (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ) | 662 | (namelen >= GNUNET_MAX_MESSAGE_SIZE) ) |
663 | { | 663 | { |
664 | /* address too large for us, this should not happen */ | 664 | /* address too large for us, this should not happen */ |
665 | GNUNET_break (0); | 665 | GNUNET_break (0); |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 1a4a33206..ba34cbacb 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -571,7 +571,7 @@ transmit_req_addr (struct AddressIteration *ai, | |||
571 | msize = plugin_addr_len + plugin_name_length; | 571 | msize = plugin_addr_len + plugin_name_length; |
572 | 572 | ||
573 | GNUNET_assert (sizeof (struct PeerInformationMessage) + msize | 573 | GNUNET_assert (sizeof (struct PeerInformationMessage) + msize |
574 | < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 574 | < GNUNET_MAX_MESSAGE_SIZE); |
575 | env = GNUNET_MQ_msg_extra (msg, | 575 | env = GNUNET_MQ_msg_extra (msg, |
576 | msize, | 576 | msize, |
577 | GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE); | 577 | GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE); |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 5252a71bc..07ddf0531 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -85,7 +85,7 @@ notify_client (struct GNUNET_SERVICE_Client *client, | |||
85 | 85 | ||
86 | if (NULL != prop) | 86 | if (NULL != prop) |
87 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); | 87 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); |
88 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 88 | GNUNET_assert (msize < GNUNET_MAX_MESSAGE_SIZE); |
89 | msg = (struct PeerInformationMessage *) buf; | 89 | msg = (struct PeerInformationMessage *) buf; |
90 | msg->header.size = htons (msize); | 90 | msg->header.size = htons (msize); |
91 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION); | 91 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION); |
diff --git a/src/core/core_api.c b/src/core/core_api.c index fd789295d..ed8ce364d 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -321,7 +321,7 @@ core_mq_send_impl (struct GNUNET_MQ_Handle *mq, | |||
321 | 321 | ||
322 | /* check message size for sanity */ | 322 | /* check message size for sanity */ |
323 | msize = ntohs (msg->size); | 323 | msize = ntohs (msg->size); |
324 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct SendMessage)) | 324 | if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SendMessage)) |
325 | { | 325 | { |
326 | GNUNET_break (0); | 326 | GNUNET_break (0); |
327 | GNUNET_MQ_impl_send_continue (mq); | 327 | GNUNET_MQ_impl_send_continue (mq); |
@@ -796,7 +796,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
796 | h->handlers = GNUNET_MQ_copy_handlers (handlers); | 796 | h->handlers = GNUNET_MQ_copy_handlers (handlers); |
797 | h->hcnt = GNUNET_MQ_count_handlers (handlers); | 797 | h->hcnt = GNUNET_MQ_count_handlers (handlers); |
798 | GNUNET_assert (h->hcnt < | 798 | GNUNET_assert (h->hcnt < |
799 | (GNUNET_SERVER_MAX_MESSAGE_SIZE - | 799 | (GNUNET_MAX_MESSAGE_SIZE - |
800 | sizeof (struct InitMessage)) / sizeof (uint16_t)); | 800 | sizeof (struct InitMessage)) / sizeof (uint16_t)); |
801 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 801 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
802 | "Connecting to CORE service\n"); | 802 | "Connecting to CORE service\n"); |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 31b91f12f..625bf9655 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -807,7 +807,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender, | |||
807 | { | 807 | { |
808 | size_t size = msize + sizeof (struct NotifyTrafficMessage); | 808 | size_t size = msize + sizeof (struct NotifyTrafficMessage); |
809 | 809 | ||
810 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 810 | if (size >= GNUNET_MAX_MESSAGE_SIZE) |
811 | { | 811 | { |
812 | GNUNET_break (0); | 812 | GNUNET_break (0); |
813 | return; | 813 | return; |
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index ef7cd7532..c677654aa 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -1001,7 +1001,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
1001 | struct DataMessage *dm; | 1001 | struct DataMessage *dm; |
1002 | union QueueContext qc; | 1002 | union QueueContext qc; |
1003 | 1003 | ||
1004 | if (size + sizeof (*dm) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1004 | if (size + sizeof (*dm) >= GNUNET_MAX_MESSAGE_SIZE) |
1005 | { | 1005 | { |
1006 | GNUNET_break (0); | 1006 | GNUNET_break (0); |
1007 | return NULL; | 1007 | return NULL; |
@@ -1212,7 +1212,7 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | |||
1212 | struct GNUNET_MQ_Envelope *env; | 1212 | struct GNUNET_MQ_Envelope *env; |
1213 | union QueueContext qc; | 1213 | union QueueContext qc; |
1214 | 1214 | ||
1215 | if (sizeof (*dm) + size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1215 | if (sizeof (*dm) + size >= GNUNET_MAX_MESSAGE_SIZE) |
1216 | { | 1216 | { |
1217 | GNUNET_break (0); | 1217 | GNUNET_break (0); |
1218 | return NULL; | 1218 | return NULL; |
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index bde2843a6..dabec3d6d 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -529,7 +529,7 @@ transmit_item (void *cls, | |||
529 | return GNUNET_OK; | 529 | return GNUNET_OK; |
530 | } | 530 | } |
531 | GNUNET_assert (sizeof (struct DataMessage) + size < | 531 | GNUNET_assert (sizeof (struct DataMessage) + size < |
532 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | 532 | GNUNET_MAX_MESSAGE_SIZE); |
533 | env = GNUNET_MQ_msg_extra (dm, | 533 | env = GNUNET_MQ_msg_extra (dm, |
534 | size, | 534 | size, |
535 | GNUNET_MESSAGE_TYPE_DATASTORE_DATA); | 535 | GNUNET_MESSAGE_TYPE_DATASTORE_DATA); |
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index ee208b50e..42ddc7b60 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -319,7 +319,7 @@ send_get_known_results (struct GNUNET_DHT_GetHandle *gh, | |||
319 | unsigned int max; | 319 | unsigned int max; |
320 | unsigned int transmission_offset; | 320 | unsigned int transmission_offset; |
321 | 321 | ||
322 | max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*msg)) | 322 | max = (GNUNET_MAX_MESSAGE_SIZE - sizeof (*msg)) |
323 | / sizeof (struct GNUNET_HashCode); | 323 | / sizeof (struct GNUNET_HashCode); |
324 | transmission_offset = transmission_offset_start; | 324 | transmission_offset = transmission_offset_start; |
325 | while (transmission_offset < gh->seen_results_end) | 325 | while (transmission_offset < gh->seen_results_end) |
@@ -704,9 +704,9 @@ check_client_result (void *cls, | |||
704 | sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length); | 704 | sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length); |
705 | if ( (msize < meta_length) || | 705 | if ( (msize < meta_length) || |
706 | (get_path_length > | 706 | (get_path_length > |
707 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || | 707 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || |
708 | (put_path_length > | 708 | (put_path_length > |
709 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ) | 709 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ) |
710 | { | 710 | { |
711 | GNUNET_break (0); | 711 | GNUNET_break (0); |
712 | return GNUNET_SYSERR; | 712 | return GNUNET_SYSERR; |
@@ -998,8 +998,8 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
998 | struct GNUNET_DHT_PutHandle *ph; | 998 | struct GNUNET_DHT_PutHandle *ph; |
999 | 999 | ||
1000 | msize = sizeof (struct GNUNET_DHT_ClientPutMessage) + size; | 1000 | msize = sizeof (struct GNUNET_DHT_ClientPutMessage) + size; |
1001 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 1001 | if ((msize >= GNUNET_MAX_MESSAGE_SIZE) || |
1002 | (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) | 1002 | (size >= GNUNET_MAX_MESSAGE_SIZE)) |
1003 | { | 1003 | { |
1004 | GNUNET_break (0); | 1004 | GNUNET_break (0); |
1005 | return NULL; | 1005 | return NULL; |
@@ -1090,8 +1090,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
1090 | size_t msize; | 1090 | size_t msize; |
1091 | 1091 | ||
1092 | msize = sizeof (struct GNUNET_DHT_ClientGetMessage) + xquery_size; | 1092 | msize = sizeof (struct GNUNET_DHT_ClientGetMessage) + xquery_size; |
1093 | if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 1093 | if ((msize >= GNUNET_MAX_MESSAGE_SIZE) || |
1094 | (xquery_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)) | 1094 | (xquery_size >= GNUNET_MAX_MESSAGE_SIZE)) |
1095 | { | 1095 | { |
1096 | GNUNET_break (0); | 1096 | GNUNET_break (0); |
1097 | return NULL; | 1097 | return NULL; |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 0f521a401..cb155c484 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -1166,7 +1166,7 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration, | |||
1166 | 1166 | ||
1167 | msize = sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size + | 1167 | msize = sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size + |
1168 | (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity); | 1168 | (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity); |
1169 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1169 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) |
1170 | { | 1170 | { |
1171 | GNUNET_break (0); | 1171 | GNUNET_break (0); |
1172 | return; | 1172 | return; |
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index fef637cad..36047d561 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c | |||
@@ -72,7 +72,7 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
72 | _("%s request received, but have no datacache!\n"), "PUT"); | 72 | _("%s request received, but have no datacache!\n"), "PUT"); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | if (data_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 75 | if (data_size >= GNUNET_MAX_MESSAGE_SIZE) |
76 | { | 76 | { |
77 | GNUNET_break (0); | 77 | GNUNET_break (0); |
78 | return; | 78 | return; |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 15071edca..0309bea88 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -1423,7 +1423,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | |||
1423 | UINT32_MAX); | 1423 | UINT32_MAX); |
1424 | } | 1424 | } |
1425 | msize = xquery_size + reply_bf_size; | 1425 | msize = xquery_size + reply_bf_size; |
1426 | if (msize + sizeof (struct PeerGetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1426 | if (msize + sizeof (struct PeerGetMessage) >= GNUNET_MAX_MESSAGE_SIZE) |
1427 | { | 1427 | { |
1428 | GNUNET_break (0); | 1428 | GNUNET_break (0); |
1429 | GNUNET_free_non_null (reply_bf); | 1429 | GNUNET_free_non_null (reply_bf); |
@@ -1522,12 +1522,12 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target, | |||
1522 | 1522 | ||
1523 | msize = data_size + (get_path_length + put_path_length) * | 1523 | msize = data_size + (get_path_length + put_path_length) * |
1524 | sizeof (struct GNUNET_PeerIdentity); | 1524 | sizeof (struct GNUNET_PeerIdentity); |
1525 | if ((msize + sizeof (struct PeerResultMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 1525 | if ((msize + sizeof (struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) || |
1526 | (get_path_length > | 1526 | (get_path_length > |
1527 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || | 1527 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || |
1528 | (put_path_length > | 1528 | (put_path_length > |
1529 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || | 1529 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || |
1530 | (data_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)) | 1530 | (data_size > GNUNET_MAX_MESSAGE_SIZE)) |
1531 | { | 1531 | { |
1532 | GNUNET_break (0); | 1532 | GNUNET_break (0); |
1533 | return; | 1533 | return; |
@@ -1627,7 +1627,7 @@ check_dht_p2p_put (void *cls, | |||
1627 | sizeof (struct PeerPutMessage) + | 1627 | sizeof (struct PeerPutMessage) + |
1628 | putlen * sizeof (struct GNUNET_PeerIdentity)) || | 1628 | putlen * sizeof (struct GNUNET_PeerIdentity)) || |
1629 | (putlen > | 1629 | (putlen > |
1630 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity))) | 1630 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity))) |
1631 | { | 1631 | { |
1632 | GNUNET_break_op (0); | 1632 | GNUNET_break_op (0); |
1633 | return GNUNET_SYSERR; | 1633 | return GNUNET_SYSERR; |
@@ -2213,9 +2213,9 @@ check_dht_p2p_result (void *cls, | |||
2213 | put_path_length) * | 2213 | put_path_length) * |
2214 | sizeof (struct GNUNET_PeerIdentity)) || | 2214 | sizeof (struct GNUNET_PeerIdentity)) || |
2215 | (get_path_length > | 2215 | (get_path_length > |
2216 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || | 2216 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) || |
2217 | (put_path_length > | 2217 | (put_path_length > |
2218 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity))) | 2218 | GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity))) |
2219 | { | 2219 | { |
2220 | GNUNET_break_op (0); | 2220 | GNUNET_break_op (0); |
2221 | return GNUNET_SYSERR; | 2221 | return GNUNET_SYSERR; |
diff --git a/src/dns/dns_api.c b/src/dns/dns_api.c index e7450a1d4..9f0dee9a9 100644 --- a/src/dns/dns_api.c +++ b/src/dns/dns_api.c | |||
@@ -317,7 +317,7 @@ GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh, | |||
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | if (reply_length + sizeof (struct GNUNET_DNS_Response) | 319 | if (reply_length + sizeof (struct GNUNET_DNS_Response) |
320 | >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 320 | >= GNUNET_MAX_MESSAGE_SIZE) |
321 | { | 321 | { |
322 | GNUNET_break (0); | 322 | GNUNET_break (0); |
323 | GNUNET_free (rh); | 323 | GNUNET_free (rh); |
diff --git a/src/dns/gnunet-helper-dns.c b/src/dns/gnunet-helper-dns.c index d083a9df2..5cf1967f5 100644 --- a/src/dns/gnunet-helper-dns.c +++ b/src/dns/gnunet-helper-dns.c | |||
@@ -79,7 +79,7 @@ | |||
79 | #include "gnunet_protocols.h" | 79 | #include "gnunet_protocols.h" |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 82 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
83 | */ | 83 | */ |
84 | #define MAX_SIZE 65536 | 84 | #define MAX_SIZE 65536 |
85 | 85 | ||
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 079f74ce4..ffc94afb7 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c | |||
@@ -347,7 +347,7 @@ request_done (struct RequestRecord *rr) | |||
347 | } | 347 | } |
348 | reply_len += sizeof (struct GNUNET_TUN_UdpHeader); | 348 | reply_len += sizeof (struct GNUNET_TUN_UdpHeader); |
349 | reply_len += rr->payload_length; | 349 | reply_len += rr->payload_length; |
350 | if (reply_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 350 | if (reply_len >= GNUNET_MAX_MESSAGE_SIZE) |
351 | { | 351 | { |
352 | /* response too big, drop */ | 352 | /* response too big, drop */ |
353 | GNUNET_break (0); /* how can this be? */ | 353 | GNUNET_break (0); /* how can this be? */ |
@@ -481,7 +481,7 @@ send_request_to_client (struct RequestRecord *rr, | |||
481 | struct GNUNET_MQ_Envelope *env; | 481 | struct GNUNET_MQ_Envelope *env; |
482 | struct GNUNET_DNS_Request *req; | 482 | struct GNUNET_DNS_Request *req; |
483 | 483 | ||
484 | if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 484 | if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_MAX_MESSAGE_SIZE) |
485 | { | 485 | { |
486 | GNUNET_break (0); | 486 | GNUNET_break (0); |
487 | cleanup_rr (rr); | 487 | cleanup_rr (rr); |
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 062f9a95f..ab521ec1f 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -437,7 +437,7 @@ GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh, | |||
437 | struct ConnectedPeer *peer; | 437 | struct ConnectedPeer *peer; |
438 | struct GNUNET_MQ_Envelope *env; | 438 | struct GNUNET_MQ_Envelope *env; |
439 | 439 | ||
440 | if (ntohs (msg->size) + sizeof (*sm) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 440 | if (ntohs (msg->size) + sizeof (*sm) >= GNUNET_MAX_MESSAGE_SIZE) |
441 | { | 441 | { |
442 | GNUNET_break (0); | 442 | GNUNET_break (0); |
443 | return; | 443 | return; |
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 3fbd0cc03..fa1c16be8 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -399,7 +399,7 @@ send_data_to_plugin (const struct GNUNET_MessageHeader *message, | |||
399 | (unsigned int) distance); | 399 | (unsigned int) distance); |
400 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + | 400 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + |
401 | ntohs (message->size); | 401 | ntohs (message->size); |
402 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 402 | if (size >= GNUNET_MAX_MESSAGE_SIZE) |
403 | { | 403 | { |
404 | GNUNET_break (0); /* too big */ | 404 | GNUNET_break (0); /* too big */ |
405 | return; | 405 | return; |
@@ -537,7 +537,7 @@ forward_payload (struct DirectNeighbor *target, | |||
537 | return; | 537 | return; |
538 | } | 538 | } |
539 | if (sizeof (struct RouteMessage) + ntohs (payload->size) | 539 | if (sizeof (struct RouteMessage) + ntohs (payload->size) |
540 | >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 540 | >= GNUNET_MAX_MESSAGE_SIZE) |
541 | { | 541 | { |
542 | GNUNET_break (0); | 542 | GNUNET_break (0); |
543 | return; | 543 | return; |
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 15a462ada..2cd3441a1 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -979,7 +979,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address, | |||
979 | } | 979 | } |
980 | len += sizeof (struct GNUNET_TUN_TcpHeader); | 980 | len += sizeof (struct GNUNET_TUN_TcpHeader); |
981 | len += payload_length; | 981 | len += payload_length; |
982 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 982 | if (len >= GNUNET_MAX_MESSAGE_SIZE) |
983 | { | 983 | { |
984 | GNUNET_break (0); | 984 | GNUNET_break (0); |
985 | return; | 985 | return; |
@@ -1079,7 +1079,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address, | |||
1079 | } | 1079 | } |
1080 | len += sizeof (struct GNUNET_TUN_IcmpHeader); | 1080 | len += sizeof (struct GNUNET_TUN_IcmpHeader); |
1081 | len += payload_length; | 1081 | len += payload_length; |
1082 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1082 | if (len >= GNUNET_MAX_MESSAGE_SIZE) |
1083 | { | 1083 | { |
1084 | GNUNET_break (0); | 1084 | GNUNET_break (0); |
1085 | return; | 1085 | return; |
@@ -1358,7 +1358,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address, | |||
1358 | } | 1358 | } |
1359 | len += sizeof (struct GNUNET_TUN_UdpHeader); | 1359 | len += sizeof (struct GNUNET_TUN_UdpHeader); |
1360 | len += payload_length; | 1360 | len += payload_length; |
1361 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1361 | if (len >= GNUNET_MAX_MESSAGE_SIZE) |
1362 | { | 1362 | { |
1363 | GNUNET_break (0); | 1363 | GNUNET_break (0); |
1364 | return; | 1364 | return; |
@@ -2884,7 +2884,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, | |||
2884 | mtcp->crc = 0; | 2884 | mtcp->crc = 0; |
2885 | 2885 | ||
2886 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + (pktlen - sizeof (struct GNUNET_TUN_TcpHeader)); | 2886 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + (pktlen - sizeof (struct GNUNET_TUN_TcpHeader)); |
2887 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 2887 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
2888 | { | 2888 | { |
2889 | GNUNET_break (0); | 2889 | GNUNET_break (0); |
2890 | return; | 2890 | return; |
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c index 6be65ccd5..aa7a7a4a3 100644 --- a/src/exit/gnunet-helper-exit-windows.c +++ b/src/exit/gnunet-helper-exit-windows.c | |||
@@ -77,7 +77,7 @@ | |||
77 | static boolean privilege_testing = FALSE; | 77 | static boolean privilege_testing = FALSE; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 80 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
81 | */ | 81 | */ |
82 | #define MAX_SIZE 65536 | 82 | #define MAX_SIZE 65536 |
83 | 83 | ||
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c index e14c6ca43..3c6f97557 100644 --- a/src/exit/gnunet-helper-exit.c +++ b/src/exit/gnunet-helper-exit.c | |||
@@ -62,7 +62,7 @@ | |||
62 | #define DEBUG GNUNET_NO | 62 | #define DEBUG GNUNET_NO |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 65 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
66 | */ | 66 | */ |
67 | #define MAX_SIZE 65536 | 67 | #define MAX_SIZE 65536 |
68 | 68 | ||
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 86a58a58b..759467ba4 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -837,7 +837,7 @@ hash_for_index_cb (void *cls, | |||
837 | GNUNET_assert (fn != NULL); | 837 | GNUNET_assert (fn != NULL); |
838 | slen = strlen (fn) + 1; | 838 | slen = strlen (fn) + 1; |
839 | if (slen >= | 839 | if (slen >= |
840 | GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage)) | 840 | GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage)) |
841 | { | 841 | { |
842 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 842 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
843 | _ | 843 | _ |
@@ -1226,7 +1226,7 @@ fip_signal_start (void *cls, | |||
1226 | { | 1226 | { |
1227 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); | 1227 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); |
1228 | pc->reserve_entries += kc; | 1228 | pc->reserve_entries += kc; |
1229 | pc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc; | 1229 | pc->reserve_space += GNUNET_MAX_MESSAGE_SIZE * kc; |
1230 | } | 1230 | } |
1231 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; | 1231 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; |
1232 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); | 1232 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 01e65ed57..8c6f5edcf 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -1121,7 +1121,7 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1121 | if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) | 1121 | if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) |
1122 | options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY; | 1122 | options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY; |
1123 | 1123 | ||
1124 | fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode); | 1124 | fit = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode); |
1125 | todo = GNUNET_MIN (fit, | 1125 | todo = GNUNET_MIN (fit, |
1126 | left); | 1126 | left); |
1127 | env = GNUNET_MQ_msg_extra (sm, | 1127 | env = GNUNET_MQ_msg_extra (sm, |
diff --git a/src/fs/gnunet-service-fs_cadet_server.c b/src/fs/gnunet-service-fs_cadet_server.c index 8567e63a2..b1a098175 100644 --- a/src/fs/gnunet-service-fs_cadet_server.c +++ b/src/fs/gnunet-service-fs_cadet_server.c | |||
@@ -289,7 +289,7 @@ handle_datastore_reply (void *cls, | |||
289 | } | 289 | } |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | if (msize > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 292 | if (msize > GNUNET_MAX_MESSAGE_SIZE) |
293 | { | 293 | { |
294 | GNUNET_break (0); | 294 | GNUNET_break (0); |
295 | continue_writing (sc); | 295 | continue_writing (sc); |
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 3f7783ded..817aed257 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -859,7 +859,7 @@ handle_p2p_reply (void *cls, | |||
859 | size_t msize; | 859 | size_t msize; |
860 | 860 | ||
861 | GNUNET_assert (data_len + sizeof (struct PutMessage) < | 861 | GNUNET_assert (data_len + sizeof (struct PutMessage) < |
862 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | 862 | GNUNET_MAX_MESSAGE_SIZE); |
863 | GNUNET_assert (peerreq->pr == pr); | 863 | GNUNET_assert (peerreq->pr == pr); |
864 | prd = GSF_pending_request_get_data_ (pr); | 864 | prd = GSF_pending_request_get_data_ (pr); |
865 | if (NULL == data) | 865 | if (NULL == data) |
@@ -883,7 +883,7 @@ handle_p2p_reply (void *cls, | |||
883 | gettext_noop ("# replies received for other peers"), | 883 | gettext_noop ("# replies received for other peers"), |
884 | 1, GNUNET_NO); | 884 | 1, GNUNET_NO); |
885 | msize = sizeof (struct PutMessage) + data_len; | 885 | msize = sizeof (struct PutMessage) + data_len; |
886 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 886 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) |
887 | { | 887 | { |
888 | GNUNET_break (0); | 888 | GNUNET_break (0); |
889 | return; | 889 | return; |
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 3ce68f487..ce6bcec41 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -438,7 +438,7 @@ GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq) | |||
438 | fn = pos->filename; | 438 | fn = pos->filename; |
439 | slen = strlen (fn) + 1; | 439 | slen = strlen (fn) + 1; |
440 | if (slen + sizeof (struct IndexInfoMessage) >= | 440 | if (slen + sizeof (struct IndexInfoMessage) >= |
441 | GNUNET_SERVER_MAX_MESSAGE_SIZE) | 441 | GNUNET_MAX_MESSAGE_SIZE) |
442 | { | 442 | { |
443 | GNUNET_break (0); | 443 | GNUNET_break (0); |
444 | break; | 444 | break; |
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 15a59a4bc..26293f4df 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -391,7 +391,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
391 | "Trying to lookup `%s' in GNS\n", | 391 | "Trying to lookup `%s' in GNS\n", |
392 | name); | 392 | name); |
393 | nlen = strlen (name) + 1; | 393 | nlen = strlen (name) + 1; |
394 | if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*lr)) | 394 | if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*lr)) |
395 | { | 395 | { |
396 | GNUNET_break (0); | 396 | GNUNET_break (0); |
397 | return NULL; | 397 | return NULL; |
diff --git a/src/hello/hello.c b/src/hello/hello.c index f9b21aa4f..27580275f 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -206,7 +206,7 @@ GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | |||
206 | void *addrgen_cls, | 206 | void *addrgen_cls, |
207 | int friend_only) | 207 | int friend_only) |
208 | { | 208 | { |
209 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - 256 - | 209 | char buffer[GNUNET_MAX_MESSAGE_SIZE - 1 - 256 - |
210 | sizeof (struct GNUNET_HELLO_Message)]; | 210 | sizeof (struct GNUNET_HELLO_Message)]; |
211 | size_t max; | 211 | size_t max; |
212 | size_t used; | 212 | size_t used; |
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index a973fcc28..207cc4a81 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -350,7 +350,7 @@ callback_download (void *ptr, | |||
350 | size_t nmemb, | 350 | size_t nmemb, |
351 | void *ctx) | 351 | void *ctx) |
352 | { | 352 | { |
353 | static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 353 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; |
354 | const char *cbuf = ptr; | 354 | const char *cbuf = ptr; |
355 | const struct GNUNET_MessageHeader *msg; | 355 | const struct GNUNET_MessageHeader *msg; |
356 | struct HelloOffer *ho; | 356 | struct HelloOffer *ho; |
@@ -373,7 +373,7 @@ callback_download (void *ptr, | |||
373 | left = total; | 373 | left = total; |
374 | while ((left > 0) || (download_pos > 0)) | 374 | while ((left > 0) || (download_pos > 0)) |
375 | { | 375 | { |
376 | cpy = GNUNET_MIN (left, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - download_pos); | 376 | cpy = GNUNET_MIN (left, GNUNET_MAX_MESSAGE_SIZE - 1 - download_pos); |
377 | GNUNET_memcpy (&download_buffer[download_pos], cbuf, cpy); | 377 | GNUNET_memcpy (&download_buffer[download_pos], cbuf, cpy); |
378 | cbuf += cpy; | 378 | cbuf += cpy; |
379 | download_pos += cpy; | 379 | download_pos += cpy; |
@@ -1042,7 +1042,7 @@ download_hostlist () | |||
1042 | #if 0 | 1042 | #if 0 |
1043 | CURL_EASY_SETOPT (curl, CURLOPT_VERBOSE, 1); | 1043 | CURL_EASY_SETOPT (curl, CURLOPT_VERBOSE, 1); |
1044 | #endif | 1044 | #endif |
1045 | CURL_EASY_SETOPT (curl, CURLOPT_BUFFERSIZE, GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1045 | CURL_EASY_SETOPT (curl, CURLOPT_BUFFERSIZE, GNUNET_MAX_MESSAGE_SIZE); |
1046 | if (0 == strncmp (current_url, "http", 4)) | 1046 | if (0 == strncmp (current_url, "http", 4)) |
1047 | CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet"); | 1047 | CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet"); |
1048 | CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L); | 1048 | CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L); |
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index 48c1a5622..3df6f1ef8 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c | |||
@@ -489,7 +489,7 @@ connect_handler (void *cls, | |||
489 | return NULL; | 489 | return NULL; |
490 | size = strlen (hostlist_uri) + 1; | 490 | size = strlen (hostlist_uri) + 1; |
491 | if (size + sizeof (struct GNUNET_MessageHeader) >= | 491 | if (size + sizeof (struct GNUNET_MessageHeader) >= |
492 | GNUNET_SERVER_MAX_MESSAGE_SIZE) | 492 | GNUNET_MAX_MESSAGE_SIZE) |
493 | { | 493 | { |
494 | GNUNET_break (0); | 494 | GNUNET_break (0); |
495 | return NULL; | 495 | return NULL; |
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 32c3cb703..845d1f753 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c | |||
@@ -440,7 +440,7 @@ GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id | |||
440 | size_t slen; | 440 | size_t slen; |
441 | 441 | ||
442 | slen = strlen (scopes) + 1; | 442 | slen = strlen (scopes) + 1; |
443 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage)) | 443 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage)) |
444 | { | 444 | { |
445 | GNUNET_break (0); | 445 | GNUNET_break (0); |
446 | return NULL; | 446 | return NULL; |
@@ -493,7 +493,7 @@ GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
493 | ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); | 493 | ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); |
494 | 494 | ||
495 | slen = strlen (ticket_str) + 1; | 495 | slen = strlen (ticket_str) + 1; |
496 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage)) | 496 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage)) |
497 | { | 497 | { |
498 | GNUNET_free (ticket_str); | 498 | GNUNET_free (ticket_str); |
499 | GNUNET_break (0); | 499 | GNUNET_break (0); |
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 905b3fd8b..1601ae2fd 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -671,7 +671,7 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, | |||
671 | if (NULL == h->mq) | 671 | if (NULL == h->mq) |
672 | return NULL; | 672 | return NULL; |
673 | slen = strlen (service_name) + 1; | 673 | slen = strlen (service_name) + 1; |
674 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) | 674 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) |
675 | { | 675 | { |
676 | GNUNET_break (0); | 676 | GNUNET_break (0); |
677 | return NULL; | 677 | return NULL; |
@@ -722,7 +722,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
722 | if (NULL == h->mq) | 722 | if (NULL == h->mq) |
723 | return NULL; | 723 | return NULL; |
724 | slen = strlen (service_name) + 1; | 724 | slen = strlen (service_name) + 1; |
725 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) | 725 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) |
726 | { | 726 | { |
727 | GNUNET_break (0); | 727 | GNUNET_break (0); |
728 | return NULL; | 728 | return NULL; |
@@ -773,7 +773,7 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | |||
773 | if (NULL == h->mq) | 773 | if (NULL == h->mq) |
774 | return NULL; | 774 | return NULL; |
775 | slen = strlen (name) + 1; | 775 | slen = strlen (name) + 1; |
776 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage)) | 776 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage)) |
777 | { | 777 | { |
778 | GNUNET_break (0); | 778 | GNUNET_break (0); |
779 | return NULL; | 779 | return NULL; |
@@ -830,9 +830,9 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, | |||
830 | return NULL; | 830 | return NULL; |
831 | slen_old = strlen (old_name) + 1; | 831 | slen_old = strlen (old_name) + 1; |
832 | slen_new = strlen (new_name) + 1; | 832 | slen_new = strlen (new_name) + 1; |
833 | if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 833 | if ( (slen_old >= GNUNET_MAX_MESSAGE_SIZE) || |
834 | (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 834 | (slen_new >= GNUNET_MAX_MESSAGE_SIZE) || |
835 | (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)) ) | 835 | (slen_old + slen_new >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)) ) |
836 | { | 836 | { |
837 | GNUNET_break (0); | 837 | GNUNET_break (0); |
838 | return NULL; | 838 | return NULL; |
@@ -885,7 +885,7 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, | |||
885 | if (NULL == h->mq) | 885 | if (NULL == h->mq) |
886 | return NULL; | 886 | return NULL; |
887 | slen = strlen (name) + 1; | 887 | slen = strlen (name) + 1; |
888 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage)) | 888 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage)) |
889 | { | 889 | { |
890 | GNUNET_break (0); | 890 | GNUNET_break (0); |
891 | return NULL; | 891 | return NULL; |
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 178ddaaac..967d50dea 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -133,7 +133,7 @@ struct GNUNET_BANDWIDTH_Tracker | |||
133 | /** | 133 | /** |
134 | * Maximum number of seconds over which bandwidth may "accumulate". | 134 | * Maximum number of seconds over which bandwidth may "accumulate". |
135 | * Note that additionally, we also always allow at least | 135 | * Note that additionally, we also always allow at least |
136 | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. | 136 | * #GNUNET_MAX_MESSAGE_SIZE to accumulate. |
137 | */ | 137 | */ |
138 | uint32_t max_carry_s__; | 138 | uint32_t max_carry_s__; |
139 | }; | 139 | }; |
@@ -214,10 +214,10 @@ GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
214 | /** | 214 | /** |
215 | * Initialize bandwidth tracker. Note that in addition to the | 215 | * Initialize bandwidth tracker. Note that in addition to the |
216 | * 'max_carry_s' limit, we also always allow at least | 216 | * 'max_carry_s' limit, we also always allow at least |
217 | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | 217 | * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the |
218 | * bytes-per-second limit is so small that within 'max_carry_s' not | 218 | * bytes-per-second limit is so small that within 'max_carry_s' not |
219 | * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | 219 | * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is |
220 | * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | 220 | * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in |
221 | * bytes). | 221 | * bytes). |
222 | * | 222 | * |
223 | * @param av tracker to initialize | 223 | * @param av tracker to initialize |
@@ -238,10 +238,10 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | |||
238 | /** | 238 | /** |
239 | * Initialize bandwidth tracker. Note that in addition to the | 239 | * Initialize bandwidth tracker. Note that in addition to the |
240 | * 'max_carry_s' limit, we also always allow at least | 240 | * 'max_carry_s' limit, we also always allow at least |
241 | * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | 241 | * GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the |
242 | * bytes-per-second limit is so small that within 'max_carry_s' not | 242 | * bytes-per-second limit is so small that within 'max_carry_s' not |
243 | * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | 243 | * even GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is |
244 | * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | 244 | * ignored and replaced by GNUNET_MAX_MESSAGE_SIZE (which is in |
245 | * bytes). | 245 | * bytes). |
246 | * | 246 | * |
247 | * @param av tracker to initialize | 247 | * @param av tracker to initialize |
diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h index 1d0232cea..1c48298a0 100644 --- a/src/include/gnunet_constants.h +++ b/src/include/gnunet_constants.h | |||
@@ -40,6 +40,8 @@ extern "C" | |||
40 | #endif | 40 | #endif |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | |||
44 | |||
43 | /** | 45 | /** |
44 | * Bandwidth (in/out) to assume initially (before either peer has | 46 | * Bandwidth (in/out) to assume initially (before either peer has |
45 | * communicated any particular preference). Should be rather low; set | 47 | * communicated any particular preference). Should be rather low; set |
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index c506fc6fa..aacafe956 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009-2013, 2016 GNUnet e.V. | 3 | Copyright (C) 2009-2013, 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -46,27 +46,6 @@ extern "C" | |||
46 | #include "gnunet_configuration_lib.h" | 46 | #include "gnunet_configuration_lib.h" |
47 | #include "gnunet_mq_lib.h" | 47 | #include "gnunet_mq_lib.h" |
48 | 48 | ||
49 | /** | ||
50 | * Largest supported message (to be precise, one byte more | ||
51 | * than the largest possible message, so tests involving | ||
52 | * this value should check for messages being smaller than | ||
53 | * this value). NOTE: legacy name. | ||
54 | */ | ||
55 | #define GNUNET_SERVER_MAX_MESSAGE_SIZE 65536 | ||
56 | |||
57 | /** | ||
58 | * Smallest supported message. NOTE: legacy name. | ||
59 | */ | ||
60 | #define GNUNET_SERVER_MIN_BUFFER_SIZE sizeof (struct GNUNET_MessageHeader) | ||
61 | |||
62 | /** | ||
63 | * Timeout we use on TCP connect before trying another | ||
64 | * result from the DNS resolver. Actual value used | ||
65 | * is this value divided by the number of address families. | ||
66 | * Default is 5s. NOTE: legacy name. | ||
67 | */ | ||
68 | #define GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
69 | |||
70 | 49 | ||
71 | /** | 50 | /** |
72 | * Options for the service (bitmask). | 51 | * Options for the service (bitmask). |
@@ -95,51 +74,6 @@ enum GNUNET_SERVICE_Options | |||
95 | 74 | ||
96 | 75 | ||
97 | 76 | ||
98 | |||
99 | /** | ||
100 | * Opaque handle for a service. | ||
101 | */ | ||
102 | struct GNUNET_SERVICE_Context; | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Run a service startup sequence within an existing | ||
107 | * initialized system. | ||
108 | * | ||
109 | * @param service_name our service name | ||
110 | * @param cfg configuration to use | ||
111 | * @param options service options | ||
112 | * @return NULL on error, service handle | ||
113 | * @deprecated | ||
114 | */ | ||
115 | struct GNUNET_SERVICE_Context * | ||
116 | GNUNET_SERVICE_start (const char *service_name, | ||
117 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
118 | enum GNUNET_SERVICE_Options options); | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Get the NULL-terminated array of listen sockets for this service. | ||
123 | * | ||
124 | * @param ctx service context to query | ||
125 | * @return NULL if there are no listen sockets, otherwise NULL-terminated | ||
126 | * array of listen sockets. | ||
127 | * @deprecated | ||
128 | */ | ||
129 | struct GNUNET_NETWORK_Handle *const * | ||
130 | GNUNET_SERVICE_get_listen_sockets (struct GNUNET_SERVICE_Context *ctx); | ||
131 | |||
132 | |||
133 | /** | ||
134 | * Stop a service that was started with #GNUNET_SERVICE_start. | ||
135 | * | ||
136 | * @param sctx the service context returned from the start function | ||
137 | * @deprecated | ||
138 | */ | ||
139 | void | ||
140 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx); | ||
141 | |||
142 | |||
143 | /* **************** NEW SERVICE API ********************** */ | 77 | /* **************** NEW SERVICE API ********************** */ |
144 | 78 | ||
145 | /** | 79 | /** |
@@ -218,7 +152,7 @@ typedef void | |||
218 | * dropped. Additionally, clients can be dropped at any time using | 152 | * dropped. Additionally, clients can be dropped at any time using |
219 | * #GNUNET_SERVICE_client_drop(). | 153 | * #GNUNET_SERVICE_client_drop(). |
220 | * | 154 | * |
221 | * The service must be stopped using #GNUNET_SERVICE_stoP(). | 155 | * The service must be stopped using #GNUNET_SERVICE_stop(). |
222 | * | 156 | * |
223 | * @param service_name name of the service to run | 157 | * @param service_name name of the service to run |
224 | * @param cfg configuration to use | 158 | * @param cfg configuration to use |
@@ -231,7 +165,7 @@ typedef void | |||
231 | * @return NULL on error | 165 | * @return NULL on error |
232 | */ | 166 | */ |
233 | struct GNUNET_SERVICE_Handle * | 167 | struct GNUNET_SERVICE_Handle * |
234 | GNUNET_SERVICE_starT (const char *service_name, | 168 | GNUNET_SERVICE_start (const char *service_name, |
235 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 169 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
236 | GNUNET_SERVICE_ConnectHandler connect_cb, | 170 | GNUNET_SERVICE_ConnectHandler connect_cb, |
237 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | 171 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, |
@@ -240,12 +174,12 @@ GNUNET_SERVICE_starT (const char *service_name, | |||
240 | 174 | ||
241 | 175 | ||
242 | /** | 176 | /** |
243 | * Stops a service that was started with #GNUNET_SERVICE_starT(). | 177 | * Stops a service that was started with #GNUNET_SERVICE_start(). |
244 | * | 178 | * |
245 | * @param srv service to stop | 179 | * @param srv service to stop |
246 | */ | 180 | */ |
247 | void | 181 | void |
248 | GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv); | 182 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); |
249 | 183 | ||
250 | 184 | ||
251 | /** | 185 | /** |
@@ -290,7 +224,7 @@ GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv); | |||
290 | * @return 0 on success, non-zero on error | 224 | * @return 0 on success, non-zero on error |
291 | */ | 225 | */ |
292 | int | 226 | int |
293 | GNUNET_SERVICE_ruN_ (int argc, | 227 | GNUNET_SERVICE_run_ (int argc, |
294 | char *const *argv, | 228 | char *const *argv, |
295 | const char *service_name, | 229 | const char *service_name, |
296 | enum GNUNET_SERVICE_Options options, | 230 | enum GNUNET_SERVICE_Options options, |
@@ -366,7 +300,7 @@ GNUNET_SERVICE_ruN_ (int argc, | |||
366 | struct GNUNET_MQ_MessageHandler mh[] = { \ | 300 | struct GNUNET_MQ_MessageHandler mh[] = { \ |
367 | __VA_ARGS__ \ | 301 | __VA_ARGS__ \ |
368 | }; \ | 302 | }; \ |
369 | return GNUNET_SERVICE_ruN_ (argc, \ | 303 | return GNUNET_SERVICE_run_ (argc, \ |
370 | argv, \ | 304 | argv, \ |
371 | service_name, \ | 305 | service_name, \ |
372 | service_options, \ | 306 | service_options, \ |
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h index b42751d2a..a9bd6c33f 100644 --- a/src/include/gnunet_util_lib.h +++ b/src/include/gnunet_util_lib.h | |||
@@ -38,6 +38,21 @@ extern "C" | |||
38 | #endif | 38 | #endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | |||
42 | /** | ||
43 | * Largest supported message (to be precise, one byte more | ||
44 | * than the largest possible message, so tests involving | ||
45 | * this value should check for messages being smaller than | ||
46 | * this value). | ||
47 | */ | ||
48 | #define GNUNET_MAX_MESSAGE_SIZE 65536 | ||
49 | |||
50 | /** | ||
51 | * Smallest supported message. | ||
52 | */ | ||
53 | #define GNUNET_MIN_MESSAGE_SIZE sizeof (struct GNUNET_MessageHeader) | ||
54 | |||
55 | |||
41 | #include "gnunet_crypto_lib.h" | 56 | #include "gnunet_crypto_lib.h" |
42 | #include "gnunet_bandwidth_lib.h" | 57 | #include "gnunet_bandwidth_lib.h" |
43 | #include "gnunet_bio_lib.h" | 58 | #include "gnunet_bio_lib.h" |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index ae65802b0..6cb4290a0 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1136,7 +1136,7 @@ handle_zone_to_name_it (void *cls, | |||
1136 | name_len = (NULL == name) ? 0 : strlen (name) + 1; | 1136 | name_len = (NULL == name) ? 0 : strlen (name) + 1; |
1137 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 1137 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); |
1138 | msg_size = sizeof (struct ZoneToNameResponseMessage) + name_len + rd_ser_len; | 1138 | msg_size = sizeof (struct ZoneToNameResponseMessage) + name_len + rd_ser_len; |
1139 | if (msg_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1139 | if (msg_size >= GNUNET_MAX_MESSAGE_SIZE) |
1140 | { | 1140 | { |
1141 | GNUNET_break (0); | 1141 | GNUNET_break (0); |
1142 | ztn_ctx->success = GNUNET_SYSERR; | 1142 | ztn_ctx->success = GNUNET_SYSERR; |
diff --git a/src/nat-auto/nat_auto_api.c b/src/nat-auto/nat_auto_api.c index 6660239c3..8a7eaf264 100644 --- a/src/nat-auto/nat_auto_api.c +++ b/src/nat-auto/nat_auto_api.c | |||
@@ -224,7 +224,7 @@ GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
224 | 224 | ||
225 | buf = GNUNET_CONFIGURATION_serialize (cfg, | 225 | buf = GNUNET_CONFIGURATION_serialize (cfg, |
226 | &size); | 226 | &size); |
227 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*req)) | 227 | if (size > GNUNET_MAX_MESSAGE_SIZE - sizeof (*req)) |
228 | { | 228 | { |
229 | GNUNET_break (0); | 229 | GNUNET_break (0); |
230 | GNUNET_free (buf); | 230 | GNUNET_free (buf); |
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c index a0e9f4793..69612584e 100644 --- a/src/nat/nat_api.c +++ b/src/nat/nat_api.c | |||
@@ -403,7 +403,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
403 | len += addrlens[i]; | 403 | len += addrlens[i]; |
404 | str_len = strlen (config_section) + 1; | 404 | str_len = strlen (config_section) + 1; |
405 | len += str_len; | 405 | len += str_len; |
406 | if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) || | 406 | if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof (*rm)) || |
407 | (num_addrs > UINT16_MAX) ) | 407 | (num_addrs > UINT16_MAX) ) |
408 | { | 408 | { |
409 | GNUNET_break (0); | 409 | GNUNET_break (0); |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index bc4a2a10d..731c24bf1 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -283,7 +283,7 @@ read_host_file (const char *fn, | |||
283 | int unlink_garbage, | 283 | int unlink_garbage, |
284 | struct ReadHostFileContext *r) | 284 | struct ReadHostFileContext *r) |
285 | { | 285 | { |
286 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; | 286 | char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; |
287 | ssize_t size_total; | 287 | ssize_t size_total; |
288 | struct GNUNET_TIME_Absolute now; | 288 | struct GNUNET_TIME_Absolute now; |
289 | unsigned int left; | 289 | unsigned int left; |
@@ -919,7 +919,7 @@ add_to_tc (void *cls, | |||
919 | { | 919 | { |
920 | /* Copy public HELLO */ | 920 | /* Copy public HELLO */ |
921 | hs = GNUNET_HELLO_size (pos->hello); | 921 | hs = GNUNET_HELLO_size (pos->hello); |
922 | GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE - | 922 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - |
923 | sizeof (struct InfoMessage)); | 923 | sizeof (struct InfoMessage)); |
924 | env = GNUNET_MQ_msg_extra (im, | 924 | env = GNUNET_MQ_msg_extra (im, |
925 | hs, | 925 | hs, |
@@ -937,7 +937,7 @@ add_to_tc (void *cls, | |||
937 | { | 937 | { |
938 | /* Copy friend only HELLO */ | 938 | /* Copy friend only HELLO */ |
939 | hs = GNUNET_HELLO_size (pos->friend_only_hello); | 939 | hs = GNUNET_HELLO_size (pos->friend_only_hello); |
940 | GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE - | 940 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - |
941 | sizeof (struct InfoMessage)); | 941 | sizeof (struct InfoMessage)); |
942 | env = GNUNET_MQ_msg_extra (im, | 942 | env = GNUNET_MQ_msg_extra (im, |
943 | hs, | 943 | hs, |
@@ -977,7 +977,7 @@ discard_hosts_helper (void *cls, | |||
977 | const char *fn) | 977 | const char *fn) |
978 | { | 978 | { |
979 | struct GNUNET_TIME_Absolute *now = cls; | 979 | struct GNUNET_TIME_Absolute *now = cls; |
980 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; | 980 | char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; |
981 | const struct GNUNET_HELLO_Message *hello; | 981 | const struct GNUNET_HELLO_Message *hello; |
982 | struct GNUNET_HELLO_Message *new_hello; | 982 | struct GNUNET_HELLO_Message *new_hello; |
983 | int read_size; | 983 | int read_size; |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index c6544df3a..c93d8b383 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -1309,7 +1309,7 @@ channel_history_replay (struct GNUNET_PSYC_Channel *chn, | |||
1309 | 1309 | ||
1310 | GNUNET_assert (NULL != method_prefix); | 1310 | GNUNET_assert (NULL != method_prefix); |
1311 | uint16_t method_size = strnlen (method_prefix, | 1311 | uint16_t method_size = strnlen (method_prefix, |
1312 | GNUNET_SERVER_MAX_MESSAGE_SIZE | 1312 | GNUNET_MAX_MESSAGE_SIZE |
1313 | - sizeof (*req)) + 1; | 1313 | - sizeof (*req)) + 1; |
1314 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); | 1314 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); |
1315 | 1315 | ||
@@ -1454,7 +1454,7 @@ channel_state_get (struct GNUNET_PSYC_Channel *chn, | |||
1454 | sr->op_id = GNUNET_OP_add (chn->op, op_recv_state_result, sr, NULL); | 1454 | sr->op_id = GNUNET_OP_add (chn->op, op_recv_state_result, sr, NULL); |
1455 | 1455 | ||
1456 | GNUNET_assert (NULL != name); | 1456 | GNUNET_assert (NULL != name); |
1457 | size_t name_size = strnlen (name, GNUNET_SERVER_MAX_MESSAGE_SIZE | 1457 | size_t name_size = strnlen (name, GNUNET_MAX_MESSAGE_SIZE |
1458 | - sizeof (*req)) + 1; | 1458 | - sizeof (*req)) + 1; |
1459 | struct GNUNET_MQ_Envelope * | 1459 | struct GNUNET_MQ_Envelope * |
1460 | env = GNUNET_MQ_msg_extra (req, name_size, type); | 1460 | env = GNUNET_MQ_msg_extra (req, name_size, type); |
diff --git a/src/psycstore/gnunet-service-psycstore.c b/src/psycstore/gnunet-service-psycstore.c index 10c92a878..1bee8da65 100644 --- a/src/psycstore/gnunet-service-psycstore.c +++ b/src/psycstore/gnunet-service-psycstore.c | |||
@@ -106,7 +106,7 @@ send_result_code (struct GNUNET_SERVICE_Client *client, | |||
106 | 106 | ||
107 | if (NULL != err_msg) | 107 | if (NULL != err_msg) |
108 | err_size = strnlen (err_msg, | 108 | err_size = strnlen (err_msg, |
109 | GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*res) - 1) + 1; | 109 | GNUNET_MAX_MESSAGE_SIZE - sizeof (*res) - 1) + 1; |
110 | struct GNUNET_MQ_Envelope * | 110 | struct GNUNET_MQ_Envelope * |
111 | env = GNUNET_MQ_msg_extra (res, err_size, | 111 | env = GNUNET_MQ_msg_extra (res, err_size, |
112 | GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE); | 112 | GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE); |
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c index 40322662e..d79daa357 100644 --- a/src/psycstore/psycstore_api.c +++ b/src/psycstore/psycstore_api.c | |||
@@ -809,7 +809,7 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, | |||
809 | if (NULL == method_prefix) | 809 | if (NULL == method_prefix) |
810 | method_prefix = ""; | 810 | method_prefix = ""; |
811 | uint16_t method_size = strnlen (method_prefix, | 811 | uint16_t method_size = strnlen (method_prefix, |
812 | GNUNET_SERVER_MAX_MESSAGE_SIZE | 812 | GNUNET_MAX_MESSAGE_SIZE |
813 | - sizeof (*req)) + 1; | 813 | - sizeof (*req)) + 1; |
814 | 814 | ||
815 | struct GNUNET_MQ_Envelope * | 815 | struct GNUNET_MQ_Envelope * |
@@ -875,7 +875,7 @@ GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h, | |||
875 | if (NULL == method_prefix) | 875 | if (NULL == method_prefix) |
876 | method_prefix = ""; | 876 | method_prefix = ""; |
877 | uint16_t method_size = strnlen (method_prefix, | 877 | uint16_t method_size = strnlen (method_prefix, |
878 | GNUNET_SERVER_MAX_MESSAGE_SIZE | 878 | GNUNET_MAX_MESSAGE_SIZE |
879 | - sizeof (*req)) + 1; | 879 | - sizeof (*req)) + 1; |
880 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); | 880 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); |
881 | 881 | ||
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index e763bf08d..9a40a5264 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c | |||
@@ -220,7 +220,7 @@ handle_search_result (void *cls, | |||
220 | if ( (get_path_length >= 65536) || | 220 | if ( (get_path_length >= 65536) || |
221 | (put_path_length >= 65536) || | 221 | (put_path_length >= 65536) || |
222 | ( (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)) | 222 | ( (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)) |
223 | + sizeof (struct ResultMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 223 | + sizeof (struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) |
224 | { | 224 | { |
225 | GNUNET_break (0); | 225 | GNUNET_break (0); |
226 | return; | 226 | return; |
diff --git a/src/regex/regex_api_announce.c b/src/regex/regex_api_announce.c index 70bf34bc8..8e018f26c 100644 --- a/src/regex/regex_api_announce.c +++ b/src/regex/regex_api_announce.c | |||
@@ -146,7 +146,7 @@ GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
146 | size_t slen; | 146 | size_t slen; |
147 | 147 | ||
148 | slen = strlen (regex) + 1; | 148 | slen = strlen (regex) + 1; |
149 | if (slen + sizeof (struct AnnounceMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 149 | if (slen + sizeof (struct AnnounceMessage) >= GNUNET_MAX_MESSAGE_SIZE) |
150 | { | 150 | { |
151 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 151 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
152 | _("Regex `%s' is too long!\n"), | 152 | _("Regex `%s' is too long!\n"), |
diff --git a/src/regex/regex_api_search.c b/src/regex/regex_api_search.c index b7a015f87..a5480ac7a 100644 --- a/src/regex/regex_api_search.c +++ b/src/regex/regex_api_search.c | |||
@@ -206,7 +206,7 @@ GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
206 | struct GNUNET_REGEX_Search *s; | 206 | struct GNUNET_REGEX_Search *s; |
207 | size_t slen = strlen (string) + 1; | 207 | size_t slen = strlen (string) + 1; |
208 | 208 | ||
209 | if (slen + sizeof (struct RegexSearchMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 209 | if (slen + sizeof (struct RegexSearchMessage) >= GNUNET_MAX_MESSAGE_SIZE) |
210 | { | 210 | { |
211 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 211 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
212 | _("Search string `%s' is too long!\n"), | 212 | _("Search string `%s' is too long!\n"), |
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 4a2f96123..0a4543b30 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1026,7 +1026,7 @@ client_respond (void *cls, | |||
1026 | size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) + | 1026 | size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) + |
1027 | num_peers * sizeof (struct GNUNET_PeerIdentity); | 1027 | num_peers * sizeof (struct GNUNET_PeerIdentity); |
1028 | 1028 | ||
1029 | GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= size_needed); | 1029 | GNUNET_assert (GNUNET_MAX_MESSAGE_SIZE >= size_needed); |
1030 | 1030 | ||
1031 | ev = GNUNET_MQ_msg_extra (out_msg, | 1031 | ev = GNUNET_MQ_msg_extra (out_msg, |
1032 | num_peers * sizeof (struct GNUNET_PeerIdentity), | 1032 | num_peers * sizeof (struct GNUNET_PeerIdentity), |
@@ -1067,7 +1067,7 @@ handle_client_request (void *cls, | |||
1067 | size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) + | 1067 | size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) + |
1068 | num_peers * sizeof (struct GNUNET_PeerIdentity); | 1068 | num_peers * sizeof (struct GNUNET_PeerIdentity); |
1069 | 1069 | ||
1070 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) | 1070 | if (GNUNET_MAX_MESSAGE_SIZE < size_needed) |
1071 | { | 1071 | { |
1072 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1072 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1073 | "Message received from client has size larger than expected\n"); | 1073 | "Message received from client has size larger than expected\n"); |
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c index 504f28b92..ccd480086 100644 --- a/src/rps/rps_api.c +++ b/src/rps/rps_api.c | |||
@@ -389,12 +389,12 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, | |||
389 | n * sizeof (struct GNUNET_PeerIdentity); | 389 | n * sizeof (struct GNUNET_PeerIdentity); |
390 | /* The number of peers that fits in one message together with | 390 | /* The number of peers that fits in one message together with |
391 | * the respective header */ | 391 | * the respective header */ |
392 | num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - | 392 | num_peers_max = (GNUNET_MAX_MESSAGE_SIZE - |
393 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / | 393 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / |
394 | sizeof (struct GNUNET_PeerIdentity); | 394 | sizeof (struct GNUNET_PeerIdentity); |
395 | tmp_peer_pointer = ids; | 395 | tmp_peer_pointer = ids; |
396 | 396 | ||
397 | while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) | 397 | while (GNUNET_MAX_MESSAGE_SIZE < size_needed) |
398 | { | 398 | { |
399 | ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity), | 399 | ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity), |
400 | GNUNET_MESSAGE_TYPE_RPS_CS_SEED); | 400 | GNUNET_MESSAGE_TYPE_RPS_CS_SEED); |
@@ -463,12 +463,12 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | |||
463 | num_peers * sizeof (struct GNUNET_PeerIdentity); | 463 | num_peers * sizeof (struct GNUNET_PeerIdentity); |
464 | /* The number of peers that fit in one message together with | 464 | /* The number of peers that fit in one message together with |
465 | * the respective header */ | 465 | * the respective header */ |
466 | num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - | 466 | num_peers_max = (GNUNET_MAX_MESSAGE_SIZE - |
467 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / | 467 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / |
468 | sizeof (struct GNUNET_PeerIdentity); | 468 | sizeof (struct GNUNET_PeerIdentity); |
469 | tmp_peer_pointer = peer_ids; | 469 | tmp_peer_pointer = peer_ids; |
470 | 470 | ||
471 | while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) | 471 | while (GNUNET_MAX_MESSAGE_SIZE < size_needed) |
472 | { | 472 | { |
473 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 473 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
474 | "Too many peers to send at once, sending %" PRIu32 " (all we can so far)\n", | 474 | "Too many peers to send at once, sending %" PRIu32 " (all we can so far)\n", |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 1ce174454..acd3a165d 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -546,7 +546,7 @@ seed_peers_big (void *cls) | |||
546 | unsigned int i; | 546 | unsigned int i; |
547 | 547 | ||
548 | seed_msg_size = 8; /* sizeof (struct GNUNET_RPS_CS_SeedMessage) */ | 548 | seed_msg_size = 8; /* sizeof (struct GNUNET_RPS_CS_SeedMessage) */ |
549 | num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - seed_msg_size) / | 549 | num_peers_max = (GNUNET_MAX_MESSAGE_SIZE - seed_msg_size) / |
550 | sizeof (struct GNUNET_PeerIdentity); | 550 | sizeof (struct GNUNET_PeerIdentity); |
551 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 551 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
552 | "Peers that fit in one seed msg; %u\n", | 552 | "Peers that fit in one seed msg; %u\n", |
@@ -980,7 +980,7 @@ seed_cb (struct RPSPeer *rps_peer) | |||
980 | static void | 980 | static void |
981 | seed_big_cb (struct RPSPeer *rps_peer) | 981 | seed_big_cb (struct RPSPeer *rps_peer) |
982 | { | 982 | { |
983 | // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers | 983 | // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers |
984 | GNUNET_SCHEDULER_add_delayed ( | 984 | GNUNET_SCHEDULER_add_delayed ( |
985 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 985 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
986 | seed_peers_big, rps_peer); | 986 | seed_peers_big, rps_peer); |
@@ -1457,7 +1457,7 @@ main (int argc, char *argv[]) | |||
1457 | 1457 | ||
1458 | else if (strstr (argv[0], "_seed_big") != NULL) | 1458 | else if (strstr (argv[0], "_seed_big") != NULL) |
1459 | { | 1459 | { |
1460 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n"); | 1460 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_MAX_MESSAGE_SIZE)\n"); |
1461 | num_peers = 1; | 1461 | num_peers = 1; |
1462 | cur_test_run.name = "test-rps-seed-big"; | 1462 | cur_test_run.name = "test-rps-seed-big"; |
1463 | cur_test_run.main_test = seed_big_cb; | 1463 | cur_test_run.main_test = seed_big_cb; |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index df9f8d196..05c122e74 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -268,7 +268,7 @@ GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handl | |||
268 | GNUNET_free (h); | 268 | GNUNET_free (h); |
269 | return NULL; | 269 | return NULL; |
270 | } | 270 | } |
271 | possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobComputationMessage)) | 271 | possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobComputationMessage)) |
272 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); | 272 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); |
273 | todo = GNUNET_MIN (possible, | 273 | todo = GNUNET_MIN (possible, |
274 | element_count); | 274 | element_count); |
@@ -285,7 +285,7 @@ GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handl | |||
285 | element_count_transfered = todo; | 285 | element_count_transfered = todo; |
286 | GNUNET_MQ_send (h->mq, | 286 | GNUNET_MQ_send (h->mq, |
287 | env); | 287 | env); |
288 | possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg)) | 288 | possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg)) |
289 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); | 289 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); |
290 | while (element_count_transfered < element_count) | 290 | while (element_count_transfered < element_count) |
291 | { | 291 | { |
@@ -426,7 +426,7 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle | |||
426 | h->cfg = cfg; | 426 | h->cfg = cfg; |
427 | h->key = *session_key; | 427 | h->key = *session_key; |
428 | 428 | ||
429 | possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct AliceComputationMessage)) | 429 | possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (struct AliceComputationMessage)) |
430 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); | 430 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); |
431 | todo = GNUNET_MIN (possible, | 431 | todo = GNUNET_MIN (possible, |
432 | element_count); | 432 | element_count); |
@@ -445,7 +445,7 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle | |||
445 | GNUNET_MQ_send (h->mq, | 445 | GNUNET_MQ_send (h->mq, |
446 | env); | 446 | env); |
447 | element_count_transfered = todo; | 447 | element_count_transfered = todo; |
448 | possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg)) | 448 | possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg)) |
449 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); | 449 | / sizeof (struct GNUNET_SCALARPRODUCT_Element); |
450 | while (element_count_transfered < element_count) | 450 | while (element_count_transfered < element_count) |
451 | { | 451 | { |
diff --git a/src/social/social_api.c b/src/social/social_api.c index a7fe0916f..af1d6e57e 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -2110,7 +2110,7 @@ GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc, | |||
2110 | GNUNET_assert (NULL != method_prefix); | 2110 | GNUNET_assert (NULL != method_prefix); |
2111 | struct MsgProcRequest *mpreq; | 2111 | struct MsgProcRequest *mpreq; |
2112 | uint16_t method_size = strnlen (method_prefix, | 2112 | uint16_t method_size = strnlen (method_prefix, |
2113 | GNUNET_SERVER_MAX_MESSAGE_SIZE | 2113 | GNUNET_MAX_MESSAGE_SIZE |
2114 | - sizeof (*mpreq)) + 1; | 2114 | - sizeof (*mpreq)) + 1; |
2115 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); | 2115 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); |
2116 | 2116 | ||
@@ -2159,7 +2159,7 @@ place_history_replay (struct GNUNET_SOCIAL_Place *plc, | |||
2159 | 2159 | ||
2160 | GNUNET_assert (NULL != method_prefix); | 2160 | GNUNET_assert (NULL != method_prefix); |
2161 | uint16_t method_size = strnlen (method_prefix, | 2161 | uint16_t method_size = strnlen (method_prefix, |
2162 | GNUNET_SERVER_MAX_MESSAGE_SIZE | 2162 | GNUNET_MAX_MESSAGE_SIZE |
2163 | - sizeof (*req)) + 1; | 2163 | - sizeof (*req)) + 1; |
2164 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); | 2164 | GNUNET_assert ('\0' == method_prefix[method_size - 1]); |
2165 | 2165 | ||
@@ -2285,7 +2285,7 @@ place_state_get (struct GNUNET_SOCIAL_Place *plc, | |||
2285 | look->op_id = GNUNET_OP_add (plc->op, &op_recv_state_result, look, NULL); | 2285 | look->op_id = GNUNET_OP_add (plc->op, &op_recv_state_result, look, NULL); |
2286 | 2286 | ||
2287 | GNUNET_assert (NULL != name); | 2287 | GNUNET_assert (NULL != name); |
2288 | size_t name_size = strnlen (name, GNUNET_SERVER_MAX_MESSAGE_SIZE | 2288 | size_t name_size = strnlen (name, GNUNET_MAX_MESSAGE_SIZE |
2289 | - sizeof (*req)) + 1; | 2289 | - sizeof (*req)) + 1; |
2290 | struct GNUNET_MQ_Envelope * | 2290 | struct GNUNET_MQ_Envelope * |
2291 | env = GNUNET_MQ_msg_extra (req, name_size, type); | 2291 | env = GNUNET_MQ_msg_extra (req, name_size, type); |
@@ -2426,7 +2426,7 @@ GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app, | |||
2426 | size_t relay_size = relay_count * sizeof (*relays); | 2426 | size_t relay_size = relay_count * sizeof (*relays); |
2427 | size_t payload_size = name_size + password_size + relay_size; | 2427 | size_t payload_size = name_size + password_size + relay_size; |
2428 | 2428 | ||
2429 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size) | 2429 | if (GNUNET_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size) |
2430 | return GNUNET_SYSERR; | 2430 | return GNUNET_SYSERR; |
2431 | 2431 | ||
2432 | struct GNUNET_MQ_Envelope * | 2432 | struct GNUNET_MQ_Envelope * |
@@ -2506,7 +2506,7 @@ GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app, | |||
2506 | struct ZoneAddNymRequest *nreq; | 2506 | struct ZoneAddNymRequest *nreq; |
2507 | 2507 | ||
2508 | size_t name_size = strlen (name) + 1; | 2508 | size_t name_size = strlen (name) + 1; |
2509 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*nreq) + name_size) | 2509 | if (GNUNET_MAX_MESSAGE_SIZE < sizeof (*nreq) + name_size) |
2510 | return GNUNET_SYSERR; | 2510 | return GNUNET_SYSERR; |
2511 | 2511 | ||
2512 | struct GNUNET_MQ_Envelope * | 2512 | struct GNUNET_MQ_Envelope * |
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 85c84b89d..0cb136b99 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -359,7 +359,7 @@ transmit (struct ClientEntry *ce, | |||
359 | 359 | ||
360 | size = strlen (e->subsystem->service) + 1 + | 360 | size = strlen (e->subsystem->service) + 1 + |
361 | strlen (e->name) + 1; | 361 | strlen (e->name) + 1; |
362 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 362 | GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE); |
363 | env = GNUNET_MQ_msg_extra (m, | 363 | env = GNUNET_MQ_msg_extra (m, |
364 | size, | 364 | size, |
365 | GNUNET_MESSAGE_TYPE_STATISTICS_VALUE); | 365 | GNUNET_MESSAGE_TYPE_STATISTICS_VALUE); |
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index ad4453b2a..9d04e854f 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -349,7 +349,7 @@ schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, | |||
349 | slen = strlen (watch->subsystem) + 1; | 349 | slen = strlen (watch->subsystem) + 1; |
350 | nlen = strlen (watch->name) + 1; | 350 | nlen = strlen (watch->name) + 1; |
351 | nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen; | 351 | nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen; |
352 | if (nsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 352 | if (nsize >= GNUNET_MAX_MESSAGE_SIZE) |
353 | { | 353 | { |
354 | GNUNET_break (0); | 354 | GNUNET_break (0); |
355 | return; | 355 | return; |
@@ -1098,7 +1098,7 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, | |||
1098 | slen1 = strlen (subsystem) + 1; | 1098 | slen1 = strlen (subsystem) + 1; |
1099 | slen2 = strlen (name) + 1; | 1099 | slen2 = strlen (name) + 1; |
1100 | GNUNET_assert (slen1 + slen2 + sizeof (struct GNUNET_MessageHeader) < | 1100 | GNUNET_assert (slen1 + slen2 + sizeof (struct GNUNET_MessageHeader) < |
1101 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1101 | GNUNET_MAX_MESSAGE_SIZE); |
1102 | ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle); | 1102 | ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle); |
1103 | ai->sh = handle; | 1103 | ai->sh = handle; |
1104 | ai->subsystem = GNUNET_strdup (subsystem); | 1104 | ai->subsystem = GNUNET_strdup (subsystem); |
@@ -1246,7 +1246,7 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, | |||
1246 | slen = strlen (h->subsystem) + 1; | 1246 | slen = strlen (h->subsystem) + 1; |
1247 | nlen = strlen (name) + 1; | 1247 | nlen = strlen (name) + 1; |
1248 | nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen; | 1248 | nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen; |
1249 | if (nsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1249 | if (nsize >= GNUNET_MAX_MESSAGE_SIZE) |
1250 | { | 1250 | { |
1251 | GNUNET_break (0); | 1251 | GNUNET_break (0); |
1252 | return; | 1252 | return; |
diff --git a/src/testbed-logger/testbed_logger_api.c b/src/testbed-logger/testbed_logger_api.c index 25494aed0..7aa4ade35 100644 --- a/src/testbed-logger/testbed_logger_api.c +++ b/src/testbed-logger/testbed_logger_api.c | |||
@@ -39,7 +39,7 @@ | |||
39 | /** | 39 | /** |
40 | * The size of the buffer we fill before sending out the message | 40 | * The size of the buffer we fill before sending out the message |
41 | */ | 41 | */ |
42 | #define BUFFER_SIZE (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader)) | 42 | #define BUFFER_SIZE (GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader)) |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Connection handle for the logger service | 45 | * Connection handle for the logger service |
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index 6368fb74b..d2a3a98b7 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c | |||
@@ -495,7 +495,7 @@ error: | |||
495 | static void | 495 | static void |
496 | read_task (void *cls) | 496 | read_task (void *cls) |
497 | { | 497 | { |
498 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 498 | char buf[GNUNET_MAX_MESSAGE_SIZE]; |
499 | ssize_t sread; | 499 | ssize_t sread; |
500 | 500 | ||
501 | read_task_id = NULL; | 501 | read_task_id = NULL; |
diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index a201d22bb..681ed6df2 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c | |||
@@ -478,7 +478,7 @@ GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
478 | LOG_DEBUG ("Launching testbed-barrier service\n"); | 478 | LOG_DEBUG ("Launching testbed-barrier service\n"); |
479 | barrier_map = GNUNET_CONTAINER_multihashmap_create (3, | 479 | barrier_map = GNUNET_CONTAINER_multihashmap_create (3, |
480 | GNUNET_YES); | 480 | GNUNET_YES); |
481 | ctx = GNUNET_SERVICE_starT ("testbed-barrier", | 481 | ctx = GNUNET_SERVICE_start ("testbed-barrier", |
482 | cfg, | 482 | cfg, |
483 | &connect_cb, | 483 | &connect_cb, |
484 | &disconnect_cb, | 484 | &disconnect_cb, |
@@ -524,7 +524,7 @@ GST_barriers_destroy () | |||
524 | NULL)); | 524 | NULL)); |
525 | GNUNET_CONTAINER_multihashmap_destroy (barrier_map); | 525 | GNUNET_CONTAINER_multihashmap_destroy (barrier_map); |
526 | GNUNET_assert (NULL != ctx); | 526 | GNUNET_assert (NULL != ctx); |
527 | GNUNET_SERVICE_stoP (ctx); | 527 | GNUNET_SERVICE_stop (ctx); |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 2af62b44a..871e554a9 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -969,7 +969,7 @@ GNUNET_TESTBED_peer_manage_service (void *op_cls, | |||
969 | GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */ | 969 | GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */ |
970 | msize = strlen (service_name) + 1; | 970 | msize = strlen (service_name) + 1; |
971 | msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage); | 971 | msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage); |
972 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE < msize) | 972 | if (GNUNET_MAX_MESSAGE_SIZE < msize) |
973 | return NULL; | 973 | return NULL; |
974 | data = GNUNET_new (struct ManageServiceData); | 974 | data = GNUNET_new (struct ManageServiceData); |
975 | data->cb = cb; | 975 | data->cb = cb; |
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 067ebce23..537ffe059 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -499,7 +499,7 @@ schedule_next_hello (void *cls) | |||
499 | /* find applicable HELLOs */ | 499 | /* find applicable HELLOs */ |
500 | fah.peer = pl; | 500 | fah.peer = pl; |
501 | fah.result = NULL; | 501 | fah.result = NULL; |
502 | fah.max_size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1; | 502 | fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1; |
503 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; | 503 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; |
504 | GNUNET_CONTAINER_multipeermap_iterate (peers, | 504 | GNUNET_CONTAINER_multipeermap_iterate (peers, |
505 | &find_advertisable_hello, | 505 | &find_advertisable_hello, |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 505626b59..4a6d427be 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -599,7 +599,7 @@ transmit_ping_if_allowed (void *cls, | |||
599 | ping.challenge = htonl (ve->challenge); | 599 | ping.challenge = htonl (ve->challenge); |
600 | ping.target = *pid; | 600 | ping.target = *pid; |
601 | 601 | ||
602 | if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 602 | if (tsize >= GNUNET_MAX_MESSAGE_SIZE) |
603 | { | 603 | { |
604 | GNUNET_break (0); | 604 | GNUNET_break (0); |
605 | hsize = 0; | 605 | hsize = 0; |
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index bd4d3072b..9292c42d4 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -520,7 +520,7 @@ run (void *cls, | |||
520 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; | 520 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; |
521 | 521 | ||
522 | ret = 1; | 522 | ret = 1; |
523 | if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= benchmark_size) | 523 | if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size) |
524 | { | 524 | { |
525 | FPRINTF (stderr, | 525 | FPRINTF (stderr, |
526 | "Message size too big!\n"); | 526 | "Message size too big!\n"); |
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index e91149289..e20948c5a 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -1638,7 +1638,7 @@ client_connect_get (struct GNUNET_ATS_Session *s) | |||
1638 | CURLOPT_CONNECTTIMEOUT_MS, | 1638 | CURLOPT_CONNECTTIMEOUT_MS, |
1639 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); | 1639 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); |
1640 | curl_easy_setopt (s->get.easyhandle, CURLOPT_BUFFERSIZE, | 1640 | curl_easy_setopt (s->get.easyhandle, CURLOPT_BUFFERSIZE, |
1641 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1641 | 2 * GNUNET_MAX_MESSAGE_SIZE); |
1642 | #if CURL_TCP_NODELAY | 1642 | #if CURL_TCP_NODELAY |
1643 | curl_easy_setopt (ps->recv_endpoint, | 1643 | curl_easy_setopt (ps->recv_endpoint, |
1644 | CURLOPT_TCP_NODELAY, | 1644 | CURLOPT_TCP_NODELAY, |
@@ -1815,7 +1815,7 @@ client_connect_put (struct GNUNET_ATS_Session *s) | |||
1815 | CURLOPT_CONNECTTIMEOUT_MS, | 1815 | CURLOPT_CONNECTTIMEOUT_MS, |
1816 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); | 1816 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); |
1817 | curl_easy_setopt (s->put.easyhandle, CURLOPT_BUFFERSIZE, | 1817 | curl_easy_setopt (s->put.easyhandle, CURLOPT_BUFFERSIZE, |
1818 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1818 | 2 * GNUNET_MAX_MESSAGE_SIZE); |
1819 | #if CURL_TCP_NODELAY | 1819 | #if CURL_TCP_NODELAY |
1820 | curl_easy_setopt (s->put.easyhandle, CURLOPT_TCP_NODELAY, 1); | 1820 | curl_easy_setopt (s->put.easyhandle, CURLOPT_TCP_NODELAY, 1); |
1821 | #endif | 1821 | #endif |
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 2d6f40d58..ff2d68602 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -2224,7 +2224,7 @@ run_mhd_start_daemon (struct HTTP_Server_Plugin *plugin, | |||
2224 | timeout, | 2224 | timeout, |
2225 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 2225 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
2226 | (size_t) (2 * | 2226 | (size_t) (2 * |
2227 | GNUNET_SERVER_MAX_MESSAGE_SIZE), | 2227 | GNUNET_MAX_MESSAGE_SIZE), |
2228 | MHD_OPTION_NOTIFY_COMPLETED, | 2228 | MHD_OPTION_NOTIFY_COMPLETED, |
2229 | &server_disconnect_cb, plugin, | 2229 | &server_disconnect_cb, plugin, |
2230 | MHD_OPTION_EXTERNAL_LOGGER, | 2230 | MHD_OPTION_EXTERNAL_LOGGER, |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 10ea01cec..a63013caa 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -71,6 +71,21 @@ struct GNUNET_SERVER_TransmitHandle; | |||
71 | */ | 71 | */ |
72 | struct GNUNET_CONNECTION_Handle; | 72 | struct GNUNET_CONNECTION_Handle; |
73 | 73 | ||
74 | /** | ||
75 | * @brief handle for a network service | ||
76 | */ | ||
77 | struct LEGACY_SERVICE_Context; | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Stops a service that was started with #GNUNET_SERVICE_start(). | ||
82 | * | ||
83 | * @param srv service to stop | ||
84 | */ | ||
85 | void | ||
86 | LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv); | ||
87 | |||
88 | |||
74 | 89 | ||
75 | /** | 90 | /** |
76 | * Function called to notify a client about the connection begin ready | 91 | * Function called to notify a client about the connection begin ready |
@@ -269,6 +284,34 @@ struct GNUNET_SERVER_MessageHandler | |||
269 | 284 | ||
270 | }; | 285 | }; |
271 | 286 | ||
287 | |||
288 | /** | ||
289 | * Options for the service (bitmask). | ||
290 | */ | ||
291 | enum LEGACY_SERVICE_Options | ||
292 | { | ||
293 | /** | ||
294 | * Use defaults. Terminates all client connections and the listen | ||
295 | * sockets immediately upon receiving the shutdown signal. | ||
296 | */ | ||
297 | LEGACY_SERVICE_OPTION_NONE = 0, | ||
298 | |||
299 | /** | ||
300 | * Do not trigger server shutdown on signal at all; instead, allow | ||
301 | * for the user to terminate the server explicitly when needed | ||
302 | * by calling #LEGACY_SERVICE_shutdown(). | ||
303 | */ | ||
304 | LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN = 1, | ||
305 | |||
306 | /** | ||
307 | * Trigger a SOFT server shutdown on signals, allowing active | ||
308 | * non-monitor clients to complete their transactions. | ||
309 | */ | ||
310 | LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN = 2 | ||
311 | }; | ||
312 | |||
313 | |||
314 | |||
272 | /** | 315 | /** |
273 | * Ask the server to disconnect from the given client. This is the | 316 | * Ask the server to disconnect from the given client. This is the |
274 | * same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done, | 317 | * same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done, |
@@ -453,7 +496,7 @@ GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client); | |||
453 | * @param cfg configuration to use | 496 | * @param cfg configuration to use |
454 | */ | 497 | */ |
455 | typedef void | 498 | typedef void |
456 | (*GNUNET_SERVICE_Main) (void *cls, | 499 | (*LEGACY_SERVICE_Main) (void *cls, |
457 | struct GNUNET_SERVER_Handle *server, | 500 | struct GNUNET_SERVER_Handle *server, |
458 | const struct GNUNET_CONFIGURATION_Handle *cfg); | 501 | const struct GNUNET_CONFIGURATION_Handle *cfg); |
459 | 502 | ||
@@ -919,7 +962,7 @@ struct Plugin | |||
919 | /** | 962 | /** |
920 | * Handle to the network service. | 963 | * Handle to the network service. |
921 | */ | 964 | */ |
922 | struct GNUNET_SERVICE_Context *service; | 965 | struct LEGACY_SERVICE_Context *service; |
923 | 966 | ||
924 | /** | 967 | /** |
925 | * Handle to the server for this service. | 968 | * Handle to the server for this service. |
@@ -3733,7 +3776,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
3733 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; | 3776 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; |
3734 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 3777 | struct GNUNET_TRANSPORT_PluginFunctions *api; |
3735 | struct Plugin *plugin; | 3778 | struct Plugin *plugin; |
3736 | struct GNUNET_SERVICE_Context *service; | 3779 | struct LEGACY_SERVICE_Context *service; |
3737 | unsigned long long aport; | 3780 | unsigned long long aport; |
3738 | unsigned long long bport; | 3781 | unsigned long long bport; |
3739 | unsigned long long max_connections; | 3782 | unsigned long long max_connections; |
@@ -3788,9 +3831,9 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
3788 | aport = 0; | 3831 | aport = 0; |
3789 | if (0 != bport) | 3832 | if (0 != bport) |
3790 | { | 3833 | { |
3791 | service = GNUNET_SERVICE_start ("transport-tcp", | 3834 | service = LEGACY_SERVICE_start ("transport-tcp", |
3792 | env->cfg, | 3835 | env->cfg, |
3793 | GNUNET_SERVICE_OPTION_NONE); | 3836 | LEGACY_SERVICE_OPTION_NONE); |
3794 | if (NULL == service) | 3837 | if (NULL == service) |
3795 | { | 3838 | { |
3796 | LOG (GNUNET_ERROR_TYPE_WARNING, | 3839 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -3821,7 +3864,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
3821 | { | 3864 | { |
3822 | #ifdef TCP_STEALTH | 3865 | #ifdef TCP_STEALTH |
3823 | plugin->myoptions |= TCP_OPTIONS_TCP_STEALTH; | 3866 | plugin->myoptions |= TCP_OPTIONS_TCP_STEALTH; |
3824 | lsocks = GNUNET_SERVICE_get_listen_sockets (service); | 3867 | lsocks = LEGACY_SERVICE_get_listen_sockets (service); |
3825 | if (NULL != lsocks) | 3868 | if (NULL != lsocks) |
3826 | { | 3869 | { |
3827 | uint32_t len = sizeof (struct WelcomeMessage); | 3870 | uint32_t len = sizeof (struct WelcomeMessage); |
@@ -3914,7 +3957,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
3914 | plugin->service = service; | 3957 | plugin->service = service; |
3915 | if (NULL != service) | 3958 | if (NULL != service) |
3916 | { | 3959 | { |
3917 | plugin->server = GNUNET_SERVICE_get_server (service); | 3960 | plugin->server = LEGACY_SERVICE_get_server (service); |
3918 | } | 3961 | } |
3919 | else | 3962 | else |
3920 | { | 3963 | { |
@@ -3977,7 +4020,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
3977 | GNUNET_NAT_unregister (plugin->nat); | 4020 | GNUNET_NAT_unregister (plugin->nat); |
3978 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessionmap); | 4021 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessionmap); |
3979 | if (NULL != service) | 4022 | if (NULL != service) |
3980 | GNUNET_SERVICE_stop (service); | 4023 | LEGACY_SERVICE_stop (service); |
3981 | GNUNET_free (plugin); | 4024 | GNUNET_free (plugin); |
3982 | GNUNET_free_non_null (api); | 4025 | GNUNET_free_non_null (api); |
3983 | return NULL; | 4026 | return NULL; |
@@ -4030,7 +4073,7 @@ libgnunet_plugin_transport_tcp_done (void *cls) | |||
4030 | } | 4073 | } |
4031 | 4074 | ||
4032 | if (NULL != plugin->service) | 4075 | if (NULL != plugin->service) |
4033 | GNUNET_SERVICE_stop (plugin->service); | 4076 | LEGACY_SERVICE_stop (plugin->service); |
4034 | else | 4077 | else |
4035 | GNUNET_SERVER_destroy (plugin->server); | 4078 | GNUNET_SERVER_destroy (plugin->server); |
4036 | GNUNET_free (plugin->handlers); | 4079 | GNUNET_free (plugin->handlers); |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 3a9013a5a..1ff962544 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2061,7 +2061,7 @@ udp_plugin_send (void *cls, | |||
2061 | if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) && | 2061 | if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) && |
2062 | (NULL == plugin->sockv4) ) | 2062 | (NULL == plugin->sockv4) ) |
2063 | return GNUNET_SYSERR; | 2063 | return GNUNET_SYSERR; |
2064 | if (udpmlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 2064 | if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE) |
2065 | { | 2065 | { |
2066 | GNUNET_break (0); | 2066 | GNUNET_break (0); |
2067 | return GNUNET_SYSERR; | 2067 | return GNUNET_SYSERR; |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 3f5ada10b..b23739d3c 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -744,7 +744,7 @@ send_ack (void *cls, | |||
744 | GNUNET_break (0); | 744 | GNUNET_break (0); |
745 | return; | 745 | return; |
746 | } | 746 | } |
747 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 747 | if (size >= GNUNET_MAX_MESSAGE_SIZE) |
748 | { | 748 | { |
749 | GNUNET_break (0); | 749 | GNUNET_break (0); |
750 | return; | 750 | return; |
diff --git a/src/transport/tcp_connection_legacy.c b/src/transport/tcp_connection_legacy.c index f5253445d..5b219a467 100644 --- a/src/transport/tcp_connection_legacy.c +++ b/src/transport/tcp_connection_legacy.c | |||
@@ -35,6 +35,15 @@ | |||
35 | #include "gnunet_resolver_service.h" | 35 | #include "gnunet_resolver_service.h" |
36 | 36 | ||
37 | 37 | ||
38 | /** | ||
39 | * Timeout we use on TCP connect before trying another | ||
40 | * result from the DNS resolver. Actual value used | ||
41 | * is this value divided by the number of address families. | ||
42 | * Default is 5s. | ||
43 | */ | ||
44 | #define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
45 | |||
46 | |||
38 | 47 | ||
39 | #define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall) | 48 | #define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall) |
40 | 49 | ||
@@ -304,7 +313,7 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket) | |||
304 | struct GNUNET_CONNECTION_Handle *connection; | 313 | struct GNUNET_CONNECTION_Handle *connection; |
305 | 314 | ||
306 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 315 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
307 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 316 | connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE; |
308 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 317 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
309 | connection->sock = osSocket; | 318 | connection->sock = osSocket; |
310 | return connection; | 319 | return connection; |
@@ -451,7 +460,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
451 | return NULL; | 460 | return NULL; |
452 | } | 461 | } |
453 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 462 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
454 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 463 | connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE; |
455 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 464 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
456 | connection->addr = uaddr; | 465 | connection->addr = uaddr; |
457 | connection->addrlen = addrlen; | 466 | connection->addrlen = addrlen; |
@@ -824,7 +833,7 @@ try_connect_using_address (void *cls, | |||
824 | return; | 833 | return; |
825 | } | 834 | } |
826 | GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap); | 835 | GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap); |
827 | delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; | 836 | delay = CONNECT_RETRY_TIMEOUT; |
828 | if (NULL != connection->nth.notify_ready) | 837 | if (NULL != connection->nth.notify_ready) |
829 | delay = GNUNET_TIME_relative_min (delay, | 838 | delay = GNUNET_TIME_relative_min (delay, |
830 | GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout)); | 839 | GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout)); |
@@ -858,14 +867,14 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle | |||
858 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ | 867 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ |
859 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 868 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
860 | connection->cfg = cfg; | 869 | connection->cfg = cfg; |
861 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 870 | connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE; |
862 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 871 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
863 | connection->port = port; | 872 | connection->port = port; |
864 | connection->hostname = GNUNET_strdup (hostname); | 873 | connection->hostname = GNUNET_strdup (hostname); |
865 | connection->dns_active = | 874 | connection->dns_active = |
866 | GNUNET_RESOLVER_ip_get (connection->hostname, | 875 | GNUNET_RESOLVER_ip_get (connection->hostname, |
867 | AF_UNSPEC, | 876 | AF_UNSPEC, |
868 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 877 | CONNECT_RETRY_TIMEOUT, |
869 | &try_connect_using_address, | 878 | &try_connect_using_address, |
870 | connection); | 879 | connection); |
871 | return connection; | 880 | return connection; |
@@ -909,7 +918,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA | |||
909 | #endif | 918 | #endif |
910 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); | 919 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
911 | connection->cfg = cfg; | 920 | connection->cfg = cfg; |
912 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 921 | connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE; |
913 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 922 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
914 | connection->port = 0; | 923 | connection->port = 0; |
915 | connection->hostname = NULL; | 924 | connection->hostname = NULL; |
@@ -1535,7 +1544,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec | |||
1535 | return NULL; | 1544 | return NULL; |
1536 | } | 1545 | } |
1537 | GNUNET_assert (NULL != notify); | 1546 | GNUNET_assert (NULL != notify); |
1538 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1547 | GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE); |
1539 | GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size); | 1548 | GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size); |
1540 | GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size); | 1549 | GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size); |
1541 | GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off); | 1550 | GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off); |
diff --git a/src/transport/tcp_server_legacy.c b/src/transport/tcp_server_legacy.c index c055285b1..6b4daa525 100644 --- a/src/transport/tcp_server_legacy.c +++ b/src/transport/tcp_server_legacy.c | |||
@@ -1045,7 +1045,7 @@ process_mst (struct GNUNET_SERVER_Client *client, | |||
1045 | GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES)); | 1045 | GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES)); |
1046 | client->receive_pending = GNUNET_YES; | 1046 | client->receive_pending = GNUNET_YES; |
1047 | GNUNET_CONNECTION_receive (client->connection, | 1047 | GNUNET_CONNECTION_receive (client->connection, |
1048 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 1048 | GNUNET_MAX_MESSAGE_SIZE - 1, |
1049 | client->idle_timeout, | 1049 | client->idle_timeout, |
1050 | &process_incoming, | 1050 | &process_incoming, |
1051 | client); | 1051 | client); |
@@ -1124,7 +1124,7 @@ process_incoming (void *cls, | |||
1124 | client); | 1124 | client); |
1125 | client->receive_pending = GNUNET_YES; | 1125 | client->receive_pending = GNUNET_YES; |
1126 | GNUNET_CONNECTION_receive (client->connection, | 1126 | GNUNET_CONNECTION_receive (client->connection, |
1127 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 1127 | GNUNET_MAX_MESSAGE_SIZE - 1, |
1128 | GNUNET_TIME_absolute_get_remaining (end), | 1128 | GNUNET_TIME_absolute_get_remaining (end), |
1129 | &process_incoming, | 1129 | &process_incoming, |
1130 | client); | 1130 | client); |
@@ -1200,7 +1200,7 @@ restart_processing (void *cls) | |||
1200 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Server begins to read again from client.\n"); | 1200 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Server begins to read again from client.\n"); |
1201 | client->receive_pending = GNUNET_YES; | 1201 | client->receive_pending = GNUNET_YES; |
1202 | GNUNET_CONNECTION_receive (client->connection, | 1202 | GNUNET_CONNECTION_receive (client->connection, |
1203 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 1203 | GNUNET_MAX_MESSAGE_SIZE - 1, |
1204 | client->idle_timeout, | 1204 | client->idle_timeout, |
1205 | &process_incoming, | 1205 | &process_incoming, |
1206 | client); | 1206 | client); |
@@ -1288,7 +1288,7 @@ GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, | |||
1288 | n->callback (n->callback_cls, client); | 1288 | n->callback (n->callback_cls, client); |
1289 | client->receive_pending = GNUNET_YES; | 1289 | client->receive_pending = GNUNET_YES; |
1290 | GNUNET_CONNECTION_receive (client->connection, | 1290 | GNUNET_CONNECTION_receive (client->connection, |
1291 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 1291 | GNUNET_MAX_MESSAGE_SIZE - 1, |
1292 | client->idle_timeout, | 1292 | client->idle_timeout, |
1293 | &process_incoming, | 1293 | &process_incoming, |
1294 | client); | 1294 | client); |
diff --git a/src/transport/tcp_server_mst_legacy.c b/src/transport/tcp_server_mst_legacy.c index ba42b1837..78e04c1b1 100644 --- a/src/transport/tcp_server_mst_legacy.c +++ b/src/transport/tcp_server_mst_legacy.c | |||
@@ -89,8 +89,8 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb, | |||
89 | struct GNUNET_SERVER_MessageStreamTokenizer *ret; | 89 | struct GNUNET_SERVER_MessageStreamTokenizer *ret; |
90 | 90 | ||
91 | ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer); | 91 | ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer); |
92 | ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE); | 92 | ret->hdr = GNUNET_malloc (GNUNET_MIN_MESSAGE_SIZE); |
93 | ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE; | 93 | ret->curr_buf = GNUNET_MIN_MESSAGE_SIZE; |
94 | ret->cb = cb; | 94 | ret->cb = cb; |
95 | ret->cb_cls = cb_cls; | 95 | ret->cb_cls = cb_cls; |
96 | return ret; | 96 | return ret; |
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c index 050a38acc..7c2d3e55a 100644 --- a/src/transport/tcp_service_legacy.c +++ b/src/transport/tcp_service_legacy.c | |||
@@ -105,7 +105,7 @@ NEXT: | |||
105 | /** | 105 | /** |
106 | * Context for "service_task". | 106 | * Context for "service_task". |
107 | */ | 107 | */ |
108 | struct GNUNET_SERVICE_Context | 108 | struct LEGACY_SERVICE_Context |
109 | { | 109 | { |
110 | /** | 110 | /** |
111 | * Our configuration. | 111 | * Our configuration. |
@@ -131,7 +131,7 @@ struct GNUNET_SERVICE_Context | |||
131 | /** | 131 | /** |
132 | * Main service-specific task to run. | 132 | * Main service-specific task to run. |
133 | */ | 133 | */ |
134 | GNUNET_SERVICE_Main task; | 134 | LEGACY_SERVICE_Main task; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Closure for @e task. | 137 | * Closure for @e task. |
@@ -223,7 +223,7 @@ struct GNUNET_SERVICE_Context | |||
223 | /** | 223 | /** |
224 | * Our options. | 224 | * Our options. |
225 | */ | 225 | */ |
226 | enum GNUNET_SERVICE_Options options; | 226 | enum LEGACY_SERVICE_Options options; |
227 | 227 | ||
228 | }; | 228 | }; |
229 | 229 | ||
@@ -307,7 +307,7 @@ static int | |||
307 | check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, | 307 | check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, |
308 | const struct sockaddr *addr, socklen_t addrlen) | 308 | const struct sockaddr *addr, socklen_t addrlen) |
309 | { | 309 | { |
310 | struct GNUNET_SERVICE_Context *sctx = cls; | 310 | struct LEGACY_SERVICE_Context *sctx = cls; |
311 | const struct sockaddr_in *i4; | 311 | const struct sockaddr_in *i4; |
312 | const struct sockaddr_in6 *i6; | 312 | const struct sockaddr_in6 *i6; |
313 | int ret; | 313 | int ret; |
@@ -359,7 +359,7 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, | |||
359 | * @return name of the file for the process ID | 359 | * @return name of the file for the process ID |
360 | */ | 360 | */ |
361 | static char * | 361 | static char * |
362 | get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) | 362 | get_pid_file_name (struct LEGACY_SERVICE_Context *sctx) |
363 | { | 363 | { |
364 | char *pif; | 364 | char *pif; |
365 | 365 | ||
@@ -382,7 +382,7 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) | |||
382 | */ | 382 | */ |
383 | static int | 383 | static int |
384 | process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | 384 | process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, |
385 | struct GNUNET_SERVICE_Context *sctx, | 385 | struct LEGACY_SERVICE_Context *sctx, |
386 | const char *option) | 386 | const char *option) |
387 | { | 387 | { |
388 | char *opt; | 388 | char *opt; |
@@ -420,7 +420,7 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | |||
420 | */ | 420 | */ |
421 | static int | 421 | static int |
422 | process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, | 422 | process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, |
423 | struct GNUNET_SERVICE_Context *sctx, | 423 | struct LEGACY_SERVICE_Context *sctx, |
424 | const char *option) | 424 | const char *option) |
425 | { | 425 | { |
426 | char *opt; | 426 | char *opt; |
@@ -507,7 +507,7 @@ add_unixpath (struct sockaddr **saddrs, | |||
507 | * set to NULL). | 507 | * set to NULL). |
508 | */ | 508 | */ |
509 | int | 509 | int |
510 | GNUNET_SERVICE_get_server_addresses (const char *service_name, | 510 | LEGACY_SERVICE_get_server_addresses (const char *service_name, |
511 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 511 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
512 | struct sockaddr ***addrs, | 512 | struct sockaddr ***addrs, |
513 | socklen_t ** addr_lens) | 513 | socklen_t ** addr_lens) |
@@ -838,7 +838,7 @@ GNUNET_SERVICE_get_server_addresses (const char *service_name, | |||
838 | * and #GNUNET_SYSERR on error. | 838 | * and #GNUNET_SYSERR on error. |
839 | */ | 839 | */ |
840 | static int | 840 | static int |
841 | receive_sockets_from_parent (struct GNUNET_SERVICE_Context *sctx) | 841 | receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx) |
842 | { | 842 | { |
843 | const char *env_buf; | 843 | const char *env_buf; |
844 | int fail; | 844 | int fail; |
@@ -932,7 +932,7 @@ receive_sockets_from_parent (struct GNUNET_SERVICE_Context *sctx) | |||
932 | * @return #GNUNET_OK if configuration succeeded | 932 | * @return #GNUNET_OK if configuration succeeded |
933 | */ | 933 | */ |
934 | static int | 934 | static int |
935 | setup_service (struct GNUNET_SERVICE_Context *sctx) | 935 | setup_service (struct LEGACY_SERVICE_Context *sctx) |
936 | { | 936 | { |
937 | struct GNUNET_TIME_Relative idleout; | 937 | struct GNUNET_TIME_Relative idleout; |
938 | int tolerant; | 938 | int tolerant; |
@@ -1015,7 +1015,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1015 | 1015 | ||
1016 | if ((NULL == sctx->lsocks) && | 1016 | if ((NULL == sctx->lsocks) && |
1017 | (GNUNET_SYSERR == | 1017 | (GNUNET_SYSERR == |
1018 | GNUNET_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg, | 1018 | LEGACY_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg, |
1019 | &sctx->addrs, &sctx->addrlens))) | 1019 | &sctx->addrs, &sctx->addrlens))) |
1020 | return GNUNET_SYSERR; | 1020 | return GNUNET_SYSERR; |
1021 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; | 1021 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; |
@@ -1042,7 +1042,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) | |||
1042 | * @return value of the 'USERNAME' option | 1042 | * @return value of the 'USERNAME' option |
1043 | */ | 1043 | */ |
1044 | static char * | 1044 | static char * |
1045 | get_user_name (struct GNUNET_SERVICE_Context *sctx) | 1045 | get_user_name (struct LEGACY_SERVICE_Context *sctx) |
1046 | { | 1046 | { |
1047 | char *un; | 1047 | char *un; |
1048 | 1048 | ||
@@ -1062,7 +1062,7 @@ get_user_name (struct GNUNET_SERVICE_Context *sctx) | |||
1062 | * @return #GNUNET_OK on success (including no work to be done) | 1062 | * @return #GNUNET_OK on success (including no work to be done) |
1063 | */ | 1063 | */ |
1064 | static int | 1064 | static int |
1065 | write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid) | 1065 | write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid) |
1066 | { | 1066 | { |
1067 | FILE *pidfd; | 1067 | FILE *pidfd; |
1068 | char *pif; | 1068 | char *pif; |
@@ -1117,16 +1117,16 @@ write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid) | |||
1117 | /** | 1117 | /** |
1118 | * Task run during shutdown. Stops the server/service. | 1118 | * Task run during shutdown. Stops the server/service. |
1119 | * | 1119 | * |
1120 | * @param cls the `struct GNUNET_SERVICE_Context` | 1120 | * @param cls the `struct LEGACY_SERVICE_Context` |
1121 | */ | 1121 | */ |
1122 | static void | 1122 | static void |
1123 | shutdown_task (void *cls) | 1123 | shutdown_task (void *cls) |
1124 | { | 1124 | { |
1125 | struct GNUNET_SERVICE_Context *service = cls; | 1125 | struct LEGACY_SERVICE_Context *service = cls; |
1126 | struct GNUNET_SERVER_Handle *server = service->server; | 1126 | struct GNUNET_SERVER_Handle *server = service->server; |
1127 | 1127 | ||
1128 | service->shutdown_task = NULL; | 1128 | service->shutdown_task = NULL; |
1129 | if (0 != (service->options & GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN)) | 1129 | if (0 != (service->options & LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN)) |
1130 | GNUNET_SERVER_stop_listening (server); | 1130 | GNUNET_SERVER_stop_listening (server); |
1131 | else | 1131 | else |
1132 | GNUNET_SERVER_destroy (server); | 1132 | GNUNET_SERVER_destroy (server); |
@@ -1141,7 +1141,7 @@ shutdown_task (void *cls) | |||
1141 | static void | 1141 | static void |
1142 | service_task (void *cls) | 1142 | service_task (void *cls) |
1143 | { | 1143 | { |
1144 | struct GNUNET_SERVICE_Context *sctx = cls; | 1144 | struct LEGACY_SERVICE_Context *sctx = cls; |
1145 | unsigned int i; | 1145 | unsigned int i; |
1146 | 1146 | ||
1147 | GNUNET_RESOLVER_connect (sctx->cfg); | 1147 | GNUNET_RESOLVER_connect (sctx->cfg); |
@@ -1174,7 +1174,7 @@ service_task (void *cls) | |||
1174 | #endif | 1174 | #endif |
1175 | 1175 | ||
1176 | 1176 | ||
1177 | if (0 == (sctx->options & GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN)) | 1177 | if (0 == (sctx->options & LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN)) |
1178 | { | 1178 | { |
1179 | /* install a task that will kill the server | 1179 | /* install a task that will kill the server |
1180 | * process if the scheduler ever gets a shutdown signal */ | 1180 | * process if the scheduler ever gets a shutdown signal */ |
@@ -1215,7 +1215,7 @@ service_task (void *cls) | |||
1215 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1215 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1216 | */ | 1216 | */ |
1217 | static int | 1217 | static int |
1218 | detach_terminal (struct GNUNET_SERVICE_Context *sctx) | 1218 | detach_terminal (struct LEGACY_SERVICE_Context *sctx) |
1219 | { | 1219 | { |
1220 | #ifndef MINGW | 1220 | #ifndef MINGW |
1221 | pid_t pid; | 1221 | pid_t pid; |
@@ -1296,7 +1296,7 @@ detach_terminal (struct GNUNET_SERVICE_Context *sctx) | |||
1296 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 1296 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1297 | */ | 1297 | */ |
1298 | static int | 1298 | static int |
1299 | set_user_id (struct GNUNET_SERVICE_Context *sctx) | 1299 | set_user_id (struct LEGACY_SERVICE_Context *sctx) |
1300 | { | 1300 | { |
1301 | char *user; | 1301 | char *user; |
1302 | 1302 | ||
@@ -1342,7 +1342,7 @@ set_user_id (struct GNUNET_SERVICE_Context *sctx) | |||
1342 | * @param sctx service context | 1342 | * @param sctx service context |
1343 | */ | 1343 | */ |
1344 | static void | 1344 | static void |
1345 | pid_file_delete (struct GNUNET_SERVICE_Context *sctx) | 1345 | pid_file_delete (struct LEGACY_SERVICE_Context *sctx) |
1346 | { | 1346 | { |
1347 | char *pif = get_pid_file_name (sctx); | 1347 | char *pif = get_pid_file_name (sctx); |
1348 | 1348 | ||
@@ -1368,10 +1368,10 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx) | |||
1368 | * if we shutdown nicely | 1368 | * if we shutdown nicely |
1369 | */ | 1369 | */ |
1370 | int | 1370 | int |
1371 | GNUNET_SERVICE_run (int argc, char *const *argv, | 1371 | LEGACY_SERVICE_run (int argc, char *const *argv, |
1372 | const char *service_name, | 1372 | const char *service_name, |
1373 | enum GNUNET_SERVICE_Options options, | 1373 | enum LEGACY_SERVICE_Options options, |
1374 | GNUNET_SERVICE_Main task, | 1374 | LEGACY_SERVICE_Main task, |
1375 | void *task_cls) | 1375 | void *task_cls) |
1376 | { | 1376 | { |
1377 | #define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0) | 1377 | #define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0) |
@@ -1387,7 +1387,7 @@ GNUNET_SERVICE_run (int argc, char *const *argv, | |||
1387 | unsigned long long skew_offset; | 1387 | unsigned long long skew_offset; |
1388 | unsigned long long skew_variance; | 1388 | unsigned long long skew_variance; |
1389 | long long clock_offset; | 1389 | long long clock_offset; |
1390 | struct GNUNET_SERVICE_Context sctx; | 1390 | struct LEGACY_SERVICE_Context sctx; |
1391 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1391 | struct GNUNET_CONFIGURATION_Handle *cfg; |
1392 | const char *xdg; | 1392 | const char *xdg; |
1393 | 1393 | ||
@@ -1548,15 +1548,15 @@ shutdown: | |||
1548 | * @param options service options | 1548 | * @param options service options |
1549 | * @return NULL on error, service handle | 1549 | * @return NULL on error, service handle |
1550 | */ | 1550 | */ |
1551 | struct GNUNET_SERVICE_Context * | 1551 | struct LEGACY_SERVICE_Context * |
1552 | GNUNET_SERVICE_start (const char *service_name, | 1552 | LEGACY_SERVICE_start (const char *service_name, |
1553 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1553 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1554 | enum GNUNET_SERVICE_Options options) | 1554 | enum LEGACY_SERVICE_Options options) |
1555 | { | 1555 | { |
1556 | int i; | 1556 | int i; |
1557 | struct GNUNET_SERVICE_Context *sctx; | 1557 | struct LEGACY_SERVICE_Context *sctx; |
1558 | 1558 | ||
1559 | sctx = GNUNET_new (struct GNUNET_SERVICE_Context); | 1559 | sctx = GNUNET_new (struct LEGACY_SERVICE_Context); |
1560 | sctx->ready_confirm_fd = -1; /* no daemonizing */ | 1560 | sctx->ready_confirm_fd = -1; /* no daemonizing */ |
1561 | sctx->ret = GNUNET_OK; | 1561 | sctx->ret = GNUNET_OK; |
1562 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1562 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
@@ -1567,7 +1567,7 @@ GNUNET_SERVICE_start (const char *service_name, | |||
1567 | /* setup subsystems */ | 1567 | /* setup subsystems */ |
1568 | if (GNUNET_OK != setup_service (sctx)) | 1568 | if (GNUNET_OK != setup_service (sctx)) |
1569 | { | 1569 | { |
1570 | GNUNET_SERVICE_stop (sctx); | 1570 | LEGACY_SERVICE_stop (sctx); |
1571 | return NULL; | 1571 | return NULL; |
1572 | } | 1572 | } |
1573 | if (NULL != sctx->lsocks) | 1573 | if (NULL != sctx->lsocks) |
@@ -1581,7 +1581,7 @@ GNUNET_SERVICE_start (const char *service_name, | |||
1581 | 1581 | ||
1582 | if (NULL == sctx->server) | 1582 | if (NULL == sctx->server) |
1583 | { | 1583 | { |
1584 | GNUNET_SERVICE_stop (sctx); | 1584 | LEGACY_SERVICE_stop (sctx); |
1585 | return NULL; | 1585 | return NULL; |
1586 | } | 1586 | } |
1587 | #ifndef WINDOWS | 1587 | #ifndef WINDOWS |
@@ -1611,7 +1611,7 @@ GNUNET_SERVICE_start (const char *service_name, | |||
1611 | * @return handle to the server for this service, NULL if there is none | 1611 | * @return handle to the server for this service, NULL if there is none |
1612 | */ | 1612 | */ |
1613 | struct GNUNET_SERVER_Handle * | 1613 | struct GNUNET_SERVER_Handle * |
1614 | GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx) | 1614 | LEGACY_SERVICE_get_server (struct LEGACY_SERVICE_Context *ctx) |
1615 | { | 1615 | { |
1616 | return ctx->server; | 1616 | return ctx->server; |
1617 | } | 1617 | } |
@@ -1625,19 +1625,19 @@ GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx) | |||
1625 | * array of listen sockets. | 1625 | * array of listen sockets. |
1626 | */ | 1626 | */ |
1627 | struct GNUNET_NETWORK_Handle *const* | 1627 | struct GNUNET_NETWORK_Handle *const* |
1628 | GNUNET_SERVICE_get_listen_sockets (struct GNUNET_SERVICE_Context *ctx) | 1628 | LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx) |
1629 | { | 1629 | { |
1630 | return ctx->lsocks; | 1630 | return ctx->lsocks; |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | 1633 | ||
1634 | /** | 1634 | /** |
1635 | * Stop a service that was started with "GNUNET_SERVICE_start". | 1635 | * Stop a service that was started with "LEGACY_SERVICE_start". |
1636 | * | 1636 | * |
1637 | * @param sctx the service context returned from the start function | 1637 | * @param sctx the service context returned from the start function |
1638 | */ | 1638 | */ |
1639 | void | 1639 | void |
1640 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx) | 1640 | LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx) |
1641 | { | 1641 | { |
1642 | unsigned int i; | 1642 | unsigned int i; |
1643 | 1643 | ||
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 375a935c8..e5ba2831b 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -217,7 +217,7 @@ notify_receive (void *cls, | |||
217 | { | 217 | { |
218 | static int n; | 218 | static int n; |
219 | unsigned int s; | 219 | unsigned int s; |
220 | char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 220 | char cbuf[GNUNET_MAX_MESSAGE_SIZE - 1]; |
221 | 221 | ||
222 | if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (hdr->header.type)) | 222 | if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (hdr->header.type)) |
223 | return; | 223 | return; |
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c index b9c72dcb3..902764a8f 100644 --- a/src/transport/transport_api_address_to_string.c +++ b/src/transport/transport_api_address_to_string.c | |||
@@ -199,10 +199,10 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf | |||
199 | 199 | ||
200 | alen = address->address_length; | 200 | alen = address->address_length; |
201 | slen = strlen (address->transport_name) + 1; | 201 | slen = strlen (address->transport_name) + 1; |
202 | if ( (alen + slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE | 202 | if ( (alen + slen >= GNUNET_MAX_MESSAGE_SIZE |
203 | - sizeof (struct AddressLookupMessage)) || | 203 | - sizeof (struct AddressLookupMessage)) || |
204 | (alen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 204 | (alen >= GNUNET_MAX_MESSAGE_SIZE) || |
205 | (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ) | 205 | (slen >= GNUNET_MAX_MESSAGE_SIZE) ) |
206 | { | 206 | { |
207 | GNUNET_break (0); | 207 | GNUNET_break (0); |
208 | GNUNET_free (alc); | 208 | GNUNET_free (alc); |
diff --git a/src/transport/transport_api_core.c b/src/transport/transport_api_core.c index c99ade92f..9c29d4908 100644 --- a/src/transport/transport_api_core.c +++ b/src/transport/transport_api_core.c | |||
@@ -425,7 +425,7 @@ mq_send_impl (struct GNUNET_MQ_Handle *mq, | |||
425 | 425 | ||
426 | GNUNET_assert (GNUNET_YES == n->is_ready); | 426 | GNUNET_assert (GNUNET_YES == n->is_ready); |
427 | msize = ntohs (msg->size); | 427 | msize = ntohs (msg->size); |
428 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*obm)) | 428 | if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*obm)) |
429 | { | 429 | { |
430 | GNUNET_break (0); | 430 | GNUNET_break (0); |
431 | GNUNET_MQ_impl_send_continue (mq); | 431 | GNUNET_MQ_impl_send_continue (mq); |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 2ca977065..9be572bb6 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -30,9 +30,9 @@ W32CONSOLEHELPER = gnunet-helper-w32-console | |||
30 | endif | 30 | endif |
31 | 31 | ||
32 | if !MINGW | 32 | if !MINGW |
33 | TEST_CLIENT_UNIC_NC = test_client_unix.nc | 33 | TEST_CLIENT_UNIX_NC = test_client_unix.nc |
34 | else | 34 | else |
35 | TEST_CLIENT_UNIC_NC = | 35 | TEST_CLIENT_UNIX_NC = |
36 | endif | 36 | endif |
37 | 37 | ||
38 | if USE_COVERAGE | 38 | if USE_COVERAGE |
@@ -106,7 +106,7 @@ libgnunetutil_la_SOURCES = \ | |||
106 | program.c \ | 106 | program.c \ |
107 | resolver_api.c resolver.h \ | 107 | resolver_api.c resolver.h \ |
108 | scheduler.c \ | 108 | scheduler.c \ |
109 | service_new.c \ | 109 | service.c \ |
110 | signal.c \ | 110 | signal.c \ |
111 | strings.c \ | 111 | strings.c \ |
112 | time.c \ | 112 | time.c \ |
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index a059fc738..bc0c3b9b4 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -184,8 +184,8 @@ update_excess (struct GNUNET_BANDWIDTH_Tracker *av) | |||
184 | } | 184 | } |
185 | /* negative current_consumption means that we have savings */ | 185 | /* negative current_consumption means that we have savings */ |
186 | max_carry = ((uint64_t) av->available_bytes_per_s__) * av->max_carry_s__; | 186 | max_carry = ((uint64_t) av->available_bytes_per_s__) * av->max_carry_s__; |
187 | if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE) | 187 | if (max_carry < GNUNET_MAX_MESSAGE_SIZE) |
188 | max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE; | 188 | max_carry = GNUNET_MAX_MESSAGE_SIZE; |
189 | if (max_carry > INT64_MAX) | 189 | if (max_carry > INT64_MAX) |
190 | max_carry = INT64_MAX; | 190 | max_carry = INT64_MAX; |
191 | left_bytes = current_consumption + max_carry; | 191 | left_bytes = current_consumption + max_carry; |
@@ -224,10 +224,10 @@ update_excess (struct GNUNET_BANDWIDTH_Tracker *av) | |||
224 | /** | 224 | /** |
225 | * Initialize bandwidth tracker. Note that in addition to the | 225 | * Initialize bandwidth tracker. Note that in addition to the |
226 | * 'max_carry_s' limit, we also always allow at least | 226 | * 'max_carry_s' limit, we also always allow at least |
227 | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | 227 | * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the |
228 | * bytes-per-second limit is so small that within 'max_carry_s' not | 228 | * bytes-per-second limit is so small that within 'max_carry_s' not |
229 | * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | 229 | * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is |
230 | * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | 230 | * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in |
231 | * bytes). | 231 | * bytes). |
232 | * | 232 | * |
233 | * To stop notifications about updates and excess callbacks use | 233 | * To stop notifications about updates and excess callbacks use |
@@ -271,10 +271,10 @@ GNUNET_BANDWIDTH_tracker_init2 (struct GNUNET_BANDWIDTH_Tracker *av, | |||
271 | /** | 271 | /** |
272 | * Initialize bandwidth tracker. Note that in addition to the | 272 | * Initialize bandwidth tracker. Note that in addition to the |
273 | * 'max_carry_s' limit, we also always allow at least | 273 | * 'max_carry_s' limit, we also always allow at least |
274 | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | 274 | * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the |
275 | * bytes-per-second limit is so small that within 'max_carry_s' not | 275 | * bytes-per-second limit is so small that within 'max_carry_s' not |
276 | * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | 276 | * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is |
277 | * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | 277 | * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in |
278 | * bytes). | 278 | * bytes). |
279 | * | 279 | * |
280 | * @param av tracker to initialize | 280 | * @param av tracker to initialize |
@@ -345,8 +345,8 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) | |||
345 | left_bytes = - av->consumption_since_last_update__; | 345 | left_bytes = - av->consumption_since_last_update__; |
346 | max_carry = ((unsigned long long) av->available_bytes_per_s__) * | 346 | max_carry = ((unsigned long long) av->available_bytes_per_s__) * |
347 | av->max_carry_s__; | 347 | av->max_carry_s__; |
348 | if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE) | 348 | if (max_carry < GNUNET_MAX_MESSAGE_SIZE) |
349 | max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE; | 349 | max_carry = GNUNET_MAX_MESSAGE_SIZE; |
350 | if (max_carry > INT64_MAX) | 350 | if (max_carry > INT64_MAX) |
351 | max_carry = INT64_MAX; | 351 | max_carry = INT64_MAX; |
352 | if (max_carry > left_bytes) | 352 | if (max_carry > left_bytes) |
diff --git a/src/util/client.c b/src/util/client.c index 163ae6eb9..3d74bff33 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -35,6 +35,15 @@ | |||
35 | 35 | ||
36 | #define LOG(kind,...) GNUNET_log_from (kind, "util-client",__VA_ARGS__) | 36 | #define LOG(kind,...) GNUNET_log_from (kind, "util-client",__VA_ARGS__) |
37 | 37 | ||
38 | /** | ||
39 | * Timeout we use on TCP connect before trying another | ||
40 | * result from the DNS resolver. Actual value used | ||
41 | * is this value divided by the number of address families. | ||
42 | * Default is 5s. | ||
43 | */ | ||
44 | #define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
45 | |||
46 | |||
38 | 47 | ||
39 | /** | 48 | /** |
40 | * Internal state for a client connected to a GNUnet service. | 49 | * Internal state for a client connected to a GNUnet service. |
@@ -656,7 +665,7 @@ try_connect_using_address (void *cls, | |||
656 | GNUNET_CONTAINER_DLL_insert (cstate->ap_head, | 665 | GNUNET_CONTAINER_DLL_insert (cstate->ap_head, |
657 | cstate->ap_tail, | 666 | cstate->ap_tail, |
658 | ap); | 667 | ap); |
659 | ap->task = GNUNET_SCHEDULER_add_write_net (GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 668 | ap->task = GNUNET_SCHEDULER_add_write_net (CONNECT_RETRY_TIMEOUT, |
660 | ap->sock, | 669 | ap->sock, |
661 | &connect_probe_continuation, | 670 | &connect_probe_continuation, |
662 | ap); | 671 | ap); |
@@ -760,7 +769,7 @@ start_connect (void *cls) | |||
760 | cstate->dns_active | 769 | cstate->dns_active |
761 | = GNUNET_RESOLVER_ip_get (cstate->hostname, | 770 | = GNUNET_RESOLVER_ip_get (cstate->hostname, |
762 | AF_UNSPEC, | 771 | AF_UNSPEC, |
763 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 772 | CONNECT_RETRY_TIMEOUT, |
764 | &try_connect_using_address, | 773 | &try_connect_using_address, |
765 | cstate); | 774 | cstate); |
766 | } | 775 | } |
diff --git a/src/util/helper.c b/src/util/helper.c index 1a79c477a..a84b06e66 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -323,7 +323,7 @@ static void | |||
323 | helper_read (void *cls) | 323 | helper_read (void *cls) |
324 | { | 324 | { |
325 | struct GNUNET_HELPER_Handle *h = cls; | 325 | struct GNUNET_HELPER_Handle *h = cls; |
326 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN; | 326 | char buf[GNUNET_MAX_MESSAGE_SIZE] GNUNET_ALIGN; |
327 | ssize_t t; | 327 | ssize_t t; |
328 | 328 | ||
329 | h->read_task = NULL; | 329 | h->read_task = NULL; |
diff --git a/src/util/mst.c b/src/util/mst.c index 9f1d30d7a..0d90c5d10 100644 --- a/src/util/mst.c +++ b/src/util/mst.c | |||
@@ -90,8 +90,8 @@ GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, | |||
90 | struct GNUNET_MessageStreamTokenizer *ret; | 90 | struct GNUNET_MessageStreamTokenizer *ret; |
91 | 91 | ||
92 | ret = GNUNET_new (struct GNUNET_MessageStreamTokenizer); | 92 | ret = GNUNET_new (struct GNUNET_MessageStreamTokenizer); |
93 | ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE); | 93 | ret->hdr = GNUNET_malloc (GNUNET_MIN_MESSAGE_SIZE); |
94 | ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE; | 94 | ret->curr_buf = GNUNET_MIN_MESSAGE_SIZE; |
95 | ret->cb = cb; | 95 | ret->cb = cb; |
96 | ret->cb_cls = cb_cls; | 96 | ret->cb_cls = cb_cls; |
97 | return ret; | 97 | return ret; |
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index f33c31f1c..0c915932c 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -876,7 +876,7 @@ GNUNET_RESOLVER_ip_get (const char *hostname, | |||
876 | 876 | ||
877 | slen = strlen (hostname) + 1; | 877 | slen = strlen (hostname) + 1; |
878 | if (slen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= | 878 | if (slen + sizeof (struct GNUNET_RESOLVER_GetMessage) >= |
879 | GNUNET_SERVER_MAX_MESSAGE_SIZE) | 879 | GNUNET_MAX_MESSAGE_SIZE) |
880 | { | 880 | { |
881 | GNUNET_break (0); | 881 | GNUNET_break (0); |
882 | return NULL; | 882 | return NULL; |
diff --git a/src/util/server_mst.c b/src/util/server_mst.c deleted file mode 100644 index 5155b54da..000000000 --- a/src/util/server_mst.c +++ /dev/null | |||
@@ -1,313 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file util/server_mst.c | ||
23 | * @brief convenience functions for handling inbound message buffers | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | |||
31 | #if HAVE_UNALIGNED_64_ACCESS | ||
32 | #define ALIGN_FACTOR 4 | ||
33 | #else | ||
34 | #define ALIGN_FACTOR 8 | ||
35 | #endif | ||
36 | |||
37 | #define LOG(kind,...) GNUNET_log_from (kind, "util-server-mst", __VA_ARGS__) | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Handle to a message stream tokenizer. | ||
42 | */ | ||
43 | struct GNUNET_SERVER_MessageStreamTokenizer | ||
44 | { | ||
45 | |||
46 | /** | ||
47 | * Function to call on completed messages. | ||
48 | */ | ||
49 | GNUNET_SERVER_MessageTokenizerCallback cb; | ||
50 | |||
51 | /** | ||
52 | * Closure for @e cb. | ||
53 | */ | ||
54 | void *cb_cls; | ||
55 | |||
56 | /** | ||
57 | * Size of the buffer (starting at @e hdr). | ||
58 | */ | ||
59 | size_t curr_buf; | ||
60 | |||
61 | /** | ||
62 | * How many bytes in buffer have we already processed? | ||
63 | */ | ||
64 | size_t off; | ||
65 | |||
66 | /** | ||
67 | * How many bytes in buffer are valid right now? | ||
68 | */ | ||
69 | size_t pos; | ||
70 | |||
71 | /** | ||
72 | * Beginning of the buffer. Typed like this to force alignment. | ||
73 | */ | ||
74 | struct GNUNET_MessageHeader *hdr; | ||
75 | |||
76 | }; | ||
77 | |||
78 | |||
79 | |||
80 | /** | ||
81 | * Create a message stream tokenizer. | ||
82 | * | ||
83 | * @param cb function to call on completed messages | ||
84 | * @param cb_cls closure for @a cb | ||
85 | * @return handle to tokenizer | ||
86 | */ | ||
87 | struct GNUNET_SERVER_MessageStreamTokenizer * | ||
88 | GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb, | ||
89 | void *cb_cls) | ||
90 | { | ||
91 | struct GNUNET_SERVER_MessageStreamTokenizer *ret; | ||
92 | |||
93 | ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer); | ||
94 | ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE); | ||
95 | ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE; | ||
96 | ret->cb = cb; | ||
97 | ret->cb_cls = cb_cls; | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Add incoming data to the receive buffer and call the | ||
104 | * callback for all complete messages. | ||
105 | * | ||
106 | * @param mst tokenizer to use | ||
107 | * @param client_identity ID of client for which this is a buffer | ||
108 | * @param buf input data to add | ||
109 | * @param size number of bytes in @a buf | ||
110 | * @param purge should any excess bytes in the buffer be discarded | ||
111 | * (i.e. for packet-based services like UDP) | ||
112 | * @param one_shot only call callback once, keep rest of message in buffer | ||
113 | * @return #GNUNET_OK if we are done processing (need more data) | ||
114 | * #GNUNET_NO if @a one_shot was set and we have another message ready | ||
115 | * #GNUNET_SYSERR if the data stream is corrupt | ||
116 | */ | ||
117 | int | ||
118 | GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst, | ||
119 | void *client_identity, | ||
120 | const char *buf, size_t size, | ||
121 | int purge, int one_shot) | ||
122 | { | ||
123 | const struct GNUNET_MessageHeader *hdr; | ||
124 | size_t delta; | ||
125 | uint16_t want; | ||
126 | char *ibuf; | ||
127 | int need_align; | ||
128 | unsigned long offset; | ||
129 | int ret; | ||
130 | |||
131 | GNUNET_assert (mst->off <= mst->pos); | ||
132 | GNUNET_assert (mst->pos <= mst->curr_buf); | ||
133 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
134 | "Server-mst receives %u bytes with %u bytes already in private buffer\n", | ||
135 | (unsigned int) size, (unsigned int) (mst->pos - mst->off)); | ||
136 | ret = GNUNET_OK; | ||
137 | ibuf = (char *) mst->hdr; | ||
138 | while (mst->pos > 0) | ||
139 | { | ||
140 | do_align: | ||
141 | GNUNET_assert (mst->pos >= mst->off); | ||
142 | if ((mst->curr_buf - mst->off < sizeof (struct GNUNET_MessageHeader)) || | ||
143 | (0 != (mst->off % ALIGN_FACTOR))) | ||
144 | { | ||
145 | /* need to align or need more space */ | ||
146 | mst->pos -= mst->off; | ||
147 | memmove (ibuf, &ibuf[mst->off], mst->pos); | ||
148 | mst->off = 0; | ||
149 | } | ||
150 | if (mst->pos - mst->off < sizeof (struct GNUNET_MessageHeader)) | ||
151 | { | ||
152 | delta = | ||
153 | GNUNET_MIN (sizeof (struct GNUNET_MessageHeader) - | ||
154 | (mst->pos - mst->off), size); | ||
155 | GNUNET_memcpy (&ibuf[mst->pos], buf, delta); | ||
156 | mst->pos += delta; | ||
157 | buf += delta; | ||
158 | size -= delta; | ||
159 | } | ||
160 | if (mst->pos - mst->off < sizeof (struct GNUNET_MessageHeader)) | ||
161 | { | ||
162 | if (purge) | ||
163 | { | ||
164 | mst->off = 0; | ||
165 | mst->pos = 0; | ||
166 | } | ||
167 | return GNUNET_OK; | ||
168 | } | ||
169 | hdr = (const struct GNUNET_MessageHeader *) &ibuf[mst->off]; | ||
170 | want = ntohs (hdr->size); | ||
171 | if (want < sizeof (struct GNUNET_MessageHeader)) | ||
172 | { | ||
173 | GNUNET_break_op (0); | ||
174 | return GNUNET_SYSERR; | ||
175 | } | ||
176 | if ( (mst->curr_buf - mst->off < want) && | ||
177 | (mst->off > 0) ) | ||
178 | { | ||
179 | /* can get more space by moving */ | ||
180 | mst->pos -= mst->off; | ||
181 | memmove (ibuf, &ibuf[mst->off], mst->pos); | ||
182 | mst->off = 0; | ||
183 | } | ||
184 | if (mst->curr_buf < want) | ||
185 | { | ||
186 | /* need to get more space by growing buffer */ | ||
187 | GNUNET_assert (0 == mst->off); | ||
188 | mst->hdr = GNUNET_realloc (mst->hdr, want); | ||
189 | ibuf = (char *) mst->hdr; | ||
190 | mst->curr_buf = want; | ||
191 | } | ||
192 | hdr = (const struct GNUNET_MessageHeader *) &ibuf[mst->off]; | ||
193 | if (mst->pos - mst->off < want) | ||
194 | { | ||
195 | delta = GNUNET_MIN (want - (mst->pos - mst->off), size); | ||
196 | GNUNET_assert (mst->pos + delta <= mst->curr_buf); | ||
197 | GNUNET_memcpy (&ibuf[mst->pos], buf, delta); | ||
198 | mst->pos += delta; | ||
199 | buf += delta; | ||
200 | size -= delta; | ||
201 | } | ||
202 | if (mst->pos - mst->off < want) | ||
203 | { | ||
204 | if (purge) | ||
205 | { | ||
206 | mst->off = 0; | ||
207 | mst->pos = 0; | ||
208 | } | ||
209 | return GNUNET_OK; | ||
210 | } | ||
211 | if (one_shot == GNUNET_SYSERR) | ||
212 | { | ||
213 | /* cannot call callback again, but return value saying that | ||
214 | * we have another full message in the buffer */ | ||
215 | ret = GNUNET_NO; | ||
216 | goto copy; | ||
217 | } | ||
218 | if (one_shot == GNUNET_YES) | ||
219 | one_shot = GNUNET_SYSERR; | ||
220 | mst->off += want; | ||
221 | if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr)) | ||
222 | return GNUNET_SYSERR; | ||
223 | if (mst->off == mst->pos) | ||
224 | { | ||
225 | /* reset to beginning of buffer, it's free right now! */ | ||
226 | mst->off = 0; | ||
227 | mst->pos = 0; | ||
228 | } | ||
229 | } | ||
230 | GNUNET_assert (0 == mst->pos); | ||
231 | while (size > 0) | ||
232 | { | ||
233 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
234 | "Server-mst has %u bytes left in inbound buffer\n", | ||
235 | (unsigned int) size); | ||
236 | if (size < sizeof (struct GNUNET_MessageHeader)) | ||
237 | break; | ||
238 | offset = (unsigned long) buf; | ||
239 | need_align = (0 != (offset % ALIGN_FACTOR)) ? GNUNET_YES : GNUNET_NO; | ||
240 | if (GNUNET_NO == need_align) | ||
241 | { | ||
242 | /* can try to do zero-copy and process directly from original buffer */ | ||
243 | hdr = (const struct GNUNET_MessageHeader *) buf; | ||
244 | want = ntohs (hdr->size); | ||
245 | if (want < sizeof (struct GNUNET_MessageHeader)) | ||
246 | { | ||
247 | GNUNET_break_op (0); | ||
248 | mst->off = 0; | ||
249 | return GNUNET_SYSERR; | ||
250 | } | ||
251 | if (size < want) | ||
252 | break; /* or not: buffer incomplete, so copy to private buffer... */ | ||
253 | if (one_shot == GNUNET_SYSERR) | ||
254 | { | ||
255 | /* cannot call callback again, but return value saying that | ||
256 | * we have another full message in the buffer */ | ||
257 | ret = GNUNET_NO; | ||
258 | goto copy; | ||
259 | } | ||
260 | if (one_shot == GNUNET_YES) | ||
261 | one_shot = GNUNET_SYSERR; | ||
262 | if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr)) | ||
263 | return GNUNET_SYSERR; | ||
264 | buf += want; | ||
265 | size -= want; | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | /* need to copy to private buffer to align; | ||
270 | * yes, we go a bit more spagetti than usual here */ | ||
271 | goto do_align; | ||
272 | } | ||
273 | } | ||
274 | copy: | ||
275 | if ((size > 0) && (!purge)) | ||
276 | { | ||
277 | if (size + mst->pos > mst->curr_buf) | ||
278 | { | ||
279 | mst->hdr = GNUNET_realloc (mst->hdr, size + mst->pos); | ||
280 | ibuf = (char *) mst->hdr; | ||
281 | mst->curr_buf = size + mst->pos; | ||
282 | } | ||
283 | GNUNET_assert (size + mst->pos <= mst->curr_buf); | ||
284 | GNUNET_memcpy (&ibuf[mst->pos], buf, size); | ||
285 | mst->pos += size; | ||
286 | } | ||
287 | if (purge) | ||
288 | { | ||
289 | mst->off = 0; | ||
290 | mst->pos = 0; | ||
291 | } | ||
292 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
293 | "Server-mst leaves %u bytes in private buffer\n", | ||
294 | (unsigned int) (mst->pos - mst->off)); | ||
295 | return ret; | ||
296 | } | ||
297 | |||
298 | |||
299 | /** | ||
300 | * Destroys a tokenizer. | ||
301 | * | ||
302 | * @param mst tokenizer to destroy | ||
303 | */ | ||
304 | void | ||
305 | GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst) | ||
306 | { | ||
307 | GNUNET_free (mst->hdr); | ||
308 | GNUNET_free (mst); | ||
309 | } | ||
310 | |||
311 | |||
312 | |||
313 | /* end of server_mst.c */ | ||
diff --git a/src/util/server_nc.c b/src/util/server_nc.c deleted file mode 100644 index a95cd7f6d..000000000 --- a/src/util/server_nc.c +++ /dev/null | |||
@@ -1,472 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file util/server_nc.c | ||
23 | * @brief convenience functions for transmission of | ||
24 | * a notification stream | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | #define LOG(kind,...) GNUNET_log_from (kind, "util-server-nc", __VA_ARGS__) | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Entry in list of messages pending to be transmitted. | ||
36 | */ | ||
37 | struct PendingMessageList | ||
38 | { | ||
39 | |||
40 | /** | ||
41 | * This is a doubly-linked list. | ||
42 | */ | ||
43 | struct PendingMessageList *next; | ||
44 | |||
45 | /** | ||
46 | * This is a doubly-linked list. | ||
47 | */ | ||
48 | struct PendingMessageList *prev; | ||
49 | |||
50 | /** | ||
51 | * Message to transmit (allocated at the end of this | ||
52 | * struct, do not free) | ||
53 | */ | ||
54 | const struct GNUNET_MessageHeader *msg; | ||
55 | |||
56 | /** | ||
57 | * Can this message be dropped? | ||
58 | */ | ||
59 | int can_drop; | ||
60 | |||
61 | }; | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Lists of clients we manage for notifications. | ||
66 | */ | ||
67 | struct ClientList | ||
68 | { | ||
69 | |||
70 | /** | ||
71 | * This is a doubly linked list. | ||
72 | */ | ||
73 | struct ClientList *next; | ||
74 | |||
75 | /** | ||
76 | * This is a doubly linked list. | ||
77 | */ | ||
78 | struct ClientList *prev; | ||
79 | |||
80 | /** | ||
81 | * Overall context this client belongs to. | ||
82 | */ | ||
83 | struct GNUNET_SERVER_NotificationContext *nc; | ||
84 | |||
85 | /** | ||
86 | * Handle to the client. | ||
87 | */ | ||
88 | struct GNUNET_SERVER_Client *client; | ||
89 | |||
90 | /** | ||
91 | * Handle for pending transmission request to the client (or NULL). | ||
92 | */ | ||
93 | struct GNUNET_SERVER_TransmitHandle *th; | ||
94 | |||
95 | /** | ||
96 | * Head of linked list of requests queued for transmission. | ||
97 | */ | ||
98 | struct PendingMessageList *pending_head; | ||
99 | |||
100 | /** | ||
101 | * Tail of linked list of requests queued for transmission. | ||
102 | */ | ||
103 | struct PendingMessageList *pending_tail; | ||
104 | |||
105 | /** | ||
106 | * Number of messages currently in the list. | ||
107 | */ | ||
108 | unsigned int num_pending; | ||
109 | |||
110 | }; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * The notification context is the key datastructure for a convenience | ||
115 | * API used for transmission of notifications to the client until the | ||
116 | * client disconnects (or the notification context is destroyed, in | ||
117 | * which case we disconnect these clients). Essentially, all | ||
118 | * (notification) messages are queued up until the client is able to | ||
119 | * read them. | ||
120 | */ | ||
121 | struct GNUNET_SERVER_NotificationContext | ||
122 | { | ||
123 | |||
124 | /** | ||
125 | * Server we do notifications for. | ||
126 | */ | ||
127 | struct GNUNET_SERVER_Handle *server; | ||
128 | |||
129 | /** | ||
130 | * Head of list of clients receiving notifications. | ||
131 | */ | ||
132 | struct ClientList *clients_head; | ||
133 | |||
134 | /** | ||
135 | * Tail of list of clients receiving notifications. | ||
136 | */ | ||
137 | struct ClientList *clients_tail; | ||
138 | |||
139 | /** | ||
140 | * Maximum number of optional messages to queue per client. | ||
141 | */ | ||
142 | unsigned int queue_length; | ||
143 | |||
144 | }; | ||
145 | |||
146 | |||
147 | /** | ||
148 | * Client has disconnected, clean up. | ||
149 | * | ||
150 | * @param cls our `struct GNUNET_SERVER_NotificationContext *` | ||
151 | * @param client handle of client that disconnected | ||
152 | */ | ||
153 | static void | ||
154 | handle_client_disconnect (void *cls, | ||
155 | struct GNUNET_SERVER_Client *client) | ||
156 | { | ||
157 | struct GNUNET_SERVER_NotificationContext *nc = cls; | ||
158 | struct ClientList *pos; | ||
159 | struct PendingMessageList *pml; | ||
160 | |||
161 | if (NULL == client) | ||
162 | { | ||
163 | nc->server = NULL; | ||
164 | return; | ||
165 | } | ||
166 | for (pos = nc->clients_head; NULL != pos; pos = pos->next) | ||
167 | if (pos->client == client) | ||
168 | break; | ||
169 | if (NULL == pos) | ||
170 | return; | ||
171 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
172 | "Client disconnected, cleaning up %u messages in NC queue\n", | ||
173 | pos->num_pending); | ||
174 | GNUNET_CONTAINER_DLL_remove (nc->clients_head, | ||
175 | nc->clients_tail, | ||
176 | pos); | ||
177 | while (NULL != (pml = pos->pending_head)) | ||
178 | { | ||
179 | GNUNET_CONTAINER_DLL_remove (pos->pending_head, | ||
180 | pos->pending_tail, | ||
181 | pml); | ||
182 | GNUNET_free (pml); | ||
183 | pos->num_pending--; | ||
184 | } | ||
185 | if (NULL != pos->th) | ||
186 | { | ||
187 | GNUNET_SERVER_notify_transmit_ready_cancel (pos->th); | ||
188 | pos->th = NULL; | ||
189 | } | ||
190 | GNUNET_SERVER_client_drop (client); | ||
191 | GNUNET_assert (0 == pos->num_pending); | ||
192 | GNUNET_free (pos); | ||
193 | } | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Create a new notification context. | ||
198 | * | ||
199 | * @param server server for which this function creates the context | ||
200 | * @param queue_length maximum number of messages to keep in | ||
201 | * the notification queue; optional messages are dropped | ||
202 | * if the queue gets longer than this number of messages | ||
203 | * @return handle to the notification context | ||
204 | */ | ||
205 | struct GNUNET_SERVER_NotificationContext * | ||
206 | GNUNET_SERVER_notification_context_create (struct GNUNET_SERVER_Handle *server, | ||
207 | unsigned int queue_length) | ||
208 | { | ||
209 | struct GNUNET_SERVER_NotificationContext *ret; | ||
210 | |||
211 | ret = GNUNET_new (struct GNUNET_SERVER_NotificationContext); | ||
212 | ret->server = server; | ||
213 | ret->queue_length = queue_length; | ||
214 | GNUNET_SERVER_disconnect_notify (server, | ||
215 | &handle_client_disconnect, | ||
216 | ret); | ||
217 | return ret; | ||
218 | } | ||
219 | |||
220 | |||
221 | /** | ||
222 | * Destroy the context, force disconnect for all clients. | ||
223 | * | ||
224 | * @param nc context to destroy. | ||
225 | */ | ||
226 | void | ||
227 | GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_NotificationContext *nc) | ||
228 | { | ||
229 | struct ClientList *pos; | ||
230 | struct PendingMessageList *pml; | ||
231 | |||
232 | while (NULL != (pos = nc->clients_head)) | ||
233 | { | ||
234 | GNUNET_CONTAINER_DLL_remove (nc->clients_head, | ||
235 | nc->clients_tail, | ||
236 | pos); | ||
237 | if (NULL != pos->th) | ||
238 | { | ||
239 | GNUNET_SERVER_notify_transmit_ready_cancel (pos->th); | ||
240 | pos->th = NULL; | ||
241 | } | ||
242 | GNUNET_SERVER_client_drop (pos->client); | ||
243 | while (NULL != (pml = pos->pending_head)) | ||
244 | { | ||
245 | GNUNET_CONTAINER_DLL_remove (pos->pending_head, | ||
246 | pos->pending_tail, | ||
247 | pml); | ||
248 | GNUNET_free (pml); | ||
249 | pos->num_pending--; | ||
250 | } | ||
251 | GNUNET_assert (0 == pos->num_pending); | ||
252 | GNUNET_free (pos); | ||
253 | } | ||
254 | if (NULL != nc->server) | ||
255 | GNUNET_SERVER_disconnect_notify_cancel (nc->server, | ||
256 | &handle_client_disconnect, | ||
257 | nc); | ||
258 | GNUNET_free (nc); | ||
259 | } | ||
260 | |||
261 | |||
262 | /** | ||
263 | * Add a client to the notification context. | ||
264 | * | ||
265 | * @param nc context to modify | ||
266 | * @param client client to add | ||
267 | */ | ||
268 | void | ||
269 | GNUNET_SERVER_notification_context_add (struct GNUNET_SERVER_NotificationContext *nc, | ||
270 | struct GNUNET_SERVER_Client *client) | ||
271 | { | ||
272 | struct ClientList *cl; | ||
273 | |||
274 | for (cl = nc->clients_head; NULL != cl; cl = cl->next) | ||
275 | if (cl->client == client) | ||
276 | return; /* already present */ | ||
277 | cl = GNUNET_new (struct ClientList); | ||
278 | GNUNET_CONTAINER_DLL_insert (nc->clients_head, | ||
279 | nc->clients_tail, | ||
280 | cl); | ||
281 | cl->nc = nc; | ||
282 | cl->client = client; | ||
283 | GNUNET_SERVER_client_keep (client); | ||
284 | } | ||
285 | |||
286 | |||
287 | /** | ||
288 | * Function called to notify a client about the socket begin ready to | ||
289 | * queue more data. @a buf will be NULL and @a size zero if the socket | ||
290 | * was closed for writing in the meantime. | ||
291 | * | ||
292 | * @param cls the `struct ClientList *` | ||
293 | * @param size number of bytes available in @a buf | ||
294 | * @param buf where the callee should write the message | ||
295 | * @return number of bytes written to buf | ||
296 | */ | ||
297 | static size_t | ||
298 | transmit_message (void *cls, | ||
299 | size_t size, | ||
300 | void *buf) | ||
301 | { | ||
302 | struct ClientList *cl = cls; | ||
303 | char *cbuf = buf; | ||
304 | struct PendingMessageList *pml; | ||
305 | uint16_t msize; | ||
306 | size_t ret; | ||
307 | |||
308 | cl->th = NULL; | ||
309 | if (NULL == buf) | ||
310 | { | ||
311 | /* 'cl' should be freed via disconnect notification shortly */ | ||
312 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
313 | "Failed to transmit message from NC queue to client\n"); | ||
314 | return 0; | ||
315 | } | ||
316 | ret = 0; | ||
317 | while (NULL != (pml = cl->pending_head)) | ||
318 | { | ||
319 | msize = ntohs (pml->msg->size); | ||
320 | if (size < msize) | ||
321 | break; | ||
322 | GNUNET_CONTAINER_DLL_remove (cl->pending_head, | ||
323 | cl->pending_tail, | ||
324 | pml); | ||
325 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
326 | "Copying message of type %u and size %u from pending queue to transmission buffer\n", | ||
327 | ntohs (pml->msg->type), | ||
328 | msize); | ||
329 | GNUNET_memcpy (&cbuf[ret], pml->msg, msize); | ||
330 | ret += msize; | ||
331 | size -= msize; | ||
332 | GNUNET_free (pml); | ||
333 | cl->num_pending--; | ||
334 | } | ||
335 | if (NULL != pml) | ||
336 | { | ||
337 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
338 | "Have %u messages left in NC queue, will try transmission again\n", | ||
339 | cl->num_pending); | ||
340 | cl->th = | ||
341 | GNUNET_SERVER_notify_transmit_ready (cl->client, | ||
342 | ntohs (pml->msg->size), | ||
343 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
344 | &transmit_message, cl); | ||
345 | } | ||
346 | else | ||
347 | { | ||
348 | GNUNET_assert (0 == cl->num_pending); | ||
349 | } | ||
350 | return ret; | ||
351 | } | ||
352 | |||
353 | |||
354 | /** | ||
355 | * Send a message to a particular client. | ||
356 | * | ||
357 | * @param nc context to modify | ||
358 | * @param client client to transmit to | ||
359 | * @param msg message to send | ||
360 | * @param can_drop can this message be dropped due to queue length limitations | ||
361 | */ | ||
362 | static void | ||
363 | do_unicast (struct GNUNET_SERVER_NotificationContext *nc, | ||
364 | struct ClientList *client, | ||
365 | const struct GNUNET_MessageHeader *msg, | ||
366 | int can_drop) | ||
367 | { | ||
368 | struct PendingMessageList *pml; | ||
369 | uint16_t size; | ||
370 | |||
371 | if ( (client->num_pending > nc->queue_length) && | ||
372 | (GNUNET_YES == can_drop) ) | ||
373 | { | ||
374 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
375 | "Dropping message of type %u and size %u due to full queue (%u entries)\n", | ||
376 | ntohs (msg->type), ntohs (msg->size), (unsigned int) nc->queue_length); | ||
377 | return; /* drop! */ | ||
378 | } | ||
379 | if (client->num_pending > nc->queue_length) | ||
380 | { | ||
381 | /* FIXME: consider checking for other messages in the | ||
382 | * queue that are 'droppable' */ | ||
383 | } | ||
384 | client->num_pending++; | ||
385 | size = ntohs (msg->size); | ||
386 | pml = GNUNET_malloc (sizeof (struct PendingMessageList) + size); | ||
387 | pml->msg = (const struct GNUNET_MessageHeader *) &pml[1]; | ||
388 | pml->can_drop = can_drop; | ||
389 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
390 | "Adding message of type %u and size %u to pending queue (which has %u entries)\n", | ||
391 | ntohs (msg->type), | ||
392 | ntohs (msg->size), | ||
393 | (unsigned int) nc->queue_length); | ||
394 | GNUNET_memcpy (&pml[1], msg, size); | ||
395 | /* append */ | ||
396 | GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, | ||
397 | client->pending_tail, | ||
398 | pml); | ||
399 | if (NULL == client->th) | ||
400 | client->th = | ||
401 | GNUNET_SERVER_notify_transmit_ready (client->client, | ||
402 | ntohs (client->pending_head-> | ||
403 | msg->size), | ||
404 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
405 | &transmit_message, client); | ||
406 | } | ||
407 | |||
408 | |||
409 | /** | ||
410 | * Send a message to a particular client; must have | ||
411 | * already been added to the notification context. | ||
412 | * | ||
413 | * @param nc context to modify | ||
414 | * @param client client to transmit to | ||
415 | * @param msg message to send | ||
416 | * @param can_drop can this message be dropped due to queue length limitations | ||
417 | */ | ||
418 | void | ||
419 | GNUNET_SERVER_notification_context_unicast (struct GNUNET_SERVER_NotificationContext *nc, | ||
420 | struct GNUNET_SERVER_Client *client, | ||
421 | const struct GNUNET_MessageHeader *msg, | ||
422 | int can_drop) | ||
423 | { | ||
424 | struct ClientList *pos; | ||
425 | |||
426 | for (pos = nc->clients_head; NULL != pos; pos = pos->next) | ||
427 | if (pos->client == client) | ||
428 | break; | ||
429 | GNUNET_assert (NULL != pos); | ||
430 | do_unicast (nc, pos, msg, can_drop); | ||
431 | } | ||
432 | |||
433 | |||
434 | /** | ||
435 | * Send a message to all clients of this context. | ||
436 | * | ||
437 | * @param nc context to modify | ||
438 | * @param msg message to send | ||
439 | * @param can_drop can this message be dropped due to queue length limitations | ||
440 | */ | ||
441 | void | ||
442 | GNUNET_SERVER_notification_context_broadcast (struct | ||
443 | GNUNET_SERVER_NotificationContext *nc, | ||
444 | const struct GNUNET_MessageHeader *msg, | ||
445 | int can_drop) | ||
446 | { | ||
447 | struct ClientList *pos; | ||
448 | |||
449 | for (pos = nc->clients_head; NULL != pos; pos = pos->next) | ||
450 | do_unicast (nc, pos, msg, can_drop); | ||
451 | } | ||
452 | |||
453 | |||
454 | /** | ||
455 | * Return active number of subscribers in this context. | ||
456 | * | ||
457 | * @param nc context to query | ||
458 | * @return number of current subscribers | ||
459 | */ | ||
460 | unsigned int | ||
461 | GNUNET_SERVER_notification_context_get_size (struct GNUNET_SERVER_NotificationContext *nc) | ||
462 | { | ||
463 | unsigned int num; | ||
464 | struct ClientList *pos; | ||
465 | |||
466 | num = 0; | ||
467 | for (pos = nc->clients_head; NULL != pos; pos = pos->next) | ||
468 | num++; | ||
469 | return num; | ||
470 | } | ||
471 | |||
472 | /* end of server_nc.c */ | ||
diff --git a/src/util/server_tc.c b/src/util/server_tc.c deleted file mode 100644 index 8ae380a85..000000000 --- a/src/util/server_tc.c +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file util/server_tc.c | ||
23 | * @brief convenience functions for transmission of | ||
24 | * complex responses as a server | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | |||
32 | #define LOG(kind,...) GNUNET_log_from (kind, "util-server-tc", __VA_ARGS__) | ||
33 | |||
34 | |||
35 | /** | ||
36 | * How much buffer space do we want to have at least | ||
37 | * before transmitting another increment? | ||
38 | */ | ||
39 | #define MIN_BLOCK_SIZE 128 | ||
40 | |||
41 | |||
42 | |||
43 | struct GNUNET_SERVER_TransmitContext | ||
44 | { | ||
45 | /** | ||
46 | * Which client are we transmitting to? | ||
47 | */ | ||
48 | struct GNUNET_SERVER_Client *client; | ||
49 | |||
50 | /** | ||
51 | * Transmission buffer. (current offset for writing). | ||
52 | */ | ||
53 | char *buf; | ||
54 | |||
55 | /** | ||
56 | * Number of bytes in buf. | ||
57 | */ | ||
58 | size_t total; | ||
59 | |||
60 | /** | ||
61 | * Offset for writing in buf. | ||
62 | */ | ||
63 | size_t off; | ||
64 | |||
65 | /** | ||
66 | * Timeout for this request. | ||
67 | */ | ||
68 | struct GNUNET_TIME_Absolute timeout; | ||
69 | }; | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Helper function for incremental transmission of the response. | ||
74 | */ | ||
75 | static size_t | ||
76 | transmit_response (void *cls, size_t size, void *buf) | ||
77 | { | ||
78 | struct GNUNET_SERVER_TransmitContext *tc = cls; | ||
79 | size_t msize; | ||
80 | |||
81 | if (NULL == buf) | ||
82 | { | ||
83 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); | ||
84 | return 0; | ||
85 | } | ||
86 | if (tc->total - tc->off > size) | ||
87 | msize = size; | ||
88 | else | ||
89 | msize = tc->total - tc->off; | ||
90 | GNUNET_memcpy (buf, &tc->buf[tc->off], msize); | ||
91 | tc->off += msize; | ||
92 | if (tc->total == tc->off) | ||
93 | { | ||
94 | GNUNET_SERVER_receive_done (tc->client, GNUNET_OK); | ||
95 | GNUNET_SERVER_client_drop (tc->client); | ||
96 | GNUNET_free_non_null (tc->buf); | ||
97 | GNUNET_free (tc); | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | if (NULL == | ||
102 | GNUNET_SERVER_notify_transmit_ready (tc->client, | ||
103 | GNUNET_MIN (MIN_BLOCK_SIZE, | ||
104 | tc->total - tc->off), | ||
105 | GNUNET_TIME_absolute_get_remaining | ||
106 | (tc->timeout), &transmit_response, | ||
107 | tc)) | ||
108 | { | ||
109 | GNUNET_break (0); | ||
110 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); | ||
111 | } | ||
112 | } | ||
113 | return msize; | ||
114 | } | ||
115 | |||
116 | |||
117 | /** | ||
118 | * Create a new transmission context for the | ||
119 | * given client. | ||
120 | * | ||
121 | * @param client client to create the context for. | ||
122 | * @return NULL on error | ||
123 | */ | ||
124 | struct GNUNET_SERVER_TransmitContext * | ||
125 | GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client) | ||
126 | { | ||
127 | struct GNUNET_SERVER_TransmitContext *tc; | ||
128 | |||
129 | GNUNET_assert (NULL != client); | ||
130 | tc = GNUNET_new (struct GNUNET_SERVER_TransmitContext); | ||
131 | GNUNET_SERVER_client_keep (client); | ||
132 | tc->client = client; | ||
133 | return tc; | ||
134 | } | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Append a message to the transmission context. | ||
139 | * All messages in the context will be sent by | ||
140 | * the transmit_context_run method. | ||
141 | * | ||
142 | * @param tc context to use | ||
143 | * @param data what to append to the result message | ||
144 | * @param length length of data | ||
145 | * @param type type of the message | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext | ||
149 | *tc, const void *data, | ||
150 | size_t length, uint16_t type) | ||
151 | { | ||
152 | struct GNUNET_MessageHeader *msg; | ||
153 | size_t size; | ||
154 | |||
155 | GNUNET_assert (length < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
156 | size = length + sizeof (struct GNUNET_MessageHeader); | ||
157 | GNUNET_assert (size > length); | ||
158 | tc->buf = GNUNET_realloc (tc->buf, tc->total + size); | ||
159 | msg = (struct GNUNET_MessageHeader *) &tc->buf[tc->total]; | ||
160 | tc->total += size; | ||
161 | msg->size = htons (size); | ||
162 | msg->type = htons (type); | ||
163 | GNUNET_memcpy (&msg[1], data, length); | ||
164 | } | ||
165 | |||
166 | |||
167 | /** | ||
168 | * Append a message to the transmission context. | ||
169 | * All messages in the context will be sent by | ||
170 | * the transmit_context_run method. | ||
171 | * | ||
172 | * @param tc context to use | ||
173 | * @param msg message to append | ||
174 | */ | ||
175 | void | ||
176 | GNUNET_SERVER_transmit_context_append_message (struct | ||
177 | GNUNET_SERVER_TransmitContext | ||
178 | *tc, | ||
179 | const struct GNUNET_MessageHeader | ||
180 | *msg) | ||
181 | { | ||
182 | struct GNUNET_MessageHeader *m; | ||
183 | uint16_t size; | ||
184 | |||
185 | size = ntohs (msg->size); | ||
186 | tc->buf = GNUNET_realloc (tc->buf, tc->total + size); | ||
187 | m = (struct GNUNET_MessageHeader *) &tc->buf[tc->total]; | ||
188 | tc->total += size; | ||
189 | GNUNET_memcpy (m, msg, size); | ||
190 | } | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Execute a transmission context. If there is | ||
195 | * an error in the transmission, the #GNUNET_SERVER_receive_done() | ||
196 | * method will be called with an error code (#GNUNET_SYSERR), | ||
197 | * otherwise with #GNUNET_OK. | ||
198 | * | ||
199 | * @param tc transmission context to use | ||
200 | * @param timeout when to time out and abort the transmission | ||
201 | */ | ||
202 | void | ||
203 | GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc, | ||
204 | struct GNUNET_TIME_Relative timeout) | ||
205 | { | ||
206 | tc->timeout = GNUNET_TIME_relative_to_absolute (timeout); | ||
207 | if (NULL == | ||
208 | GNUNET_SERVER_notify_transmit_ready (tc->client, | ||
209 | GNUNET_MIN (MIN_BLOCK_SIZE, | ||
210 | tc->total), timeout, | ||
211 | &transmit_response, tc)) | ||
212 | { | ||
213 | GNUNET_break (0); | ||
214 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | |||
219 | /** | ||
220 | * Destroy a transmission context. This function must not be called | ||
221 | * after 'GNUNET_SERVER_transmit_context_run'. | ||
222 | * | ||
223 | * @param tc transmission context to destroy | ||
224 | * @param success code to give to 'GNUNET_SERVER_receive_done' for | ||
225 | * the client: GNUNET_OK to keep the connection open and | ||
226 | * continue to receive | ||
227 | * GNUNET_NO to close the connection (normal behavior) | ||
228 | * GNUNET_SYSERR to close the connection (signal | ||
229 | * serious error) | ||
230 | */ | ||
231 | void | ||
232 | GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext | ||
233 | *tc, int success) | ||
234 | { | ||
235 | GNUNET_SERVER_receive_done (tc->client, success); | ||
236 | GNUNET_SERVER_client_drop (tc->client); | ||
237 | GNUNET_free_non_null (tc->buf); | ||
238 | GNUNET_free (tc); | ||
239 | } | ||
240 | |||
241 | |||
242 | /* end of server_tc.c */ | ||
diff --git a/src/util/service.c b/src/util/service.c index b4d03c17c..800d09a42 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -1596,7 +1596,7 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh) | |||
1596 | * dropped. Additionally, clients can be dropped at any time using | 1596 | * dropped. Additionally, clients can be dropped at any time using |
1597 | * #GNUNET_SERVICE_client_drop(). | 1597 | * #GNUNET_SERVICE_client_drop(). |
1598 | * | 1598 | * |
1599 | * The service must be stopped using #GNUNET_SERVICE_stoP(). | 1599 | * The service must be stopped using #GNUNET_SERVICE_stop(). |
1600 | * | 1600 | * |
1601 | * @param service_name name of the service to run | 1601 | * @param service_name name of the service to run |
1602 | * @param cfg configuration to use | 1602 | * @param cfg configuration to use |
@@ -1609,7 +1609,7 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh) | |||
1609 | * @return NULL on error | 1609 | * @return NULL on error |
1610 | */ | 1610 | */ |
1611 | struct GNUNET_SERVICE_Handle * | 1611 | struct GNUNET_SERVICE_Handle * |
1612 | GNUNET_SERVICE_starT (const char *service_name, | 1612 | GNUNET_SERVICE_start (const char *service_name, |
1613 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1613 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1614 | GNUNET_SERVICE_ConnectHandler connect_cb, | 1614 | GNUNET_SERVICE_ConnectHandler connect_cb, |
1615 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | 1615 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, |
@@ -1637,12 +1637,12 @@ GNUNET_SERVICE_starT (const char *service_name, | |||
1637 | 1637 | ||
1638 | 1638 | ||
1639 | /** | 1639 | /** |
1640 | * Stops a service that was started with #GNUNET_SERVICE_starT(). | 1640 | * Stops a service that was started with #GNUNET_SERVICE_start(). |
1641 | * | 1641 | * |
1642 | * @param srv service to stop | 1642 | * @param srv service to stop |
1643 | */ | 1643 | */ |
1644 | void | 1644 | void |
1645 | GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv) | 1645 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv) |
1646 | { | 1646 | { |
1647 | struct GNUNET_SERVICE_Client *client; | 1647 | struct GNUNET_SERVICE_Client *client; |
1648 | 1648 | ||
@@ -1697,7 +1697,7 @@ GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv) | |||
1697 | * @return 0 on success, non-zero on error | 1697 | * @return 0 on success, non-zero on error |
1698 | */ | 1698 | */ |
1699 | int | 1699 | int |
1700 | GNUNET_SERVICE_ruN_ (int argc, | 1700 | GNUNET_SERVICE_run_ (int argc, |
1701 | char *const *argv, | 1701 | char *const *argv, |
1702 | const char *service_name, | 1702 | const char *service_name, |
1703 | enum GNUNET_SERVICE_Options options, | 1703 | enum GNUNET_SERVICE_Options options, |
diff --git a/src/util/test_client.c b/src/util/test_client.c index f60e5b7f7..527b400b0 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c | |||
@@ -179,7 +179,7 @@ main (int argc, | |||
179 | test_argv[2] = "test_client_unix.conf"; | 179 | test_argv[2] = "test_client_unix.conf"; |
180 | global_ret = 1; | 180 | global_ret = 1; |
181 | if (0 != | 181 | if (0 != |
182 | GNUNET_SERVICE_ruN_ (3, | 182 | GNUNET_SERVICE_run_ (3, |
183 | test_argv, | 183 | test_argv, |
184 | "test_client", | 184 | "test_client", |
185 | GNUNET_SERVICE_OPTION_NONE, | 185 | GNUNET_SERVICE_OPTION_NONE, |
diff --git a/src/util/test_service.c b/src/util/test_service.c index d2136b42f..1567c97ce 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -148,7 +148,7 @@ check (const char *sname) | |||
148 | sname); | 148 | sname); |
149 | global_ret = 1; | 149 | global_ret = 1; |
150 | GNUNET_assert (0 == | 150 | GNUNET_assert (0 == |
151 | GNUNET_SERVICE_ruN_ (3, | 151 | GNUNET_SERVICE_run_ (3, |
152 | argv, | 152 | argv, |
153 | sname, | 153 | sname, |
154 | GNUNET_SERVICE_OPTION_NONE, | 154 | GNUNET_SERVICE_OPTION_NONE, |
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index a9596752a..e74a0aa2f 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -77,7 +77,7 @@ | |||
77 | static boolean privilege_testing = FALSE; | 77 | static boolean privilege_testing = FALSE; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 80 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
81 | */ | 81 | */ |
82 | #define MAX_SIZE 65536 | 82 | #define MAX_SIZE 65536 |
83 | 83 | ||
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c index 02889d65b..4ed4e079e 100644 --- a/src/vpn/gnunet-helper-vpn.c +++ b/src/vpn/gnunet-helper-vpn.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #define DEBUG GNUNET_NO | 53 | #define DEBUG GNUNET_NO |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) | 56 | * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) |
57 | */ | 57 | */ |
58 | #define MAX_SIZE 65536 | 58 | #define MAX_SIZE 65536 |
59 | 59 | ||
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 4759f3746..d9daaa7e2 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -1839,7 +1839,7 @@ route_packet (struct DestinationEntry *destination, | |||
1839 | 1839 | ||
1840 | mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) + | 1840 | mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) + |
1841 | payload_length - sizeof (struct GNUNET_TUN_UdpHeader); | 1841 | payload_length - sizeof (struct GNUNET_TUN_UdpHeader); |
1842 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1842 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
1843 | { | 1843 | { |
1844 | GNUNET_break (0); | 1844 | GNUNET_break (0); |
1845 | return; | 1845 | return; |
@@ -1864,7 +1864,7 @@ route_packet (struct DestinationEntry *destination, | |||
1864 | 1864 | ||
1865 | mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) + | 1865 | mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) + |
1866 | alen + payload_length - sizeof (struct GNUNET_TUN_UdpHeader); | 1866 | alen + payload_length - sizeof (struct GNUNET_TUN_UdpHeader); |
1867 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1867 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
1868 | { | 1868 | { |
1869 | GNUNET_break (0); | 1869 | GNUNET_break (0); |
1870 | return; | 1870 | return; |
@@ -1904,7 +1904,7 @@ route_packet (struct DestinationEntry *destination, | |||
1904 | 1904 | ||
1905 | mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) + | 1905 | mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) + |
1906 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader); | 1906 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1907 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1907 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
1908 | { | 1908 | { |
1909 | GNUNET_break (0); | 1909 | GNUNET_break (0); |
1910 | return; | 1910 | return; |
@@ -1927,7 +1927,7 @@ route_packet (struct DestinationEntry *destination, | |||
1927 | 1927 | ||
1928 | mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) + | 1928 | mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) + |
1929 | alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); | 1929 | alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1930 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1930 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
1931 | { | 1931 | { |
1932 | GNUNET_break (0); | 1932 | GNUNET_break (0); |
1933 | return; | 1933 | return; |
@@ -1963,7 +1963,7 @@ route_packet (struct DestinationEntry *destination, | |||
1963 | 1963 | ||
1964 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + | 1964 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + |
1965 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader); | 1965 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1966 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1966 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
1967 | { | 1967 | { |
1968 | GNUNET_break (0); | 1968 | GNUNET_break (0); |
1969 | return; | 1969 | return; |
@@ -2038,7 +2038,7 @@ route_packet (struct DestinationEntry *destination, | |||
2038 | /* update length calculations, as payload_length may have changed */ | 2038 | /* update length calculations, as payload_length may have changed */ |
2039 | mlen = sizeof (struct GNUNET_EXIT_IcmpServiceMessage) + | 2039 | mlen = sizeof (struct GNUNET_EXIT_IcmpServiceMessage) + |
2040 | alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader); | 2040 | alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader); |
2041 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 2041 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
2042 | { | 2042 | { |
2043 | GNUNET_break (0); | 2043 | GNUNET_break (0); |
2044 | return; | 2044 | return; |
@@ -2168,7 +2168,7 @@ route_packet (struct DestinationEntry *destination, | |||
2168 | /* update length calculations, as payload_length may have changed */ | 2168 | /* update length calculations, as payload_length may have changed */ |
2169 | mlen = sizeof (struct GNUNET_EXIT_IcmpInternetMessage) + | 2169 | mlen = sizeof (struct GNUNET_EXIT_IcmpInternetMessage) + |
2170 | alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader); | 2170 | alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader); |
2171 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 2171 | if (mlen >= GNUNET_MAX_MESSAGE_SIZE) |
2172 | { | 2172 | { |
2173 | GNUNET_break (0); | 2173 | GNUNET_break (0); |
2174 | return; | 2174 | return; |