* FIXME: remove from struct
*/
struct GNUNET_NETWORK_Handle **lsocks;
+
+ /**
+ * If GNUNET_YES, consider unknown message types an error where the
+ * client is disconnected.
+ * FIXME: remove?
+ */
+ int require_found;
};
struct GNUNET_SERVICE_Client *prev;
/**
- * Server that this client belongs to.
+ * Service that this client belongs to.
*/
- struct GNUNET_SERVER_Handle *sh;
+ struct GNUNET_SERVICE_Handle *sh;
/**
* Socket of this client.
}
-/**
- * First task run by any service. Initializes our shutdown task,
- * starts the listening operation on our listen sockets and launches
- * the custom logic of the application service.
- *
- * @param cls our `struct GNUNET_SERVICE_Handle`
- */
-static void
-service_main (void *cls)
-{
- struct GNUNET_SERVICE_Handle *sh = cls;
-
- if (GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN != sh->options)
- GNUNET_SCHEDULER_add_shutdown (&service_shutdown,
- sh);
- GNUNET_SERVICE_resume (sh);
- sh->service_init_cb (sh->cb_cls,
- sh->cfg,
- sh);
-}
-
-
/**
* Parse an IPv4 access control list.
*
*/
static int
process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
- struct GNUNET_SERVICE_Context *sh,
+ struct GNUNET_SERVICE_Handle *sh,
const char *option)
{
char *opt;
*/
static int
process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
- struct GNUNET_SERVICE_Context *sh,
+ struct GNUNET_SERVICE_Handle *sh,
const char *option)
{
char *opt;
* and #GNUNET_SYSERR on error.
*/
static int
-receive_sockets_from_parent (struct GNUNET_SERVICE_Context *sh)
+receive_sockets_from_parent (struct GNUNET_SERVICE_Handle *sh)
{
const char *env_buf;
int fail;
int num;
num = get_server_addresses (sh->service_name, sh->cfg,
- &addrs, &addrlens)));
+ &addrs, &addrlens);
if (GNUNET_SYSERR == num)
return GNUNET_SYSERR;
unsigned long long skew_offset;
unsigned long long skew_variance;
long long clock_offset;
- struct GNUNET_SERVICE_Context sh;
struct GNUNET_CONFIGURATION_Handle *cfg;
+ int ret;
+ int err;
struct GNUNET_GETOPT_CommandLineOption service_options[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename),
goto shutdown;
}
if (GNUNET_OK != GNUNET_log_setup (service_name, loglev, logfile))
- HANDLE_ERROR;
+ {
+ GNUNET_break (0);
+ goto shutdown;
+ }
if (NULL == opt_cfg_filename)
opt_cfg_filename = GNUNET_strdup (cfg_filename);
if (GNUNET_YES == GNUNET_DISK_file_test (opt_cfg_filename))
err = 0;
GNUNET_SCHEDULER_run (&service_main, &sh);
/* shutdown */
- if ((1 == do_daemonize) && (NULL != sh.server))
+ if (1 == do_daemonize)
pid_file_delete (&sh);
- GNUNET_free_non_null (sh.my_handlers);
shutdown:
if (-1 != sh.ready_confirm_fd)
GNUNET_SPEEDUP_stop_ ();
GNUNET_CONFIGURATION_destroy (cfg);
- while (NULL != sh->slc_head)
+ while (NULL != sh.slc_head)
{
- struct ServiceListenContext *slc = sh->slc_head;
- sh->slc_head = slc->next;
+ struct ServiceListenContext *slc = sh.slc_head;
+ sh.slc_head = slc->next;
// FIXME: destroy slc
GNUNET_free (slc);
}
{
struct ServiceListenContext *slc;
- for (slc = slc_head; NULL != slc; slc = slc->next)
+ for (slc = sh->slc_head; NULL != slc; slc = slc->next)
{
if (NULL != slc->listen_task)
{
const struct GNUNET_MessageHeader *msg,
void *impl_state)
{
- struct GNUNET_SERVICE_Client *client = cls;
+ // struct GNUNET_SERVICE_Client *client = cls;
// FIXME 1: setup "client->send_task" for transmission.
// FIXME 2: I seriously hope we do not need to make a copy of `msg`!
service_mq_cancel (struct GNUNET_MQ_Handle *mq,
void *impl_state)
{
- struct GNUNET_SERVICE_Client *client = cls;
+ // struct GNUNET_SERVICE_Client *client = cls;
// FIXME: stop transmission! (must be possible, otherwise
// we must have told MQ that the message was sent!)
* the scope of this callback.
*
* @param cls closure with the `struct GNUNET_SERVICE_Client *`
- * @param client closure with the `struct GNUNET_SERVICE_Client *`
+ * @param client_cls closure with the `struct GNUNET_SERVICE_Client *`
* @param message the actual message
* @return #GNUNET_OK on success (always)
*/
static int
service_client_mst_cb (void *cls,
- void *client,
+ void *client_cls,
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVICE_Client *client = cls;
accept_client (void *cls)
{
struct ServiceListenContext *slc = cls;
+ struct GNUNET_SERVICE_Handle *sh = slc->sh;
slc->listen_task = NULL;
while (1)
&addrlen);
if (NULL == sock)
break;
- switch (sa.sa_family)
+ switch (sa.ss_family)
{
case AF_INET:
GNUNET_assert (addrlen == sizeof (struct sockaddr_in));
- v4 = (const struct sockaddr_in *) addr;
+ v4 = (const struct sockaddr_in *) &sa;
ok = ( ( (NULL == sh->v4_allowed) ||
(check_ipv4_listed (sh->v4_allowed,
- &i4->sin_addr))) &&
+ &v4->sin_addr))) &&
( (NULL == sh->v4_denied) ||
(! check_ipv4_listed (sh->v4_denied,
- &i4->sin_addr)) ) );
+ &v4->sin_addr)) ) );
break;
case AF_INET6:
GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
- v6 = (const struct sockaddr_in6 *) addr;
+ v6 = (const struct sockaddr_in6 *) &sa;
ok = ( ( (NULL == sh->v6_allowed) ||
(check_ipv6_listed (sh->v6_allowed,
- &i6->sin6_addr))) &&
+ &v6->sin6_addr))) &&
( (NULL == sh->v6_denied) ||
(! check_ipv6_listed (sh->v6_denied,
- &i6->sin6_addr)) ) );
+ &v6->sin6_addr)) ) );
break;
#ifndef WINDOWS
case AF_UNIX:
default:
LOG (GNUNET_ERROR_TYPE_WARNING,
_("Unknown address family %d\n"),
- addr->sa_family);
+ sa.ss_family);
return GNUNET_SYSERR;
}
if (! ok)
{
struct ServiceListenContext *slc;
- for (slc = slc_head; NULL != slc; slc = slc->next)
+ for (slc = sh->slc_head; NULL != slc; slc = slc->next)
{
GNUNET_assert (NULL == slc->listen_task);
slc->listen_task = GNUNET_SCHEDULER_add_read (slc->listen_socket,
GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c)
{
c->is_monitor = GNUNET_YES;
- if ( (GNUNET_YES == sh->got_shutdown) &&
- (GNUNET_NO == have_non_monitor_clients (sh)) )
- GNUNET_SERVICE_shutdown (sh);
+ if ( (GNUNET_YES == c->sh->got_shutdown) &&
+ (GNUNET_NO == have_non_monitor_clients (c->sh)) )
+ GNUNET_SERVICE_shutdown (c->sh);
}