438 "error occurred when adding required event fields.\n");
445 "error occurred when adding optional event fields.\n");
478 security_topic =
NULL;
488 if (!security_topic) {
500 static const struct {
504 #define MAX_SECURITY_IES 12 507 #undef MAX_SECURITY_IES 510 #define SEC_EVT_FIELD(e, field) (offsetof(struct ast_security_event_##e, field)) 536 .name =
"InvalidAccountID",
558 .name =
"SessionLimit",
580 .name =
"MemoryLimit",
602 .name =
"LoadAverageLimit",
624 .name =
"RequestNotSupported",
647 .name =
"RequestNotAllowed",
671 .name =
"AuthMethodNotAllowed",
694 .name =
"RequestBadFormat",
718 .name =
"SuccessfulAuth",
741 .name =
"UnexpectedAddress",
764 .name =
"ChallengeResponseFailed",
789 .name =
"InvalidPassword",
814 .name =
"ChallengeSent",
837 .name =
"InvalidTransport",
863 static const struct {
966 str = *((
const char **)(((
const char *) sec) + ie_type->
offset));
970 "type '%u' (%s) not present\n", ie_type->
ie_type,
995 val = *((
const uint32_t *)(((
const char *) sec) + ie_type->
offset));
1014 if (req && !addr->
addr) {
1016 "type '%u' (%s) not present\n", ie_type->
ie_type,
1030 const struct timeval *tval;
1032 tval = *((
const struct timeval **)(((
const char *) sec) + ie_type->
offset));
1036 "type '%u' (%s) not present\n", ie_type->
ie_type,
1059 "will be missing data.\n", ie_type->
ie_type,
1070 const char *severity_str;
1105 severity_str =
S_OR(
Struct containing info for an AMI event to send out.
ast_security_event_severity
the severity of a security event
An attempt at basic password authentication failed.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
enum ast_security_event_type event_type
The security event sub-type.
Asterisk main include file. File version handling, generic pbx functions.
ast_security_event_type
Security event types.
FYI FWIW, Successful authentication has occurred.
Security Event Reporting API.
#define SEC_EVT_FIELD(e, field)
String manipulation functions.
static int add_ip_json_object(struct ast_json *json, enum ast_event_ie_type ie_type, const struct ast_security_event_ip_addr *addr)
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
#define AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION
Event descriptor version.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
static struct stasis_topic * security_topic
Security Topic.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
static struct ast_manager_event_blob * security_event_to_ami(struct stasis_message *message)
static int append_event_str_from_json(struct ast_str **str, struct ast_json *json, const struct ast_security_event_ie_type *ies)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
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.
static const struct @418 sec_events[AST_SECURITY_EVENT_NUM_TYPES]
#define AST_SECURITY_EVENT_CHAL_SENT_VERSION
Event descriptor version.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
enum ast_cc_service_type service
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
struct ast_json * ast_json_stringf(const char *format,...)
Create a JSON string, printf style.
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 timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
const char * ast_security_event_severity_get_name(const enum ast_security_event_severity severity)
Get the name of a security event severity.
Common structure elements.
A request was made that is not allowed.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
struct ast_security_event_ie_type required_ies[MAX_SECURITY_IES]
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.
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Informational event, not something that has gone wrong.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
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.
ast_event_ie_type
Event Information Element types.
STASIS_MESSAGE_TYPE_DEFN(ast_security_event_type,.to_ami=security_event_to_ami,)
Message type for security events.
Asterisk JSON abstraction layer.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
static struct ast_json * alloc_security_event_json_object(const struct ast_security_event_common *sec)
Request received with bad formatting.
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
enum ast_transport transport
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Challenge was sent out, informational.
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
#define AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_MEM_LIMIT_VERSION
Event descriptor version.
const struct ast_sockaddr * addr
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Wrapper for network related headers, masking differences between various operating systems...
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
static int add_json_object(struct ast_json *json, const struct ast_security_event_common *sec, const struct ast_security_event_ie_type *ie_type, enum ie_required req)
static int check_event_type(const enum ast_security_event_type event_type)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static const size_t SECURITY_EVENT_BUF_INIT_LEN
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
int ast_security_stasis_init(void)
initializes stasis topic/event types for ast_security_topic and ast_security_event_type ...
enum ast_event_ie_type ie_type
Load Average limit reached.
An attempt at challenge/response authentication failed.
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
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.
#define EVENT_FLAG_SECURITY
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
static int handle_security_event(const struct ast_security_event_common *sec)
static int append_event_str_single(struct ast_str **str, struct ast_json *json, const enum ast_event_ie_type ie_type)
This must stay at the end.
#define AST_SECURITY_EVENT_LOAD_AVG_VERSION
Event descriptor version.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
struct ast_json * ast_json_ipaddr(const struct ast_sockaddr *addr, enum ast_transport transport_type)
Construct an IP address as JSON.
#define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_INVAL_TRANSPORT_VERSION
Event descriptor version.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
const char * ast_security_event_get_name(const enum ast_security_event_type event_type)
Get the name of a security event sub-type.
enum ast_security_event_severity severity
const char * ast_event_get_ie_type_name(enum ast_event_ie_type ie_type)
Get the string representation of an information element type.
Abstract JSON element (object, array, string, int, ...).
#define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION
Event descriptor version.
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
static void security_stasis_cleanup(void)
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
struct ast_security_event_ie_type optional_ies[MAX_SECURITY_IES]
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
static const struct @419 severities[]
#define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION
Event descriptor version.
Something has gone wrong.
static struct ast_manager_event_blob * security_event_to_ami_blob(struct ast_json *json)
An attempt to contact a peer on an invalid transport.
#define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION
Event descriptor version.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
A request was made that we understand, but do not support.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.