35 #include "asterisk/utils.h"
46 #define MAX_SECURITY_IES 12
49 #undef MAX_SECURITY_IES
52 #define SEC_EVT_FIELD(e, field) (offsetof(struct ast_security_event_##e, field))
78 .name =
"InvalidAccountID",
100 .name =
"SessionLimit",
122 .name =
"MemoryLimit",
144 .name =
"LoadAverageLimit",
166 .name =
"RequestNotSupported",
189 .name =
"RequestNotAllowed",
213 .name =
"AuthMethodNotAllowed",
236 .name =
"RequestBadFormat",
260 .name =
"SuccessfulAuth",
282 .name =
"UnexpectedAddress",
305 .name =
"ChallengeResponseFailed",
330 .name =
"InvalidPassword",
355 static const struct {
419 (
unsigned int) tv->tv_sec,
420 (
unsigned int) tv->tv_usec);
427 const char *severity_str;
450 const struct timeval *
tv)
480 ntohs(addr->
sin->sin_port));
510 str = *((
const char **)(((
const char *) sec) + ie_type->
offset));
514 "type '%u' not present\n", ie_type->
ie_type,
528 val = *((
const uint32_t *)(((
const char *) sec) + ie_type->
offset));
540 if (req && !addr->
sin) {
542 "type '%u' not present\n", ie_type->
ie_type,
554 const struct timeval *tval;
556 tval = *((
const struct timeval **)(((
const char *) sec) + ie_type->
offset));
560 "type '%u' not present\n", ie_type->
ie_type,
577 "will be missing data.\n", ie_type->
ie_type);
ast_security_event_severity
the severity of a security event
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
An attempt at basic password authentication failed.
enum ast_security_event_type event_type
The security event sub-type.
Security Event Reporting API.
Asterisk main include file. File version handling, generic pbx functions.
ast_security_event_type
Security event types.
FYI FWIW, Successful authentication has occurred.
String manipulation functions.
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.
#define AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION
Event descriptor version.
static void encode_timestamp(struct ast_str **str, const struct timeval *tv)
const char * service
Service that generated the event.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
enum ast_cc_service_type service
const char * ast_security_event_severity_get_name(const enum ast_security_event_severity severity)
Get the name of a security event severity.
size_t offset
For internal usage.
The attempted authentication method is not allowed.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
struct ast_security_event_ie_type optional_ies[MAX_SECURITY_IES]
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Common structure elements.
#define ast_str_alloca(init_len)
A request was made that is not allowed.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
An unexpected source address was seen for a session in progress.
uint32_t version
security event version
#define AST_SECURITY_EVENT_UNEXPECTED_ADDR_VERSION
Event descriptor version.
Informational event, not something that has gone wrong.
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.
static struct @298 sec_events[AST_SECURITY_EVENT_NUM_TYPES]
static const size_t TIMESTAMP_STR_LEN
enum ast_security_event_transport_type transport
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
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)
int ast_event_queue(struct ast_event *event)
Queue an event.
ast_event_ie_type
Event Information Element types.
Request received with bad formatting.
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_MEM_LIMIT_VERSION
Event descriptor version.
Wrapper for network related headers, masking differences between various operating systems...
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
static struct @299 severities[]
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static int add_ipv4_ie(struct ast_event **event, enum ast_event_ie_type ie_type, const struct ast_security_event_ipv4_addr *addr)
enum ast_event_ie_type ie_type
Load Average limit reached.
static int add_timeval_ie(struct ast_event **event, enum ast_event_ie_type ie_type, const struct timeval *tv)
An attempt at challenge/response authentication failed.
int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_type, const char *str)
Append an information element that has a string payload.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static struct ast_event * alloc_event(const struct ast_security_event_common *sec)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
static int handle_security_event(const struct ast_security_event_common *sec)
#define SEC_EVT_FIELD(e, field)
#define AST_SECURITY_EVENT_LOAD_AVG_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION
Event descriptor version.
void ast_event_destroy(struct ast_event *event)
Destroy an event.
enum ast_security_event_severity severity
struct ast_event * ast_event_new(enum ast_event_type event_type,...)
Create a new event.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
static int check_event_type(const enum ast_security_event_type event_type)
struct ast_security_event_ie_type required_ies[MAX_SECURITY_IES]
const char * ast_security_event_get_name(const enum ast_security_event_type event_type)
Get the name of a security event sub-type.
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
Something has gone wrong.
int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t data)
Append an information element that has an integer payload.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
A request was made that we understand, but do not support.