Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Security Event Reporting Helpers. More...
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/strings.h"
#include "asterisk/network.h"
#include "asterisk/event.h"
#include "asterisk/security_events.h"
#include "asterisk/netsock2.h"
#include "asterisk/stasis.h"
#include "asterisk/json.h"
#include "asterisk/astobj2.h"
Go to the source code of this file.
Macros | |
#define | MAX_SECURITY_IES 12 |
#define | SEC_EVT_FIELD(e, field) (offsetof(struct ast_security_event_##e, field)) |
Enumerations | |
enum | ie_required { NOT_REQUIRED , REQUIRED , NOT_REQUIRED , REQUIRED } |
Variables | |
struct { | |
const char * name | |
struct ast_security_event_ie_type optional_ies [MAX_SECURITY_IES] | |
struct ast_security_event_ie_type required_ies [MAX_SECURITY_IES] | |
enum ast_security_event_severity severity | |
uint32_t version | |
} | sec_events [AST_SECURITY_EVENT_NUM_TYPES] |
static const size_t | SECURITY_EVENT_BUF_INIT_LEN = 256 |
static struct stasis_topic * | security_topic |
Security Topic. More... | |
struct { | |
enum ast_security_event_severity severity | |
const char * str | |
} | severities [] |
Security Event Reporting Helpers.
Definition in file main/security_events.c.
#define MAX_SECURITY_IES 12 |
Definition at line 504 of file main/security_events.c.
#define SEC_EVT_FIELD | ( | e, | |
field | |||
) | (offsetof(struct ast_security_event_##e, field)) |
enum ie_required |
Enumerator | |
---|---|
NOT_REQUIRED | |
REQUIRED | |
NOT_REQUIRED | |
REQUIRED |
Definition at line 937 of file main/security_events.c.
|
static |
Definition at line 924 of file main/security_events.c.
References ast_security_event_ip_addr::addr, ast_event_get_ie_type_name(), ast_json_ipaddr(), ast_json_object_set(), and ast_security_event_ip_addr::transport.
Referenced by add_json_object().
|
static |
Definition at line 942 of file main/security_events.c.
References add_ip_json_object(), ast_security_event_ip_addr::addr, ast_event_get_ie_type_name(), AST_EVENT_IE_ACCOUNT_ID, AST_EVENT_IE_ACL_NAME, AST_EVENT_IE_ATTEMPTED_TRANSPORT, AST_EVENT_IE_AUTH_METHOD, AST_EVENT_IE_CHALLENGE, AST_EVENT_IE_EVENT_TV, AST_EVENT_IE_EVENT_VERSION, AST_EVENT_IE_EXPECTED_ADDR, AST_EVENT_IE_EXPECTED_RESPONSE, AST_EVENT_IE_LOCAL_ADDR, AST_EVENT_IE_MODULE, AST_EVENT_IE_RECEIVED_CHALLENGE, AST_EVENT_IE_RECEIVED_HASH, AST_EVENT_IE_REMOTE_ADDR, AST_EVENT_IE_REQUEST_PARAMS, AST_EVENT_IE_REQUEST_TYPE, AST_EVENT_IE_RESPONSE, AST_EVENT_IE_SERVICE, AST_EVENT_IE_SESSION_ID, AST_EVENT_IE_SESSION_TV, AST_EVENT_IE_SEVERITY, AST_EVENT_IE_USING_PASSWORD, ast_json_object_set(), ast_json_string_create(), ast_json_stringf(), ast_json_timeval(), ast_log, ast_security_event_get_name(), ast_security_event_ie_type::ie_type, LOG_WARNING, NULL, ast_security_event_ie_type::offset, and str.
Referenced by handle_security_event().
|
static |
Definition at line 1067 of file main/security_events.c.
References ast_event_get_ie_type_name(), AST_EVENT_IE_EVENT_TV, AST_EVENT_IE_EVENT_VERSION, AST_EVENT_IE_SERVICE, AST_EVENT_IE_SEVERITY, ast_json_integer_create(), ast_json_object_create(), ast_json_object_set(), ast_json_ref(), ast_json_string_create(), ast_json_stringf(), ast_json_timeval(), ast_json_unref(), ast_security_event_severity_get_name(), ast_tvnow(), ast_security_event_common::event_type, NULL, RAII_VAR, S_OR, sec_events, ast_security_event_common::service, and ast_security_event_common::version.
Referenced by handle_security_event().
|
static |
Definition at line 402 of file main/security_events.c.
References append_event_str_single(), AST_EVENT_IE_END, ast_security_event_ie_type::ie_type, and str.
Referenced by security_event_to_ami_blob().
|
static |
Definition at line 385 of file main/security_events.c.
References ast_event_get_ie_type_name(), ast_json_object_get(), ast_json_string_get(), ast_str_append(), S_OR, and str.
Referenced by append_event_str_from_json().
const char * ast_security_event_get_name | ( | const enum ast_security_event_type | event_type | ) |
Get the name of a security event sub-type.
[in] | event_type | security event sub-type |
NULL | if event_type is invalid |
non-NULL | the name of the security event type |
Definition at line 895 of file main/security_events.c.
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().
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.
[in] | event_type | security event sub-type |
NULL | invalid event_type |
non-NULL | An array terminated with the value AST_EVENT_IE_END |
Definition at line 914 of file main/security_events.c.
References check_event_type(), NULL, and sec_events.
Referenced by handle_security_event(), security_event_stasis_cb(), and security_event_to_ami_blob().
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.
[in] | event_type | security event sub-type |
NULL | invalid event_type |
non-NULL | An array terminated with the value AST_EVENT_IE_END |
Definition at line 904 of file main/security_events.c.
References check_event_type(), NULL, and sec_events.
Referenced by handle_security_event(), security_event_stasis_cb(), and security_event_to_ami_blob().
int ast_security_event_report | ( | const struct ast_security_event_common * | sec | ) |
Report a security event.
[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. |
0 | success |
non-zero | failure |
Definition at line 1171 of file main/security_events.c.
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().
const char * ast_security_event_severity_get_name | ( | const enum ast_security_event_severity | severity | ) |
Get the name of a security event severity.
[in] | severity | security event severity |
NULL | if severity is invalid |
non-NULL | the name of the security event severity |
Definition at line 871 of file main/security_events.c.
References ARRAY_LEN, NULL, severities, and severity.
Referenced by alloc_security_event_json_object().
int ast_security_stasis_init | ( | void | ) |
initializes stasis topic/event types for ast_security_topic and ast_security_event_type
0 | on success |
-1 | on failure |
Definition at line 483 of file main/security_events.c.
References ast_register_cleanup(), security_stasis_cleanup(), security_topic, STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().
Referenced by asterisk_daemon().
struct stasis_topic * ast_security_topic | ( | void | ) |
A stasis_topic which publishes messages for security related issues.
NULL | on error |
Definition at line 380 of file main/security_events.c.
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().
|
static |
Definition at line 885 of file main/security_events.c.
References ast_log, AST_SECURITY_EVENT_NUM_TYPES, and LOG_ERROR.
Referenced by ast_security_event_get_name(), ast_security_event_get_optional_ies(), and ast_security_event_get_required_ies().
|
static |
Definition at line 1118 of file main/security_events.c.
References add_json_object(), alloc_security_event_json_object(), ao2_cleanup, AST_EVENT_IE_END, ast_json_payload_create(), ast_json_unref(), ast_security_event_get_optional_ies(), ast_security_event_get_required_ies(), ast_security_topic(), ast_security_event_common::event_type, ast_security_event_ie_type::ie_type, NOT_REQUIRED, NULL, RAII_VAR, REQUIRED, stasis_message_create(), and stasis_publish().
Referenced by ast_security_event_report().
|
static |
Definition at line 455 of file main/security_events.c.
References ast_json_payload::json, NULL, security_event_to_ami_blob(), stasis_message_data(), and stasis_message_type().
|
static |
Definition at line 420 of file main/security_events.c.
References append_event_str_from_json(), ast_assert, ast_free, ast_json_integer_get(), ast_json_object_get(), ast_log, AST_LOG_ERROR, ast_manager_event_blob_create(), ast_security_event_get_name(), ast_security_event_get_optional_ies(), ast_security_event_get_required_ies(), AST_SECURITY_EVENT_NUM_TYPES, ast_str_buffer(), ast_str_create, EVENT_FLAG_SECURITY, NULL, RAII_VAR, SECURITY_EVENT_BUF_INIT_LEN, and str.
Referenced by security_event_to_ami().
|
static |
Definition at line 475 of file main/security_events.c.
References ao2_cleanup, NULL, security_topic, and STASIS_MESSAGE_TYPE_CLEANUP.
Referenced by ast_security_stasis_init().
STASIS_MESSAGE_TYPE_DEFN | ( | ast_security_event_type | , |
. | to_ami = security_event_to_ami |
||
) |
Message type for security events.
const char* name |
Definition at line 501 of file main/security_events.c.
struct ast_security_event_ie_type optional_ies[MAX_SECURITY_IES] |
Definition at line 506 of file main/security_events.c.
struct ast_security_event_ie_type required_ies[MAX_SECURITY_IES] |
Definition at line 505 of file main/security_events.c.
const struct { ... } sec_events[AST_SECURITY_EVENT_NUM_TYPES] |
|
static |
Definition at line 375 of file main/security_events.c.
Referenced by security_event_to_ami_blob().
|
static |
Security Topic.
Definition at line 378 of file main/security_events.c.
Referenced by ast_security_stasis_init(), ast_security_topic(), and security_stasis_cleanup().
const struct { ... } severities[] |
Referenced by ast_security_event_severity_get_name().
enum ast_security_event_severity severity |
Definition at line 503 of file main/security_events.c.
Referenced by ast_security_event_severity_get_name(), parse_error_handler(), and tds_message_handler().
const char* str |
Definition at line 865 of file main/security_events.c.
Referenced by add_json_object(), append_event_str_from_json(), append_event_str_single(), and security_event_to_ami_blob().
uint32_t version |
Definition at line 502 of file main/security_events.c.