Mon Aug 31 12:30:45 2015

Asterisk developer's documentation


security_events.h File Reference

Security Event Reporting API. More...

#include "asterisk/event.h"
#include "asterisk/security_events_defs.h"

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_type security event sub-type
Return values:
NULL if event_type is invalid
non-NULL the name of the security event type
Since:
1.8

Definition at line 387 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by security_event_cb().

00388 {
00389    if (check_event_type(event_type)) {
00390       return NULL;
00391    }
00392 
00393    return sec_events[event_type].name;
00394 }

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_type security event sub-type
Return values:
NULL invalid event_type
non-NULL An array terminated with the value AST_EVENT_IE_END
Since:
1.8

Definition at line 406 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by handle_security_event(), and security_event_cb().

00408 {
00409    if (check_event_type(event_type)) {
00410       return NULL;
00411    }
00412 
00413    return sec_events[event_type].optional_ies;
00414 }

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_type security event sub-type
Return values:
NULL invalid event_type
non-NULL An array terminated with the value AST_EVENT_IE_END
Since:
1.8

Definition at line 396 of file security_events.c.

References check_event_type(), and sec_events.

Referenced by handle_security_event(), and security_event_cb().

00398 {
00399    if (check_event_type(event_type)) {
00400       return NULL;
00401    }
00402 
00403    return sec_events[event_type].required_ies;
00404 }

int ast_security_event_report ( const struct ast_security_event_common sec  ) 

Report a security event.

Parameters:
[in] sec security 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:
0 success
non-zero failure

Definition at line 625 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().

00626 {
00627    int res;
00628 
00629    if (sec->event_type < 0 || sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
00630       ast_log(LOG_ERROR, "Invalid security event type\n");
00631       return -1;
00632    }
00633 
00634    if (!sec_events[sec->event_type].name) {
00635       ast_log(LOG_WARNING, "Security event type %u not handled\n",
00636             sec->event_type);
00637       return -1;
00638    }
00639 
00640    if (sec->version != sec_events[sec->event_type].version) {
00641       ast_log(LOG_WARNING, "Security event %u version mismatch\n",
00642             sec->event_type);
00643       return -1;
00644    }
00645 
00646    res = handle_security_event(sec);
00647 
00648    return res;
00649 }

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] severity security event severity
Return values:
NULL if severity is invalid
non-NULL the name of the security event severity
Since:
1.8

Definition at line 363 of file security_events.c.

References ARRAY_LEN, and severities.

Referenced by alloc_event().

00365 {
00366    unsigned int i;
00367 
00368    for (i = 0; i < ARRAY_LEN(severities); i++) {
00369       if (severities[i].severity == severity) {
00370          return severities[i].str;
00371       }
00372    }
00373 
00374    return NULL;
00375 }


Generated on 31 Aug 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1