Security Event Reporting Helpers. More...
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/strings.h"
#include "asterisk/network.h"
#include "asterisk/security_events.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 } |
Functions | |
static int | add_ie (struct ast_event **event, const struct ast_security_event_common *sec, const struct ast_security_event_ie_type *ie_type, enum ie_required req) |
static int | add_ipv4_ie (struct ast_event **event, enum ast_event_ie_type ie_type, const struct ast_security_event_ipv4_addr *addr) |
static int | add_timeval_ie (struct ast_event **event, enum ast_event_ie_type ie_type, const struct timeval *tv) |
static struct ast_event * | alloc_event (const struct ast_security_event_common *sec) |
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... | |
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. More... | |
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. 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... | |
static int | check_event_type (const enum ast_security_event_type event_type) |
static void | encode_timestamp (struct ast_str **str, const struct timeval *tv) |
static int | handle_security_event (const struct ast_security_event_common *sec) |
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] |
struct { | |
enum ast_security_event_severity severity | |
const char * str | |
} | severities [] |
static const size_t | TIMESTAMP_STR_LEN = 32 |
Security Event Reporting Helpers.
Definition in file security_events.c.
#define MAX_SECURITY_IES 12 |
Definition at line 46 of file 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 485 of file security_events.c.
|
static |
Definition at line 490 of file security_events.c.
References add_ipv4_ie(), add_timeval_ie(), ast_event_append_ie_str(), ast_event_append_ie_uint(), AST_EVENT_IE_ACCOUNT_ID, AST_EVENT_IE_ACL_NAME, 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_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_log(), ast_security_event_common::event_type, ast_security_event_ie_type::ie_type, LOG_WARNING, ast_security_event_ie_type::offset, ast_security_event_ipv4_addr::sin, and str.
Referenced by handle_security_event().
|
static |
Definition at line 459 of file security_events.c.
References ast_event_append_ie_str(), ast_inet_ntoa(), AST_SECURITY_EVENT_TRANSPORT_TCP, AST_SECURITY_EVENT_TRANSPORT_TLS, AST_SECURITY_EVENT_TRANSPORT_UDP, ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_security_event_ipv4_addr::sin, str, and ast_security_event_ipv4_addr::transport.
Referenced by add_ie().
|
static |
Definition at line 449 of file security_events.c.
References ast_event_append_ie_str(), ast_str_alloca, ast_str_buffer(), encode_timestamp(), and str.
Referenced by add_ie().
|
static |
Definition at line 423 of file security_events.c.
References AST_EVENT_IE_END, AST_EVENT_IE_EVENT_TV, AST_EVENT_IE_EVENT_VERSION, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_IE_SECURITY_EVENT, AST_EVENT_IE_SERVICE, AST_EVENT_IE_SEVERITY, ast_event_new(), AST_EVENT_SECURITY, ast_security_event_severity_get_name(), ast_str_alloca, ast_str_buffer(), ast_tvnow(), check_event_type(), encode_timestamp(), ast_security_event_common::event_type, S_OR, sec_events, ast_security_event_common::service, str, and ast_security_event_common::version.
Referenced by handle_security_event().
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 387 of file security_events.c.
References check_event_type(), and sec_events.
Referenced by security_event_cb().
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 406 of file security_events.c.
References check_event_type(), and sec_events.
Referenced by handle_security_event(), and security_event_cb().
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 396 of file security_events.c.
References check_event_type(), and sec_events.
Referenced by handle_security_event(), and security_event_cb().
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 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().
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 363 of file security_events.c.
References ARRAY_LEN, and severities.
Referenced by alloc_event().
|
static |
Definition at line 377 of file security_events.c.
References ast_log(), AST_SECURITY_EVENT_NUM_TYPES, and LOG_ERROR.
Referenced by alloc_event(), ast_security_event_get_name(), ast_security_event_get_optional_ies(), and ast_security_event_get_required_ies().
|
static |
Definition at line 416 of file security_events.c.
References ast_str_set().
Referenced by add_timeval_ie(), and alloc_event().
|
static |
Definition at line 584 of file security_events.c.
References add_ie(), alloc_event(), ast_event_destroy(), AST_EVENT_IE_END, ast_event_queue(), ast_security_event_get_optional_ies(), ast_security_event_get_required_ies(), ast_security_event_common::event_type, ast_security_event_ie_type::ie_type, NOT_REQUIRED, and REQUIRED.
Referenced by ast_security_event_report().
const char* name |
Definition at line 43 of file security_events.c.
struct ast_security_event_ie_type optional_ies[MAX_SECURITY_IES] |
Definition at line 48 of file security_events.c.
struct ast_security_event_ie_type required_ies[MAX_SECURITY_IES] |
Definition at line 47 of file security_events.c.
struct { ... } sec_events[AST_SECURITY_EVENT_NUM_TYPES] |
struct { ... } severities[] |
Referenced by ast_security_event_severity_get_name().
enum ast_security_event_severity severity |
Definition at line 45 of file security_events.c.
const char* str |
Definition at line 357 of file security_events.c.
|
static |
Definition at line 40 of file security_events.c.
uint32_t version |
Definition at line 44 of file security_events.c.
Referenced by add_sdp(), aji_dinfo_handler(), ast_readconfig(), ast_remotecontrol(), ast_rtp_read(), ast_var_Version(), check_access(), config_module(), dump_versioned_codec(), iax_ie_append_versioned_uint64(), iax_parse_ies(), manager_modulecheck(), and update_registry().