Mon Mar 12 2012 21:45:43

Asterisk developer's documentation


security_events.h File Reference

Security Event Reporting API. More...

Include dependency graph for security_events.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_security_event_ie_type

Functions

const char * ast_security_event_get_name (const enum ast_security_event_type event_type)
 Get the name of a security event sub-type.
struct ast_security_event_ie_typeast_security_event_get_optional_ies (const enum ast_security_event_type event_type)
 Get the list of optional IEs for a given security event sub-type.
struct ast_security_event_ie_typeast_security_event_get_required_ies (const enum ast_security_event_type event_type)
 Get the list of required IEs for a given security event sub-type.
int ast_security_event_report (const struct ast_security_event_common *sec)
 Report a security event.
const char * ast_security_event_severity_get_name (const enum ast_security_event_severity severity)
 Get the name of a security event severity.

Detailed Description

Security Event Reporting API.

Author:
Russell Bryant <russell@digium.com>

Definition in file security_events.h.


Function Documentation

const char* ast_security_event_get_name ( const enum ast_security_event_type  event_type)

Get the name of a security event sub-type.

Parameters:
[in]event_typesecurity event sub-type
Return values:
NULLif event_type is invalid
non-NULLthe name of the security event type
Since:
1.8

Definition at line 383 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by security_event_cb().

{
   if (check_event_type(event_type)) {
      return NULL;
   }

   return sec_events[event_type].name;
}
struct ast_security_event_ie_type* ast_security_event_get_optional_ies ( const enum ast_security_event_type  event_type) [read]

Get the list of optional IEs for a given security event sub-type.

Parameters:
[in]event_typesecurity event sub-type
Return values:
NULLinvalid event_type
non-NULLAn array terminated with the value AST_EVENT_IE_END
Since:
1.8

Definition at line 402 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by handle_security_event(), and security_event_cb().

{
   if (check_event_type(event_type)) {
      return NULL;
   }

   return sec_events[event_type].optional_ies;
}
struct ast_security_event_ie_type* ast_security_event_get_required_ies ( const enum ast_security_event_type  event_type) [read]

Get the list of required IEs for a given security event sub-type.

Parameters:
[in]event_typesecurity event sub-type
Return values:
NULLinvalid event_type
non-NULLAn array terminated with the value AST_EVENT_IE_END
Since:
1.8

Definition at line 392 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by handle_security_event(), and security_event_cb().

{
   if (check_event_type(event_type)) {
      return NULL;
   }

   return sec_events[event_type].required_ies;
}
int ast_security_event_report ( const struct ast_security_event_common sec)

Report a security event.

Parameters:
[in]secsecurity event data. Callers of this function should never declare an instance of ast_security_event_common directly. The argument should be an instance of a specific security event descriptor which has ast_security_event_common at the very beginning.
Return values:
0success
non-zerofailure

Definition at line 621 of file security_events.c.

References ast_log(), AST_SECURITY_EVENT_NUM_TYPES, ast_security_event_common::event_type, handle_security_event(), LOG_ERROR, LOG_WARNING, sec_events, and ast_security_event_common::version.

Referenced by report_auth_success(), report_failed_acl(), report_failed_challenge_response(), report_inval_password(), report_invalid_user(), report_req_bad_format(), report_req_not_allowed(), and report_session_limit().

{
   int res;

   if (sec->event_type < 0 || sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
      ast_log(LOG_ERROR, "Invalid security event type\n");
      return -1;
   }

   if (!sec_events[sec->event_type].name) {
      ast_log(LOG_WARNING, "Security event type %u not handled\n",
            sec->event_type);
      return -1;
   }

   if (sec->version != sec_events[sec->event_type].version) {
      ast_log(LOG_WARNING, "Security event %u version mismatch\n",
            sec->event_type);
      return -1;
   }

   res = handle_security_event(sec);

   return res;
}
const char* ast_security_event_severity_get_name ( const enum ast_security_event_severity  severity)

Get the name of a security event severity.

Parameters:
[in]severitysecurity event severity
Return values:
NULLif severity is invalid
non-NULLthe name of the security event severity
Since:
1.8

Definition at line 359 of file security_events.c.

References ARRAY_LEN, and severities.

Referenced by alloc_event().

{
   unsigned int i;

   for (i = 0; i < ARRAY_LEN(severities); i++) {
      if (severities[i].severity == severity) {
         return severities[i].str;
      }
   }

   return NULL;
}