Show
Ignore:
Timestamp:
12/17/11 01:12:19 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1324084339 -0500
git-parent:

[49fac1c926b76895e6420ab372d773c01944b246]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1324084339 -0500
Message:

Hook support. Go forth and instrument.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_check_tools.h

    r899f2d2 r8da7f66  
    3939#include "noit_check.h" 
    4040#include "utils/noit_hash.h" 
     41#include "utils/noit_hooks.h" 
    4142#include "noit_check_tools_shared.h" 
    4243 
     
    6263  noit_check_stats_from_json_str(stats_t *s, const char *json_str, int len); 
    6364 
     65/*#* DOCBOOK 
     66 * <section><title>Check Hooks</title> 
     67 *   <section><title>check_preflight</title> 
     68 *   <programlisting> 
     69 *     noit_hook_return_t (*f)(void *closure, noit_module_t *self, 
     70 *                             noit_check_t *check, noit_check_t *cause); 
     71 *   </programlisting> 
     72 *   <para>the check_preflight hook is invoked immediately prior to every 
     73 *   check being performed.  The actual invocation of the check can be 
     74 *   avoided by returning NOIT_HOOK_DONE instead of NOIT_HOOK_CONTINUE. 
     75 *   </para> 
     76 *   <para>The arguments to this function are the module of the check 
     77 *   the check itself and the causal check (NULL if this check was not 
     78 *   induced by the completion of another check), respectively.</para> 
     79 *   <para>This instrumentation point can be used to audit intended check 
     80 *   activity or prevent a check from running (such as an ACL).</para> 
     81 *   </section> 
     82 *   <section><title>check_postflight</title> 
     83 *   <programlisting> 
     84 *     noit_hook_return_t (*f)(void *closure, noit_module_t *self, 
     85 *                             noit_check_t *check, noit_check_t *cause); 
     86 *   </programlisting> 
     87 *   <para>The check_postflight hook is invoked immediately subsequent to 
     88 *   a check being commenced.  Note that due to the asynchronous nature 
     89 *   of Reconnoiter, it is highly unlikely that the check will have  
     90 *   completed by this time.</para> 
     91 *   <para>The arguments to this function are the module of the check, 
     92 *   the check itself and the causal check (NULL if this check was not 
     93 *   induced by the completion of another check), respectively.</para> 
     94 *   <para>Returning NOIT_HOOK_CONTINUE and NOIT_HOOK_DONE have the same 
     95 *   effect for this instrumentation point.</para> 
     96 *   </section> 
     97 * </section> 
     98 */ 
     99NOIT_HOOK_PROTO(check_preflight, 
     100                (noit_module_t *self, noit_check_t *check, noit_check_t *cause), 
     101                void *, closure, 
     102                (void *closure, noit_module_t *self, noit_check_t *check, noit_check_t *cause)); 
     103NOIT_HOOK_PROTO(check_postflight, 
     104                (noit_module_t *self, noit_check_t *check, noit_check_t *cause), 
     105                void *, closure, 
     106                (void *closure, noit_module_t *self, noit_check_t *check, noit_check_t *cause)); 
     107 
    64108#define INITIATE_CHECK(func, self, check, cause) do { \ 
    65109  if(once) { \ 
    66     func(self, check, cause); \ 
     110    if(NOIT_HOOK_CONTINUE == \ 
     111       check_preflight_hook_invoke(self, check, cause)) \ 
     112      func(self, check, cause); \ 
     113    check_postflight_hook_invoke(self, check, cause); \ 
    67114  } \ 
    68115  else if(!check->fire_event) { \