void S1mmeSession::UpdateKqiInfo(S1APNode* p_node) { MsgCommonInfo& common = p_node->GetCommonInfo(); SPUserInfo& sp_user_info = p_node->GetUserInfo(); uint64_t imsi = sp_user_info->GetIMSI(); uint64_t imei = common.imei; uint32_t eci = common.eci == 0 ? sp_user_info->GetEci() : common.eci; uint16_t tac = common.tac; uint64_t last_time = current_time_.tv_sec; //IMSI_T imsi_key(imsi); //IMSI_Iter iter = ue_imsi_map_.find(imsi_key); //LogInfo("%d",common.imei); KqiValue& kqi_value = kqi_map_[imsi]; auto it = kqi_map_.find(imsi); if (it != kqi_map_.end()) { // 如果imsi已存在,则更新其value kqi_value.imsi = imsi; kqi_value.imei = imei; kqi_value.eci = eci; kqi_value.tac = tac; clock_gettime(CLOCK_REALTIME, &kqi_value.last_time); } LogInfo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!!!"); return; }添加代码,如果imsi不存在就正常添加
时间: 2024-03-26 16:38:14 浏览: 70
可以在`if (it != kqi_map_.end())`语句块之前添加如下代码:
```cpp
if (it == kqi_map_.end()) {
// 如果imsi不存在,则创建一个新的KqiValue对象并插入map中
KqiValue kqi_value_new;
kqi_value_new.imsi = imsi;
kqi_value_new.imei = imei;
kqi_value_new.eci = eci;
kqi_value_new.tac = tac;
clock_gettime(CLOCK_REALTIME, &kqi_value_new.last_time);
kqi_map_.insert({imsi, kqi_value_new});
return;
}
```
这样就可以在`imsi`不存在时创建一个新的`KqiValue`对象并将其插入到`kqi_map_`中。完整的函数代码如下:
```cpp
void S1mmeSession::UpdateKqiInfo(S1APNode* p_node) {
MsgCommonInfo& common = p_node->GetCommonInfo();
SPUserInfo& sp_user_info = p_node->GetUserInfo();
uint64_t imsi = sp_user_info->GetIMSI();
uint64_t imei = common.imei;
uint32_t eci = common.eci == 0 ? sp_user_info->GetEci() : common.eci;
uint16_t tac = common.tac;
uint64_t last_time = current_time_.tv_sec;
KqiValue& kqi_value = kqi_map_[imsi];
auto it = kqi_map_.find(imsi);
if (it == kqi_map_.end()) {
// 如果imsi不存在,则创建一个新的KqiValue对象并插入map中
KqiValue kqi_value_new;
kqi_value_new.imsi = imsi;
kqi_value_new.imei = imei;
kqi_value_new.eci = eci;
kqi_value_new.tac = tac;
clock_gettime(CLOCK_REALTIME, &kqi_value_new.last_time);
kqi_map_.insert({imsi, kqi_value_new});
return;
}
// 如果imsi已存在,则更新其value
kqi_value.imsi = imsi;
kqi_value.imei = imei;
kqi_value.eci = eci;
kqi_value.tac = tac;
clock_gettime(CLOCK_REALTIME, &kqi_value.last_time);
return;
}
```
阅读全文