Asterisk - The Open Source Telephony Project GIT-master-8f1982c
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Data Structures | Functions
security_events.h File Reference

Security Event Reporting API. More...

#include "asterisk/event.h"
#include "asterisk/security_events_defs.h"
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. More...
 
const 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. More...
 
const 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. More...
 
int ast_security_event_report (const struct ast_security_event_common *sec)
 Report a security event. More...
 
const char * ast_security_event_severity_get_name (const enum ast_security_event_severity severity)
 Get the name of a security event severity. More...
 
struct stasis_message_typeast_security_event_type (void)
 A stasis_message_type for security events. More...
 
int ast_security_stasis_init (void)
 initializes stasis topic/event types for ast_security_topic and ast_security_event_type More...
 
struct stasis_topicast_security_topic (void)
 A stasis_topic which publishes messages for security related issues. More...
 

Detailed Description

Security Event Reporting API.

Author
Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com

Definition in file security_events.h.

Function Documentation

◆ ast_security_event_get_name()

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 940 of file main/security_events.c.

941{
942 if (check_event_type(event_type)) {
943 return NULL;
944 }
945
946 return sec_events[event_type].name;
947}
static int check_event_type(const enum ast_security_event_type event_type)
static const struct @392 sec_events[AST_SECURITY_EVENT_NUM_TYPES]
#define NULL
Definition: resample.c:96

References check_event_type(), NULL, and sec_events.

Referenced by add_json_object(), ast_security_event_report(), gen_events(), security_event_stasis_cb(), and security_event_to_ami_blob().

◆ ast_security_event_get_optional_ies()

const struct ast_security_event_ie_type * ast_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.

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 959 of file main/security_events.c.

961{
962 if (check_event_type(event_type)) {
963 return NULL;
964 }
965
966 return sec_events[event_type].optional_ies;
967}

References check_event_type(), NULL, and sec_events.

Referenced by handle_security_event(), security_event_stasis_cb(), and security_event_to_ami_blob().

◆ ast_security_event_get_required_ies()

const struct ast_security_event_ie_type * ast_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.

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 949 of file main/security_events.c.

951{
952 if (check_event_type(event_type)) {
953 return NULL;
954 }
955
956 return sec_events[event_type].required_ies;
957}

References check_event_type(), NULL, and sec_events.

Referenced by handle_security_event(), security_event_stasis_cb(), and security_event_to_ami_blob().

◆ ast_security_event_report()

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 1216 of file main/security_events.c.

1217{
1218 if ((unsigned int)sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) {
1219 ast_log(LOG_ERROR, "Invalid security event type\n");
1220 return -1;
1221 }
1222
1223 if (!sec_events[sec->event_type].name) {
1224 ast_log(LOG_WARNING, "Security event type %u not handled\n",
1225 sec->event_type);
1226 return -1;
1227 }
1228
1229 if (sec->version != sec_events[sec->event_type].version) {
1230 ast_log(LOG_WARNING, "Security event %u version mismatch\n",
1231 sec->event_type);
1232 return -1;
1233 }
1234
1235 if (handle_security_event(sec)) {
1236 ast_log(LOG_ERROR, "Failed to issue security event of type %s.\n",
1238 }
1239
1240 return 0;
1241}
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
#define LOG_WARNING
const char * ast_security_event_get_name(const enum ast_security_event_type event_type)
Get the name of a security event sub-type.
static int handle_security_event(const struct ast_security_event_common *sec)
@ AST_SECURITY_EVENT_NUM_TYPES
This must stay at the end.
enum ast_security_event_type event_type
The security event sub-type.
uint32_t version
security event version

References ast_log, ast_security_event_get_name(), 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 ast_sip_report_auth_challenge_sent(), ast_sip_report_auth_failed_challenge_response(), ast_sip_report_auth_success(), ast_sip_report_failed_acl(), ast_sip_report_invalid_endpoint(), ast_sip_report_mem_limit(), ast_sip_report_req_no_support(), evt_gen_auth_method_not_allowed(), evt_gen_chal_resp_failed(), evt_gen_chal_sent(), evt_gen_failed_acl(), evt_gen_inval_acct_id(), evt_gen_inval_password(), evt_gen_inval_transport(), evt_gen_load_avg(), evt_gen_mem_limit(), evt_gen_req_bad_format(), evt_gen_req_no_support(), evt_gen_req_not_allowed(), evt_gen_session_limit(), evt_gen_successful_auth(), evt_gen_unexpected_addr(), 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().

◆ ast_security_event_severity_get_name()

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 916 of file main/security_events.c.

918{
919 unsigned int i;
920
921 for (i = 0; i < ARRAY_LEN(severities); i++) {
922 if (severities[i].severity == severity) {
923 return severities[i].str;
924 }
925 }
926
927 return NULL;
928}
static const struct @393 severities[]
enum ast_security_event_severity severity
#define ARRAY_LEN(a)
Definition: utils.h:666

References ARRAY_LEN, NULL, severities, and severity.

Referenced by alloc_security_event_json_object().

◆ ast_security_event_type()

A stasis_message_type for security events.

Since
12
Return values
NULLon error
Returns
stasis_message_type for security events
Note
Messages of this type should always be issued on and expected from the ast_security_topic stasis_topic

◆ ast_security_stasis_init()

int ast_security_stasis_init ( void  )

initializes stasis topic/event types for ast_security_topic and ast_security_event_type

Since
12
Return values
0on success
-1on failure

Definition at line 528 of file main/security_events.c.

529{
531
532 security_topic = stasis_topic_create("security:all");
533 if (!security_topic) {
534 return -1;
535 }
536
538 return -1;
539 }
540
541
542 return 0;
543}
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct stasis_topic * security_topic
Security Topic.
static void security_stasis_cleanup(void)
ast_security_event_type
Security event types.
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:644
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493

References ast_register_cleanup(), security_stasis_cleanup(), security_topic, STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by asterisk_daemon().

◆ ast_security_topic()

struct stasis_topic * ast_security_topic ( void  )

A stasis_topic which publishes messages for security related issues.

Since
12
Returns
stasis_topic for security related issues.
Return values
NULLon error

Definition at line 425 of file main/security_events.c.

426{
427 return security_topic;
428}

References security_topic.

Referenced by acl_change_stasis_subscribe(), ast_res_pjsip_initialize_configuration(), common_config_load(), handle_security_event(), load_module(), manager_subscriptions_init(), publish_acl_change(), and rtp_reload().