- verbose(level, file, line, "%s {plugin %s}", p, desc->plugin->v1.prefix);
- free(p);
- }
-}
-
-static const struct afb_daemon_itf daemon_itf = {
- .get_event_sender = (void*)afb_api_so_get_event_sender,
- .get_event_loop = (void*)afb_common_get_event_loop,
- .get_user_bus = (void*)afb_common_get_user_bus,
- .get_system_bus = (void*)afb_common_get_system_bus,
- .vverbose = (void*)afb_api_so_vverbose
-};
-
-struct monitoring {
- struct afb_req req;
- void (*action)(struct afb_req);
-};
-
-static void monitored_call(int signum, struct monitoring *data)
-{
- if (signum != 0)
- afb_req_fail_f(data->req, "aborted", "signal %s(%d) caught", strsignal(signum), signum);
- else
- data->action(data->req);
-}
-
-static void call_check(struct afb_req req, struct afb_context *context, const struct AFB_verb_desc_v1 *verb)
-{
- struct monitoring data;
-
- int stag = (int)verb->session;
-
- if ((stag & (AFB_SESSION_CREATE|AFB_SESSION_CLOSE|AFB_SESSION_RENEW|AFB_SESSION_CHECK|AFB_SESSION_LOA_EQ)) != 0) {
- if (!afb_context_check(context)) {
- afb_context_close(context);
- afb_req_fail(req, "failed", "invalid token's identity");
- return;
- }
- }
-
- if ((stag & AFB_SESSION_CREATE) != 0) {
- if (afb_context_check_loa(context, 1)) {
- afb_req_fail(req, "failed", "invalid creation state");
- return;
- }
- afb_context_change_loa(context, 1);
- afb_context_refresh(context);
- }
-
- if ((stag & (AFB_SESSION_CREATE | AFB_SESSION_RENEW)) != 0)
- afb_context_refresh(context);
-
- if ((stag & AFB_SESSION_CLOSE) != 0) {
- afb_context_change_loa(context, 0);
- afb_context_close(context);
- }
-
- if ((stag & AFB_SESSION_LOA_GE) != 0) {
- int loa = (stag >> AFB_SESSION_LOA_SHIFT) & AFB_SESSION_LOA_MASK;
- if (!afb_context_check_loa(context, loa)) {
- afb_req_fail(req, "failed", "invalid LOA");
- return;
- }