Mon Mar 12 2012 21:45:00

Asterisk developer's documentation


res_security_log.c File Reference

Security Event Logging. More...

Include dependency graph for res_security_log.c:

Go to the source code of this file.

Enumerations

enum  ie_required { NOT_REQUIRED, REQUIRED, NOT_REQUIRED, REQUIRED }

Functions

static void __init_security_event_buf (void)
static void __reg_module (void)
static void __unreg_module (void)
static void append_ie (struct ast_str **str, const struct ast_event *event, const enum ast_event_ie_type ie_type, enum ie_required required)
static void append_ies (struct ast_str **str, const struct ast_event *event, const struct ast_security_event_ie_type *ies, enum ie_required required)
 ASTERISK_FILE_VERSION (__FILE__,"$Revision: 328209 $")
static int ie_is_present (const struct ast_event *event, const enum ast_event_ie_type ie_type)
static int load_module (void)
static void security_event_cb (const struct ast_event *event, void *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Security Event Logging" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static struct ast_module_infoast_module_info = &__mod_info
static int LOG_SECURITY
static const char LOG_SECURITY_NAME [] = "SECURITY"
static struct ast_threadstorage security_event_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_security_event_buf , .custom_init = NULL , }
static const size_t SECURITY_EVENT_BUF_INIT_LEN = 256
static struct ast_event_subsecurity_event_sub

Detailed Description

Security Event Logging.

Author:
Russell Bryant <russell@digium.com>
Todo:

Make informational security events optional

Escape quotes in string payload IE contents

Definition in file res_security_log.c.


Enumeration Type Documentation

Enumerator:
NOT_REQUIRED 
REQUIRED 
NOT_REQUIRED 
REQUIRED 

Definition at line 54 of file res_security_log.c.


Function Documentation

static void __init_security_event_buf ( void  ) [static]

Definition at line 51 of file res_security_log.c.

{
static void __reg_module ( void  ) [static]

Definition at line 167 of file res_security_log.c.

static void __unreg_module ( void  ) [static]

Definition at line 167 of file res_security_log.c.

static void append_ie ( struct ast_str **  str,
const struct ast_event event,
const enum ast_event_ie_type  ie_type,
enum ie_required  required 
) [static]

Definition at line 65 of file res_security_log.c.

References ast_assert, ast_event_get_ie_bitflags(), ast_event_get_ie_pltype(), ast_event_get_ie_str(), ast_event_get_ie_type_name(), ast_event_get_ie_uint(), AST_EVENT_IE_PLTYPE_BITFLAGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_PLTYPE_RAW, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_PLTYPE_UNKNOWN, ast_log(), ast_str_append(), ie_is_present(), and LOG_WARNING.

Referenced by append_ies().

{
   if (!required && !ie_is_present(event, ie_type)) {
      /* Optional IE isn't present.  Ignore. */
      return;
   }

   /* At this point, it _better_ be there! */
   ast_assert(ie_is_present(event, ie_type));

   switch (ast_event_get_ie_pltype(ie_type)) {
   case AST_EVENT_IE_PLTYPE_UINT:
      ast_str_append(str, 0, ",%s=\"%u\"",
            ast_event_get_ie_type_name(ie_type),
            ast_event_get_ie_uint(event, ie_type));
      break;
   case AST_EVENT_IE_PLTYPE_STR:
      ast_str_append(str, 0, ",%s=\"%s\"",
            ast_event_get_ie_type_name(ie_type),
            ast_event_get_ie_str(event, ie_type));
      break;
   case AST_EVENT_IE_PLTYPE_BITFLAGS:
      ast_str_append(str, 0, ",%s=\"%u\"",
            ast_event_get_ie_type_name(ie_type),
            ast_event_get_ie_bitflags(event, ie_type));
      break;
   case AST_EVENT_IE_PLTYPE_UNKNOWN:
   case AST_EVENT_IE_PLTYPE_EXISTS:
   case AST_EVENT_IE_PLTYPE_RAW:
      ast_log(LOG_WARNING, "Unexpected payload type for IE '%s'\n",
            ast_event_get_ie_type_name(ie_type));
      break;
   }
}
static void append_ies ( struct ast_str **  str,
const struct ast_event event,
const struct ast_security_event_ie_type ies,
enum ie_required  required 
) [static]

Definition at line 101 of file res_security_log.c.

References append_ie(), AST_EVENT_IE_END, and ast_security_event_ie_type::ie_type.

Referenced by security_event_cb().

{
   unsigned int i;

   for (i = 0; ies[i].ie_type != AST_EVENT_IE_END; i++) {
      append_ie(str, event, ies[i].ie_type, required);
   }
}
ASTERISK_FILE_VERSION ( __FILE__  ,
"$Revision: 328209 $"   
)
static int ie_is_present ( const struct ast_event event,
const enum ast_event_ie_type  ie_type 
) [static]

Definition at line 59 of file res_security_log.c.

References ast_event_get_ie_raw().

Referenced by append_ie().

{
   return (ast_event_get_ie_raw(event, ie_type) != NULL);
}
static int unload_module ( void  ) [static]

Definition at line 156 of file res_security_log.c.

References ast_event_unsubscribe(), and ast_verb.

{
   if (security_event_sub) {
      security_event_sub = ast_event_unsubscribe(security_event_sub);
   }

   ast_verb(3, "Security Logging Disabled\n");

   return 0;
}

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Security Event Logging" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 167 of file res_security_log.c.

Definition at line 167 of file res_security_log.c.

int LOG_SECURITY [static]

Definition at line 47 of file res_security_log.c.

Referenced by load_module(), and security_event_cb().

const char LOG_SECURITY_NAME[] = "SECURITY" [static]

Definition at line 45 of file res_security_log.c.

Referenced by load_module().

struct ast_threadstorage security_event_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_security_event_buf , .custom_init = NULL , } [static]

Definition at line 51 of file res_security_log.c.

Referenced by security_event_cb().

const size_t SECURITY_EVENT_BUF_INIT_LEN = 256 [static]

Definition at line 52 of file res_security_log.c.

Referenced by security_event_cb().

Definition at line 49 of file res_security_log.c.