{
sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (sched,
cfg,
- unixpath,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1);
+ unixpath);
GNUNET_free (unixpath);
if (sock != NULL)
return sock;
sock = GNUNET_CONNECTION_create_from_connect (sched,
cfg,
hostname,
- port,
- GNUNET_SERVER_MAX_MESSAGE_SIZE - 1);
+ port);
GNUNET_free (hostname);
return sock;
}
*/
char *write_buffer;
- /**
- * Max size of our write buffer.
- */
- size_t max_write_buffer_size;
-
/**
* Current size of our write buffer.
*/
*
* @param sched scheduler to use
* @param osSocket existing socket to box
- * @param maxbuf maximum write buffer size for the socket (use
- * 0 for sockets that need no write buffers, such as listen sockets)
* @return the boxed socket handle
*/
struct GNUNET_CONNECTION_Handle *
GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle
*sched,
struct GNUNET_NETWORK_Handle
- *osSocket, size_t maxbuf)
+ *osSocket)
{
struct GNUNET_CONNECTION_Handle *ret;
ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
- GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE);
ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->max_write_buffer_size = maxbuf;
ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
ret->sock = osSocket;
ret->sched = sched;
* @param access function to use to check if access is allowed
* @param access_cls closure for access
* @param lsock listen socket
- * @param maxbuf maximum write buffer size for the socket (use
- * 0 for sockets that need no write buffers, such as listen sockets)
* @return the socket handle, NULL on error
*/
struct GNUNET_CONNECTION_Handle *
*sched,
GNUNET_CONNECTION_AccessCheck access,
void *access_cls,
- struct GNUNET_NETWORK_Handle *lsock,
- size_t maxbuf)
+ struct GNUNET_NETWORK_Handle *lsock)
{
struct GNUNET_CONNECTION_Handle *ret;
char addr[128];
return NULL;
}
ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
-
- GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE);
ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->max_write_buffer_size = maxbuf;
ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
ret->addr = uaddr;
ret->addrlen = addrlen;
* @param cfg configuration to use
* @param hostname name of the host to connect to
* @param port port to connect to
- * @param maxbuf maximum write buffer size for the socket (use
- * 0 for sockets that need no write buffers, such as listen sockets)
* @return the socket handle
*/
struct GNUNET_CONNECTION_Handle *
GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched,
const struct
GNUNET_CONFIGURATION_Handle *cfg,
- const char *hostname, uint16_t port,
- size_t maxbuf)
+ const char *hostname, uint16_t port)
{
struct GNUNET_CONNECTION_Handle *ret;
ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
ret->cfg = cfg;
ret->sched = sched;
-
- GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE);
ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->max_write_buffer_size = maxbuf;
ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
ret->port = port;
ret->hostname = GNUNET_strdup (hostname);
* @param sched scheduler to use
* @param cfg configuration to use
* @param unixpath path to connect to
- * @param maxbuf maximum write buffer size for the socket (use
- * 0 for sockets that need no write buffers, such as listen sockets)
* @return the socket handle, NULL on systems without UNIX support
*/
struct GNUNET_CONNECTION_Handle *
GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched,
const struct
GNUNET_CONFIGURATION_Handle *cfg,
- const char *unixpath,
- size_t maxbuf)
+ const char *unixpath)
{
#ifdef AF_UNIX
struct GNUNET_CONNECTION_Handle *ret;
ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle));
ret->cfg = cfg;
ret->sched = sched;
- GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE);
ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->max_write_buffer_size = maxbuf;
ret->write_buffer = GNUNET_malloc(ret->write_buffer_size);
ret->port = 0;
ret->hostname = NULL;
* @param af_family address family to use
* @param serv_addr server address
* @param addrlen length of server address
- * @param maxbuf maximum write buffer size for the socket (use
- * 0 for sockets that need no write buffers, such as listen sockets)
* @return the socket handle
*/
struct GNUNET_CONNECTION_Handle *
GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle
*sched, int af_family,
const struct sockaddr *serv_addr,
- socklen_t addrlen, size_t maxbuf)
+ socklen_t addrlen)
{
struct GNUNET_NETWORK_Handle *s;
struct GNUNET_CONNECTION_Handle *ret;
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
return NULL;
}
- ret = GNUNET_CONNECTION_create_from_existing (sched, s, maxbuf);
+ ret = GNUNET_CONNECTION_create_from_existing (sched, s);
ret->addr = GNUNET_malloc (addrlen);
memcpy (ret->addr, serv_addr, addrlen);
ret->addrlen = addrlen;
if (sock->nth.notify_ready != NULL)
return NULL;
GNUNET_assert (notify != NULL);
- if ((sock->write_buffer_size < size) && (size < sock->max_write_buffer_size))
+ if ((sock->write_buffer_size < size) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE))
{
temp_size = sock->write_buffer_size + size;
- if (temp_size > sock->max_write_buffer_size)
- temp_size = sock->max_write_buffer_size;
+ if (temp_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ temp_size = GNUNET_SERVER_MAX_MESSAGE_SIZE;
sock->write_buffer = GNUNET_realloc(sock->write_buffer, temp_size);
sock->write_buffer_size = temp_size;
*/
struct GNUNET_TIME_Relative idle_timeout;
- /**
- * maximum write buffer size for accepted sockets
- */
- size_t maxbuf;
-
/**
* Task scheduled to do the listening.
*/
sock =
GNUNET_CONNECTION_create_from_accept (tc->sched, server->access,
server->access_cls,
- server->listen_sockets[i],
- server->maxbuf);
+ server->listen_sockets[i]);
if (sock != NULL)
{
#if DEBUG_SERVER
* @param access function for access control
* @param access_cls closure for access
* @param lsocks NULL-terminated array of listen sockets
- * @param maxbuf maximum write buffer size for accepted sockets
* @param idle_timeout after how long should we timeout idle connections?
* @param require_found if YES, connections sending messages of unknown type
* will be closed
GNUNET_SERVER_create_with_sockets (struct GNUNET_SCHEDULER_Handle *sched,
GNUNET_CONNECTION_AccessCheck access, void *access_cls,
struct GNUNET_NETWORK_Handle **lsocks,
- size_t maxbuf,
struct GNUNET_TIME_Relative
idle_timeout,
int require_found)
ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Handle));
ret->sched = sched;
- ret->maxbuf = maxbuf;
ret->idle_timeout = idle_timeout;
ret->listen_sockets = lsocks;
ret->access = access;
* @param access_cls closure for access
* @param serverAddr address to listen on (including port), NULL terminated array
* @param socklen length of serverAddr
- * @param maxbuf maximum write buffer size for accepted sockets
* @param idle_timeout after how long should we timeout idle connections?
* @param require_found if YES, connections sending messages of unknown type
* will be closed
void *access_cls,
struct sockaddr *const *serverAddr,
const socklen_t * socklen,
- size_t maxbuf,
struct GNUNET_TIME_Relative
idle_timeout, int require_found)
{
return GNUNET_SERVER_create_with_sockets (sched,
access, access_cls,
lsocks,
- maxbuf,
idle_timeout,
require_found);
}
client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client));
client->connection = connection;
- client->mst = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
- &client_message_tokenizer_callback,
+ client->mst = GNUNET_SERVER_mst_create (&client_message_tokenizer_callback,
server);
client->reference_count = 1;
client->server = server;
*/
size_t curr_buf;
- /**
- * Maximum size of the buffer.
- */
- size_t maxbuf;
-
/**
* How many bytes in buffer have we already processed?
*/
/**
* Create a message stream tokenizer.
*
- * @param maxbuf maximum message size to support (typically
- * GNUNET_SERVER_MAX_MESSAGE_SIZE - 1)
* @param cb function to call on completed messages
* @param cb_cls closure for cb
* @return handle to tokenizer
*/
struct GNUNET_SERVER_MessageStreamTokenizer *
-GNUNET_SERVER_mst_create (size_t maxbuf,
- GNUNET_SERVER_MessageTokenizerCallback cb,
+GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
void *cb_cls)
{
struct GNUNET_SERVER_MessageStreamTokenizer *ret;
ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_MessageStreamTokenizer));
ret->hdr = GNUNET_malloc(GNUNET_SERVER_MIN_BUFFER_SIZE);
ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE;
- ret->maxbuf = maxbuf;
ret->cb = cb;
ret->cb_cls = cb_cls;
return ret;
(unsigned int) size,
(unsigned int) (mst->pos - mst->off));
#endif
- if ((size > mst->curr_buf) && (size < mst->maxbuf)) /* Received bigger message than we can currently handle! */
+ if ((size > mst->curr_buf) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE)) /* Received bigger message than we can currently handle! */
{
newsize = mst->curr_buf + size; /* How much space do we need? */
- if (newsize > mst->maxbuf)
- newsize = mst->maxbuf; /* Check it's not bigger than maxbuf */
+ if (newsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ newsize = GNUNET_SERVER_MAX_MESSAGE_SIZE; /* Check it's not bigger than GNUNET_SERVER_MAX_MESSAGE_SIZE */
mst->hdr = GNUNET_realloc(mst->hdr, newsize);
mst->curr_buf = newsize;
*/
struct GNUNET_TIME_Relative timeout;
- /**
- * Maximum buffer size for the server.
- */
- size_t maxbuf;
-
/**
* Overall success/failure of the service start.
*/
/**
- * Setup addr, addrlen, maxbuf, idle_timeout
+ * Setup addr, addrlen, idle_timeout
* based on configuration!
*
* Configuration may specify:
* - PORT (where to bind to for TCP)
* - UNIXPATH (where to bind to for UNIX domain sockets)
* - TIMEOUT (after how many ms does an inactive service timeout);
- * - MAXBUF (maximum incoming message size supported)
* - DISABLEV6 (disable support for IPv6, otherwise we use dual-stack)
* - BINDTO (hostname or IP address to bind to, otherwise we take everything)
* - ACCEPT_FROM (only allow connections from specified IPv4 subnets)
static int
setup_service (struct GNUNET_SERVICE_Context *sctx)
{
- unsigned long long maxbuf;
struct GNUNET_TIME_Relative idleout;
int tolerant;
const char *lpid;
}
else
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
- if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
- sctx->serviceName, "MAXBUF"))
- {
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (sctx->cfg,
- sctx->serviceName,
- "MAXBUF", &maxbuf))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Specified value for `%s' of service `%s' is invalid\n"),
- "MAXBUF",
- sctx->serviceName);
- return GNUNET_SYSERR;
- }
- }
- else
- maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1;
if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
sctx->serviceName, "TOLERANT"))
&sctx->addrlens)) )
return GNUNET_SYSERR;
sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
- sctx->maxbuf = (size_t) maxbuf;
- if (sctx->maxbuf != maxbuf)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _
- ("Value in configuration for `%s' and service `%s' too large!\n"),
- "MAXBUF", sctx->serviceName);
- return GNUNET_SYSERR;
- }
process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM");
process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM");
&check_access,
sctx,
sctx->lsocks,
- sctx->maxbuf,
sctx->timeout, sctx->require_found);
else
sctx->server = GNUNET_SERVER_create (tc->sched,
sctx,
sctx->addrs,
sctx->addrlens,
- sctx->maxbuf,
sctx->timeout, sctx->require_found);
if (sctx->server == NULL)
{
sctx.ready_confirm_fd = -1;
sctx.ret = GNUNET_OK;
sctx.timeout = GNUNET_TIME_UNIT_FOREVER_REL;
- sctx.maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1;
sctx.task = task;
sctx.serviceName = serviceName;
sctx.cfg = cfg = GNUNET_CONFIGURATION_create ();
sctx->ready_confirm_fd = -1; /* no daemonizing */
sctx->ret = GNUNET_OK;
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
- sctx->maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE;
sctx->serviceName = serviceName;
sctx->cfg = cfg;
sctx->sched = sched;
&check_access,
sctx,
sctx->lsocks,
- sctx->maxbuf,
sctx->timeout, sctx->require_found);
else
sctx->server = GNUNET_SERVER_create (sched,
sctx,
sctx->addrs,
sctx->addrlens,
- sctx->maxbuf,
sctx->timeout,
sctx->require_found);
NULL,
sap,
slens,
- 1024,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 10000),
GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test accepts connection\n");
#endif
asock = GNUNET_CONNECTION_create_from_accept (tc->sched,
- NULL, NULL, ls, 1024);
+ NULL, NULL, ls);
GNUNET_assert (asock != NULL);
GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
#if VERBOSE
task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
ls = open_listen_socket ();
- lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls, 0);
+ lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls);
GNUNET_assert (lsock != NULL);
csock = GNUNET_CONNECTION_create_from_connect (tc->sched,
cfg,
- "localhost", PORT, 1024);
+ "localhost", PORT);
GNUNET_assert (csock != NULL);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n");
struct sockaddr_in expect;
asock = GNUNET_CONNECTION_create_from_accept (tc->sched,
- NULL, NULL, ls, 1024);
+ NULL, NULL, ls);
GNUNET_assert (asock != NULL);
GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
GNUNET_assert (GNUNET_OK ==
{
struct sockaddr_in v4;
ls = open_listen_socket ();
- lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls, 0);
+ lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls);
GNUNET_assert (lsock != NULL);
#if HAVE_SOCKADDR_IN_SIN_LEN
csock = GNUNET_CONNECTION_create_from_sockaddr (tc->sched,
AF_INET,
(const struct sockaddr
- *) &v4, sizeof (v4), 1024);
+ *) &v4, sizeof (v4));
GNUNET_assert (csock != NULL);
GNUNET_assert (NULL !=
GNUNET_CONNECTION_notify_transmit_ready (csock,
{
asock = GNUNET_CONNECTION_create_from_accept (tc->sched,
- NULL, NULL, ls, 1024);
+ NULL, NULL, ls);
GNUNET_assert (asock != NULL);
GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock));
GNUNET_CONNECTION_destroy (lsock, GNUNET_YES);
task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
ls = open_listen_socket ();
- lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls, 0);
+ lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls);
GNUNET_assert (lsock != NULL);
csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg,
- "localhost", PORT, 1024);
+ "localhost", PORT);
GNUNET_assert (csock != NULL);
GNUNET_SCHEDULER_add_read_net (tc->sched,
GNUNET_TIME_UNIT_FOREVER_REL,
{
ls = open_listen_socket ();
- lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls, 0);
+ lsock = GNUNET_CONNECTION_create_from_existing (tc->sched, ls);
GNUNET_assert (lsock != NULL);
csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg,
- "localhost", PORT, 1024);
+ "localhost", PORT);
GNUNET_assert (csock != NULL);
GNUNET_assert (NULL !=
GNUNET_CONNECTION_notify_transmit_ready (csock,
task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg,
- "localhost", PORT, 1024);
+ "localhost", PORT);
GNUNET_assert (csock != NULL);
GNUNET_assert (NULL !=
GNUNET_CONNECTION_notify_transmit_ready (csock,
struct GNUNET_CONNECTION_Handle *csock;
csock = GNUNET_CONNECTION_create_from_connect (tc->sched, cfg,
- "localhost", PORT, 1024);
+ "localhost", PORT);
GNUNET_assert (csock != NULL);
th = GNUNET_CONNECTION_notify_transmit_ready (csock,
12,
GNUNET_assert (ok == 3);
ok = 4;
- GNUNET_assert (size > sizeof (struct GNUNET_MessageHeader));
+ GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg.type = htons (MY_TYPE);
msg.size = htons (sizeof (struct GNUNET_MessageHeader));
memcpy (buf, &msg, sizeof (struct GNUNET_MessageHeader));
{
struct GNUNET_MessageHeader msg;
- GNUNET_assert (size > sizeof (struct GNUNET_MessageHeader));
+ GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg.type = htons (MY_TYPE2);
msg.size = htons (sizeof (struct GNUNET_MessageHeader));
memcpy (buf, &msg, sizeof (struct GNUNET_MessageHeader));
GNUNET_assert (ok == 1);
ok = 2;
- GNUNET_assert (size > sizeof (struct GNUNET_MessageHeader));
+ GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg.type = htons (MY_TYPE);
msg.size = htons (sizeof (struct GNUNET_MessageHeader));
memcpy (buf, &msg, sizeof (struct GNUNET_MessageHeader));
NULL,
sap,
slens,
- 1024,
TIMEOUT,
GNUNET_NO);
GNUNET_assert (server != NULL);
GNUNET_assert (ok == 1);
ok = 2;
- GNUNET_assert (size > sizeof (struct GNUNET_MessageHeader));
+ GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg.type = htons (MY_TYPE);
msg.size = htons (sizeof (struct GNUNET_MessageHeader));
memcpy (buf, &msg, sizeof (struct GNUNET_MessageHeader));
NULL,
sap,
slens,
- 1024,
TIMEOUT,
GNUNET_NO);
GNUNET_assert (server != NULL);
NULL,
sap,
slens,
- 1024,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 250),
GNUNET_NO);