44 static const char LOG_SECURITY_NAME[] =
"SECURITY";
46 static int LOG_SECURITY;
51 static const size_t SECURITY_EVENT_BUF_INIT_LEN = 256;
58 static void append_json_single(
struct ast_str **str,
struct ast_json *json,
67 if (!required && !json_string) {
73 ast_assert(json_string != NULL);
86 append_json_single(str, json, ies[i].ie_type, required);
90 static void security_event_stasis_cb(
struct ast_json *json)
102 SECURITY_EVENT_BUF_INIT_LEN))) {
109 append_json(&str, json,
111 append_json(&str, json,
130 security_event_stasis_cb(payload->json);
133 static int load_module(
void)
139 if (!(security_stasis_sub = stasis_subscribe(
ast_security_topic(), security_stasis_cb, NULL))) {
147 ast_verb(3,
"Security Logging Enabled\n");
152 static int unload_module(
void)
154 if (security_stasis_sub) {
160 ast_verb(3,
"Security Logging Disabled\n");
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Security Event Reporting API.
Asterisk main include file. File version handling, generic pbx functions.
ast_security_event_type
Security event types.
String manipulation functions.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definitions to aid in the use of thread local storage.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
ast_event_ie_type
Event Information Element types.
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.
Asterisk JSON abstraction layer.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Support for dynamic strings.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
Support for logging to various files, console and syslog Configuration in file logger.conf.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Module has failed to load, may be in an inconsistent state.
This must stay at the end.
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.
int ast_logger_register_level(const char *name)
Register a new logger level.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
const char * ast_event_get_ie_type_name(enum ast_event_ie_type ie_type)
Get the string representation of an information element type.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Abstract JSON element (object, array, string, int, ...).
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
const char * ast_security_event_get_name(const enum ast_security_event_type event_type)
Get the name of a security event sub-type.