|
|
|
@ -25,6 +25,10 @@ kernelEventFilterBubble::~kernelEventFilterBubble(){ |
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++) free(*idx); |
|
|
|
m_vTargetBubbles.clear(); |
|
|
|
}; |
|
|
|
if ( m_vFrozenBubbles.size() ) { |
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vFrozenBubbles.begin(); idx != m_vFrozenBubbles.end(); idx++) free(*idx); |
|
|
|
m_vFrozenBubbles.clear(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t kernelEventFilterBubble::serial = 0; |
|
|
|
@ -41,42 +45,50 @@ bool kernelEventFilterBubble::createBubble( TARGET_DATA *ptr ){ |
|
|
|
tData->system_center.z = ptr->system_target.z; |
|
|
|
//Only In Case of Disabling
|
|
|
|
//tData->id = m_pDBC->addRegisteredBubble( tData );
|
|
|
|
if( createBubble( tData, true ) ) return true; |
|
|
|
if( createBubbleExt( tData, true, false ) ) return true; |
|
|
|
free( tData ); |
|
|
|
}; |
|
|
|
return false; |
|
|
|
}; |
|
|
|
|
|
|
|
bool kernelEventFilterBubble::createBubble( TARGET_SEGMENT *ptr, bool locking ){ |
|
|
|
if ( ptr == NULL ) return false; |
|
|
|
if( ptr->hit_count >= m_sBubbleFilterData.min_block_counts ){ |
|
|
|
bool kernelEventFilterBubble::createBubbleExt( TARGET_SEGMENT *ptr, bool locking, bool frozen ){ |
|
|
|
if ( ptr == NULL ) return false; |
|
|
|
//Additional checking for Frozen not be harmful
|
|
|
|
if( ptr->hit_count >= m_sBubbleFilterData.min_block_counts || frozen ){ |
|
|
|
ptr->mode = TS_MODE_PERMANENT; |
|
|
|
frozen = true; |
|
|
|
} else { |
|
|
|
ptr->bts = getMilliseconds(); |
|
|
|
ptr->ttl = ptr->bts + m_sBubbleFilterData.ttl; |
|
|
|
}; |
|
|
|
if( locking ) m_mDataProtector.lock(); |
|
|
|
m_vTargetBubbles.push_back( ptr ); |
|
|
|
if( locking ) m_mDataProtector.unlock(); |
|
|
|
|
|
|
|
if ( m_sBubbleFilterData.enable_evt && ( ptr->mode == 0 ) ) { |
|
|
|
//Triggering Session in Kernel
|
|
|
|
kernelPrototype *AK = kernelPrototype::getInstance(); |
|
|
|
if ( AK ) AK->startSession(); |
|
|
|
|
|
|
|
TARGET_DATA *tData = (TARGET_DATA *)malloc(sizeof(TARGET_DATA)); |
|
|
|
if ( tData ) { |
|
|
|
memset( tData, 0, sizeof(TARGET_DATA) ); |
|
|
|
tData->area = ptr->boundary * 100; |
|
|
|
tData->lrf_id = ptr->segment_id & 0xFF; |
|
|
|
decart2spherical( ptr->system_center, tData->local_target ); |
|
|
|
tData->digital = 0; |
|
|
|
tData->system_target.x = ptr->system_center.x; |
|
|
|
tData->system_target.y = ptr->system_center.y; |
|
|
|
tData->system_target.z = ptr->system_center.z; |
|
|
|
tData->segment_id = ptr->segment_id; |
|
|
|
createFilterEvent( EVT_FLT_BUBBLE_CREATED, tData ); |
|
|
|
free( tData ); |
|
|
|
if ( frozen ) { |
|
|
|
if ( locking ) m_mDataProtector.lock(); |
|
|
|
m_vFrozenBubbles.push_back( ptr ); |
|
|
|
if ( locking ) m_mDataProtector.unlock(); |
|
|
|
} else { |
|
|
|
if ( locking ) m_mDataProtector.lock(); |
|
|
|
m_vTargetBubbles.push_back( ptr ); |
|
|
|
if ( locking ) m_mDataProtector.unlock(); |
|
|
|
//Trig Create Event only for Newborn baby bubbles
|
|
|
|
if ( m_sBubbleFilterData.enable_evt && ( ptr->mode == 0 ) ) { |
|
|
|
//Triggering Session in Kernel
|
|
|
|
kernelPrototype *AK = kernelPrototype::getInstance(); |
|
|
|
if ( AK ) AK->startSession(); |
|
|
|
|
|
|
|
TARGET_DATA *tData = (TARGET_DATA *)malloc(sizeof(TARGET_DATA)); |
|
|
|
if ( tData ) { |
|
|
|
memset( tData, 0, sizeof(TARGET_DATA) ); |
|
|
|
tData->area = ptr->boundary * 100; |
|
|
|
tData->lrf_id = ptr->segment_id & 0xFF; |
|
|
|
decart2spherical( ptr->system_center, tData->local_target ); |
|
|
|
tData->digital = 0; |
|
|
|
tData->system_target.x = ptr->system_center.x; |
|
|
|
tData->system_target.y = ptr->system_center.y; |
|
|
|
tData->system_target.z = ptr->system_center.z; |
|
|
|
tData->segment_id = ptr->segment_id; |
|
|
|
createFilterEvent( EVT_FLT_BUBBLE_CREATED, tData ); |
|
|
|
free( tData ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
return true; |
|
|
|
@ -116,7 +128,7 @@ bool kernelEventFilterBubble::initFilter(){ |
|
|
|
for ( DBC_INT_LIST::iterator idx = tList->begin(); idx != tList->end(); idx++ ) { |
|
|
|
TARGET_SEGMENT *tBubble = m_pDBC->getRegisteredBubble( *idx ); |
|
|
|
if ( tBubble ) { |
|
|
|
if ( !createBubble( tBubble, false ) ) free( tBubble ); |
|
|
|
if ( !createBubbleExt( tBubble, false, true ) ) free( tBubble ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -190,7 +202,8 @@ bool kernelEventFilterBubble::updateBubble( TARGET_SEGMENT *bubble, TARGET_DATA |
|
|
|
if ( target == NULL ) return false; |
|
|
|
uint64_t cts = getMilliseconds(); |
|
|
|
bubble->ttl = cts + m_sBubbleFilterData.ttl; |
|
|
|
if( bubble->mode < TS_MODE_PERMANENT ){ |
|
|
|
//Since We have Frozen Bubbles in Different Vector -> No need to check here
|
|
|
|
//if( bubble->mode < TS_MODE_PERMANENT ){
|
|
|
|
//Only Active Bubles
|
|
|
|
if ( bubble->mode < TS_MODE_PUNCHED ) { |
|
|
|
#ifdef BUBBLE_TIME_BUCKET
|
|
|
|
@ -248,20 +261,25 @@ bool kernelEventFilterBubble::updateBubble( TARGET_SEGMENT *bubble, TARGET_DATA |
|
|
|
if ( bubble->boundary > m_sBubbleFilterData.maximal_range ) { |
|
|
|
bubble->boundary = m_sBubbleFilterData.maximal_range; |
|
|
|
}; |
|
|
|
}; |
|
|
|
//};
|
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool kernelEventFilterBubble::blockCurrentActiveBubbles(){ |
|
|
|
m_mDataProtector.lock(); |
|
|
|
for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++ ) { |
|
|
|
for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); /* idx++ */ ) { |
|
|
|
if( (*idx)->mode == TS_MODE_PUNCHED ){ |
|
|
|
if( m_pDBC->updateRegisteredBubble((*idx)) < m_sBubbleFilterData.min_block_counts ){ |
|
|
|
(*idx)->mode = TS_MODE_BLOCKED; |
|
|
|
idx++; |
|
|
|
} else { |
|
|
|
(*idx)->mode = TS_MODE_PERMANENT; |
|
|
|
// Instead of converting bubble to a permanent indaplace - remove and add to Frozen Vector
|
|
|
|
TARGET_SEGMENT *tSegment = (*idx); |
|
|
|
m_vTargetBubbles.erase( idx ); |
|
|
|
m_vFrozenBubbles.push_back( tSegment ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else idx++; |
|
|
|
}; |
|
|
|
m_mDataProtector.unlock(); |
|
|
|
}; |
|
|
|
@ -273,6 +291,10 @@ bool kernelEventFilterBubble::resetAllBubbles(){ |
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++) free(*idx); |
|
|
|
m_vTargetBubbles.clear(); |
|
|
|
}; |
|
|
|
if ( m_vFrozenBubbles.size() ) { |
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vFrozenBubbles.begin(); idx != m_vFrozenBubbles.end(); idx++) free(*idx); |
|
|
|
m_vFrozenBubbles.clear(); |
|
|
|
}; |
|
|
|
m_mDataProtector.unlock(); |
|
|
|
}; |
|
|
|
|
|
|
|
@ -290,6 +312,19 @@ bool kernelEventFilterBubble::validateTarget( uint32_t DevID, TARGET_DATA *ptr ) |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
//If The Bubble was not found in Current Regular Bubbles Only Then Check a Frozen Vector
|
|
|
|
if ( cBubble == NULL ) { |
|
|
|
if ( m_vFrozenBubbles.size() ) { |
|
|
|
for( V_TARGET_SEGMENTS::iterator idx = m_vFrozenBubbles.begin(); idx != m_vFrozenBubbles.end(); idx++ ){ |
|
|
|
if ( checkBubble( *idx, ptr ) ) { |
|
|
|
// No Update of Frozen Bubbles
|
|
|
|
//updateBubble( *idx, ptr );
|
|
|
|
cBubble = *idx; |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
m_mDataProtector.unlock(); |
|
|
|
if ( cBubble != NULL ) { |
|
|
|
if( cBubble->mode == TS_MODE_PUNCHED ) { |
|
|
|
@ -321,6 +356,7 @@ bool kernelEventFilterBubble::validateTarget( uint32_t DevID, TARGET_DATA *ptr ) |
|
|
|
RetValue = true; |
|
|
|
}; |
|
|
|
} else { |
|
|
|
// The Bubble was not found nor Regular nor Frozen -> Creating New
|
|
|
|
RetValue = createBubble( ptr ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -381,13 +417,10 @@ bool kernelEventFilterBubble::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|
|
|
case EVT_FLT_BUBBLES_BLOCK: blockCurrentActiveBubbles(); break; |
|
|
|
case EVT_FLT_BUBBLES_RELOAD:{ |
|
|
|
m_mDataProtector.lock(); |
|
|
|
if ( m_vTargetBubbles.size() ) { |
|
|
|
//Erase Currently loadded Permanent Bubbles
|
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); ) |
|
|
|
if( (*idx)->mode > TS_MODE_BLOCKED ){ |
|
|
|
free(*idx); |
|
|
|
m_vTargetBubbles.erase(idx); |
|
|
|
} else idx++; |
|
|
|
if ( m_vFrozenBubbles.size() ) { |
|
|
|
//Erase Currently loadded Permanent(FROZEN) Bubbles
|
|
|
|
for (V_TARGET_SEGMENTS::iterator idx = m_vFrozenBubbles.begin(); idx != m_vFrozenBubbles.end(); idx++ ) free(*idx); |
|
|
|
m_vFrozenBubbles.clear(); |
|
|
|
}; |
|
|
|
DBC_INT_LIST *tList = m_pDBC->listFrozenBubbles( m_sBubbleFilterData.min_block_counts ); |
|
|
|
if ( tList ) { |
|
|
|
@ -395,7 +428,7 @@ bool kernelEventFilterBubble::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|
|
|
for ( DBC_INT_LIST::iterator idx = tList->begin(); idx != tList->end(); idx++ ) { |
|
|
|
TARGET_SEGMENT *tBubble = m_pDBC->getRegisteredBubble( *idx ); |
|
|
|
if ( tBubble ) { |
|
|
|
if ( !createBubble( tBubble, false ) ) free( tBubble ); |
|
|
|
if ( !createBubbleExt( tBubble, false, true ) ) free( tBubble ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|