serval-dna.h File Reference

re-implementation of the serval-dna daemon as a commotiond plugin More...

Go to the source code of this file.

Macros

#define DEFAULT_SID   "0000000000000000000000000000000000000000000000000000000000000000"
 
#define DEFAULT_MDP_PATH   "/etc/commotion/keys.d/mdp.keyring/serval.keyring"
 
#define DEFAULT_SERVAL_PATH   "/var/serval-node"
 
#define PATH_MAX   4096
 
#define CHECK_ERR(A, M,...)
 
#define CHECK_ERR(A, M,...)
 
#define CLEAR_ERR()   err_msg = NULL;
 
#define INS_ERROR()   if (err_msg) { CMD_OUTPUT("errors",err_msg); }
 

Functions

int co_plugin_register (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 
int co_plugin_init (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 
int co_plugin_name (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 
int co_plugin_shutdown (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 
int serval_socket_cb (co_obj_t *self, co_obj_t *context)
 
int serval_timer_cb (co_obj_t *self, co_obj_t **output, co_obj_t *context)
 
int serval_schema (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 
int serval_daemon_handler (co_obj_t *self, co_obj_t **output, co_obj_t *params)
 

Detailed Description

re-implementation of the serval-dna daemon as a commotiond plugin

Author
Dan Staples (dismantl), danst.nosp@m.aple.nosp@m.s@ope.nosp@m.ntec.nosp@m.hinst.nosp@m.itut.nosp@m.e.org

Macro Definition Documentation

#define CHECK_ERR (   A,
  M,
  ... 
)
Value:
if(!(A)) { \
ERROR(M, ##__VA_ARGS__); \
if (err_msg == NULL) \
err_msg = co_list16_create(); \
char *msg = NULL; \
int len = snprintf(NULL, 0, M, ##__VA_ARGS__); \
msg = calloc(len + 1,sizeof(char)); \
sprintf(msg, M, ##__VA_ARGS__); \
if (len < UINT8_MAX) { \
co_list_append(err_msg, co_str8_create(msg,len+1,0)); \
} else if (len < UINT16_MAX) { \
co_list_append(err_msg, co_str16_create(msg,len+1,0)); \
} else if (len < UINT32_MAX) { \
co_list_append(err_msg, co_str32_create(msg,len+1,0)); \
} \
free(msg); \
goto error; \
}
int co_list_append(co_obj_t *list, co_obj_t *new_obj)
insert new item at end of list
Definition: list.c:425

until we have nested tree support

#define CHECK_ERR (   A,
  M,
  ... 
)
Value:
if(!(A)) { \
ERROR(M, ##__VA_ARGS__); \
if (err_msg) \
co_obj_free(err_msg); \
char *msg = NULL; \
int len = snprintf(NULL, 0, M, ##__VA_ARGS__); \
msg = calloc(len + 1,sizeof(char)); \
sprintf(msg, M, ##__VA_ARGS__); \
if (len < UINT8_MAX) { \
err_msg = co_str8_create(msg,len+1,0); \
} else if (len < UINT16_MAX) { \
err_msg = co_str16_create(msg,len+1,0); \
} else if (len < UINT32_MAX) { \
err_msg = co_str32_create(msg,len+1,0); \
} \
free(msg); \
goto error; \
}

until we have nested tree support

Function Documentation

int serval_socket_cb ( co_obj_t self,
co_obj_t context 
)

Callback function for when Serval socket has data to read

References co_list_parse().

Referenced by _watch().

117  {
118 // DEBUG("SERVAL_SOCKET_CB");
119  co_socket_t *sock = (co_socket_t*)self;
120  co_obj_t *node = NULL;
121  struct sched_ent *alarm = NULL;
122 
123  // find alarm associated w/ sock, call alarm->function(alarm)
124  if ((node = co_list_parse(sock_alarms, _alarm_fd_match_i, &sock->fd->fd))) {
125  alarm = ((co_alarm_t*)node)->alarm;
126  alarm->poll.revents = sock->events;
127 
128  alarm->function(alarm); // Serval callback function associated with alarm/socket
129  alarm->poll.revents = 0;
130 
131  return 1;
132  }
133 
134  return 0;
135 }
Definition: obj.h:131
Definition: socket.h:65
co_obj_t * co_list_parse(co_obj_t *list, co_iter_t iter, void *context)
process list with given iterator function
Definition: list.c:233
Definition: serval-dna.c:60