linkd

Control plane daemon for unos
git clone git://git.finwo.net/app/linkd
Log | Files | Refs | README

plugin.h (1804B)


      1 #ifndef __LINKD_DATAPLANE_PLUGIN_H__
      2 #define __LINKD_DATAPLANE_PLUGIN_H__
      3 
      4 #include <sys/types.h>
      5 #include <time.h>
      6 
      7 #include "finwo/resp.h"
      8 
      9 struct dp_plugin {
     10   char  *target;
     11   int    optional;
     12 
     13   int    fd;            // socketpair to the child, or the tcp socket
     14   pid_t  pid;           // 0 when connected over tcp
     15   char  *user;          // tcp:// credentials, if any
     16   char  *pass;
     17 
     18   int    up;
     19   int    hardware;      // hardware_detected from INFO
     20 
     21   char **commands;      // verbs from COMMAND, upper-cased
     22   size_t commands_n;
     23   char **config_keys;   // directives from CONFIG LIST
     24   size_t config_keys_n;
     25 
     26   int    backoff_ms;    // 0 until the first failure
     27   struct timespec retry_at;
     28 
     29   struct dp_plugin *next;
     30 };
     31 
     32 // Send argv as a RESP array and read one reply. NULL on transport failure,
     33 // which also marks the plugin down. Caller owns the result.
     34 resp_object *dp_plugin_call(struct dp_plugin *p, const char **argv, int argc);
     35 
     36 // True if COMMAND advertised this verb.
     37 int dp_plugin_supports(const struct dp_plugin *p, const char *verb);
     38 
     39 // True if CONFIG LIST advertised this directive.
     40 int dp_plugin_config_supports(const struct dp_plugin *p, const char *key);
     41 
     42 // Start, or reconnect after backoff. Returns 0 when usable.
     43 int  dp_plugin_up(struct dp_plugin *p);
     44 void dp_plugin_down(struct dp_plugin *p, const char *why);
     45 
     46 // Plugin list, in declaration order.
     47 struct dp_plugin *dp_plugin_list(void);
     48 
     49 // Look up or create the entry for a target, starting it if needed. Called
     50 // during config parsing (to ask about directives) and by dp_start().
     51 struct dp_plugin *dp_plugin_for(const char *target);
     52 
     53 // CONFIG SET <key> <argv...>. Returns 0 on +OK.
     54 int dp_plugin_config_set(struct dp_plugin *p, const char *key, char **argv, size_t argc);
     55 
     56 #endif // __LINKD_DATAPLANE_PLUGIN_H__