[asterisk-commits] russell: branch group/security_events r199282 - in /team/group/security_event...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 5 14:10:29 CDT 2009
Author: russell
Date: Fri Jun 5 14:10:26 2009
New Revision: 199282
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=199282
Log:
Add a new event for call limits, including test generation code
Modified:
team/group/security_events/include/asterisk/security_events_defs.h
team/group/security_events/main/security_events.c
team/group/security_events/tests/test_security_events.c
Modified: team/group/security_events/include/asterisk/security_events_defs.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/include/asterisk/security_events_defs.h?view=diff&rev=199282&r1=199281&r2=199282
==============================================================================
--- team/group/security_events/include/asterisk/security_events_defs.h (original)
+++ team/group/security_events/include/asterisk/security_events_defs.h Fri Jun 5 14:10:26 2009
@@ -58,6 +58,13 @@
* this event should be used.
*/
AST_SECURITY_EVENT_INVAL_ACCT_ID,
+ /*!
+ * \brief Call limit reached
+ *
+ * A request has been denied because a configured call limit has been
+ * reached.
+ */
+ AST_SECURITY_EVENT_CALL_LIMIT,
/* \brief This _must_ stay at the end. */
AST_SECURITY_EVENT_NUM_TYPES
};
@@ -192,6 +199,49 @@
struct ast_security_event_ipv4_addr remote_addr;
};
+/*!
+ * \brief Request denied because of a call limit
+ */
+struct ast_security_event_call_limit {
+ /*!
+ * \brief Event descriptor version
+ * \note This _must_ be changed if this event descriptor is changed.
+ */
+ #define AST_SECURITY_EVENT_CALL_LIMIT_VERSION 1
+ /*! \brief Common security event descriptor elements */
+ struct ast_security_event_common common;
+ /*!
+ * \brief Module, Normally the AST_MODULE define
+ * \note optional
+ */
+ const char *module;
+ /*!
+ * \brief Account ID, specific to the service type
+ * \note required
+ */
+ const char *account_id;
+ /*!
+ * \brief Session ID, specific to the service type
+ * \note required
+ */
+ const char *session_id;
+ /*!
+ * \brief Session timeval, when the session started
+ * \note optional
+ */
+ const struct timeval *session_tv;
+ /*!
+ * \brief Local address the request came in on
+ * \note required
+ */
+ struct ast_security_event_ipv4_addr local_addr;
+ /*!
+ * \brief Remote address the request came from
+ * \note required
+ */
+ struct ast_security_event_ipv4_addr remote_addr;
+};
+
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/group/security_events/main/security_events.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/main/security_events.c?view=diff&rev=199282&r1=199281&r2=199282
==============================================================================
--- team/group/security_events/main/security_events.c (original)
+++ team/group/security_events/main/security_events.c Fri Jun 5 14:10:26 2009
@@ -85,6 +85,25 @@
},
},
+[AST_SECURITY_EVENT_CALL_LIMIT] = {
+ .name = "CallLimit",
+ .version = AST_SECURITY_EVENT_CALL_LIMIT_VERSION,
+ .required_ies = {
+ { AST_EVENT_IE_SERVICE, SEC_EVT_FIELD(common, service) },
+ { AST_EVENT_IE_EVENT_VERSION, SEC_EVT_FIELD(common, version) },
+ { AST_EVENT_IE_ACCOUNT_ID, SEC_EVT_FIELD(call_limit, account_id) },
+ { AST_EVENT_IE_SESSION_ID, SEC_EVT_FIELD(call_limit, session_id) },
+ { AST_EVENT_IE_LOCAL_ADDR, SEC_EVT_FIELD(call_limit, local_addr) },
+ { AST_EVENT_IE_REMOTE_ADDR, SEC_EVT_FIELD(call_limit, remote_addr) },
+ { AST_EVENT_IE_END, 0 }
+ },
+ .optional_ies = {
+ { AST_EVENT_IE_MODULE, SEC_EVT_FIELD(call_limit, module) },
+ { AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(call_limit, session_tv) },
+ { AST_EVENT_IE_END, 0 }
+ },
+},
+
#undef SEC_EVT_FIELD
};
Modified: team/group/security_events/tests/test_security_events.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/tests/test_security_events.c?view=diff&rev=199282&r1=199281&r2=199282
==============================================================================
--- team/group/security_events/tests/test_security_events.c (original)
+++ team/group/security_events/tests/test_security_events.c Fri Jun 5 14:10:26 2009
@@ -38,11 +38,13 @@
static void evt_gen_failed_acl(void);
static void evt_gen_inval_acct_id(void);
+static void evt_gen_call_limit(void);
typedef void (*evt_generator)(void);
evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
[AST_SECURITY_EVENT_FAILED_ACL] = evt_gen_failed_acl,
[AST_SECURITY_EVENT_INVAL_ACCT_ID] = evt_gen_inval_acct_id,
+ [AST_SECURITY_EVENT_CALL_LIMIT] = evt_gen_call_limit,
};
static void evt_gen_failed_acl(void)
@@ -118,6 +120,44 @@
sin_remote.sin_port = htons(1234);
ast_security_event_report(AST_SEC_EVT(&inval_acct_id));
+}
+
+static void evt_gen_call_limit(void)
+{
+ struct sockaddr_in sin_local = {
+ .sin_family = AF_INET
+ };
+ struct sockaddr_in sin_remote = {
+ .sin_family = AF_INET
+ };
+ struct timeval session_tv = ast_tvnow();
+ struct ast_security_event_call_limit call_limit = {
+ .common.event_type = AST_SECURITY_EVENT_CALL_LIMIT,
+ .common.version = AST_SECURITY_EVENT_CALL_LIMIT_VERSION,
+ .common.service = "TEST",
+
+ .module = AST_MODULE,
+ .account_id = "Jenny",
+ .session_id = "8675309",
+ .session_tv = &session_tv,
+ .local_addr = {
+ .sin = &sin_local,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TLS,
+ },
+ .remote_addr = {
+ .sin = &sin_remote,
+ .transport = AST_SECURITY_EVENT_TRANSPORT_TLS,
+ },
+ };
+
+ inet_aton("10.5.4.3", &sin_local.sin_addr);
+ sin_local.sin_port = htons(4444);
+
+ inet_aton("10.5.4.2", &sin_remote.sin_addr);
+ sin_remote.sin_port = htons(3333);
+
+ ast_security_event_report(AST_SEC_EVT(&call_limit));
+
}
static void gen_events(struct ast_cli_args *a)
More information about the asterisk-commits
mailing list