daemon.h (1896B)
1 #ifndef __LINKD_CONFIG_DAEMON_H__ 2 #define __LINKD_CONFIG_DAEMON_H__ 3 4 #include <stddef.h> 5 6 // linkd's own configuration: /etc/linkd.cnf. Same grammar as the rest, so 7 // `source` works here too. 8 9 struct linkd_plugin_cfg { 10 char *target; // executable path, or tcp://[user:pass@]host[:port] 11 int optional; // failures do not fail the operation 12 struct linkd_plugin_cfg *next; 13 }; 14 15 struct linkd_daemon_cfg { 16 char **ports; size_t ports_n; // path/glob patterns 17 char **iface; size_t iface_n; 18 char **listen; size_t listen_n; 19 char *authfile; 20 21 // argv template for `method dhcp`, each element rendered per interface. 22 // Empty means autodetect. 23 char **dhcp_client; size_t dhcp_client_n; 24 25 struct linkd_plugin_cfg *plugins; 26 }; 27 28 void daemon_cfg_register(void); 29 30 // A missing config file is not an error; the defaults are usable. 31 int daemon_cfg_load(const char *path); 32 33 // Never NULL; returns defaults before daemon_cfg_load() runs. 34 const struct linkd_daemon_cfg *daemon_cfg(void); 35 36 void daemon_cfg_free(void); 37 38 // First unix:// listen address, minus the scheme. NULL if only tcp:// is 39 // configured. Used by the daemon to bind and by the clients to connect. 40 const char *daemon_cfg_unix_socket(void); 41 42 // Same, for the CLI tools: loads the config first, honouring $LINKD_CONFIG. 43 // Never NULL -- falls back to the built-in default. 44 const char *linkd_client_socket(void); 45 46 // Load "ports" / "interfaces" from config_ports / config_iface patterns. 47 // Expanded via `source`, so a pattern matching nothing is not an error. 48 // Shared by startup and ifreload so the two cannot drift apart. 49 int load_namespace(const char *ns_name, char **patterns, size_t n); 50 51 // Drop-in dir, used only when LINKD_CONFIG_PATH is absent. 52 #define LINKD_CONFIG_PATH "/etc/linkd.cnf" 53 #define LINKD_CONFIG_DIR "/etc/linkd" 54 55 #endif // __LINKD_CONFIG_DAEMON_H__