@ -1,7 +1,7 @@
/*
/*
* Asterisk - - An open source telephony toolkit .
* Asterisk - - An open source telephony toolkit .
*
*
* Copyright ( C ) 20 09 , Digium , Inc .
* Copyright ( C ) 20 12 , Digium , Inc .
*
*
* Russell Bryant < russell @ digium . com >
* Russell Bryant < russell @ digium . com >
*
*
@ -36,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# include "asterisk/cli.h"
# include "asterisk/cli.h"
# include "asterisk/utils.h"
# include "asterisk/utils.h"
# include "asterisk/security_events.h"
# include "asterisk/security_events.h"
# include "asterisk/netsock2.h"
static void evt_gen_failed_acl ( void ) ;
static void evt_gen_failed_acl ( void ) ;
static void evt_gen_inval_acct_id ( void ) ;
static void evt_gen_inval_acct_id ( void ) ;
@ -70,12 +71,9 @@ static const evt_generator evt_generators[AST_SECURITY_EVENT_NUM_TYPES] = {
static void evt_gen_failed_acl ( void )
static void evt_gen_failed_acl ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_failed_acl failed_acl_event = {
struct ast_security_event_failed_acl failed_acl_event = {
. common . event_type = AST_SECURITY_EVENT_FAILED_ACL ,
. common . event_type = AST_SECURITY_EVENT_FAILED_ACL ,
@ -86,34 +84,34 @@ static void evt_gen_failed_acl(void)
. common . session_id = " Session123 " ,
. common . session_id = " Session123 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. acl_name = " TEST_ACL " ,
. acl_name = " TEST_ACL " ,
} ;
} ;
inet_aton ( " 192.168.1.1 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 12121 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 192.168.1.1:12121 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 192.168.1.2:12345 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 192.168.1.2 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 12345 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & failed_acl_event ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & failed_acl_event ) ) ;
}
}
static void evt_gen_inval_acct_id ( void )
static void evt_gen_inval_acct_id ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_inval_acct_id inval_acct_id = {
struct ast_security_event_inval_acct_id inval_acct_id = {
. common . event_type = AST_SECURITY_EVENT_INVAL_ACCT_ID ,
. common . event_type = AST_SECURITY_EVENT_INVAL_ACCT_ID ,
@ -124,32 +122,32 @@ static void evt_gen_inval_acct_id(void)
. common . session_id = " Session456 " ,
. common . session_id = " Session456 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.1.2.3 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4321 ) ;
char remoteaddr [ 53 ] ;
inet_aton ( " 10.1.2.4 " , & sin_remote . sin_addr ) ;
ast_copy_string ( localaddr , " 10.1.2.3:4321 " , sizeof ( localaddr ) ) ;
sin_remote . sin_port = htons ( 1234 ) ;
ast_copy_string ( remoteaddr , " 10.1.2.4:123 " , sizeof ( remoteaddr ) ) ;
ast_sockaddr_parse ( & addr_local , localaddr , 0 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & inval_acct_id ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & inval_acct_id ) ) ;
}
}
static void evt_gen_session_limit ( void )
static void evt_gen_session_limit ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_session_limit session_limit = {
struct ast_security_event_session_limit session_limit = {
. common . event_type = AST_SECURITY_EVENT_SESSION_LIMIT ,
. common . event_type = AST_SECURITY_EVENT_SESSION_LIMIT ,
@ -160,32 +158,32 @@ static void evt_gen_session_limit(void)
. common . session_id = " 8675309 " ,
. common . session_id = " 8675309 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TLS ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TLS ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TLS ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TLS ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.5.4.3 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4444 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.5.4.3:4444 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.5.4.2:3333 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.5.4.2 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 3333 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & session_limit ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & session_limit ) ) ;
}
}
static void evt_gen_mem_limit ( void )
static void evt_gen_mem_limit ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_mem_limit mem_limit = {
struct ast_security_event_mem_limit mem_limit = {
. common . event_type = AST_SECURITY_EVENT_MEM_LIMIT ,
. common . event_type = AST_SECURITY_EVENT_MEM_LIMIT ,
@ -196,32 +194,32 @@ static void evt_gen_mem_limit(void)
. common . session_id = " Session2604 " ,
. common . session_id = " Session2604 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.10.10.10 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 555 ) ;
char remoteaddr [ 53 ] ;
inet_aton ( " 10.10.10.12 " , & sin_remote . sin_addr ) ;
ast_copy_string ( localaddr , " 10.10.10.10:555 " , sizeof ( localaddr ) ) ;
sin_remote . sin_port = htons ( 5656 ) ;
ast_copy_string ( remoteaddr , " 10.10.10.12:5656 " , sizeof ( remoteaddr ) ) ;
ast_sockaddr_parse ( & addr_local , localaddr , 0 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & mem_limit ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & mem_limit ) ) ;
}
}
static void evt_gen_load_avg ( void )
static void evt_gen_load_avg ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_load_avg load_avg = {
struct ast_security_event_load_avg load_avg = {
. common . event_type = AST_SECURITY_EVENT_LOAD_AVG ,
. common . event_type = AST_SECURITY_EVENT_LOAD_AVG ,
@ -232,32 +230,32 @@ static void evt_gen_load_avg(void)
. common . session_id = " XYZ123 " ,
. common . session_id = " XYZ123 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.11.12.13 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 9876 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.11.12.13:9876 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.12.11.10:9825 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.12.11.10 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 9825 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & load_avg ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & load_avg ) ) ;
}
}
static void evt_gen_req_no_support ( void )
static void evt_gen_req_no_support ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_req_no_support req_no_support = {
struct ast_security_event_req_no_support req_no_support = {
. common . event_type = AST_SECURITY_EVENT_REQ_NO_SUPPORT ,
. common . event_type = AST_SECURITY_EVENT_REQ_NO_SUPPORT ,
@ -268,34 +266,34 @@ static void evt_gen_req_no_support(void)
. common . session_id = " asdkl23478289lasdkf " ,
. common . session_id = " asdkl23478289lasdkf " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. request_type = " MakeMeDinner " ,
. request_type = " MakeMeDinner " ,
} ;
} ;
inet_aton ( " 10.110.120.130 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 9888 ) ;
char remoteaddr [ 53 ] ;
inet_aton ( " 10.120.110.100 " , & sin_remote . sin_addr ) ;
ast_copy_string ( localaddr , " 10.110.120.130:9888 " , sizeof ( localaddr ) ) ;
sin_remote . sin_port = htons ( 9777 ) ;
ast_copy_string ( remoteaddr , " 10.120.110.100:9777 " , sizeof ( remoteaddr ) ) ;
ast_sockaddr_parse ( & addr_local , localaddr , 0 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_no_support ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_no_support ) ) ;
}
}
static void evt_gen_req_not_allowed ( void )
static void evt_gen_req_not_allowed ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_req_not_allowed req_not_allowed = {
struct ast_security_event_req_not_allowed req_not_allowed = {
. common . event_type = AST_SECURITY_EVENT_REQ_NOT_ALLOWED ,
. common . event_type = AST_SECURITY_EVENT_REQ_NOT_ALLOWED ,
@ -306,11 +304,11 @@ static void evt_gen_req_not_allowed(void)
. common . session_id = " alksdjf023423h4lka0df " ,
. common . session_id = " alksdjf023423h4lka0df " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
@ -318,23 +316,23 @@ static void evt_gen_req_not_allowed(void)
. request_params = " BACONNNN! " ,
. request_params = " BACONNNN! " ,
} ;
} ;
inet_aton ( " 10.110.120.130 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 9888 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.110.120.130:9888 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.120.110.100:9777 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.120.110.100 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 9777 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_not_allowed ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_not_allowed ) ) ;
}
}
static void evt_gen_auth_method_not_allowed ( void )
static void evt_gen_auth_method_not_allowed ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_auth_method_not_allowed auth_method_not_allowed = {
struct ast_security_event_auth_method_not_allowed auth_method_not_allowed = {
. common . event_type = AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED ,
. common . event_type = AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED ,
@ -345,34 +343,34 @@ static void evt_gen_auth_method_not_allowed(void)
. common . session_id = " 010101010101 " ,
. common . session_id = " 010101010101 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. auth_method = " PlainText "
. auth_method = " PlainText "
} ;
} ;
inet_aton ( " 10.110.120.135 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 8754 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.110.120.135:8754 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.120.110.105:8745 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.120.110.105 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 8745 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & auth_method_not_allowed ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & auth_method_not_allowed ) ) ;
}
}
static void evt_gen_req_bad_format ( void )
static void evt_gen_req_bad_format ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_req_bad_format req_bad_format = {
struct ast_security_event_req_bad_format req_bad_format = {
. common . event_type = AST_SECURITY_EVENT_REQ_BAD_FORMAT ,
. common . event_type = AST_SECURITY_EVENT_REQ_BAD_FORMAT ,
@ -383,11 +381,11 @@ static void evt_gen_req_bad_format(void)
. common . session_id = " 838383fhfhf83hf8h3f8h " ,
. common . session_id = " 838383fhfhf83hf8h3f8h " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
@ -395,23 +393,23 @@ static void evt_gen_req_bad_format(void)
. request_params = " Onions,Swiss,MotorOil " ,
. request_params = " Onions,Swiss,MotorOil " ,
} ;
} ;
inet_aton ( " 10.110.220.230 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 1212 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.110.220.230:1212 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.120.210.200:2121 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.120.210.200 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 2121 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_bad_format ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & req_bad_format ) ) ;
}
}
static void evt_gen_successful_auth ( void )
static void evt_gen_successful_auth ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_successful_auth successful_auth = {
struct ast_security_event_successful_auth successful_auth = {
. common . event_type = AST_SECURITY_EVENT_SUCCESSFUL_AUTH ,
. common . event_type = AST_SECURITY_EVENT_SUCCESSFUL_AUTH ,
@ -422,35 +420,33 @@ static void evt_gen_successful_auth(void)
. common . session_id = " Session456 " ,
. common . session_id = " Session456 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.1.2.3 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4321 ) ;
char remoteaddr [ 53 ] ;
inet_aton ( " 10.1.2.4 " , & sin_remote . sin_addr ) ;
ast_copy_string ( localaddr , " 10.1.2.3:4321 " , sizeof ( localaddr ) ) ;
sin_remote . sin_port = htons ( 1234 ) ;
ast_copy_string ( remoteaddr , " 10.1.2.4:1234 " , sizeof ( remoteaddr ) ) ;
ast_sockaddr_parse ( & addr_local , localaddr , 0 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & successful_auth ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & successful_auth ) ) ;
}
}
static void evt_gen_unexpected_addr ( void )
static void evt_gen_unexpected_addr ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct ast_sockaddr addr_expected = { { 0 , } } ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct sockaddr_in sin_expected = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_unexpected_addr unexpected_addr = {
struct ast_security_event_unexpected_addr unexpected_addr = {
. common . event_type = AST_SECURITY_EVENT_UNEXPECTED_ADDR ,
. common . event_type = AST_SECURITY_EVENT_UNEXPECTED_ADDR ,
@ -461,40 +457,40 @@ static void evt_gen_unexpected_addr(void)
. common . session_id = " Session789 " ,
. common . session_id = " Session789 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
. expected_addr = {
. expected_addr = {
. sin = & sin _expected,
. addr = & addr _expected,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_UDP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.1.2.3 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4321 ) ;
char remoteaddr [ 53 ] ;
char expectedaddr [ 53 ] ;
inet_aton ( " 10.1.2.4 " , & sin_remote . sin_addr ) ;
ast_copy_string ( localaddr , " 10.1.2.3:4321 " , sizeof ( localaddr ) ) ;
sin_remote . sin_port = htons ( 1234 ) ;
ast_copy_string ( remoteaddr , " 10.1.2.4:1234 " , sizeof ( remoteaddr ) ) ;
ast_copy_string ( expectedaddr , " 10.1.2.5:2343 " , sizeof ( expectedaddr ) ) ;
inet_aton ( " 10.1.2.5 " , & sin_expected . sin_addr ) ;
ast_sockaddr_parse ( & addr_local , localaddr , 0 ) ;
sin_expected . sin_port = htons ( 2343 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_sockaddr_parse ( & addr_expected , expectedaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & unexpected_addr ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & unexpected_addr ) ) ;
}
}
static void evt_gen_chal_resp_failed ( void )
static void evt_gen_chal_resp_failed ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_chal_resp_failed chal_resp_failed = {
struct ast_security_event_chal_resp_failed chal_resp_failed = {
. common . event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED ,
. common . event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED ,
@ -505,11 +501,11 @@ static void evt_gen_chal_resp_failed(void)
. common . session_id = " Session1231231231 " ,
. common . session_id = " Session1231231231 " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
@ -518,23 +514,23 @@ static void evt_gen_chal_resp_failed(void)
. expected_response = " oiafaljhadf9834luahk3k " ,
. expected_response = " oiafaljhadf9834luahk3k " ,
} ;
} ;
inet_aton ( " 10.1.2.3 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4321 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.1.2.3:4321 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.1.2.4:1234 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.1.2.4 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 1234 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & chal_resp_failed ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & chal_resp_failed ) ) ;
}
}
static void evt_gen_inval_password ( void )
static void evt_gen_inval_password ( void )
{
{
struct sockaddr_in sin_local = {
struct ast_sockaddr addr_local = { { 0 , } } ;
. sin_family = AF_INET
struct ast_sockaddr addr_remote = { { 0 , } } ;
} ;
struct sockaddr_in sin_remote = {
. sin_family = AF_INET
} ;
struct timeval session_tv = ast_tvnow ( ) ;
struct timeval session_tv = ast_tvnow ( ) ;
struct ast_security_event_inval_password inval_password = {
struct ast_security_event_inval_password inval_password = {
. common . event_type = AST_SECURITY_EVENT_INVAL_PASSWORD ,
. common . event_type = AST_SECURITY_EVENT_INVAL_PASSWORD ,
@ -545,20 +541,23 @@ static void evt_gen_inval_password(void)
. common . session_id = " SessionIDGoesHere " ,
. common . session_id = " SessionIDGoesHere " ,
. common . session_tv = & session_tv ,
. common . session_tv = & session_tv ,
. common . local_addr = {
. common . local_addr = {
. sin = & sin _local,
. addr = & addr _local,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
. common . remote_addr = {
. common . remote_addr = {
. sin = & sin _remote,
. addr = & addr _remote,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
. transport = AST_SECURITY_EVENT_TRANSPORT_TCP ,
} ,
} ,
} ;
} ;
inet_aton ( " 10.200.100.30 " , & sin_local . sin_addr ) ;
char localaddr [ 53 ] ;
sin_local . sin_port = htons ( 4321 ) ;
char remoteaddr [ 53 ] ;
ast_copy_string ( localaddr , " 10.200.100.30:4321 " , sizeof ( localaddr ) ) ;
ast_copy_string ( remoteaddr , " 10.200.100.40:1234 " , sizeof ( remoteaddr ) ) ;
inet_aton ( " 10.200.100.40 " , & sin_remote . sin_addr ) ;
ast_sockaddr_parse( & addr_local , localaddr , 0 ) ;
sin_remote . sin_port = htons ( 1234 ) ;
ast_sockaddr_parse ( & addr_remote , remoteaddr , 0 ) ;
ast_security_event_report ( AST_SEC_EVT ( & inval_password ) ) ;
ast_security_event_report ( AST_SEC_EVT ( & inval_password ) ) ;
}
}