slen = strlen (service_name) + 1;
if (slen + sizeof (struct GNUNET_ARM_Message) >=
- GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
shc_chld =
GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
&sighandler_child_death);
- ret = GNUNET_SERVICE_ruN_ (argc,
+ ret = GNUNET_SERVICE_run_ (argc,
argv,
"arm",
GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope);
namelen = strlen (address->transport_name) + 1;
msize = address->address_length + namelen;
- if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+ if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (namelen >= GNUNET_MAX_MESSAGE_SIZE) )
{
/* address too large for us, this should not happen */
GNUNET_break (0);
msize = plugin_addr_len + plugin_name_length;
GNUNET_assert (sizeof (struct PeerInformationMessage) + msize
- < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ < GNUNET_MAX_MESSAGE_SIZE);
env = GNUNET_MQ_msg_extra (msg,
msize,
GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE);
if (NULL != prop)
GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope);
- GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_assert (msize < GNUNET_MAX_MESSAGE_SIZE);
msg = (struct PeerInformationMessage *) buf;
msg->header.size = htons (msize);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION);
/* check message size for sanity */
msize = ntohs (msg->size);
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct SendMessage))
+ if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SendMessage))
{
GNUNET_break (0);
GNUNET_MQ_impl_send_continue (mq);
h->handlers = GNUNET_MQ_copy_handlers (handlers);
h->hcnt = GNUNET_MQ_count_handlers (handlers);
GNUNET_assert (h->hcnt <
- (GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ (GNUNET_MAX_MESSAGE_SIZE -
sizeof (struct InitMessage)) / sizeof (uint16_t));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to CORE service\n");
{
size_t size = msize + sizeof (struct NotifyTrafficMessage);
- if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
struct DataMessage *dm;
union QueueContext qc;
- if (size + sizeof (*dm) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (size + sizeof (*dm) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
struct GNUNET_MQ_Envelope *env;
union QueueContext qc;
- if (sizeof (*dm) + size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (sizeof (*dm) + size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
return GNUNET_OK;
}
GNUNET_assert (sizeof (struct DataMessage) + size <
- GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_MAX_MESSAGE_SIZE);
env = GNUNET_MQ_msg_extra (dm,
size,
GNUNET_MESSAGE_TYPE_DATASTORE_DATA);
unsigned int max;
unsigned int transmission_offset;
- max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*msg))
+ max = (GNUNET_MAX_MESSAGE_SIZE - sizeof (*msg))
/ sizeof (struct GNUNET_HashCode);
transmission_offset = transmission_offset_start;
while (transmission_offset < gh->seen_results_end)
sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
if ( (msize < meta_length) ||
(get_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
(put_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
{
GNUNET_break (0);
return GNUNET_SYSERR;
struct GNUNET_DHT_PutHandle *ph;
msize = sizeof (struct GNUNET_DHT_ClientPutMessage) + size;
- if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
+ if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (size >= GNUNET_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return NULL;
size_t msize;
msize = sizeof (struct GNUNET_DHT_ClientGetMessage) + xquery_size;
- if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (xquery_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
+ if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (xquery_size >= GNUNET_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return NULL;
msize = sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size +
(get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (msize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
_("%s request received, but have no datacache!\n"), "PUT");
return;
}
- if (data_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (data_size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
UINT32_MAX);
}
msize = xquery_size + reply_bf_size;
- if (msize + sizeof (struct PeerGetMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (msize + sizeof (struct PeerGetMessage) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
GNUNET_free_non_null (reply_bf);
msize = data_size + (get_path_length + put_path_length) *
sizeof (struct GNUNET_PeerIdentity);
- if ((msize + sizeof (struct PeerResultMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ if ((msize + sizeof (struct PeerResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
(get_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
(put_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
- (data_size > GNUNET_SERVER_MAX_MESSAGE_SIZE))
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ (data_size > GNUNET_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return;
sizeof (struct PeerPutMessage) +
putlen * sizeof (struct GNUNET_PeerIdentity)) ||
(putlen >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
put_path_length) *
sizeof (struct GNUNET_PeerIdentity)) ||
(get_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
(put_path_length >
- GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
+ GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
return;
}
if (reply_length + sizeof (struct GNUNET_DNS_Response)
- >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
GNUNET_free (rh);
#include "gnunet_protocols.h"
/**
- * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
*/
#define MAX_SIZE 65536
}
reply_len += sizeof (struct GNUNET_TUN_UdpHeader);
reply_len += rr->payload_length;
- if (reply_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (reply_len >= GNUNET_MAX_MESSAGE_SIZE)
{
/* response too big, drop */
GNUNET_break (0); /* how can this be? */
struct GNUNET_MQ_Envelope *env;
struct GNUNET_DNS_Request *req;
- if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (sizeof (struct GNUNET_DNS_Request) + rr->payload_length >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
cleanup_rr (rr);
struct ConnectedPeer *peer;
struct GNUNET_MQ_Envelope *env;
- if (ntohs (msg->size) + sizeof (*sm) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (ntohs (msg->size) + sizeof (*sm) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
(unsigned int) distance);
size = sizeof (struct GNUNET_DV_ReceivedMessage) +
ntohs (message->size);
- if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0); /* too big */
return;
return;
}
if (sizeof (struct RouteMessage) + ntohs (payload->size)
- >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
}
len += sizeof (struct GNUNET_TUN_TcpHeader);
len += payload_length;
- if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (len >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
}
len += sizeof (struct GNUNET_TUN_IcmpHeader);
len += payload_length;
- if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (len >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
}
len += sizeof (struct GNUNET_TUN_UdpHeader);
len += payload_length;
- if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (len >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
mtcp->crc = 0;
mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + (pktlen - sizeof (struct GNUNET_TUN_TcpHeader));
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
static boolean privilege_testing = FALSE;
/**
- * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
*/
#define MAX_SIZE 65536
#define DEBUG GNUNET_NO
/**
- * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
*/
#define MAX_SIZE 65536
GNUNET_assert (fn != NULL);
slen = strlen (fn) + 1;
if (slen >=
- GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage))
+ GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_
{
kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri);
pc->reserve_entries += kc;
- pc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc;
+ pc->reserve_space += GNUNET_MAX_MESSAGE_SIZE * kc;
}
pi.status = GNUNET_FS_STATUS_PUBLISH_START;
*client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY;
- fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode);
+ fit = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode);
todo = GNUNET_MIN (fit,
left);
env = GNUNET_MQ_msg_extra (sm,
}
return;
}
- if (msize > GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (msize > GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
continue_writing (sc);
size_t msize;
GNUNET_assert (data_len + sizeof (struct PutMessage) <
- GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_MAX_MESSAGE_SIZE);
GNUNET_assert (peerreq->pr == pr);
prd = GSF_pending_request_get_data_ (pr);
if (NULL == data)
gettext_noop ("# replies received for other peers"),
1, GNUNET_NO);
msize = sizeof (struct PutMessage) + data_len;
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (msize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
fn = pos->filename;
slen = strlen (fn) + 1;
if (slen + sizeof (struct IndexInfoMessage) >=
- GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
break;
"Trying to lookup `%s' in GNS\n",
name);
nlen = strlen (name) + 1;
- if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*lr))
+ if (nlen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*lr))
{
GNUNET_break (0);
return NULL;
void *addrgen_cls,
int friend_only)
{
- char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - 256 -
+ char buffer[GNUNET_MAX_MESSAGE_SIZE - 1 - 256 -
sizeof (struct GNUNET_HELLO_Message)];
size_t max;
size_t used;
size_t nmemb,
void *ctx)
{
- static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
+ static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1];
const char *cbuf = ptr;
const struct GNUNET_MessageHeader *msg;
struct HelloOffer *ho;
left = total;
while ((left > 0) || (download_pos > 0))
{
- cpy = GNUNET_MIN (left, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - download_pos);
+ cpy = GNUNET_MIN (left, GNUNET_MAX_MESSAGE_SIZE - 1 - download_pos);
GNUNET_memcpy (&download_buffer[download_pos], cbuf, cpy);
cbuf += cpy;
download_pos += cpy;
#if 0
CURL_EASY_SETOPT (curl, CURLOPT_VERBOSE, 1);
#endif
- CURL_EASY_SETOPT (curl, CURLOPT_BUFFERSIZE, GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ CURL_EASY_SETOPT (curl, CURLOPT_BUFFERSIZE, GNUNET_MAX_MESSAGE_SIZE);
if (0 == strncmp (current_url, "http", 4))
CURL_EASY_SETOPT (curl, CURLOPT_USERAGENT, "GNUnet");
CURL_EASY_SETOPT (curl, CURLOPT_CONNECTTIMEOUT, 60L);
return NULL;
size = strlen (hostlist_uri) + 1;
if (size + sizeof (struct GNUNET_MessageHeader) >=
- GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
size_t slen;
slen = strlen (scopes) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IssueMessage))
{
GNUNET_break (0);
return NULL;
ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket);
slen = strlen (ticket_str) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct ExchangeMessage))
{
GNUNET_free (ticket_str);
GNUNET_break (0);
if (NULL == h->mq)
return NULL;
slen = strlen (service_name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage))
{
GNUNET_break (0);
return NULL;
if (NULL == h->mq)
return NULL;
slen = strlen (service_name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage))
{
GNUNET_break (0);
return NULL;
if (NULL == h->mq)
return NULL;
slen = strlen (name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage))
{
GNUNET_break (0);
return NULL;
return NULL;
slen_old = strlen (old_name) + 1;
slen_new = strlen (new_name) + 1;
- if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)) )
+ if ( (slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (slen_old + slen_new >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)) )
{
GNUNET_break (0);
return NULL;
if (NULL == h->mq)
return NULL;
slen = strlen (name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage))
{
GNUNET_break (0);
return NULL;
/**
* Maximum number of seconds over which bandwidth may "accumulate".
* Note that additionally, we also always allow at least
- * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate.
+ * #GNUNET_MAX_MESSAGE_SIZE to accumulate.
*/
uint32_t max_carry_s__;
};
/**
* Initialize bandwidth tracker. Note that in addition to the
* 'max_carry_s' limit, we also always allow at least
- * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
+ * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the
* bytes-per-second limit is so small that within 'max_carry_s' not
- * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
- * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
+ * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is
+ * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in
* bytes).
*
* @param av tracker to initialize
/**
* Initialize bandwidth tracker. Note that in addition to the
* 'max_carry_s' limit, we also always allow at least
- * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
+ * GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the
* bytes-per-second limit is so small that within 'max_carry_s' not
- * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
- * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
+ * even GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is
+ * ignored and replaced by GNUNET_MAX_MESSAGE_SIZE (which is in
* bytes).
*
* @param av tracker to initialize
#endif
#endif
+
+
/**
* Bandwidth (in/out) to assume initially (before either peer has
* communicated any particular preference). Should be rather low; set
/*
This file is part of GNUnet.
- Copyright (C) 2009-2013, 2016 GNUnet e.V.
+ Copyright (C) 2009-2013, 2016, 2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
#include "gnunet_configuration_lib.h"
#include "gnunet_mq_lib.h"
-/**
- * Largest supported message (to be precise, one byte more
- * than the largest possible message, so tests involving
- * this value should check for messages being smaller than
- * this value). NOTE: legacy name.
- */
-#define GNUNET_SERVER_MAX_MESSAGE_SIZE 65536
-
-/**
- * Smallest supported message. NOTE: legacy name.
- */
-#define GNUNET_SERVER_MIN_BUFFER_SIZE sizeof (struct GNUNET_MessageHeader)
-
-/**
- * Timeout we use on TCP connect before trying another
- * result from the DNS resolver. Actual value used
- * is this value divided by the number of address families.
- * Default is 5s. NOTE: legacy name.
- */
-#define GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-
/**
* Options for the service (bitmask).
-
-/**
- * Opaque handle for a service.
- */
-struct GNUNET_SERVICE_Context;
-
-
-/**
- * Run a service startup sequence within an existing
- * initialized system.
- *
- * @param service_name our service name
- * @param cfg configuration to use
- * @param options service options
- * @return NULL on error, service handle
- * @deprecated
- */
-struct GNUNET_SERVICE_Context *
-GNUNET_SERVICE_start (const char *service_name,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- enum GNUNET_SERVICE_Options options);
-
-
-/**
- * Get the NULL-terminated array of listen sockets for this service.
- *
- * @param ctx service context to query
- * @return NULL if there are no listen sockets, otherwise NULL-terminated
- * array of listen sockets.
- * @deprecated
- */
-struct GNUNET_NETWORK_Handle *const *
-GNUNET_SERVICE_get_listen_sockets (struct GNUNET_SERVICE_Context *ctx);
-
-
-/**
- * Stop a service that was started with #GNUNET_SERVICE_start.
- *
- * @param sctx the service context returned from the start function
- * @deprecated
- */
-void
-GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
-
-
/* **************** NEW SERVICE API ********************** */
/**
* dropped. Additionally, clients can be dropped at any time using
* #GNUNET_SERVICE_client_drop().
*
- * The service must be stopped using #GNUNET_SERVICE_stoP().
+ * The service must be stopped using #GNUNET_SERVICE_stop().
*
* @param service_name name of the service to run
* @param cfg configuration to use
* @return NULL on error
*/
struct GNUNET_SERVICE_Handle *
-GNUNET_SERVICE_starT (const char *service_name,
+GNUNET_SERVICE_start (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_SERVICE_ConnectHandler connect_cb,
GNUNET_SERVICE_DisconnectHandler disconnect_cb,
/**
- * Stops a service that was started with #GNUNET_SERVICE_starT().
+ * Stops a service that was started with #GNUNET_SERVICE_start().
*
* @param srv service to stop
*/
void
-GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv);
+GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv);
/**
* @return 0 on success, non-zero on error
*/
int
-GNUNET_SERVICE_ruN_ (int argc,
+GNUNET_SERVICE_run_ (int argc,
char *const *argv,
const char *service_name,
enum GNUNET_SERVICE_Options options,
struct GNUNET_MQ_MessageHandler mh[] = { \
__VA_ARGS__ \
}; \
- return GNUNET_SERVICE_ruN_ (argc, \
+ return GNUNET_SERVICE_run_ (argc, \
argv, \
service_name, \
service_options, \
#endif
#endif
+
+/**
+ * Largest supported message (to be precise, one byte more
+ * than the largest possible message, so tests involving
+ * this value should check for messages being smaller than
+ * this value).
+ */
+#define GNUNET_MAX_MESSAGE_SIZE 65536
+
+/**
+ * Smallest supported message.
+ */
+#define GNUNET_MIN_MESSAGE_SIZE sizeof (struct GNUNET_MessageHeader)
+
+
#include "gnunet_crypto_lib.h"
#include "gnunet_bandwidth_lib.h"
#include "gnunet_bio_lib.h"
name_len = (NULL == name) ? 0 : strlen (name) + 1;
rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
msg_size = sizeof (struct ZoneToNameResponseMessage) + name_len + rd_ser_len;
- if (msg_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (msg_size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
ztn_ctx->success = GNUNET_SYSERR;
buf = GNUNET_CONFIGURATION_serialize (cfg,
&size);
- if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*req))
+ if (size > GNUNET_MAX_MESSAGE_SIZE - sizeof (*req))
{
GNUNET_break (0);
GNUNET_free (buf);
len += addrlens[i];
str_len = strlen (config_section) + 1;
len += str_len;
- if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
+ if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
(num_addrs > UINT16_MAX) )
{
GNUNET_break (0);
int unlink_garbage,
struct ReadHostFileContext *r)
{
- char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
+ char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
ssize_t size_total;
struct GNUNET_TIME_Absolute now;
unsigned int left;
{
/* Copy public HELLO */
hs = GNUNET_HELLO_size (pos->hello);
- GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE -
sizeof (struct InfoMessage));
env = GNUNET_MQ_msg_extra (im,
hs,
{
/* Copy friend only HELLO */
hs = GNUNET_HELLO_size (pos->friend_only_hello);
- GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE -
sizeof (struct InfoMessage));
env = GNUNET_MQ_msg_extra (im,
hs,
const char *fn)
{
struct GNUNET_TIME_Absolute *now = cls;
- char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
+ char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
const struct GNUNET_HELLO_Message *hello;
struct GNUNET_HELLO_Message *new_hello;
int read_size;
GNUNET_assert (NULL != method_prefix);
uint16_t method_size = strnlen (method_prefix,
- GNUNET_SERVER_MAX_MESSAGE_SIZE
+ GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
GNUNET_assert ('\0' == method_prefix[method_size - 1]);
sr->op_id = GNUNET_OP_add (chn->op, op_recv_state_result, sr, NULL);
GNUNET_assert (NULL != name);
- size_t name_size = strnlen (name, GNUNET_SERVER_MAX_MESSAGE_SIZE
+ size_t name_size = strnlen (name, GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
struct GNUNET_MQ_Envelope *
env = GNUNET_MQ_msg_extra (req, name_size, type);
if (NULL != err_msg)
err_size = strnlen (err_msg,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*res) - 1) + 1;
+ GNUNET_MAX_MESSAGE_SIZE - sizeof (*res) - 1) + 1;
struct GNUNET_MQ_Envelope *
env = GNUNET_MQ_msg_extra (res, err_size,
GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE);
if (NULL == method_prefix)
method_prefix = "";
uint16_t method_size = strnlen (method_prefix,
- GNUNET_SERVER_MAX_MESSAGE_SIZE
+ GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
struct GNUNET_MQ_Envelope *
if (NULL == method_prefix)
method_prefix = "";
uint16_t method_size = strnlen (method_prefix,
- GNUNET_SERVER_MAX_MESSAGE_SIZE
+ GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
GNUNET_assert ('\0' == method_prefix[method_size - 1]);
if ( (get_path_length >= 65536) ||
(put_path_length >= 65536) ||
( (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity))
- + sizeof (struct ResultMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ + sizeof (struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
size_t slen;
slen = strlen (regex) + 1;
- if (slen + sizeof (struct AnnounceMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (slen + sizeof (struct AnnounceMessage) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Regex `%s' is too long!\n"),
struct GNUNET_REGEX_Search *s;
size_t slen = strlen (string) + 1;
- if (slen + sizeof (struct RegexSearchMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (slen + sizeof (struct RegexSearchMessage) >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Search string `%s' is too long!\n"),
size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) +
num_peers * sizeof (struct GNUNET_PeerIdentity);
- GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= size_needed);
+ GNUNET_assert (GNUNET_MAX_MESSAGE_SIZE >= size_needed);
ev = GNUNET_MQ_msg_extra (out_msg,
num_peers * sizeof (struct GNUNET_PeerIdentity),
size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) +
num_peers * sizeof (struct GNUNET_PeerIdentity);
- if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
+ if (GNUNET_MAX_MESSAGE_SIZE < size_needed)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Message received from client has size larger than expected\n");
n * sizeof (struct GNUNET_PeerIdentity);
/* The number of peers that fits in one message together with
* the respective header */
- num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ num_peers_max = (GNUNET_MAX_MESSAGE_SIZE -
sizeof (struct GNUNET_RPS_CS_SeedMessage)) /
sizeof (struct GNUNET_PeerIdentity);
tmp_peer_pointer = ids;
- while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
+ while (GNUNET_MAX_MESSAGE_SIZE < size_needed)
{
ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity),
GNUNET_MESSAGE_TYPE_RPS_CS_SEED);
num_peers * sizeof (struct GNUNET_PeerIdentity);
/* The number of peers that fit in one message together with
* the respective header */
- num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ num_peers_max = (GNUNET_MAX_MESSAGE_SIZE -
sizeof (struct GNUNET_RPS_CS_SeedMessage)) /
sizeof (struct GNUNET_PeerIdentity);
tmp_peer_pointer = peer_ids;
- while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
+ while (GNUNET_MAX_MESSAGE_SIZE < size_needed)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Too many peers to send at once, sending %" PRIu32 " (all we can so far)\n",
unsigned int i;
seed_msg_size = 8; /* sizeof (struct GNUNET_RPS_CS_SeedMessage) */
- num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - seed_msg_size) /
+ num_peers_max = (GNUNET_MAX_MESSAGE_SIZE - seed_msg_size) /
sizeof (struct GNUNET_PeerIdentity);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peers that fit in one seed msg; %u\n",
static void
seed_big_cb (struct RPSPeer *rps_peer)
{
- // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers
+ // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers
GNUNET_SCHEDULER_add_delayed (
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
seed_peers_big, rps_peer);
else if (strstr (argv[0], "_seed_big") != NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_MAX_MESSAGE_SIZE)\n");
num_peers = 1;
cur_test_run.name = "test-rps-seed-big";
cur_test_run.main_test = seed_big_cb;
GNUNET_free (h);
return NULL;
}
- possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobComputationMessage))
+ possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (struct BobComputationMessage))
/ sizeof (struct GNUNET_SCALARPRODUCT_Element);
todo = GNUNET_MIN (possible,
element_count);
element_count_transfered = todo;
GNUNET_MQ_send (h->mq,
env);
- possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg))
+ possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg))
/ sizeof (struct GNUNET_SCALARPRODUCT_Element);
while (element_count_transfered < element_count)
{
h->cfg = cfg;
h->key = *session_key;
- possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct AliceComputationMessage))
+ possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (struct AliceComputationMessage))
/ sizeof (struct GNUNET_SCALARPRODUCT_Element);
todo = GNUNET_MIN (possible,
element_count);
GNUNET_MQ_send (h->mq,
env);
element_count_transfered = todo;
- possible = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg))
+ possible = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*mmsg))
/ sizeof (struct GNUNET_SCALARPRODUCT_Element);
while (element_count_transfered < element_count)
{
GNUNET_assert (NULL != method_prefix);
struct MsgProcRequest *mpreq;
uint16_t method_size = strnlen (method_prefix,
- GNUNET_SERVER_MAX_MESSAGE_SIZE
+ GNUNET_MAX_MESSAGE_SIZE
- sizeof (*mpreq)) + 1;
GNUNET_assert ('\0' == method_prefix[method_size - 1]);
GNUNET_assert (NULL != method_prefix);
uint16_t method_size = strnlen (method_prefix,
- GNUNET_SERVER_MAX_MESSAGE_SIZE
+ GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
GNUNET_assert ('\0' == method_prefix[method_size - 1]);
look->op_id = GNUNET_OP_add (plc->op, &op_recv_state_result, look, NULL);
GNUNET_assert (NULL != name);
- size_t name_size = strnlen (name, GNUNET_SERVER_MAX_MESSAGE_SIZE
+ size_t name_size = strnlen (name, GNUNET_MAX_MESSAGE_SIZE
- sizeof (*req)) + 1;
struct GNUNET_MQ_Envelope *
env = GNUNET_MQ_msg_extra (req, name_size, type);
size_t relay_size = relay_count * sizeof (*relays);
size_t payload_size = name_size + password_size + relay_size;
- if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size)
+ if (GNUNET_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size)
return GNUNET_SYSERR;
struct GNUNET_MQ_Envelope *
struct ZoneAddNymRequest *nreq;
size_t name_size = strlen (name) + 1;
- if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*nreq) + name_size)
+ if (GNUNET_MAX_MESSAGE_SIZE < sizeof (*nreq) + name_size)
return GNUNET_SYSERR;
struct GNUNET_MQ_Envelope *
size = strlen (e->subsystem->service) + 1 +
strlen (e->name) + 1;
- GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
env = GNUNET_MQ_msg_extra (m,
size,
GNUNET_MESSAGE_TYPE_STATISTICS_VALUE);
slen = strlen (watch->subsystem) + 1;
nlen = strlen (watch->name) + 1;
nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen;
- if (nsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (nsize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
slen1 = strlen (subsystem) + 1;
slen2 = strlen (name) + 1;
GNUNET_assert (slen1 + slen2 + sizeof (struct GNUNET_MessageHeader) <
- GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_MAX_MESSAGE_SIZE);
ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle);
ai->sh = handle;
ai->subsystem = GNUNET_strdup (subsystem);
slen = strlen (h->subsystem) + 1;
nlen = strlen (name) + 1;
nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen;
- if (nsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (nsize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
/**
* The size of the buffer we fill before sending out the message
*/
-#define BUFFER_SIZE (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader))
+#define BUFFER_SIZE (GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader))
/**
* Connection handle for the logger service
static void
read_task (void *cls)
{
- char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
+ char buf[GNUNET_MAX_MESSAGE_SIZE];
ssize_t sread;
read_task_id = NULL;
LOG_DEBUG ("Launching testbed-barrier service\n");
barrier_map = GNUNET_CONTAINER_multihashmap_create (3,
GNUNET_YES);
- ctx = GNUNET_SERVICE_starT ("testbed-barrier",
+ ctx = GNUNET_SERVICE_start ("testbed-barrier",
cfg,
&connect_cb,
&disconnect_cb,
NULL));
GNUNET_CONTAINER_multihashmap_destroy (barrier_map);
GNUNET_assert (NULL != ctx);
- GNUNET_SERVICE_stoP (ctx);
+ GNUNET_SERVICE_stop (ctx);
}
GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */
msize = strlen (service_name) + 1;
msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage);
- if (GNUNET_SERVER_MAX_MESSAGE_SIZE < msize)
+ if (GNUNET_MAX_MESSAGE_SIZE < msize)
return NULL;
data = GNUNET_new (struct ManageServiceData);
data->cb = cb;
/* find applicable HELLOs */
fah.peer = pl;
fah.result = NULL;
- fah.max_size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1;
+ fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1;
fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_CONTAINER_multipeermap_iterate (peers,
&find_advertisable_hello,
ping.challenge = htonl (ve->challenge);
ping.target = *pid;
- if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (tsize >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
hsize = 0;
cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
ret = 1;
- if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= benchmark_size)
+ if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size)
{
FPRINTF (stderr,
"Message size too big!\n");
CURLOPT_CONNECTTIMEOUT_MS,
(long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL));
curl_easy_setopt (s->get.easyhandle, CURLOPT_BUFFERSIZE,
- 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ 2 * GNUNET_MAX_MESSAGE_SIZE);
#if CURL_TCP_NODELAY
curl_easy_setopt (ps->recv_endpoint,
CURLOPT_TCP_NODELAY,
CURLOPT_CONNECTTIMEOUT_MS,
(long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL));
curl_easy_setopt (s->put.easyhandle, CURLOPT_BUFFERSIZE,
- 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ 2 * GNUNET_MAX_MESSAGE_SIZE);
#if CURL_TCP_NODELAY
curl_easy_setopt (s->put.easyhandle, CURLOPT_TCP_NODELAY, 1);
#endif
timeout,
MHD_OPTION_CONNECTION_MEMORY_LIMIT,
(size_t) (2 *
- GNUNET_SERVER_MAX_MESSAGE_SIZE),
+ GNUNET_MAX_MESSAGE_SIZE),
MHD_OPTION_NOTIFY_COMPLETED,
&server_disconnect_cb, plugin,
MHD_OPTION_EXTERNAL_LOGGER,
*/
struct GNUNET_CONNECTION_Handle;
+/**
+ * @brief handle for a network service
+ */
+struct LEGACY_SERVICE_Context;
+
+
+/**
+ * Stops a service that was started with #GNUNET_SERVICE_start().
+ *
+ * @param srv service to stop
+ */
+void
+LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv);
+
+
/**
* Function called to notify a client about the connection begin ready
};
+
+/**
+ * Options for the service (bitmask).
+ */
+enum LEGACY_SERVICE_Options
+{
+ /**
+ * Use defaults. Terminates all client connections and the listen
+ * sockets immediately upon receiving the shutdown signal.
+ */
+ LEGACY_SERVICE_OPTION_NONE = 0,
+
+ /**
+ * Do not trigger server shutdown on signal at all; instead, allow
+ * for the user to terminate the server explicitly when needed
+ * by calling #LEGACY_SERVICE_shutdown().
+ */
+ LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN = 1,
+
+ /**
+ * Trigger a SOFT server shutdown on signals, allowing active
+ * non-monitor clients to complete their transactions.
+ */
+ LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN = 2
+};
+
+
+
/**
* Ask the server to disconnect from the given client. This is the
* same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done,
* @param cfg configuration to use
*/
typedef void
-(*GNUNET_SERVICE_Main) (void *cls,
+(*LEGACY_SERVICE_Main) (void *cls,
struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *cfg);
/**
* Handle to the network service.
*/
- struct GNUNET_SERVICE_Context *service;
+ struct LEGACY_SERVICE_Context *service;
/**
* Handle to the server for this service.
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
- struct GNUNET_SERVICE_Context *service;
+ struct LEGACY_SERVICE_Context *service;
unsigned long long aport;
unsigned long long bport;
unsigned long long max_connections;
aport = 0;
if (0 != bport)
{
- service = GNUNET_SERVICE_start ("transport-tcp",
+ service = LEGACY_SERVICE_start ("transport-tcp",
env->cfg,
- GNUNET_SERVICE_OPTION_NONE);
+ LEGACY_SERVICE_OPTION_NONE);
if (NULL == service)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
{
#ifdef TCP_STEALTH
plugin->myoptions |= TCP_OPTIONS_TCP_STEALTH;
- lsocks = GNUNET_SERVICE_get_listen_sockets (service);
+ lsocks = LEGACY_SERVICE_get_listen_sockets (service);
if (NULL != lsocks)
{
uint32_t len = sizeof (struct WelcomeMessage);
plugin->service = service;
if (NULL != service)
{
- plugin->server = GNUNET_SERVICE_get_server (service);
+ plugin->server = LEGACY_SERVICE_get_server (service);
}
else
{
GNUNET_NAT_unregister (plugin->nat);
GNUNET_CONTAINER_multipeermap_destroy (plugin->sessionmap);
if (NULL != service)
- GNUNET_SERVICE_stop (service);
+ LEGACY_SERVICE_stop (service);
GNUNET_free (plugin);
GNUNET_free_non_null (api);
return NULL;
}
if (NULL != plugin->service)
- GNUNET_SERVICE_stop (plugin->service);
+ LEGACY_SERVICE_stop (plugin->service);
else
GNUNET_SERVER_destroy (plugin->server);
GNUNET_free (plugin->handlers);
if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) &&
(NULL == plugin->sockv4) )
return GNUNET_SYSERR;
- if (udpmlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return GNUNET_SYSERR;
GNUNET_break (0);
return;
}
- if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (size >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
#include "gnunet_resolver_service.h"
+/**
+ * Timeout we use on TCP connect before trying another
+ * result from the DNS resolver. Actual value used
+ * is this value divided by the number of address families.
+ * Default is 5s.
+ */
+#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
+
#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
struct GNUNET_CONNECTION_Handle *connection;
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->sock = osSocket;
return connection;
return NULL;
}
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->addr = uaddr;
connection->addrlen = addrlen;
return;
}
GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap);
- delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT;
+ delay = CONNECT_RETRY_TIMEOUT;
if (NULL != connection->nth.notify_ready)
delay = GNUNET_TIME_relative_min (delay,
GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
GNUNET_assert (0 < strlen (hostname)); /* sanity check */
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = port;
connection->hostname = GNUNET_strdup (hostname);
connection->dns_active =
GNUNET_RESOLVER_ip_get (connection->hostname,
AF_UNSPEC,
- GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
+ CONNECT_RETRY_TIMEOUT,
&try_connect_using_address,
connection);
return connection;
#endif
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = 0;
connection->hostname = NULL;
return NULL;
}
GNUNET_assert (NULL != notify);
- GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off);
GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES));
client->receive_pending = GNUNET_YES;
GNUNET_CONNECTION_receive (client->connection,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
client->idle_timeout,
&process_incoming,
client);
client);
client->receive_pending = GNUNET_YES;
GNUNET_CONNECTION_receive (client->connection,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
GNUNET_TIME_absolute_get_remaining (end),
&process_incoming,
client);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Server begins to read again from client.\n");
client->receive_pending = GNUNET_YES;
GNUNET_CONNECTION_receive (client->connection,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
client->idle_timeout,
&process_incoming,
client);
n->callback (n->callback_cls, client);
client->receive_pending = GNUNET_YES;
GNUNET_CONNECTION_receive (client->connection,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
+ GNUNET_MAX_MESSAGE_SIZE - 1,
client->idle_timeout,
&process_incoming,
client);
struct GNUNET_SERVER_MessageStreamTokenizer *ret;
ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer);
- ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE);
- ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ ret->hdr = GNUNET_malloc (GNUNET_MIN_MESSAGE_SIZE);
+ ret->curr_buf = GNUNET_MIN_MESSAGE_SIZE;
ret->cb = cb;
ret->cb_cls = cb_cls;
return ret;
/**
* Context for "service_task".
*/
-struct GNUNET_SERVICE_Context
+struct LEGACY_SERVICE_Context
{
/**
* Our configuration.
/**
* Main service-specific task to run.
*/
- GNUNET_SERVICE_Main task;
+ LEGACY_SERVICE_Main task;
/**
* Closure for @e task.
/**
* Our options.
*/
- enum GNUNET_SERVICE_Options options;
+ enum LEGACY_SERVICE_Options options;
};
check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
const struct sockaddr *addr, socklen_t addrlen)
{
- struct GNUNET_SERVICE_Context *sctx = cls;
+ struct LEGACY_SERVICE_Context *sctx = cls;
const struct sockaddr_in *i4;
const struct sockaddr_in6 *i6;
int ret;
* @return name of the file for the process ID
*/
static char *
-get_pid_file_name (struct GNUNET_SERVICE_Context *sctx)
+get_pid_file_name (struct LEGACY_SERVICE_Context *sctx)
{
char *pif;
*/
static int
process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
- struct GNUNET_SERVICE_Context *sctx,
+ struct LEGACY_SERVICE_Context *sctx,
const char *option)
{
char *opt;
*/
static int
process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
- struct GNUNET_SERVICE_Context *sctx,
+ struct LEGACY_SERVICE_Context *sctx,
const char *option)
{
char *opt;
* set to NULL).
*/
int
-GNUNET_SERVICE_get_server_addresses (const char *service_name,
+LEGACY_SERVICE_get_server_addresses (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct sockaddr ***addrs,
socklen_t ** addr_lens)
* and #GNUNET_SYSERR on error.
*/
static int
-receive_sockets_from_parent (struct GNUNET_SERVICE_Context *sctx)
+receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
{
const char *env_buf;
int fail;
* @return #GNUNET_OK if configuration succeeded
*/
static int
-setup_service (struct GNUNET_SERVICE_Context *sctx)
+setup_service (struct LEGACY_SERVICE_Context *sctx)
{
struct GNUNET_TIME_Relative idleout;
int tolerant;
if ((NULL == sctx->lsocks) &&
(GNUNET_SYSERR ==
- GNUNET_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg,
+ LEGACY_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg,
&sctx->addrs, &sctx->addrlens)))
return GNUNET_SYSERR;
sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
* @return value of the 'USERNAME' option
*/
static char *
-get_user_name (struct GNUNET_SERVICE_Context *sctx)
+get_user_name (struct LEGACY_SERVICE_Context *sctx)
{
char *un;
* @return #GNUNET_OK on success (including no work to be done)
*/
static int
-write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
+write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
{
FILE *pidfd;
char *pif;
/**
* Task run during shutdown. Stops the server/service.
*
- * @param cls the `struct GNUNET_SERVICE_Context`
+ * @param cls the `struct LEGACY_SERVICE_Context`
*/
static void
shutdown_task (void *cls)
{
- struct GNUNET_SERVICE_Context *service = cls;
+ struct LEGACY_SERVICE_Context *service = cls;
struct GNUNET_SERVER_Handle *server = service->server;
service->shutdown_task = NULL;
- if (0 != (service->options & GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN))
+ if (0 != (service->options & LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN))
GNUNET_SERVER_stop_listening (server);
else
GNUNET_SERVER_destroy (server);
static void
service_task (void *cls)
{
- struct GNUNET_SERVICE_Context *sctx = cls;
+ struct LEGACY_SERVICE_Context *sctx = cls;
unsigned int i;
GNUNET_RESOLVER_connect (sctx->cfg);
#endif
- if (0 == (sctx->options & GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN))
+ if (0 == (sctx->options & LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN))
{
/* install a task that will kill the server
* process if the scheduler ever gets a shutdown signal */
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
-detach_terminal (struct GNUNET_SERVICE_Context *sctx)
+detach_terminal (struct LEGACY_SERVICE_Context *sctx)
{
#ifndef MINGW
pid_t pid;
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
-set_user_id (struct GNUNET_SERVICE_Context *sctx)
+set_user_id (struct LEGACY_SERVICE_Context *sctx)
{
char *user;
* @param sctx service context
*/
static void
-pid_file_delete (struct GNUNET_SERVICE_Context *sctx)
+pid_file_delete (struct LEGACY_SERVICE_Context *sctx)
{
char *pif = get_pid_file_name (sctx);
* if we shutdown nicely
*/
int
-GNUNET_SERVICE_run (int argc, char *const *argv,
+LEGACY_SERVICE_run (int argc, char *const *argv,
const char *service_name,
- enum GNUNET_SERVICE_Options options,
- GNUNET_SERVICE_Main task,
+ enum LEGACY_SERVICE_Options options,
+ LEGACY_SERVICE_Main task,
void *task_cls)
{
#define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0)
unsigned long long skew_offset;
unsigned long long skew_variance;
long long clock_offset;
- struct GNUNET_SERVICE_Context sctx;
+ struct LEGACY_SERVICE_Context sctx;
struct GNUNET_CONFIGURATION_Handle *cfg;
const char *xdg;
* @param options service options
* @return NULL on error, service handle
*/
-struct GNUNET_SERVICE_Context *
-GNUNET_SERVICE_start (const char *service_name,
+struct LEGACY_SERVICE_Context *
+LEGACY_SERVICE_start (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg,
- enum GNUNET_SERVICE_Options options)
+ enum LEGACY_SERVICE_Options options)
{
int i;
- struct GNUNET_SERVICE_Context *sctx;
+ struct LEGACY_SERVICE_Context *sctx;
- sctx = GNUNET_new (struct GNUNET_SERVICE_Context);
+ sctx = GNUNET_new (struct LEGACY_SERVICE_Context);
sctx->ready_confirm_fd = -1; /* no daemonizing */
sctx->ret = GNUNET_OK;
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
/* setup subsystems */
if (GNUNET_OK != setup_service (sctx))
{
- GNUNET_SERVICE_stop (sctx);
+ LEGACY_SERVICE_stop (sctx);
return NULL;
}
if (NULL != sctx->lsocks)
if (NULL == sctx->server)
{
- GNUNET_SERVICE_stop (sctx);
+ LEGACY_SERVICE_stop (sctx);
return NULL;
}
#ifndef WINDOWS
* @return handle to the server for this service, NULL if there is none
*/
struct GNUNET_SERVER_Handle *
-GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx)
+LEGACY_SERVICE_get_server (struct LEGACY_SERVICE_Context *ctx)
{
return ctx->server;
}
* array of listen sockets.
*/
struct GNUNET_NETWORK_Handle *const*
-GNUNET_SERVICE_get_listen_sockets (struct GNUNET_SERVICE_Context *ctx)
+LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx)
{
return ctx->lsocks;
}
/**
- * Stop a service that was started with "GNUNET_SERVICE_start".
+ * Stop a service that was started with "LEGACY_SERVICE_start".
*
* @param sctx the service context returned from the start function
*/
void
-GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx)
+LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
{
unsigned int i;
{
static int n;
unsigned int s;
- char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
+ char cbuf[GNUNET_MAX_MESSAGE_SIZE - 1];
if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (hdr->header.type))
return;
alen = address->address_length;
slen = strlen (address->transport_name) + 1;
- if ( (alen + slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE
+ if ( (alen + slen >= GNUNET_MAX_MESSAGE_SIZE
- sizeof (struct AddressLookupMessage)) ||
- (alen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+ (alen >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (slen >= GNUNET_MAX_MESSAGE_SIZE) )
{
GNUNET_break (0);
GNUNET_free (alc);
GNUNET_assert (GNUNET_YES == n->is_ready);
msize = ntohs (msg->size);
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*obm))
+ if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*obm))
{
GNUNET_break (0);
GNUNET_MQ_impl_send_continue (mq);
endif
if !MINGW
- TEST_CLIENT_UNIC_NC = test_client_unix.nc
+ TEST_CLIENT_UNIX_NC = test_client_unix.nc
else
- TEST_CLIENT_UNIC_NC =
+ TEST_CLIENT_UNIX_NC =
endif
if USE_COVERAGE
program.c \
resolver_api.c resolver.h \
scheduler.c \
- service_new.c \
+ service.c \
signal.c \
strings.c \
time.c \
}
/* negative current_consumption means that we have savings */
max_carry = ((uint64_t) av->available_bytes_per_s__) * av->max_carry_s__;
- if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE)
- max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE;
+ if (max_carry < GNUNET_MAX_MESSAGE_SIZE)
+ max_carry = GNUNET_MAX_MESSAGE_SIZE;
if (max_carry > INT64_MAX)
max_carry = INT64_MAX;
left_bytes = current_consumption + max_carry;
/**
* Initialize bandwidth tracker. Note that in addition to the
* 'max_carry_s' limit, we also always allow at least
- * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
+ * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the
* bytes-per-second limit is so small that within 'max_carry_s' not
- * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
- * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
+ * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is
+ * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in
* bytes).
*
* To stop notifications about updates and excess callbacks use
/**
* Initialize bandwidth tracker. Note that in addition to the
* 'max_carry_s' limit, we also always allow at least
- * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
+ * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the
* bytes-per-second limit is so small that within 'max_carry_s' not
- * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
- * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
+ * even #GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is
+ * ignored and replaced by #GNUNET_MAX_MESSAGE_SIZE (which is in
* bytes).
*
* @param av tracker to initialize
left_bytes = - av->consumption_since_last_update__;
max_carry = ((unsigned long long) av->available_bytes_per_s__) *
av->max_carry_s__;
- if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE)
- max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE;
+ if (max_carry < GNUNET_MAX_MESSAGE_SIZE)
+ max_carry = GNUNET_MAX_MESSAGE_SIZE;
if (max_carry > INT64_MAX)
max_carry = INT64_MAX;
if (max_carry > left_bytes)
#define LOG(kind,...) GNUNET_log_from (kind, "util-client",__VA_ARGS__)
+/**
+ * Timeout we use on TCP connect before trying another
+ * result from the DNS resolver. Actual value used
+ * is this value divided by the number of address families.
+ * Default is 5s.
+ */
+#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
+
/**
* Internal state for a client connected to a GNUnet service.
GNUNET_CONTAINER_DLL_insert (cstate->ap_head,
cstate->ap_tail,
ap);
- ap->task = GNUNET_SCHEDULER_add_write_net (GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
+ ap->task = GNUNET_SCHEDULER_add_write_net (CONNECT_RETRY_TIMEOUT,
ap->sock,
&connect_probe_continuation,
ap);
cstate->dns_active
= GNUNET_RESOLVER_ip_get (cstate->hostname,
AF_UNSPEC,
- GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
+ CONNECT_RETRY_TIMEOUT,
&try_connect_using_address,
cstate);
}
helper_read (void *cls)
{
struct GNUNET_HELPER_Handle *h = cls;
- char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN;
+ char buf[GNUNET_MAX_MESSAGE_SIZE] GNUNET_ALIGN;
ssize_t t;
h->read_task = NULL;
struct GNUNET_MessageStreamTokenizer *ret;
ret = GNUNET_new (struct GNUNET_MessageStreamTokenizer);
- ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE);
- ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE;
+ ret->hdr = GNUNET_malloc (GNUNET_MIN_MESSAGE_SIZE);
+ ret->curr_buf = GNUNET_MIN_MESSAGE_SIZE;
ret->cb = cb;
ret->cb_cls = cb_cls;
return ret;
slen = strlen (hostname) + 1;
if (slen + sizeof (struct GNUNET_RESOLVER_GetMessage) >=
- GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return NULL;
+++ /dev/null
-/*
- This file is part of GNUnet.
- Copyright (C) 2010 GNUnet e.V.
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-/**
- * @file util/server_mst.c
- * @brief convenience functions for handling inbound message buffers
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-
-#if HAVE_UNALIGNED_64_ACCESS
-#define ALIGN_FACTOR 4
-#else
-#define ALIGN_FACTOR 8
-#endif
-
-#define LOG(kind,...) GNUNET_log_from (kind, "util-server-mst", __VA_ARGS__)
-
-
-/**
- * Handle to a message stream tokenizer.
- */
-struct GNUNET_SERVER_MessageStreamTokenizer
-{
-
- /**
- * Function to call on completed messages.
- */
- GNUNET_SERVER_MessageTokenizerCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Size of the buffer (starting at @e hdr).
- */
- size_t curr_buf;
-
- /**
- * How many bytes in buffer have we already processed?
- */
- size_t off;
-
- /**
- * How many bytes in buffer are valid right now?
- */
- size_t pos;
-
- /**
- * Beginning of the buffer. Typed like this to force alignment.
- */
- struct GNUNET_MessageHeader *hdr;
-
-};
-
-
-
-/**
- * Create a message stream tokenizer.
- *
- * @param cb function to call on completed messages
- * @param cb_cls closure for @a cb
- * @return handle to tokenizer
- */
-struct GNUNET_SERVER_MessageStreamTokenizer *
-GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
- void *cb_cls)
-{
- struct GNUNET_SERVER_MessageStreamTokenizer *ret;
-
- ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer);
- ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE);
- ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->cb = cb;
- ret->cb_cls = cb_cls;
- return ret;
-}
-
-
-/**
- * Add incoming data to the receive buffer and call the
- * callback for all complete messages.
- *
- * @param mst tokenizer to use
- * @param client_identity ID of client for which this is a buffer
- * @param buf input data to add
- * @param size number of bytes in @a buf
- * @param purge should any excess bytes in the buffer be discarded
- * (i.e. for packet-based services like UDP)
- * @param one_shot only call callback once, keep rest of message in buffer
- * @return #GNUNET_OK if we are done processing (need more data)
- * #GNUNET_NO if @a one_shot was set and we have another message ready
- * #GNUNET_SYSERR if the data stream is corrupt
- */
-int
-GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
- void *client_identity,
- const char *buf, size_t size,
- int purge, int one_shot)
-{
- const struct GNUNET_MessageHeader *hdr;
- size_t delta;
- uint16_t want;
- char *ibuf;
- int need_align;
- unsigned long offset;
- int ret;
-
- GNUNET_assert (mst->off <= mst->pos);
- GNUNET_assert (mst->pos <= mst->curr_buf);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Server-mst receives %u bytes with %u bytes already in private buffer\n",
- (unsigned int) size, (unsigned int) (mst->pos - mst->off));
- ret = GNUNET_OK;
- ibuf = (char *) mst->hdr;
- while (mst->pos > 0)
- {
-do_align:
- GNUNET_assert (mst->pos >= mst->off);
- if ((mst->curr_buf - mst->off < sizeof (struct GNUNET_MessageHeader)) ||
- (0 != (mst->off % ALIGN_FACTOR)))
- {
- /* need to align or need more space */
- mst->pos -= mst->off;
- memmove (ibuf, &ibuf[mst->off], mst->pos);
- mst->off = 0;
- }
- if (mst->pos - mst->off < sizeof (struct GNUNET_MessageHeader))
- {
- delta =
- GNUNET_MIN (sizeof (struct GNUNET_MessageHeader) -
- (mst->pos - mst->off), size);
- GNUNET_memcpy (&ibuf[mst->pos], buf, delta);
- mst->pos += delta;
- buf += delta;
- size -= delta;
- }
- if (mst->pos - mst->off < sizeof (struct GNUNET_MessageHeader))
- {
- if (purge)
- {
- mst->off = 0;
- mst->pos = 0;
- }
- return GNUNET_OK;
- }
- hdr = (const struct GNUNET_MessageHeader *) &ibuf[mst->off];
- want = ntohs (hdr->size);
- if (want < sizeof (struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if ( (mst->curr_buf - mst->off < want) &&
- (mst->off > 0) )
- {
- /* can get more space by moving */
- mst->pos -= mst->off;
- memmove (ibuf, &ibuf[mst->off], mst->pos);
- mst->off = 0;
- }
- if (mst->curr_buf < want)
- {
- /* need to get more space by growing buffer */
- GNUNET_assert (0 == mst->off);
- mst->hdr = GNUNET_realloc (mst->hdr, want);
- ibuf = (char *) mst->hdr;
- mst->curr_buf = want;
- }
- hdr = (const struct GNUNET_MessageHeader *) &ibuf[mst->off];
- if (mst->pos - mst->off < want)
- {
- delta = GNUNET_MIN (want - (mst->pos - mst->off), size);
- GNUNET_assert (mst->pos + delta <= mst->curr_buf);
- GNUNET_memcpy (&ibuf[mst->pos], buf, delta);
- mst->pos += delta;
- buf += delta;
- size -= delta;
- }
- if (mst->pos - mst->off < want)
- {
- if (purge)
- {
- mst->off = 0;
- mst->pos = 0;
- }
- return GNUNET_OK;
- }
- if (one_shot == GNUNET_SYSERR)
- {
- /* cannot call callback again, but return value saying that
- * we have another full message in the buffer */
- ret = GNUNET_NO;
- goto copy;
- }
- if (one_shot == GNUNET_YES)
- one_shot = GNUNET_SYSERR;
- mst->off += want;
- if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr))
- return GNUNET_SYSERR;
- if (mst->off == mst->pos)
- {
- /* reset to beginning of buffer, it's free right now! */
- mst->off = 0;
- mst->pos = 0;
- }
- }
- GNUNET_assert (0 == mst->pos);
- while (size > 0)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Server-mst has %u bytes left in inbound buffer\n",
- (unsigned int) size);
- if (size < sizeof (struct GNUNET_MessageHeader))
- break;
- offset = (unsigned long) buf;
- need_align = (0 != (offset % ALIGN_FACTOR)) ? GNUNET_YES : GNUNET_NO;
- if (GNUNET_NO == need_align)
- {
- /* can try to do zero-copy and process directly from original buffer */
- hdr = (const struct GNUNET_MessageHeader *) buf;
- want = ntohs (hdr->size);
- if (want < sizeof (struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- mst->off = 0;
- return GNUNET_SYSERR;
- }
- if (size < want)
- break; /* or not: buffer incomplete, so copy to private buffer... */
- if (one_shot == GNUNET_SYSERR)
- {
- /* cannot call callback again, but return value saying that
- * we have another full message in the buffer */
- ret = GNUNET_NO;
- goto copy;
- }
- if (one_shot == GNUNET_YES)
- one_shot = GNUNET_SYSERR;
- if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr))
- return GNUNET_SYSERR;
- buf += want;
- size -= want;
- }
- else
- {
- /* need to copy to private buffer to align;
- * yes, we go a bit more spagetti than usual here */
- goto do_align;
- }
- }
-copy:
- if ((size > 0) && (!purge))
- {
- if (size + mst->pos > mst->curr_buf)
- {
- mst->hdr = GNUNET_realloc (mst->hdr, size + mst->pos);
- ibuf = (char *) mst->hdr;
- mst->curr_buf = size + mst->pos;
- }
- GNUNET_assert (size + mst->pos <= mst->curr_buf);
- GNUNET_memcpy (&ibuf[mst->pos], buf, size);
- mst->pos += size;
- }
- if (purge)
- {
- mst->off = 0;
- mst->pos = 0;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Server-mst leaves %u bytes in private buffer\n",
- (unsigned int) (mst->pos - mst->off));
- return ret;
-}
-
-
-/**
- * Destroys a tokenizer.
- *
- * @param mst tokenizer to destroy
- */
-void
-GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst)
-{
- GNUNET_free (mst->hdr);
- GNUNET_free (mst);
-}
-
-
-
-/* end of server_mst.c */
+++ /dev/null
-/*
- This file is part of GNUnet.
- Copyright (C) 2010 GNUnet e.V.
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-/**
- * @file util/server_nc.c
- * @brief convenience functions for transmission of
- * a notification stream
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-#define LOG(kind,...) GNUNET_log_from (kind, "util-server-nc", __VA_ARGS__)
-
-
-/**
- * Entry in list of messages pending to be transmitted.
- */
-struct PendingMessageList
-{
-
- /**
- * This is a doubly-linked list.
- */
- struct PendingMessageList *next;
-
- /**
- * This is a doubly-linked list.
- */
- struct PendingMessageList *prev;
-
- /**
- * Message to transmit (allocated at the end of this
- * struct, do not free)
- */
- const struct GNUNET_MessageHeader *msg;
-
- /**
- * Can this message be dropped?
- */
- int can_drop;
-
-};
-
-
-/**
- * Lists of clients we manage for notifications.
- */
-struct ClientList
-{
-
- /**
- * This is a doubly linked list.
- */
- struct ClientList *next;
-
- /**
- * This is a doubly linked list.
- */
- struct ClientList *prev;
-
- /**
- * Overall context this client belongs to.
- */
- struct GNUNET_SERVER_NotificationContext *nc;
-
- /**
- * Handle to the client.
- */
- struct GNUNET_SERVER_Client *client;
-
- /**
- * Handle for pending transmission request to the client (or NULL).
- */
- struct GNUNET_SERVER_TransmitHandle *th;
-
- /**
- * Head of linked list of requests queued for transmission.
- */
- struct PendingMessageList *pending_head;
-
- /**
- * Tail of linked list of requests queued for transmission.
- */
- struct PendingMessageList *pending_tail;
-
- /**
- * Number of messages currently in the list.
- */
- unsigned int num_pending;
-
-};
-
-
-/**
- * The notification context is the key datastructure for a convenience
- * API used for transmission of notifications to the client until the
- * client disconnects (or the notification context is destroyed, in
- * which case we disconnect these clients). Essentially, all
- * (notification) messages are queued up until the client is able to
- * read them.
- */
-struct GNUNET_SERVER_NotificationContext
-{
-
- /**
- * Server we do notifications for.
- */
- struct GNUNET_SERVER_Handle *server;
-
- /**
- * Head of list of clients receiving notifications.
- */
- struct ClientList *clients_head;
-
- /**
- * Tail of list of clients receiving notifications.
- */
- struct ClientList *clients_tail;
-
- /**
- * Maximum number of optional messages to queue per client.
- */
- unsigned int queue_length;
-
-};
-
-
-/**
- * Client has disconnected, clean up.
- *
- * @param cls our `struct GNUNET_SERVER_NotificationContext *`
- * @param client handle of client that disconnected
- */
-static void
-handle_client_disconnect (void *cls,
- struct GNUNET_SERVER_Client *client)
-{
- struct GNUNET_SERVER_NotificationContext *nc = cls;
- struct ClientList *pos;
- struct PendingMessageList *pml;
-
- if (NULL == client)
- {
- nc->server = NULL;
- return;
- }
- for (pos = nc->clients_head; NULL != pos; pos = pos->next)
- if (pos->client == client)
- break;
- if (NULL == pos)
- return;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Client disconnected, cleaning up %u messages in NC queue\n",
- pos->num_pending);
- GNUNET_CONTAINER_DLL_remove (nc->clients_head,
- nc->clients_tail,
- pos);
- while (NULL != (pml = pos->pending_head))
- {
- GNUNET_CONTAINER_DLL_remove (pos->pending_head,
- pos->pending_tail,
- pml);
- GNUNET_free (pml);
- pos->num_pending--;
- }
- if (NULL != pos->th)
- {
- GNUNET_SERVER_notify_transmit_ready_cancel (pos->th);
- pos->th = NULL;
- }
- GNUNET_SERVER_client_drop (client);
- GNUNET_assert (0 == pos->num_pending);
- GNUNET_free (pos);
-}
-
-
-/**
- * Create a new notification context.
- *
- * @param server server for which this function creates the context
- * @param queue_length maximum number of messages to keep in
- * the notification queue; optional messages are dropped
- * if the queue gets longer than this number of messages
- * @return handle to the notification context
- */
-struct GNUNET_SERVER_NotificationContext *
-GNUNET_SERVER_notification_context_create (struct GNUNET_SERVER_Handle *server,
- unsigned int queue_length)
-{
- struct GNUNET_SERVER_NotificationContext *ret;
-
- ret = GNUNET_new (struct GNUNET_SERVER_NotificationContext);
- ret->server = server;
- ret->queue_length = queue_length;
- GNUNET_SERVER_disconnect_notify (server,
- &handle_client_disconnect,
- ret);
- return ret;
-}
-
-
-/**
- * Destroy the context, force disconnect for all clients.
- *
- * @param nc context to destroy.
- */
-void
-GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_NotificationContext *nc)
-{
- struct ClientList *pos;
- struct PendingMessageList *pml;
-
- while (NULL != (pos = nc->clients_head))
- {
- GNUNET_CONTAINER_DLL_remove (nc->clients_head,
- nc->clients_tail,
- pos);
- if (NULL != pos->th)
- {
- GNUNET_SERVER_notify_transmit_ready_cancel (pos->th);
- pos->th = NULL;
- }
- GNUNET_SERVER_client_drop (pos->client);
- while (NULL != (pml = pos->pending_head))
- {
- GNUNET_CONTAINER_DLL_remove (pos->pending_head,
- pos->pending_tail,
- pml);
- GNUNET_free (pml);
- pos->num_pending--;
- }
- GNUNET_assert (0 == pos->num_pending);
- GNUNET_free (pos);
- }
- if (NULL != nc->server)
- GNUNET_SERVER_disconnect_notify_cancel (nc->server,
- &handle_client_disconnect,
- nc);
- GNUNET_free (nc);
-}
-
-
-/**
- * Add a client to the notification context.
- *
- * @param nc context to modify
- * @param client client to add
- */
-void
-GNUNET_SERVER_notification_context_add (struct GNUNET_SERVER_NotificationContext *nc,
- struct GNUNET_SERVER_Client *client)
-{
- struct ClientList *cl;
-
- for (cl = nc->clients_head; NULL != cl; cl = cl->next)
- if (cl->client == client)
- return; /* already present */
- cl = GNUNET_new (struct ClientList);
- GNUNET_CONTAINER_DLL_insert (nc->clients_head,
- nc->clients_tail,
- cl);
- cl->nc = nc;
- cl->client = client;
- GNUNET_SERVER_client_keep (client);
-}
-
-
-/**
- * Function called to notify a client about the socket begin ready to
- * queue more data. @a buf will be NULL and @a size zero if the socket
- * was closed for writing in the meantime.
- *
- * @param cls the `struct ClientList *`
- * @param size number of bytes available in @a buf
- * @param buf where the callee should write the message
- * @return number of bytes written to buf
- */
-static size_t
-transmit_message (void *cls,
- size_t size,
- void *buf)
-{
- struct ClientList *cl = cls;
- char *cbuf = buf;
- struct PendingMessageList *pml;
- uint16_t msize;
- size_t ret;
-
- cl->th = NULL;
- if (NULL == buf)
- {
- /* 'cl' should be freed via disconnect notification shortly */
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to transmit message from NC queue to client\n");
- return 0;
- }
- ret = 0;
- while (NULL != (pml = cl->pending_head))
- {
- msize = ntohs (pml->msg->size);
- if (size < msize)
- break;
- GNUNET_CONTAINER_DLL_remove (cl->pending_head,
- cl->pending_tail,
- pml);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Copying message of type %u and size %u from pending queue to transmission buffer\n",
- ntohs (pml->msg->type),
- msize);
- GNUNET_memcpy (&cbuf[ret], pml->msg, msize);
- ret += msize;
- size -= msize;
- GNUNET_free (pml);
- cl->num_pending--;
- }
- if (NULL != pml)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Have %u messages left in NC queue, will try transmission again\n",
- cl->num_pending);
- cl->th =
- GNUNET_SERVER_notify_transmit_ready (cl->client,
- ntohs (pml->msg->size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_message, cl);
- }
- else
- {
- GNUNET_assert (0 == cl->num_pending);
- }
- return ret;
-}
-
-
-/**
- * Send a message to a particular client.
- *
- * @param nc context to modify
- * @param client client to transmit to
- * @param msg message to send
- * @param can_drop can this message be dropped due to queue length limitations
- */
-static void
-do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
- struct ClientList *client,
- const struct GNUNET_MessageHeader *msg,
- int can_drop)
-{
- struct PendingMessageList *pml;
- uint16_t size;
-
- if ( (client->num_pending > nc->queue_length) &&
- (GNUNET_YES == can_drop) )
- {
- LOG (GNUNET_ERROR_TYPE_INFO,
- "Dropping message of type %u and size %u due to full queue (%u entries)\n",
- ntohs (msg->type), ntohs (msg->size), (unsigned int) nc->queue_length);
- return; /* drop! */
- }
- if (client->num_pending > nc->queue_length)
- {
- /* FIXME: consider checking for other messages in the
- * queue that are 'droppable' */
- }
- client->num_pending++;
- size = ntohs (msg->size);
- pml = GNUNET_malloc (sizeof (struct PendingMessageList) + size);
- pml->msg = (const struct GNUNET_MessageHeader *) &pml[1];
- pml->can_drop = can_drop;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Adding message of type %u and size %u to pending queue (which has %u entries)\n",
- ntohs (msg->type),
- ntohs (msg->size),
- (unsigned int) nc->queue_length);
- GNUNET_memcpy (&pml[1], msg, size);
- /* append */
- GNUNET_CONTAINER_DLL_insert_tail (client->pending_head,
- client->pending_tail,
- pml);
- if (NULL == client->th)
- client->th =
- GNUNET_SERVER_notify_transmit_ready (client->client,
- ntohs (client->pending_head->
- msg->size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_message, client);
-}
-
-
-/**
- * Send a message to a particular client; must have
- * already been added to the notification context.
- *
- * @param nc context to modify
- * @param client client to transmit to
- * @param msg message to send
- * @param can_drop can this message be dropped due to queue length limitations
- */
-void
-GNUNET_SERVER_notification_context_unicast (struct GNUNET_SERVER_NotificationContext *nc,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *msg,
- int can_drop)
-{
- struct ClientList *pos;
-
- for (pos = nc->clients_head; NULL != pos; pos = pos->next)
- if (pos->client == client)
- break;
- GNUNET_assert (NULL != pos);
- do_unicast (nc, pos, msg, can_drop);
-}
-
-
-/**
- * Send a message to all clients of this context.
- *
- * @param nc context to modify
- * @param msg message to send
- * @param can_drop can this message be dropped due to queue length limitations
- */
-void
-GNUNET_SERVER_notification_context_broadcast (struct
- GNUNET_SERVER_NotificationContext *nc,
- const struct GNUNET_MessageHeader *msg,
- int can_drop)
-{
- struct ClientList *pos;
-
- for (pos = nc->clients_head; NULL != pos; pos = pos->next)
- do_unicast (nc, pos, msg, can_drop);
-}
-
-
-/**
- * Return active number of subscribers in this context.
- *
- * @param nc context to query
- * @return number of current subscribers
- */
-unsigned int
-GNUNET_SERVER_notification_context_get_size (struct GNUNET_SERVER_NotificationContext *nc)
-{
- unsigned int num;
- struct ClientList *pos;
-
- num = 0;
- for (pos = nc->clients_head; NULL != pos; pos = pos->next)
- num++;
- return num;
-}
-
-/* end of server_nc.c */
+++ /dev/null
-/*
- This file is part of GNUnet.
- Copyright (C) 2009 GNUnet e.V.
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-/**
- * @file util/server_tc.c
- * @brief convenience functions for transmission of
- * complex responses as a server
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-
-#define LOG(kind,...) GNUNET_log_from (kind, "util-server-tc", __VA_ARGS__)
-
-
-/**
- * How much buffer space do we want to have at least
- * before transmitting another increment?
- */
-#define MIN_BLOCK_SIZE 128
-
-
-
-struct GNUNET_SERVER_TransmitContext
-{
- /**
- * Which client are we transmitting to?
- */
- struct GNUNET_SERVER_Client *client;
-
- /**
- * Transmission buffer. (current offset for writing).
- */
- char *buf;
-
- /**
- * Number of bytes in buf.
- */
- size_t total;
-
- /**
- * Offset for writing in buf.
- */
- size_t off;
-
- /**
- * Timeout for this request.
- */
- struct GNUNET_TIME_Absolute timeout;
-};
-
-
-/**
- * Helper function for incremental transmission of the response.
- */
-static size_t
-transmit_response (void *cls, size_t size, void *buf)
-{
- struct GNUNET_SERVER_TransmitContext *tc = cls;
- size_t msize;
-
- if (NULL == buf)
- {
- GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
- return 0;
- }
- if (tc->total - tc->off > size)
- msize = size;
- else
- msize = tc->total - tc->off;
- GNUNET_memcpy (buf, &tc->buf[tc->off], msize);
- tc->off += msize;
- if (tc->total == tc->off)
- {
- GNUNET_SERVER_receive_done (tc->client, GNUNET_OK);
- GNUNET_SERVER_client_drop (tc->client);
- GNUNET_free_non_null (tc->buf);
- GNUNET_free (tc);
- }
- else
- {
- if (NULL ==
- GNUNET_SERVER_notify_transmit_ready (tc->client,
- GNUNET_MIN (MIN_BLOCK_SIZE,
- tc->total - tc->off),
- GNUNET_TIME_absolute_get_remaining
- (tc->timeout), &transmit_response,
- tc))
- {
- GNUNET_break (0);
- GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
- }
- }
- return msize;
-}
-
-
-/**
- * Create a new transmission context for the
- * given client.
- *
- * @param client client to create the context for.
- * @return NULL on error
- */
-struct GNUNET_SERVER_TransmitContext *
-GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client)
-{
- struct GNUNET_SERVER_TransmitContext *tc;
-
- GNUNET_assert (NULL != client);
- tc = GNUNET_new (struct GNUNET_SERVER_TransmitContext);
- GNUNET_SERVER_client_keep (client);
- tc->client = client;
- return tc;
-}
-
-
-/**
- * Append a message to the transmission context.
- * All messages in the context will be sent by
- * the transmit_context_run method.
- *
- * @param tc context to use
- * @param data what to append to the result message
- * @param length length of data
- * @param type type of the message
- */
-void
-GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
- *tc, const void *data,
- size_t length, uint16_t type)
-{
- struct GNUNET_MessageHeader *msg;
- size_t size;
-
- GNUNET_assert (length < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- size = length + sizeof (struct GNUNET_MessageHeader);
- GNUNET_assert (size > length);
- tc->buf = GNUNET_realloc (tc->buf, tc->total + size);
- msg = (struct GNUNET_MessageHeader *) &tc->buf[tc->total];
- tc->total += size;
- msg->size = htons (size);
- msg->type = htons (type);
- GNUNET_memcpy (&msg[1], data, length);
-}
-
-
-/**
- * Append a message to the transmission context.
- * All messages in the context will be sent by
- * the transmit_context_run method.
- *
- * @param tc context to use
- * @param msg message to append
- */
-void
-GNUNET_SERVER_transmit_context_append_message (struct
- GNUNET_SERVER_TransmitContext
- *tc,
- const struct GNUNET_MessageHeader
- *msg)
-{
- struct GNUNET_MessageHeader *m;
- uint16_t size;
-
- size = ntohs (msg->size);
- tc->buf = GNUNET_realloc (tc->buf, tc->total + size);
- m = (struct GNUNET_MessageHeader *) &tc->buf[tc->total];
- tc->total += size;
- GNUNET_memcpy (m, msg, size);
-}
-
-
-/**
- * Execute a transmission context. If there is
- * an error in the transmission, the #GNUNET_SERVER_receive_done()
- * method will be called with an error code (#GNUNET_SYSERR),
- * otherwise with #GNUNET_OK.
- *
- * @param tc transmission context to use
- * @param timeout when to time out and abort the transmission
- */
-void
-GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
- struct GNUNET_TIME_Relative timeout)
-{
- tc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
- if (NULL ==
- GNUNET_SERVER_notify_transmit_ready (tc->client,
- GNUNET_MIN (MIN_BLOCK_SIZE,
- tc->total), timeout,
- &transmit_response, tc))
- {
- GNUNET_break (0);
- GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
- }
-}
-
-
-/**
- * Destroy a transmission context. This function must not be called
- * after 'GNUNET_SERVER_transmit_context_run'.
- *
- * @param tc transmission context to destroy
- * @param success code to give to 'GNUNET_SERVER_receive_done' for
- * the client: GNUNET_OK to keep the connection open and
- * continue to receive
- * GNUNET_NO to close the connection (normal behavior)
- * GNUNET_SYSERR to close the connection (signal
- * serious error)
- */
-void
-GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext
- *tc, int success)
-{
- GNUNET_SERVER_receive_done (tc->client, success);
- GNUNET_SERVER_client_drop (tc->client);
- GNUNET_free_non_null (tc->buf);
- GNUNET_free (tc);
-}
-
-
-/* end of server_tc.c */
* dropped. Additionally, clients can be dropped at any time using
* #GNUNET_SERVICE_client_drop().
*
- * The service must be stopped using #GNUNET_SERVICE_stoP().
+ * The service must be stopped using #GNUNET_SERVICE_stop().
*
* @param service_name name of the service to run
* @param cfg configuration to use
* @return NULL on error
*/
struct GNUNET_SERVICE_Handle *
-GNUNET_SERVICE_starT (const char *service_name,
+GNUNET_SERVICE_start (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_SERVICE_ConnectHandler connect_cb,
GNUNET_SERVICE_DisconnectHandler disconnect_cb,
/**
- * Stops a service that was started with #GNUNET_SERVICE_starT().
+ * Stops a service that was started with #GNUNET_SERVICE_start().
*
* @param srv service to stop
*/
void
-GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv)
+GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv)
{
struct GNUNET_SERVICE_Client *client;
* @return 0 on success, non-zero on error
*/
int
-GNUNET_SERVICE_ruN_ (int argc,
+GNUNET_SERVICE_run_ (int argc,
char *const *argv,
const char *service_name,
enum GNUNET_SERVICE_Options options,
test_argv[2] = "test_client_unix.conf";
global_ret = 1;
if (0 !=
- GNUNET_SERVICE_ruN_ (3,
+ GNUNET_SERVICE_run_ (3,
test_argv,
"test_client",
GNUNET_SERVICE_OPTION_NONE,
sname);
global_ret = 1;
GNUNET_assert (0 ==
- GNUNET_SERVICE_ruN_ (3,
+ GNUNET_SERVICE_run_ (3,
argv,
sname,
GNUNET_SERVICE_OPTION_NONE,
static boolean privilege_testing = FALSE;
/**
- * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
*/
#define MAX_SIZE 65536
#define DEBUG GNUNET_NO
/**
- * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ * Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
*/
#define MAX_SIZE 65536
mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) +
payload_length - sizeof (struct GNUNET_TUN_UdpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) +
alen + payload_length - sizeof (struct GNUNET_TUN_UdpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) +
payload_length - sizeof (struct GNUNET_TUN_TcpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) +
alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) +
payload_length - sizeof (struct GNUNET_TUN_TcpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
/* update length calculations, as payload_length may have changed */
mlen = sizeof (struct GNUNET_EXIT_IcmpServiceMessage) +
alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;
/* update length calculations, as payload_length may have changed */
mlen = sizeof (struct GNUNET_EXIT_IcmpInternetMessage) +
alen + payload_length - sizeof (struct GNUNET_TUN_IcmpHeader);
- if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if (mlen >= GNUNET_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
return;