GNUnet  0.11.x
Functions | Variables
gnunet-arm.c File Reference

arm for writing a tool More...

#include "platform.h"
#include "gnunet_arm_service.h"
#include "gnunet_constants.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-arm.c:

Go to the source code of this file.

Functions

static void delete_files ()
 Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete options were specified when gnunet-arm was run. More...
 
static void shutdown_task (void *cls)
 Main continuation-passing-style loop. More...
 
static const char * req_string (enum GNUNET_ARM_RequestStatus rs)
 Returns a string interpretation of rs. More...
 
static const char * ret_string (enum GNUNET_ARM_Result result)
 Returns a string interpretation of the result. More...
 
static void action_loop (void *cls)
 Main task that runs our various operations in order. More...
 
static void conn_status (void *cls, int connected)
 Function called whenever we connect to or disconnect from ARM. More...
 
static void start_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
 We have requested ARM to be started, this function is called with the result of the operation. More...
 
static void stop_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
 We have requested ARM to be stopped, this function is called with the result of the operation. More...
 
static void init_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
 We have requested a service to be started, this function is called with the result of the operation. More...
 
static void term_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
 We have requested a service to be stopped, this function is called with the result of the operation. More...
 
static void list_callback (void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const struct GNUNET_ARM_ServiceInfo *list)
 Function called with the list of running services. More...
 
static void srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
 Function called when a service starts or stops. More...
 
static void timeout_task_cb (void *cls)
 Task run on timeout (if -T is given). More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 The main function to obtain arm from gnunetd. More...
 

Variables

static int end
 Set if we are to shutdown all services (including ARM). More...
 
static int start
 Set if we are to start default services (including ARM). More...
 
static int restart
 Set if we are to stop/start default services (including ARM). More...
 
static int delete
 Set if we should delete configuration and temp directory on exit. More...
 
static int quiet
 Set if we should not print status messages. More...
 
static int show_all
 Set if we should print all services, including stopped ones. More...
 
static int monitor
 Monitor ARM activity. More...
 
static int list
 Set if we should print a list of currently running services. More...
 
static char * init
 Set to the name of a service to start. More...
 
static char * term
 Set to the name of a service to kill. More...
 
static char * config_file
 Set to the name of the config file used. More...
 
static char * dir
 Set to the directory where runtime files are stored. More...
 
static int ret
 Final status code. More...
 
static struct GNUNET_ARM_Handleh
 Connection with ARM. More...
 
static struct GNUNET_ARM_MonitorHandlem
 Monitor connection with ARM. More...
 
static struct GNUNET_CONFIGURATION_Handlecfg
 Our configuration. More...
 
static unsigned int phase
 Processing stage that we are in. More...
 
static struct GNUNET_TIME_Relative timeout
 User defined timestamp for completing operations. More...
 
static struct GNUNET_SCHEDULER_Tasktimeout_task
 Task to be run on timeout. More...
 
static int no_stdout
 Do we want to give our stdout to gnunet-service-arm? More...
 
static int no_stderr
 Do we want to give our stderr to gnunet-service-arm? More...
 
static struct GNUNET_SCHEDULER_Taskal_task
 Handle for the task running the action_loop(). More...
 
static struct GNUNET_ARM_Operationop
 Current operation. More...
 

Detailed Description

arm for writing a tool

Author
Christian Grothoff

Definition in file gnunet-arm.c.

Function Documentation

◆ delete_files()

static void delete_files ( )
static

Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete options were specified when gnunet-arm was run.

Definition at line 152 of file gnunet-arm.c.

References _, config_file, dir, GNUNET_DISK_directory_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, and GNUNET_OK.

Referenced by shutdown_task().

153 {
154  GNUNET_log (
156  "Will attempt to remove configuration file %s and service directory %s\n",
157  config_file,
158  dir);
159  if (0 != unlink (config_file))
160  {
162  _ ("Failed to remove configuration file %s\n"),
163  config_file);
164  }
166  {
168  _ ("Failed to remove servicehome directory %s\n"),
169  dir);
170  }
171 }
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
static char * config_file
Set to the name of the config file used.
Definition: gnunet-arm.c:84
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1029
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Main continuation-passing-style loop.

Runs the various jobs that we've been asked to do in order.

Parameters
clsclosure, unused

Definition at line 181 of file gnunet-arm.c.

References delete_files(), end, GNUNET_ARM_disconnect(), GNUNET_ARM_monitor_stop(), GNUNET_ARM_operation_cancel(), GNUNET_CONFIGURATION_destroy(), GNUNET_SCHEDULER_cancel(), and GNUNET_YES.

Referenced by run().

182 {
183  (void) cls;
184  if (NULL != al_task)
185  {
187  al_task = NULL;
188  }
189  if (NULL != op)
190  {
192  op = NULL;
193  }
194  if (NULL != h)
195  {
197  h = NULL;
198  }
199  if (NULL != m)
200  {
202  m = NULL;
203  }
204  if (NULL != timeout_task)
205  {
207  timeout_task = NULL;
208  }
209  if ( (GNUNET_YES == end) &&
210  (GNUNET_YES == delete) )
211  delete_files ();
213  cfg = NULL;
214 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
void GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
Abort an operation.
Definition: arm_api.c:794
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Definition: arm_api.c:604
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static void delete_files()
Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete opt...
Definition: gnunet-arm.c:152
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Definition: gnunet-arm.c:124
void GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
Disconnect from the ARM service (if connected) and destroy the context.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ req_string()

static const char* req_string ( enum GNUNET_ARM_RequestStatus  rs)
static

Returns a string interpretation of rs.

Parameters
rsthe request status from ARM
Returns
a string interpretation of the request status

Definition at line 224 of file gnunet-arm.c.

References _, GNUNET_ARM_REQUEST_DISCONNECTED, and GNUNET_ARM_REQUEST_SENT_OK.

Referenced by init_callback(), list_callback(), start_callback(), stop_callback(), and term_callback().

225 {
226  switch (rs)
227  {
229  return _ ("Message was sent successfully");
230 
232  return _ ("We disconnected from ARM before we could send a request");
233  }
234  return _ ("Unknown request status");
235 }
We disconnected from ARM, and request was not sent.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Message was sent successfully.
Here is the caller graph for this function:

◆ ret_string()

static const char* ret_string ( enum GNUNET_ARM_Result  result)
static

Returns a string interpretation of the result.

Parameters
resultthe arm result
Returns
a string interpretation

Definition at line 245 of file gnunet-arm.c.

References _, action_loop(), GNUNET_ARM_RESULT_IN_SHUTDOWN, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ARM_RESULT_IS_STARTING_ALREADY, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_IS_STOPPING_ALREADY, GNUNET_ARM_RESULT_START_FAILED, GNUNET_ARM_RESULT_STARTING, GNUNET_ARM_RESULT_STOPPED, and GNUNET_ARM_RESULT_STOPPING.

Referenced by init_callback(), start_callback(), stop_callback(), and term_callback().

246 {
247  switch (result)
248  {
250  return _ ("is stopped");
251 
253  return _ ("is starting");
254 
256  return _ ("is stopping");
257 
259  return _ ("is starting already");
260 
262  return _ ("is stopping already");
263 
265  return _ ("is started already");
266 
268  return _ ("is stopped already");
269 
271  return _ ("service is not known to ARM");
272 
274  return _ ("service failed to start");
275 
277  return _ ("service cannot be manipulated because ARM is shutting down");
278  }
279  return _ ("Unknown result code.");
280 }
ARM stopping was initiated (there's no "stopped" for ARM itself).
Asked to stop it, but it's already stopping.
Asked to start it, but it's already started.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Tried to start a service, but that failed for some reason.
Service starting was initiated.
Asked to start it, but it's already starting.
static int result
Global testing status.
Asked to start something, but ARM is shutting down and can't comply.
Asked to stop it, but it's already stopped.
Asked to start or stop a service, but it's not known.
Service was stopped (never sent for ARM itself).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ action_loop()

static void action_loop ( void *  cls)
static

Main task that runs our various operations in order.

Main action loop.

Parameters
clsclosure

Runs the various jobs that we've been asked to do, in order.

Parameters
clsclosure, unused

Definition at line 728 of file gnunet-arm.c.

References _, end, GNUNET_ARM_request_service_list(), GNUNET_ARM_request_service_start(), GNUNET_ARM_request_service_stop(), GNUNET_CLIENT_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OS_INHERIT_STD_ERR, GNUNET_OS_INHERIT_STD_NONE, GNUNET_OS_INHERIT_STD_OUT, GNUNET_SCHEDULER_shutdown(), GNUNET_YES, init, init_callback(), list, list_callback(), monitor, no_stderr, no_stdout, phase, quiet, restart, start, start_callback(), stop_callback(), term, and term_callback().

Referenced by init_callback(), list_callback(), ret_string(), run(), start_callback(), stop_callback(), and term_callback().

729 {
730  (void) cls;
731  al_task = NULL;
733  "Running requested actions\n");
734  while (1)
735  {
736  switch (phase++)
737  {
738  case 0:
739  if (NULL != term)
740  {
742  "Termination action\n");
744  term,
745  &term_callback,
746  NULL);
747  return;
748  }
749  break;
750 
751  case 1:
752  if (end || restart)
753  {
754  if (GNUNET_YES !=
756  "arm"))
757  {
759  "GNUnet not running, cannot stop the peer\n");
760  }
761  else
762  {
764  "End action\n");
766  "arm",
767  &stop_callback,
768  NULL);
769  return;
770  }
771  }
772  break;
773 
774  case 2:
775  if (start)
776  {
778  "Start action\n");
779  op =
781  "arm",
782  (no_stdout
783  ? 0
785  | (no_stderr
786  ? 0
789  NULL);
790  return;
791  }
792  break;
793 
794  case 3:
795  if (NULL != init)
796  {
798  "Initialization action\n");
800  init,
802  &init_callback,
803  NULL);
804  return;
805  }
806  break;
807 
808  case 4:
809  if (list)
810  {
812  "Going to list all running services controlled by ARM.\n");
814  &list_callback,
815  &list);
816  return;
817  }
818  break;
819 
820  case 5:
821  if (monitor)
822  {
823  if (! quiet)
824  fprintf (stderr,
825  _ ("Now only monitoring, press CTRL-C to stop.\n"));
826  quiet =
827  0; /* does not make sense to stay quiet in monitor mode at this time */
828  return; /* done with tasks, just monitor */
829  }
830  break;
831 
832  default: /* last phase */
834  return;
835  }
836  }
837 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:91
static unsigned int phase
Processing stage that we are in.
Definition: gnunet-arm.c:114
static void list_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const struct GNUNET_ARM_ServiceInfo *list)
Function called with the list of running services.
Definition: gnunet-arm.c:531
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static void stop_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be stopped, this function is called with the result of the operation...
Definition: gnunet-arm.c:375
static int restart
Set if we are to stop/start default services (including ARM).
Definition: gnunet-arm.c:44
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static void start_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be started, this function is called with the result of the operation...
Definition: gnunet-arm.c:332
static int quiet
Set if we should not print status messages.
Definition: gnunet-arm.c:54
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static char * term
Set to the name of a service to kill.
Definition: gnunet-arm.c:79
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
Definition: arm_api.c:1039
No standard streams should be inherited.
Definition: gnunet_os_lib.h:73
When this flag is set, the child process will inherit stdout of the parent.
Definition: gnunet_os_lib.h:85
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_list(struct GNUNET_ARM_Handle *h, GNUNET_ARM_ServiceListCallback cont, void *cont_cls)
Request a list of running services.
Definition: arm_api.c:1074
int GNUNET_CLIENT_test(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name)
Test if the port or UNIXPATH of the given service_name is in use and thus (most likely) the respectiv...
Definition: client.c:892
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
Definition: arm_api.c:930
static void init_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be started, this function is called with the result of the operation...
Definition: gnunet-arm.c:431
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
static void term_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be stopped, this function is called with the result of the operation...
Definition: gnunet-arm.c:478
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:64
static int no_stderr
Do we want to give our stderr to gnunet-service-arm?
Definition: gnunet-arm.c:134
#define GNUNET_log(kind,...)
static int no_stdout
Do we want to give our stdout to gnunet-service-arm?
Definition: gnunet-arm.c:129
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ conn_status()

static void conn_status ( void *  cls,
int  connected 
)
static

Function called whenever we connect to or disconnect from ARM.

Termiantes the process if we fail to connect to the service on our first attempt.

Parameters
clsclosure
connectedGNUNET_YES if connected, GNUNET_NO if disconnected, GNUNET_SYSERR on error.

Definition at line 302 of file gnunet-arm.c.

References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, and once.

Referenced by GNUNET_ARM_connect(), and run().

304 {
305  static int once;
306 
307  (void) cls;
308  if ( (GNUNET_SYSERR == connected) &&
309  (0 == once) )
310  {
312  _ ("Fatal error initializing ARM API.\n"));
314  return;
315  }
316  once = 1;
317 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static int once
Global to mark if we've run the initialization.
Definition: gnsrecord.c:68
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_callback()

static void start_callback ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

We have requested ARM to be started, this function is called with the result of the operation.

Informs the use of the result; on success, we continue with the event loop, on failure we terminate the process.

Parameters
clsclosure unused
rswhat happened to our request
resultif the request was processed, this is the result according to ARM

Definition at line 332 of file gnunet-arm.c.

References _, action_loop(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ARM_RESULT_STARTING, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), req_string(), ret_string(), and start.

Referenced by action_loop().

335 {
336  (void) cls;
337  op = NULL;
338  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
339  {
340  fprintf (stdout,
341  _ ("Failed to start the ARM service: %s\n"),
342  req_string (rs));
344  return;
345  }
348  {
349  fprintf (stdout,
350  _ ("Failed to start the ARM service: %s\n"),
351  ret_string (result));
353  return;
354  }
356  "ARM service [re]start successful\n");
357  start = 0;
359  NULL);
360 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
Asked to start it, but it's already started.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Service starting was initiated.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static int result
Global testing status.
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Definition: gnunet-arm.c:245
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:224
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_callback()

static void stop_callback ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

We have requested ARM to be stopped, this function is called with the result of the operation.

Informs the use of the result; on success, we continue with the event loop, on failure we terminate the process.

Parameters
clsclosure unused
rswhat happened to our request
resultif the request was processed, this is the result according to ARM

Definition at line 375 of file gnunet-arm.c.

References _, action_loop(), end, GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_STOPPED, GNUNET_ARM_RESULT_STOPPING, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), msg, req_string(), restart, ret_string(), and start.

Referenced by action_loop().

378 {
379  char *msg;
380 
381  (void) cls;
382  op = NULL;
383  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
384  {
385  GNUNET_asprintf (&msg,
386  "%s",
387  _ (
388  "Failed to send a stop request to the ARM service: %s\n"));
389  fprintf (stdout, msg, req_string (rs));
390  GNUNET_free (msg);
392  return;
393  }
397  {
398  fprintf (stdout,
399  _ ("Failed to stop the ARM service: %s\n"),
400  ret_string (result));
402  return;
403  }
405  "ARM service shutdown successful\n");
406  end = 0;
407  if (restart)
408  {
409  restart = 0;
410  start = 1;
412  "Initiating an ARM restart\n");
413  }
415  NULL);
416 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
ARM stopping was initiated (there's no "stopped" for ARM itself).
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static int restart
Set if we are to stop/start default services (including ARM).
Definition: gnunet-arm.c:44
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static int result
Global testing status.
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Definition: gnunet-arm.c:245
Asked to stop it, but it's already stopped.
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:224
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Service was stopped (never sent for ARM itself).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_callback()

static void init_callback ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

We have requested a service to be started, this function is called with the result of the operation.

Informs the use of the result; on success, we continue with the event loop, on failure we terminate the process.

Parameters
clsclosure unused
rswhat happened to our request
resultif the request was processed, this is the result according to ARM

Definition at line 431 of file gnunet-arm.c.

References _, action_loop(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ARM_RESULT_STARTING, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), init, req_string(), and ret_string().

Referenced by action_loop().

434 {
435  (void) cls;
436  op = NULL;
437  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
438  {
439  fprintf (stdout,
440  _ ("Failed to send a request to start the `%s' service: %s\n"),
441  init,
442  req_string (rs));
444  return;
445  }
448  {
449  fprintf (stdout,
450  _ ("Failed to start the `%s' service: %s\n"),
451  init,
452  ret_string (result));
454  return;
455  }
457  "Service %s [re]started successfully\n",
458  init);
459  GNUNET_free (init);
460  init = NULL;
462  NULL);
463 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
Asked to start it, but it's already started.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Service starting was initiated.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static int result
Global testing status.
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Definition: gnunet-arm.c:245
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:224
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ term_callback()

static void term_callback ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

We have requested a service to be stopped, this function is called with the result of the operation.

Informs the use of the result; on success, we continue with the event loop, on failure we terminate the process.

Parameters
clsclosure unused
rswhat happened to our request
resultif the request was processed, this is the result according to ARM

Definition at line 478 of file gnunet-arm.c.

References _, action_loop(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_STOPPED, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), msg, req_string(), ret_string(), and term.

Referenced by action_loop().

481 {
482  char *msg;
483 
484  (void) cls;
485  op = NULL;
486  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
487  {
488  GNUNET_asprintf (&msg,
489  _ (
490  "Failed to send a request to kill the `%s' service: %%s\n"),
491  term);
492  fprintf (stdout,
493  msg,
494  req_string (rs));
495  GNUNET_free (msg);
497  return;
498  }
499  if ( (GNUNET_ARM_RESULT_STOPPED != result) &&
501  {
502  fprintf (stdout,
503  _ ("Failed to kill the `%s' service: %s\n"),
504  term,
505  ret_string (result));
507  return;
508  }
509 
511  "Service %s stopped successfully\n",
512  term);
513  GNUNET_free (term);
514  term = NULL;
516  NULL);
517 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static char * term
Set to the name of a service to kill.
Definition: gnunet-arm.c:79
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static int result
Global testing status.
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Definition: gnunet-arm.c:245
Asked to stop it, but it's already stopped.
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:224
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
#define GNUNET_log(kind,...)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
Service was stopped (never sent for ARM itself).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_callback()

static void list_callback ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
unsigned int  count,
const struct GNUNET_ARM_ServiceInfo list 
)
static

Function called with the list of running services.

Prints the list to stdout, then starts the event loop again. Prints an error message and terminates the process on errors.

Parameters
clsclosure (unused)
rsrequest status (success, failure, etc.)
countnumber of services in the list
listlist of services managed by arm

Definition at line 531 of file gnunet-arm.c.

References _, action_loop(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_SERVICE_STATUS_FAILED, GNUNET_ARM_SERVICE_STATUS_FINISHED, GNUNET_ARM_SERVICE_STATUS_STARTED, GNUNET_ARM_SERVICE_STATUS_STOPPED, GNUNET_ARM_SERVICE_STATUS_STOPPING, GNUNET_asprintf(), GNUNET_break_op, GNUNET_free, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, msg, name, quiet, req_string(), ret, show_all, and status.

Referenced by action_loop().

535 {
536  unsigned int num_stopped = 0;
537  unsigned int num_started = 0;
538  unsigned int num_stopping = 0;
539  unsigned int num_failed = 0;
540  unsigned int num_finished = 0;
541  (void) cls;
542  op = NULL;
543  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
544  {
545  char *msg;
546 
547  GNUNET_asprintf (&msg,
548  "%s",
549  _ ("Failed to request a list of services: %s\n"));
550  fprintf (stdout,
551  msg,
552  req_string (rs));
553  GNUNET_free (msg);
554  ret = 3;
556  }
557  if (NULL == list)
558  {
559  fprintf (stderr,
560  "%s",
561  _ ("Error communicating with ARM. ARM not running?\n"));
563  ret = 3;
564  return;
565  }
566  for (unsigned int i = 0; i < count; i++)
567  {
568  switch (list[i].status)
569  {
571  num_stopped++;
572  break;
574  num_failed++;
575  break;
577  num_finished++;
578  break;
580  num_started++;
581  break;
583  num_stopping++;
584  fprintf (stdout,
585  "%s (binary='%s', status=stopping)\n",
586  list[i].name,
587  list[i].binary);
588  break;
589  default:
590  GNUNET_break_op (0);
591  fprintf (stdout,
592  "%s (binary='%s', status=unknown)\n",
593  list[i].name,
594  list[i].binary);
595  break;
596  }
597  }
598  if (! quiet)
599  {
600  if (show_all)
601  fprintf (stdout,
602  "%s",
603  _ ("All services:\n"));
604  else
605  fprintf (stdout,
606  "%s",
607  _ ("Services (excluding stopped services):\n"));
608  if (num_stopped || num_failed || num_finished || num_stopping ||
609  num_started)
610  {
611  int sep = 0;
612  fprintf (stdout, "(");
613  if (0 != num_started)
614  {
615  if (sep)
616  fprintf (stdout, " / ");
617  fprintf (stdout,
618  "started: %u",
619  num_started);
620  sep = 1;
621  }
622  if (0 != num_failed)
623  {
624  if (sep)
625  fprintf (stdout, " / ");
626  fprintf (stdout,
627  "failed: %u",
628  num_failed);
629  sep = 1;
630  }
631  if (0 != num_stopping)
632  {
633  if (sep)
634  fprintf (stdout, " / ");
635  fprintf (stdout,
636  "stopping: %u",
637  num_stopping);
638  sep = 1;
639  }
640  if (0 != num_stopped)
641  {
642  if (sep)
643  fprintf (stdout, " / ");
644  fprintf (stdout,
645  "stopped: %u",
646  num_stopped);
647  sep = 1;
648  }
649  if (0 != num_finished)
650  {
651  if (sep)
652  fprintf (stdout, " / ");
653  fprintf (stdout,
654  "finished: %u",
655  num_finished);
656  sep = 1;
657  }
658  fprintf (stdout, ")\n");
659  }
660  else
661  {
662  fprintf (stdout,
663  "%s",
664  _ ("(No services configured.)\n"));
665  }
666  }
667  for (unsigned int i = 0; i < count; i++)
668  {
669  struct GNUNET_TIME_Relative restart_in;
670  switch (list[i].status)
671  {
673  if (show_all)
674  fprintf (stdout,
675  "%s (binary='%s', status=stopped)\n",
676  list[i].name,
677  list[i].binary);
678  break;
680  restart_in = GNUNET_TIME_absolute_get_remaining (list[i].restart_at);
681  fprintf (stdout,
682  "%s (binary='%s', status=failed, exit_status=%d, restart_delay='%s')\n",
683  list[i].name,
684  list[i].binary,
685  list[i].last_exit_status,
687  GNUNET_YES));
688  break;
690  fprintf (stdout,
691  "%s (binary='%s', status=finished)\n",
692  list[i].name,
693  list[i].binary);
694  break;
696  fprintf (stdout,
697  "%s (binary='%s', status=started)\n",
698  list[i].name,
699  list[i].binary);
700  break;
702  fprintf (stdout,
703  "%s (binary='%s', status=stopping)\n",
704  list[i].name,
705  list[i].binary);
706  break;
707  default:
708  GNUNET_break_op (0);
709  fprintf (stdout,
710  "%s (binary='%s', status=unknown)\n",
711  list[i].name,
712  list[i].binary);
713  break;
714  }
715  }
717  NULL);
718 }
The service has previously failed, and will be restarted.
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
The service was started, but then exited normally.
static int quiet
Set if we should not print status messages.
Definition: gnunet-arm.c:54
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static int ret
Final status code.
Definition: gnunet-arm.c:94
static int show_all
Set if we should print all services, including stopped ones.
Definition: gnunet-arm.c:59
The service was started, and we&#39;re currently waiting for it to be stopped.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
uint16_t status
See PRISM_STATUS_*-constants.
Service has been started and is currently running.
Message was sent successfully.
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:224
const char * name
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ srv_status()

static void srv_status ( void *  cls,
const char *  service,
enum GNUNET_ARM_ServiceMonitorStatus  status 
)
static

Function called when a service starts or stops.

Parameters
clsclosure
serviceservice name
statusstatus of the service

Definition at line 848 of file gnunet-arm.c.

References _, GNUNET_ARM_SERVICE_MONITORING_STARTED, GNUNET_ARM_SERVICE_STARTING, GNUNET_ARM_SERVICE_STOPPED, GNUNET_ARM_SERVICE_STOPPING, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, msg, and quiet.

Referenced by run().

851 {
852  const char *msg;
853 
854  (void) cls;
855  switch (status)
856  {
858  return; /* this should be done silently */
859 
861  msg = _ ("Stopped %s.\n");
862  break;
863 
865  msg = _ ("Starting %s...\n");
866  break;
867 
869  msg = _ ("Stopping %s...\n");
870  break;
871 
872  default:
873  msg = NULL;
874  break;
875  }
876  if (! quiet)
877  {
878  if (NULL != msg)
879  fprintf (stderr,
880  msg,
881  service);
882  else
883  fprintf (stderr,
884  _ ("Unknown status %u for service %s.\n"),
885  status,
886  service);
887  }
889  "Got service %s status %d\n",
890  service,
891  (int) status);
892 }
Service stopping was initiated.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static int quiet
Set if we should not print status messages.
Definition: gnunet-arm.c:54
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
uint16_t status
See PRISM_STATUS_*-constants.
Service was stopped.
Service starting was initiated.
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ timeout_task_cb()

static void timeout_task_cb ( void *  cls)
static

Task run on timeout (if -T is given).

Definition at line 899 of file gnunet-arm.c.

References GNUNET_SCHEDULER_shutdown(), and ret.

Referenced by run().

900 {
901  (void) cls;
902  timeout_task = NULL;
903  ret = 2;
905 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static int ret
Final status code.
Definition: gnunet-arm.c:94
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Definition: gnunet-arm.c:124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 917 of file gnunet-arm.c.

References action_loop(), config_file, conn_status(), dir, GNUNET_ARM_connect(), GNUNET_ARM_monitor_start(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), monitor, GNUNET_TIME_Relative::rel_value_us, shutdown_task(), srv_status(), timeout, and timeout_task_cb().

Referenced by main().

921 {
922  (void) cls;
923  (void) args;
924  (void) cfgfile;
926  if (GNUNET_OK !=
928  "PATHS",
929  "GNUNET_HOME",
930  &dir))
931  {
933  "PATHS",
934  "GNUNET_HOME");
935  return;
936  }
938  "arm",
939  "CONFIG",
940  &config_file);
941  if (NULL == (h = GNUNET_ARM_connect (cfg,
942  &conn_status,
943  NULL)))
944  return;
945  if (monitor)
947  &srv_status,
948  NULL);
950  NULL);
952  NULL);
953  if (0 != timeout.rel_value_us)
954  timeout_task =
957  NULL);
958 }
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:139
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
static void timeout_task_cb(void *cls)
Task run on timeout (if -T is given).
Definition: gnunet-arm.c:899
uint64_t rel_value_us
The actual value.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
static char * config_file
Set to the name of the config file used.
Definition: gnunet-arm.c:84
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static void shutdown_task(void *cls)
Main continuation-passing-style loop.
Definition: gnunet-arm.c:181
static void srv_status(void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
Function called when a service starts or stops.
Definition: gnunet-arm.c:848
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1280
static void conn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
Definition: gnunet-arm.c:302
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
Definition: arm_api.c:579
struct GNUNET_ARM_MonitorHandle * GNUNET_ARM_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ServiceMonitorCallback cont, void *cont_cls)
Setup a context for monitoring ARM, then start connecting to the ARM service for monitoring using tha...
int 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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Definition: gnunet-arm.c:124
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:64
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:728
int 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to obtain arm from gnunetd.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error, 2 on timeout

Definition at line 969 of file gnunet-arm.c.

References end, gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_string(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), init, list, monitor, no_stderr, no_stdout, quiet, restart, ret, run(), show_all, start, term, and timeout.

970 {
973  "end",
974  gettext_noop ("stop all GNUnet services"),
975  &end),
977  "init",
978  "SERVICE",
979  gettext_noop ("start a particular service"),
980  &init),
982  "kill",
983  "SERVICE",
984  gettext_noop ("stop a particular service"),
985  &term),
987  "all",
988  gettext_noop (
989  "also show stopped services (used with -I)"),
990  &show_all),
992  "start",
993  gettext_noop (
994  "start all GNUnet default services"),
995  &start),
997  "restart",
998  gettext_noop (
999  "stop and start all GNUnet default services"),
1000  &restart),
1002  "delete",
1003  gettext_noop (
1004  "delete config file and directory on exit"),
1005  &delete),
1007  "monitor",
1008  gettext_noop ("monitor ARM activities"),
1009  &monitor),
1011  "quiet",
1012  gettext_noop ("don't print status messages"),
1013  &quiet),
1015  'T',
1016  "timeout",
1017  "DELAY",
1018  gettext_noop (
1019  "exit with error status if operation does not finish after DELAY"),
1020  &timeout),
1022  "info",
1023  gettext_noop (
1024  "list currently running services"),
1025  &list),
1027  'O',
1028  "no-stdout",
1029  gettext_noop ("don't let gnunet-service-arm inherit standard output"),
1030  &no_stdout),
1032  'E',
1033  "no-stderr",
1034  gettext_noop ("don't let gnunet-service-arm inherit standard error"),
1035  &no_stderr),
1037  };
1038  int lret;
1039 
1040  if (GNUNET_OK !=
1042  argv,
1043  &argc,
1044  &argv))
1045  return 2;
1046  if (GNUNET_OK ==
1047  (lret = GNUNET_PROGRAM_run (
1048  argc,
1049  argv,
1050  "gnunet-arm",
1051  gettext_noop (
1052  "Control services and the Automated Restart Manager (ARM)"),
1053  options,
1054  &run,
1055  NULL)))
1056  {
1057  GNUNET_free ((void *) argv);
1058  return ret;
1059  }
1060  GNUNET_free ((void *) argv);
1061  return lret;
1062 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
Definition: gnunet-arm.c:917
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int restart
Set if we are to stop/start default services (including ARM).
Definition: gnunet-arm.c:44
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1438
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
static int quiet
Set if we should not print status messages.
Definition: gnunet-arm.c:54
static int ret
Final status code.
Definition: gnunet-arm.c:94
static char * term
Set to the name of a service to kill.
Definition: gnunet-arm.c:79
static int show_all
Set if we should print all services, including stopped ones.
Definition: gnunet-arm.c:59
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:64
static int no_stderr
Do we want to give our stderr to gnunet-service-arm?
Definition: gnunet-arm.c:134
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.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
static int no_stdout
Do we want to give our stdout to gnunet-service-arm?
Definition: gnunet-arm.c:129
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ end

int end
static

◆ start

int start
static

◆ restart

int restart
static

Set if we are to stop/start default services (including ARM).

Definition at line 44 of file gnunet-arm.c.

Referenced by action_loop(), main(), and stop_callback().

◆ delete

int delete
static

Set if we should delete configuration and temp directory on exit.

Definition at line 49 of file gnunet-arm.c.

◆ quiet

int quiet
static

Set if we should not print status messages.

Definition at line 54 of file gnunet-arm.c.

Referenced by action_loop(), list_callback(), main(), and srv_status().

◆ show_all

int show_all
static

Set if we should print all services, including stopped ones.

Definition at line 59 of file gnunet-arm.c.

Referenced by list_callback(), and main().

◆ monitor

int monitor
static

Monitor ARM activity.

Definition at line 64 of file gnunet-arm.c.

Referenced by action_loop(), client_disconnect_cb(), main(), and run().

◆ list

int list
static

Set if we should print a list of currently running services.

Definition at line 69 of file gnunet-arm.c.

Referenced by action_loop(), pydiffer::dc_getdiff(), GNUNET_CONFIGURATION_iterate_value_filenames(), GNUNET_CONFIGURATION_remove_value_filename(), key_from_sexp(), main(), and render_row().

◆ init

char* init
static

◆ term

char* term
static

Set to the name of a service to kill.

Definition at line 79 of file gnunet-arm.c.

Referenced by action_loop(), main(), and term_callback().

◆ config_file

char* config_file
static

Set to the name of the config file used.

Definition at line 84 of file gnunet-arm.c.

Referenced by delete_files(), LEGACY_SERVICE_run(), main(), run(), and set_cont().

◆ dir

char* dir
static

◆ ret

int ret
static

Final status code.

Definition at line 94 of file gnunet-arm.c.

Referenced by list_callback(), main(), and timeout_task_cb().

◆ h

struct GNUNET_ARM_Handle* h
static

Connection with ARM.

Definition at line 99 of file gnunet-arm.c.

Referenced by add_setter_action(), cadet_connect_adapter(), call_flush_completion(), clean_node(), crc_init(), create_channel(), create_download_context(), derive_h(), deserialize_download(), deserialize_fi_node(), deserialize_publish_file(), deserialize_search(), deserialize_unindex_file(), destroy_channel(), disconnect_after_drop(), disconnect_on_mq_error(), encrypt_fair(), env_delete_notify(), free_queue_entry(), full_recursive_download(), GCD_search(), get_fair_encryption_challenge(), GN_start_gnunet_nat_server_(), GNUNET_ARM_monitor_start(), GNUNET_BIO_read_open(), GNUNET_BIO_write_open(), GNUNET_CADET_connect(), GNUNET_CADET_open_port(), GNUNET_CRYPTO_ecdsa_private_key_derive(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_connect(), GNUNET_DNSPARSER_hex_to_bin(), GNUNET_FS_dequeue_(), GNUNET_FS_file_information_create_empty_directory(), GNUNET_FS_file_information_create_from_file(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_probe(), GNUNET_FS_publish_sks(), GNUNET_FS_publish_start(), GNUNET_FS_queue_(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_FS_unindex_start(), GNUNET_NAMECACHE_block_cache(), GNUNET_NAMECACHE_cancel(), GNUNET_NAMECACHE_connect(), GNUNET_NAMECACHE_lookup_block(), GNUNET_NSE_connect(), GNUNET_PEERSTORE_connect(), GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_store_cancel(), GNUNET_PEERSTORE_watch(), GNUNET_PEERSTORE_watch_cancel(), GNUNET_REVOCATION_revoke(), GNUNET_RPS_connect(), GNUNET_RPS_request_cancel(), GNUNET_RPS_request_single_info_cancel(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_encrypt(), GNUNET_STATISTICS_create(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_is_host_habitable(), GNUNET_TESTBED_LOGGER_connect(), GNUNET_TESTBED_SD_init_(), GNUNET_TRANSPORT_manipulation_connect(), GST_neighbour_get_connection(), habitability_check(), handle_block_cache_response(), handle_client_error(), handle_data(), handle_data_end(), handle_dht_p2p_result(), handle_estimate(), handle_iterate_end(), handle_iterate_result(), handle_lookup_block_response(), handle_monitor_notify(), handle_revocation_response(), handle_status(), handle_stream_input(), handle_view_update(), handle_watch_record(), make_queue_entry(), mq_error_handler(), nat_server_read(), neighbour_connect_notify_task(), probe_ping_task_cb(), process_job_queue(), process_ksk_result(), read_start_time(), read_update_information_graph(), reconnect(), reconnect_arm_monitor_task(), reconnect_task(), regex_cancel_dht_get(), REGEX_INTERNAL_announce(), REGEX_INTERNAL_search(), regex_iterator(), restart_nat_server(), revocation_mq_error_handler(), rewatch_it(), rps_connect_adapter(), rps_disconnect_adapter(), run(), schedule_watch_request(), search_start(), send_get(), send_get_known_results(), send_monitor_start(), service_connect_comp(), shutdown_service(), socket_set_inheritable(), start_probe_ping_task(), transport_communicator_start(), trigger_flush_notification(), try_anat(), try_reconnect(), and update_memory_statistics().

◆ m

struct GNUNET_ARM_MonitorHandle* m
static

◆ cfg

struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

Definition at line 109 of file gnunet-arm.c.

◆ phase

unsigned int phase
static

Processing stage that we are in.

Simple counter.

Definition at line 114 of file gnunet-arm.c.

Referenced by action_loop(), and main().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

User defined timestamp for completing operations.

Definition at line 119 of file gnunet-arm.c.

Referenced by main(), and run().

◆ timeout_task

struct GNUNET_SCHEDULER_Task* timeout_task
static

Task to be run on timeout.

Definition at line 124 of file gnunet-arm.c.

◆ no_stdout

int no_stdout
static

Do we want to give our stdout to gnunet-service-arm?

Definition at line 129 of file gnunet-arm.c.

Referenced by action_loop(), and main().

◆ no_stderr

int no_stderr
static

Do we want to give our stderr to gnunet-service-arm?

Definition at line 134 of file gnunet-arm.c.

Referenced by action_loop(), and main().

◆ al_task

struct GNUNET_SCHEDULER_Task* al_task
static

Handle for the task running the action_loop().

Definition at line 139 of file gnunet-arm.c.

◆ op

struct GNUNET_ARM_Operation* op
static

Current operation.

Definition at line 144 of file gnunet-arm.c.

Referenced by adjust_running_peers(), bind_loose_channel(), change_service(), channel_end_cb(), channel_new_cb(), check_incoming_msg(), check_intersection_p2p_bf(), check_union_p2p_demand(), check_union_p2p_elements(), check_union_p2p_full_element(), check_union_p2p_ibf(), check_union_p2p_inquiry(), check_union_p2p_offer(), check_union_p2p_strata_estimator(), clean_peer(), client_disconnect_cb(), client_release_ports(), collect_generation_garbage(), create_finished(), delete_finished(), disconnect_cadet_peers(), exop_insert(), filter_all(), filtered_map_initialization(), finished_local_operations(), GCCH_channel_incoming_new(), GCCH_channel_local_new(), get_incoming(), GNUNET_ARM_disconnect(), GNUNET_ARM_request_service_list(), GNUNET_ARM_request_service_start(), GNUNET_ARM_request_service_stop(), GNUNET_IDENTITY_create(), GNUNET_IDENTITY_delete(), GNUNET_IDENTITY_disconnect(), GNUNET_IDENTITY_get(), GNUNET_IDENTITY_rename(), GNUNET_IDENTITY_set(), GNUNET_OP_add(), GNUNET_OP_get(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RECLAIM_ticket_revoke(), GST_connection_pool_get_handle(), handle_arm_list_result(), handle_arm_result(), handle_attribute_result(), handle_client_accept(), handle_client_cancel(), handle_client_evaluate(), handle_client_reject(), handle_consume_ticket_result(), handle_identity_result_code(), handle_identity_set_default(), handle_incoming_msg(), handle_intersection_p2p_bf(), handle_intersection_p2p_done(), handle_intersection_p2p_element_info(), handle_peer_create_success(), handle_port_close(), handle_port_open(), handle_revoke_ticket_result(), handle_success_response(), handle_ticket_result(), handle_union_p2p_demand(), handle_union_p2p_done(), handle_union_p2p_elements(), handle_union_p2p_full_done(), handle_union_p2p_full_element(), handle_union_p2p_ibf(), handle_union_p2p_inquiry(), handle_union_p2p_offer(), handle_union_p2p_request_full(), handle_union_p2p_strata_estimator(), incoming_timeout_cb(), init_key_to_element_iterator(), initialize_map_unfiltered(), iterator_bf_create(), iterator_bf_reduce(), load_episode(), mq_error_handler(), needs_parens(), needs_parentheses(), notify_running(), notify_starting(), ogg_demux_and_decode(), ogg_init(), op_done_task(), op_find(), op_result(), packetizer(), post_test_op(), prepare_ibf_iterator(), reconnect(), reconnect_arm_later(), remove_parentheses(), reschedule_connect(), send_client_done(), send_client_done_and_destroy(), send_full_element_iterator(), send_missing_full_elements_iter(), send_offers_for_key(), send_offers_iterator(), and send_remaining_elements().