49 const struct in_addr *
add)
56 while ((
list[i].network.s_addr != 0) || (
list[i].netmask.s_addr != 0))
58 if ((
add->s_addr &
list[i].netmask.s_addr) ==
59 (
list[i].network.s_addr &
list[i].netmask.s_addr))
76 const struct in6_addr *ip)
84 memset (&
zero, 0,
sizeof(
struct in6_addr));
87 while (0 != memcmp (&
zero, &
list[i].network,
sizeof(
struct in6_addr)))
89 for (j = 0; j <
sizeof(
struct in6_addr) / sizeof(
int); j++)
90 if (((((
int *) ip)[j] & ((
int *) &
list[i].netmask)[j])) !=
91 (((
int *) &
list[i].network)[j] & ((
int *) &
list[i].netmask)[j]))
292 { NULL, NULL, 0, 0 } };
311 const struct sockaddr *addr,
315 const struct sockaddr_in *i4;
316 const struct sockaddr_in6 *i6;
319 switch (addr->sa_family)
323 i4 = (
const struct sockaddr_in *) addr;
332 i6 = (
const struct sockaddr_in6 *) addr;
345 _ (
"Unknown address family %d\n"),
352 _ (
"Access from `%s' denied to service `%s'\n"),
410 _ (
"Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
451 _ (
"Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
475 socklen_t *saddrlens,
476 const char *unixpath,
480 struct sockaddr_un *un;
483 un->sun_family = AF_UNIX;
487 un->sun_path[0] =
'\0';
489 #if HAVE_SOCKADDR_UN_SUN_LEN
490 un->sun_len = (u_char)
sizeof(
struct sockaddr_un);
492 *saddrs = (
struct sockaddr *) un;
493 *saddrlens =
sizeof(
struct sockaddr_un);
526 struct sockaddr ***addrs,
527 socklen_t **addr_lens)
531 unsigned long long port;
533 struct addrinfo hints;
534 struct addrinfo *
res;
535 struct addrinfo *pos;
536 struct addrinfo *next;
541 struct sockaddr **saddrs;
542 socklen_t *saddrlens;
565 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
573 "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
594 _ (
"Require valid port number for service `%s' in configuration!\n"),
600 _ (
"Require valid port number for service `%s' in configuration!\n"),
626 (0 < strlen (unixpath)))
629 struct sockaddr_un s_un;
631 if (strlen (unixpath) >=
sizeof(s_un.sun_path))
634 _ (
"UNIXPATH `%s' too long, maximum length is %llu\n"),
636 (
unsigned long long)
sizeof(s_un.sun_path));
643 "USE_ABSTRACT_SOCKETS");
651 if (NULL != unixpath)
656 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
666 "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
680 if ((0 ==
port) && (NULL == unixpath))
684 "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
697 *addr_lens = saddrlens;
704 "Resolving `%s' since that is where `%s' will bind to.\n",
707 memset (&hints, 0,
sizeof(
struct addrinfo));
709 hints.ai_family = AF_INET;
710 hints.ai_protocol = IPPROTO_TCP;
715 _ (
"Failed to resolve `%s': %s\n"),
724 while (NULL != (pos = next))
727 if ((disablev6) && (pos->ai_family == AF_INET6))
734 _ (
"Failed to find %saddress for `%s'.\n"),
735 disablev6 ?
"IPv4 " :
"",
743 if (NULL != unixpath)
745 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
748 if (NULL != unixpath)
754 while (NULL != (pos = next))
757 if ((disablev6) && (AF_INET6 == pos->ai_family))
759 if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
761 if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
764 "Service `%s' will bind to `%s'\n",
767 if (AF_INET == pos->ai_family)
769 GNUNET_assert (
sizeof(
struct sockaddr_in) == pos->ai_addrlen);
770 saddrlens[i] = pos->ai_addrlen;
773 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
778 GNUNET_assert (
sizeof(
struct sockaddr_in6) == pos->ai_addrlen);
779 saddrlens[i] = pos->ai_addrlen;
782 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
797 if (NULL != unixpath)
800 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
802 if (NULL != unixpath)
807 saddrlens[i] =
sizeof(
struct sockaddr_in);
809 #if HAVE_SOCKADDR_IN_SIN_LEN
810 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[i];
812 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
813 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
819 if (NULL != unixpath)
821 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
824 if (NULL != unixpath)
829 saddrlens[i] =
sizeof(
struct sockaddr_in6);
831 #if HAVE_SOCKADDR_IN_SIN_LEN
832 ((
struct sockaddr_in6 *) saddrs[i])->sin6_len = saddrlens[0];
834 ((
struct sockaddr_in6 *) saddrs[i])->sin6_family = AF_INET6;
835 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
837 saddrlens[i] =
sizeof(
struct sockaddr_in);
839 #if HAVE_SOCKADDR_IN_SIN_LEN
840 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[1];
842 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
843 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
848 *addr_lens = saddrlens;
890 _ (
"Specified value for `%s' of service `%s' is invalid\n"),
910 _ (
"Specified value for `%s' of service `%s' is invalid\n"),
920 if ((NULL != (nfds =
getenv (
"LISTEN_FDS"))) &&
921 (1 == sscanf (nfds,
"%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
922 (cnt + 4 < FD_SETSIZE))
928 flags = fcntl (3 + cnt, F_GETFD);
929 if ((flags < 0) || (0 != (flags & FD_CLOEXEC)) ||
935 "Could not access pre-bound socket %u, will try to bind myself\n"),
936 (
unsigned int) 3 + cnt);
938 while (sctx->
lsocks[cnt] != NULL)
945 unsetenv (
"LISTEN_FDS");
948 if ((NULL == sctx->
lsocks) &&
1011 len = strlen (rdir);
1015 if (0 != access (rdir, F_OK))
1020 if ((NULL != user) && (0 < strlen (user)))
1023 if (0 != access (rdir, W_OK | X_OK))
1032 pidfd = fopen (pif,
"w");
1040 if (0 > fprintf (pidfd,
"%u",
pid))
1043 if ((NULL != user) && (0 < strlen (user)))
1062 service->shutdown_task = NULL;
1082 if (NULL != sctx->
lsocks)
1095 if (NULL == sctx->
server)
1097 if (NULL != sctx->
addrs)
1098 for (i = 0; NULL != sctx->
addrs[i]; i++)
1100 _ (
"Failed to start `%s' at `%s'\n"),
1107 if (NULL != sctx->
addrs)
1108 for (i = 0; NULL != sctx->
addrs[i]; i++)
1109 if ((AF_UNIX == sctx->
addrs[i]->sa_family) &&
1110 (
'\0' != ((
const struct sockaddr_un *) sctx->
addrs[i])->sun_path[0]))
1136 if (NULL != sctx->
addrs)
1139 while (NULL != sctx->
addrs[i])
1142 _ (
"Service `%s' runs at %s\n"),
1165 if (0 != pipe (filedes))
1183 if (1 != read (filedes[0], &c,
sizeof(
char)))
1193 _ (
"Service process failed to initialize\n"));
1198 _ (
"Service process could not initialize server function\n"));
1203 _ (
"Service process failed to report status\n"));
1211 nullfd = open (
"/dev/null", O_RDWR | O_APPEND);
1215 if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0))
1218 (void) close (nullfd);
1221 (void) close (nullfd);
1249 pws = getpwnam (user);
1253 _ (
"Cannot obtain information about user `%s': %s\n"),
1255 errno == 0 ?
_ (
"No such user") : strerror (errno));
1259 if ((0 != setgid (pws->pw_gid)) || (0 != setegid (pws->pw_gid)) ||
1261 (0 != initgroups (user, pws->pw_gid)) ||
1263 (0 != setuid (pws->pw_uid)) || (0 != seteuid (pws->pw_uid)))
1265 if ((0 != setregid (pws->pw_gid, pws->pw_gid)) ||
1266 (0 != setreuid (pws->pw_uid, pws->pw_uid)))
1269 _ (
"Cannot change user/group to `%s': %s\n"),
1294 if (0 != unlink (pif))
1321 #define HANDLE_ERROR \
1336 unsigned long long skew_offset;
1337 unsigned long long skew_variance;
1338 long long clock_offset;
1348 "do daemonize (detach from terminal)"),
1360 xdg =
getenv (
"XDG_CONFIG_HOME");
1369 memset (&sctx, 0,
sizeof(sctx));
1390 if (NULL == opt_cfg_fn)
1397 _ (
"Malformed configuration file `%s', exit ...\n"),
1407 _ (
"Malformed configuration, exit ...\n"));
1410 if (0 != strcmp (opt_cfg_fn, cfg_fn))
1412 _ (
"Could not access configuration file `%s'\n"),
1422 "Service `%s' runs with configuration from `%s'\n",
1434 clock_offset = skew_offset - skew_variance;
1442 if ((1 == do_daemonize) && (NULL != sctx.
server))
1465 struct mallinfo2 mi;
1475 if (NULL != sctx.
addrs)
1476 while (NULL != sctx.
addrs[i])
1524 if (NULL != sctx->
lsocks)
1538 if (NULL == sctx->
server)
1544 if (NULL != sctx->
addrs)
1545 for (i = 0; NULL != sctx->
addrs[i]; i++)
1546 if ((AF_UNIX == sctx->
addrs[i]->sa_family) &&
1547 (
'\0' != ((
const struct sockaddr_un *) sctx->
addrs[i])->sun_path[0]))
1614 struct mallinfo2 mi;
1627 if (NULL != sctx->
server)
1630 if (NULL != sctx->
addrs)
1633 while (NULL != sctx->
addrs[i])
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
#define LOG_STRERROR_FILE(kind, op, fn)
#define GAUGER(category, counter, value, unit)
#define gettext_noop(String)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static int list
Set if we should print a list of currently running services.
static char * config_file
Set to the name of the config file used.
static uint16_t port
Port number.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static int add
Desired action is to add a record.
#define LOG_STRERROR(kind, syscall)
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_FS_UnindexContext * uc
static char * service_name
Option -s: service name (hash to get service descriptor)
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Constants for network protocols.
Functions related to doing DNS lookups.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_change_owner(const char *filename, const char *user)
Change owner of a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
void GNUNET_DISK_fix_permissions(const char *fn, int require_uid_match, int require_gid_match)
Update POSIX permissions mask of a file on disk.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_cfgfile(char **fn)
Allow user to specify configuration file name (-c option)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_logfile(char **logfn)
Allow user to specify log file name (-l option)
int GNUNET_GETOPT_run(const char *binaryOptions, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv)
Parse the command line.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_help(const char *about)
Defining the option to print the command line help text (-h option).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_loglevel(char **level)
Define the '-L' log level option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_version(const char *version)
Define the option to print the version of the application (-v option)
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages).
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
char * GNUNET_NETWORK_shorten_unixpath(char *unixpath)
Given a unixpath that is too long (larger than UNIX_PATH_MAX), shorten it to an acceptable length whi...
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_box_native(int fd)
Box a native socket (and check that it is a socket).
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
#define GNUNET_MESSAGE_TYPE_TEST
Test if service is online.
void GNUNET_RESOLVER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create the connection to the resolver service.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_STRINGS_IPv6NetworkPolicy * GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX)
Parse an IPv6 network policy.
struct GNUNET_STRINGS_IPv4NetworkPolicy * GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX)
Parse an IPv4 network policy.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
static unsigned int size
Size of the "table".
void(* LEGACY_SERVICE_Main)(void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg)
Function called by the service's run method to run service-specific setup code.
void GNUNET_SERVER_destroy(struct GNUNET_SERVER_Handle *server)
Free resources held by this server.
LEGACY_SERVICE_Options
Options for the service (bitmask).
@ LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN
Trigger a SOFT server shutdown on signals, allowing active non-monitor clients to complete their tran...
@ LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN
Do not trigger server shutdown on signal at all; instead, allow for the user to terminate the server ...
struct GNUNET_SERVER_TransmitHandle * GNUNET_SERVER_notify_transmit_ready(struct GNUNET_SERVER_Client *client, size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify callback, void *callback_cls)
Notify us when the server has enough space to transmit a message of the given size to the given clien...
Credentials for UNIX domain sockets.
Definition of a command line option.
Entry in list of pending tasks.
handle for a client of the server
GNUNET_SERVER_MessageCallback callback
Function to call for messages of "type".
void * callback_cls
Closure argument for callback.
enum GNUNET_SERVICE_Options options
Our options.
IPV4 network in CIDR notation.
network in CIDR notation for IPV6.
Time for relative time used by GNUnet, in microseconds.
Context for "service_task".
struct GNUNET_STRINGS_IPv4NetworkPolicy * v4_allowed
IPv4 addresses that are allowed to connect (if not set, all are allowed).
LEGACY_SERVICE_Main task
Main service-specific task to run.
struct sockaddr ** addrs
NULL-terminated array of addresses to bind to, NULL if we got pre-bound listen sockets.
void * task_cls
Closure for task.
struct GNUNET_TIME_Relative timeout
Idle timeout for server.
struct GNUNET_STRINGS_IPv4NetworkPolicy * v4_denied
IPv4 addresses that are not allowed to connect.
struct GNUNET_STRINGS_IPv6NetworkPolicy * v6_denied
IPv6 addresses that are not allowed to connect.
struct GNUNET_STRINGS_IPv6NetworkPolicy * v6_allowed
IPv6 addresses that are allowed to connect (if not set, all are allowed).
int ret
Overall success/failure of the service start.
int ready_confirm_fd
If we are daemonizing, this FD is set to the pipe to the parent.
struct GNUNET_SERVER_Handle * server
Handle for the server.
int require_found
Do we close connections if we receive messages for which we have no handler?
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
int match_uid
Do we require a matching UID for UNIX domain socket connections? GNUNET_NO means that the UID does no...
const char * service_name
Name of our service.
struct GNUNET_SCHEDULER_Task * shutdown_task
Task ID of the shutdown task.
int match_gid
Do we require a matching GID for UNIX domain socket connections? Ignored if match_uid is GNUNET_YES.
struct GNUNET_NETWORK_Handle ** lsocks
NULL-terminated array of listen sockets we should take over.
struct GNUNET_SERVER_MessageHandler * my_handlers
My (default) message handlers.
socklen_t * addrlens
Array of the lengths of the entries in addrs.
enum LEGACY_SERVICE_Options options
Our options.
void GNUNET_SERVER_add_handlers(struct GNUNET_SERVER_Handle *server, const struct GNUNET_SERVER_MessageHandler *handlers)
Add additional handlers to an existing server.
struct GNUNET_SERVER_Handle * GNUNET_SERVER_create_with_sockets(GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_TIME_Relative idle_timeout, int require_found)
Create a new server.
void GNUNET_SERVER_receive_done(struct GNUNET_SERVER_Client *client, int success)
Resume receiving from this client, we are done processing the current request.
void GNUNET_SERVER_stop_listening(struct GNUNET_SERVER_Handle *server)
Stop the listen socket and get ready to shutdown the server once only 'monitor' clients are left.
struct GNUNET_SERVER_Handle * GNUNET_SERVER_create(GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct sockaddr *const *server_addr, const socklen_t *socklen, struct GNUNET_TIME_Relative idle_timeout, int require_found)
Create a new server.
void LEGACY_SERVICE_stop(struct LEGACY_SERVICE_Context *sctx)
Stop a service that was started with "LEGACY_SERVICE_start".
static int write_pid_file(struct LEGACY_SERVICE_Context *sctx, pid_t pid)
Write PID file.
static int check_access(void *cls, const struct GNUNET_CONNECTION_Credentials *uc, const struct sockaddr *addr, socklen_t addrlen)
Check if access to the service is allowed from the given address.
static int detach_terminal(struct LEGACY_SERVICE_Context *sctx)
Detach from terminal.
static void add_unixpath(struct sockaddr **saddrs, socklen_t *saddrlens, const char *unixpath, int abstract)
Add the given UNIX domain path as an address to the list (as the first entry).
static const struct GNUNET_SERVER_MessageHandler defhandlers[]
Default handlers for all services.
static int set_user_id(struct LEGACY_SERVICE_Context *sctx)
Set user ID.
static void handle_test(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
Handler for TEST message.
static void service_task(void *cls)
Initial task for the service.
static int setup_service(struct LEGACY_SERVICE_Context *sctx)
Setup addr, addrlen, idle_timeout based on configuration!
static void shutdown_task(void *cls)
Task run during shutdown.
static int check_ipv6_listed(const struct GNUNET_STRINGS_IPv6NetworkPolicy *list, const struct in6_addr *ip)
Check if the given IP address is in the list of IP addresses.
static char * get_user_name(struct LEGACY_SERVICE_Context *sctx)
Get the name of the user that'll be used to provide the service.
struct GNUNET_SERVER_Handle * LEGACY_SERVICE_get_server(struct LEGACY_SERVICE_Context *ctx)
Obtain the server used by a service.
struct GNUNET_NETWORK_Handle *const * LEGACY_SERVICE_get_listen_sockets(struct LEGACY_SERVICE_Context *ctx)
Get the NULL-terminated array of listen sockets for this service.
static size_t write_test(void *cls, size_t size, void *buf)
Send a 'TEST' message back to the client.
static int process_acl4(struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, struct LEGACY_SERVICE_Context *sctx, const char *option)
Parse an IPv4 access control list.
struct LEGACY_SERVICE_Context * LEGACY_SERVICE_start(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, enum LEGACY_SERVICE_Options options)
Run a service startup sequence within an existing initialized system.
static int process_acl6(struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, struct LEGACY_SERVICE_Context *sctx, const char *option)
Parse an IPv6 access control list.
static int check_ipv4_listed(const struct GNUNET_STRINGS_IPv4NetworkPolicy *list, const struct in_addr *add)
Check if the given IP address is in the list of IP addresses.
static char * get_pid_file_name(struct LEGACY_SERVICE_Context *sctx)
Get the name of the file where we will write the PID of the service.
static void pid_file_delete(struct LEGACY_SERVICE_Context *sctx)
Delete the PID file that was created by our parent.
int LEGACY_SERVICE_get_server_addresses(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, struct sockaddr ***addrs, socklen_t **addr_lens)
Get the list of addresses that a server for the given service should bind to.
int LEGACY_SERVICE_run(int argc, char *const *argv, const char *service_name, enum LEGACY_SERVICE_Options options, LEGACY_SERVICE_Main task, void *task_cls)
Run a standard GNUnet service startup sequence (initialize loggers and configuration,...