server/: Make initialization errors be non-fatal and restartable.
[tripe] / server / tripe.h
index fd0f44e..0e336f3 100644 (file)
@@ -598,7 +598,7 @@ typedef struct tunnel_ops {
   const char *name;                    /* Name of this tunnel driver */
   unsigned flags;                      /* Various interesting flags */
 #define TUNF_PRIVOPEN 1u               /*   Need helper to open file */
-  void (*init)(void);                  /* Initializes the system */
+  int (*init)(void);                   /* Initializes the system */
   tunnel *(*create)(struct peer */*p*/, int /*fd*/, char **/*ifn*/);
                                        /* Initializes a new tunnel */
   void (*setifname)(tunnel */*t*/, const char */*ifn*/);
@@ -841,14 +841,14 @@ extern unsigned tr_flags;         /* Trace options flags */
  *             @const char *pubkr@ = public keyring file
  *             @const char *ptag@ = default private-key tag
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
  * Use:                Initializes the key-management machinery, loading the
  *             keyrings and so on.
  */
 
-extern void km_init(const char */*privkr*/, const char */*pubkr*/,
-                   const char */*ptag*/);
+extern int km_init(const char */*privkr*/, const char */*pubkr*/,
+                  const char */*ptag*/);
 
 /* --- @km_reload@ --- *
  *
@@ -1354,13 +1354,13 @@ extern void a_daemon(void);
  *             @gid_t g@ = group to own the socket
  *             @mode_t m@ = permissions to set on the socket
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
  * Use:                Creates the admin listening socket.
  */
 
-extern void a_listen(const char */*sock*/,
-                    uid_t /*u*/, gid_t /*g*/, mode_t /*m*/);
+extern int a_listen(const char */*sock*/,
+                   uid_t /*u*/, gid_t /*g*/, mode_t /*m*/);
 
 /* --- @a_unlisten@ --- *
  *
@@ -1409,12 +1409,12 @@ extern void a_signals(void);
  *             @gid_t g@ = group to own the socket
  *             @mode_t m@ = permissions to set on the socket
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
  * Use:                Creates the admin listening socket.
  */
 
-extern void a_init(void);
+extern int a_init(void);
 
 /*----- Mapping with addresses as keys ------------------------------------*/
 
@@ -1514,13 +1514,13 @@ extern int ps_tunfd(const tunnel_ops */*tops*/, char **/*ifn*/);
  *
  * Arguments:  @int detachp@ = whether to detach the child from its terminal
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
  * Use:                Separates off the privileged tunnel-opening service from the
  *             rest of the server.
  */
 
-extern void ps_split(int /*detachp*/);
+extern int ps_split(int /*detachp*/);
 
 /* --- @ps_quit@ --- *
  *
@@ -1707,12 +1707,12 @@ extern const addr *p_addr(peer */*p*/);
  *
  * Arguments:  @struct addrinfo *ailist@ = addresses to bind to
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
  * Use:                Binds to the main UDP sockets.
  */
 
-extern void p_bind(struct addrinfo */*ailist*/);
+extern int p_bind(struct addrinfo */*ailist*/);
 
 /* --- @p_unbind@ --- *
  *
@@ -1741,18 +1741,18 @@ extern void p_init(void);
  *
  * Arguments:  @const tunnel_ops *tops@ = tunnel ops to add
  *
- * Returns:    ---
+ * Returns:    Zero on success, @-1@ on failure.
  *
- * Use:                Adds a tunnel class to the list of known classes.  If there
- *             is no current default tunnel, then this one is made the
- *             default.
+ * Use:                Adds a tunnel class to the list of known classes, if it
+ *             initializes properly.  If there is no current default tunnel,
+ *             then this one is made the default.
  *
  *             Does nothing if the tunnel class is already known.  So adding
  *             a bunch of tunnels takes quadratic time, but there will be
  *             too few to care about.
  */
 
-extern void p_addtun(const tunnel_ops */*tops*/);
+extern int p_addtun(const tunnel_ops */*tops*/);
 
 /* --- @p_setdflttun@ --- *
  *