[svn-commits] russell: branch group/security_events r199293 - in /team/group/security_event...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 5 15:47:24 CDT 2009


Author: russell
Date: Fri Jun  5 15:47:21 2009
New Revision: 199293

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=199293
Log:
Add support and test code for Request Not Supported security event

Modified:
    team/group/security_events/include/asterisk/security_events_defs.h
    team/group/security_events/main/security_events.c
    team/group/security_events/security_events.txt
    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=199293&r1=199292&r2=199293
==============================================================================
--- team/group/security_events/include/asterisk/security_events_defs.h (original)
+++ team/group/security_events/include/asterisk/security_events_defs.h Fri Jun  5 15:47:21 2009
@@ -79,6 +79,10 @@
 	 * reached.
 	 */
 	AST_SECURITY_EVENT_LOAD_AVG,
+	/*!
+	 * \brief A request was made that we understand, but do not support
+	 */
+	AST_SECURITY_EVENT_REQ_NO_SUPPORT,
 	/* \brief This _must_ stay at the end. */
 	AST_SECURITY_EVENT_NUM_TYPES
 };
@@ -342,6 +346,54 @@
 	struct ast_security_event_ipv4_addr remote_addr;
 };
 
+/*!
+ * \brief Request denied because we don't support it
+ */
+struct ast_security_event_req_no_support {
+	/*!
+	 * \brief Event descriptor version
+	 * \note This _must_ be changed if this event descriptor is changed.
+	 */
+	#define AST_SECURITY_EVENT_REQ_NO_SUPPORT_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;
+	/*!
+	 * \brief Request type that was made
+	 * \note required
+	 */
+	const char *request_type;
+};
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

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=199293&r1=199292&r2=199293
==============================================================================
--- team/group/security_events/main/security_events.c (original)
+++ team/group/security_events/main/security_events.c Fri Jun  5 15:47:21 2009
@@ -38,7 +38,7 @@
 static const struct {
 	const char *name;
 	uint32_t version;
-#define MAX_SECURITY_IES 8
+#define MAX_SECURITY_IES 9
 	struct ast_security_event_ie_type required_ies[MAX_SECURITY_IES];
 	struct ast_security_event_ie_type optional_ies[MAX_SECURITY_IES];
 #undef MAX_SECURITY_IES
@@ -143,6 +143,27 @@
 	.optional_ies = {
 		{ AST_EVENT_IE_MODULE, SEC_EVT_FIELD(load_avg, module) },
 		{ AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(load_avg, session_tv) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+},
+
+[AST_SECURITY_EVENT_REQ_NO_SUPPORT] = {
+	.name    = "RequestNotSupported",
+	.version = AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION,
+	.required_ies = {
+		{ AST_EVENT_IE_EVENT_TV, 0 },
+		{ 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(req_no_support, account_id) },
+		{ AST_EVENT_IE_SESSION_ID, SEC_EVT_FIELD(req_no_support, session_id) },
+		{ AST_EVENT_IE_LOCAL_ADDR, SEC_EVT_FIELD(req_no_support, local_addr) },
+		{ AST_EVENT_IE_REMOTE_ADDR, SEC_EVT_FIELD(req_no_support, remote_addr) },
+		{ AST_EVENT_IE_REQUEST_TYPE, SEC_EVT_FIELD(req_no_support, request_type) },
+		{ AST_EVENT_IE_END, 0 }
+	},
+	.optional_ies = {
+		{ AST_EVENT_IE_MODULE, SEC_EVT_FIELD(req_no_support, module) },
+		{ AST_EVENT_IE_SESSION_TV, SEC_EVT_FIELD(req_no_support, session_tv) },
 		{ AST_EVENT_IE_END, 0 }
 	},
 },
@@ -264,6 +285,8 @@
 	case AST_EVENT_IE_SESSION_ID:
 	case AST_EVENT_IE_MODULE:
 	case AST_EVENT_IE_ACL_NAME:
+	case AST_EVENT_IE_REQUEST_TYPE:
+	case AST_EVENT_IE_REQUEST_PARAMS:
 	{
 		const char *str;
 

Modified: team/group/security_events/security_events.txt
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/security_events.txt?view=diff&rev=199293&r1=199292&r2=199293
==============================================================================
--- team/group/security_events/security_events.txt (original)
+++ team/group/security_events/security_events.txt Fri Jun  5 15:47:21 2009
@@ -163,7 +163,7 @@
 Request Not Supported
  -> everything from inval account ID
  (-) Request Type
- DevNotes:
+ DevNotes: defined, has test code
 
 Unacceptable auth method
  -> everything from inval account ID
@@ -205,7 +205,8 @@
 
 IE: SecurityEvent
 Content: This is the security event sub-type.  
-Values: FailedACL, InvalidAccountID, CallLimit, MemoryLimit, LoadAverageLimit
+Values: FailedACL, InvalidAccountID, CallLimit, MemoryLimit, LoadAverageLimit,
+        RequestNotSupported
 
 IE: EventVersion
 Content: This is a numeric value that indicates when updates are made to the

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=199293&r1=199292&r2=199293
==============================================================================
--- team/group/security_events/tests/test_security_events.c (original)
+++ team/group/security_events/tests/test_security_events.c Fri Jun  5 15:47:21 2009
@@ -41,14 +41,16 @@
 static void evt_gen_call_limit(void);
 static void evt_gen_mem_limit(void);
 static void evt_gen_load_avg(void);
+static void evt_gen_req_no_support(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,
-	[AST_SECURITY_EVENT_MEM_LIMIT]     = evt_gen_mem_limit,
-	[AST_SECURITY_EVENT_LOAD_AVG]      = evt_gen_load_avg,
+	[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,
+	[AST_SECURITY_EVENT_MEM_LIMIT]      = evt_gen_mem_limit,
+	[AST_SECURITY_EVENT_LOAD_AVG]       = evt_gen_load_avg,
+	[AST_SECURITY_EVENT_REQ_NO_SUPPORT] = evt_gen_req_no_support,
 };
 
 static void evt_gen_failed_acl(void)
@@ -236,6 +238,44 @@
 	sin_remote.sin_port = htons(9825);
 
 	ast_security_event_report(AST_SEC_EVT(&load_avg));
+}
+
+static void evt_gen_req_no_support(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_req_no_support req_no_support = {
+		.common.event_type = AST_SECURITY_EVENT_REQ_NO_SUPPORT,
+		.common.version    = AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION,
+		.common.service    = "TEST",
+
+		.module     = AST_MODULE,
+		.account_id = "George",
+		.session_id = "alksdjf023423h4lka0df",
+		.session_tv = &session_tv,
+		.local_addr = {
+			.sin  = &sin_local,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_UDP,
+		},
+		.remote_addr = {
+			.sin = &sin_remote,
+			.transport  = AST_SECURITY_EVENT_TRANSPORT_UDP,
+		},
+		.request_type = "MakeMeDinner",
+	};
+
+	inet_aton("10.110.120.130", &sin_local.sin_addr);
+	sin_local.sin_port = htons(9888);
+
+	inet_aton("10.120.110.100", &sin_remote.sin_addr);
+	sin_remote.sin_port = htons(9777);
+
+	ast_security_event_report(AST_SEC_EVT(&req_no_support));
 }
 
 static void gen_events(struct ast_cli_args *a)




More information about the svn-commits mailing list