@ -136,6 +136,13 @@ void mme::run_thread()
FD_SET ( s1mme , & m_set ) ;
FD_SET ( s11 , & m_set ) ;
// Add timers to select
for ( std : : vector < mme_timer_t > : : iterator it = m_timers . begin ( ) ; it ! = m_timers . end ( ) ; + + it ) {
FD_SET ( it - > fd , & m_set ) ;
max_fd = std : : max ( max_fd , it - > fd ) ;
m_s1ap_log - > debug ( " Adding Timer fd %d to fd_set \n " , it - > fd ) ;
}
m_s1ap_log - > debug ( " Waiting for S1-MME or S11 Message \n " ) ;
int n = select ( max_fd + 1 , & m_set , NULL , NULL , NULL ) ;
if ( n = = - 1 ) {
@ -171,10 +178,71 @@ void mme::run_thread()
pdu - > N_bytes = recvfrom ( s11 , pdu - > msg , SRSLTE_MAX_BUFFER_SIZE_BYTES , 0 , NULL , NULL ) ;
m_mme_gtpc - > handle_s11_pdu ( pdu ) ;
}
// Handle NAS Timers
for ( std : : vector < mme_timer_t > : : iterator it = m_timers . begin ( ) ; it ! = m_timers . end ( ) ; ) {
if ( FD_ISSET ( it - > fd , & m_set ) ) {
m_s1ap_log - > info ( " Timer expired \n " ) ;
uint64_t exp ;
rd_sz = read ( it - > fd , & exp , sizeof ( uint64_t ) ) ;
m_s1ap - > expire_nas_timer ( it - > type , it - > imsi ) ;
close ( it - > fd ) ;
m_timers . erase ( it ) ;
} else {
+ + it ;
}
}
} else {
m_s1ap_log - > debug ( " No data from select. \n " ) ;
}
}
return ;
}
/*
* Timer Handling
*/
bool mme : : add_nas_timer ( int timer_fd , nas_timer_type type , uint64_t imsi )
{
m_s1ap_log - > debug ( " Adding NAS timer to MME. IMSI % " PRIu64 " , Type %d, Fd: %d \n " , imsi , type , timer_fd ) ;
mme_timer_t timer ;
timer . fd = timer_fd ;
timer . type = type ;
timer . imsi = imsi ;
m_timers . push_back ( timer ) ;
return true ;
}
bool mme : : is_nas_timer_running ( nas_timer_type type , uint64_t imsi )
{
std : : vector < mme_timer_t > : : iterator it ;
for ( it = m_timers . begin ( ) ; it ! = m_timers . end ( ) ; + + it ) {
if ( it - > type = = type & & it - > imsi = = imsi ) {
return true ; // found timer
}
}
return false ;
}
bool mme : : remove_nas_timer ( nas_timer_type type , uint64_t imsi )
{
std : : vector < mme_timer_t > : : iterator it ;
for ( it = m_timers . begin ( ) ; it ! = m_timers . end ( ) ; + + it ) {
if ( it - > type = = type & & it - > imsi = = imsi ) {
break ; // found timer to remove
}
}
if ( it = = m_timers . end ( ) ) {
m_s1ap_log - > warning ( " Could not find timer to remove. IMSI % " PRIu64 " , Type %d \n " , imsi , type ) ;
return false ;
}
// removing timer
m_s1ap_log - > debug ( " Removing NAS timer from MME. IMSI % " PRIu64 " , Type %d, Fd: %d \n " , imsi , type , it - > fd ) ;
FD_CLR ( it - > fd , & m_set ) ;
close ( it - > fd ) ;
m_timers . erase ( it ) ;
return true ;
}
} // namespace srsepc