void KalmanDetectionFilter::checkFilterAges() { if(current_filter_ && isOld(current_filter_)) { current_filter_.reset(); ROS_DEBUG("Filter aged out"); } }
void KalmanDetectionFilter::publishFilteredDetections() { if(!current_filter_) return; if(isOld(current_filter_)) return; if (current_filter_->statePost.at<float>(3) < config_.max_pub_vel && current_filter_->statePost.at<float>(4) < config_.max_pub_vel) { samplereturn_msgs::NamedPoint point_msg; current_filter_->toMsg(point_msg, ros::Time::now(), _filter_frame_id); pub_detection.publish(point_msg); } }
int sql_server(AUDIT_ENSEMBLE_REL *data, CACHE_POLICY_CONF *policy) { char buffer[1024]={0}, srcipstr[32]={0}, dstipstr[32]={0}, srcmac[64]={0}, dstmac[64]={0}; int pkt_type; int line_num; /* 2015-11-17: select语句返回的行数 */ if (data->request_size <= 0) { fprintf(stderr, "%s:%d:data->reqsize <= 0\n", __FILE__, __LINE__); return 0; } /* 生成填数据库的缓存文件的完全路径 */ if (0==itemCount[data->thid] || '\0'==curFileName[data->thid][0] || '\0'==curDstFileName[data->thid][0]) { itemCount[data->thid] = 0; sprintf(curFileName[data->thid], "%s%s%s_%d_%d", SQLSERVER_SQL_TMP_DIR, SQLSERVER_PREFIX, data->table, fileNameSuffixN[data->thid], data->thid); sprintf(curDstFileName[data->thid], "%s%s%s_%d_%d", SQLSERVER_SQL_DIR, SQLSERVER_PREFIX, data->table, fileNameSuffixN[data->thid], data->thid); fileNameSuffixN[data->thid]++; } pkt_type = TDS_parser(data->request_data, data->request_size, data->operation, 1024*1024*5-10, &line_num); if ((pkt_type>=12 && pkt_type<=20) || (pkt_type>=29)) return 0; //if ((strlen(data->operation)) < 5) { // unprintToSpace(data->request_data+8, data->request_size-8, data->operation, 1024*1024*5-10); // trim(data->operation); // if (strlen(data->operation) < 5) return 0; //} /* 点分式ip (cli对应 表里面的src ser 对应des)*/ getStrIp(ntohl(data->userip), srcipstr, 32); getStrIp(ntohl(data->desip), dstipstr, 32); /* mac sprintf(srcmac, "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c", data->srcmac[0], data->srcmac[1], data->srcmac[2], data->srcmac[3], data->srcmac[4], data->srcmac[5], data->srcmac[6], data->srcmac[7], data->srcmac[8], data->srcmac[9], data->srcmac[10], data->srcmac[11]); sprintf(dstmac, "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c", data->desmac[0], data->desmac[1], data->desmac[2], data->desmac[3], data->desmac[4], data->desmac[5], data->desmac[6], data->desmac[7], data->desmac[8], data->desmac[9], data->desmac[10], data->desmac[11]); */ strcpy(srcmac, data->srcmac); strcpy(dstmac, data->desmac); /* 2015-11-16, 新增snmp char tmpSrcmac[64]={0}, tmpDstmac[64]={0}; get_mac_str(srcipstr, tmpSrcmac); get_mac_str(dstipstr, tmpDstmac); if (tmpSrcmac[0] != '\0' && tmpDstmac[0] != '\0') { strcpy(srcmac, tmpSrcmac); strcpy(dstmac, tmpDstmac); }*/ /* 策略匹配 */ //CACHE_POLICY_CONF *policy = (CACHE_POLICY_CONF*)get_audit_cache_policy_shm(); if(NULL == policy){ printf("Fails to get CACHE_POLICY_CONF"); return 0; } sprintf(zinfo.cspHead.policytime, "%d", data->policytime); strcpy(zinfo.cspHead.userip, srcipstr); zinfo.type = pkt_type; zinfo.security_level = 0; if (0 == policy_match(&zinfo, policy)) { return 0; } /* request缓存 operation_command的偏移量不计算偏移内容后的\n */ sprintf(buffer, "rowkey=%lu" "|colfam1:table=%s" "|colfam1:app_id=%d" "|colfam1:src_ip=%s" "|colfam1:src_mac=%s" "|colfam1:src_port=%hu" "|colfam1:dst_ip=%s" "|colfam1:dst_mac=%s" "|colfam1:dst_port=%hu" "|colfam1:user_id=%hu" #if GA_TEST "|colfam1:security_level=%hu" #endif "|colfam1:charset=%s" "|colfam1:interval_time=%lu" /* 2015-11-09新增字段 */ "|colfam1:operation_command=%d" "|colfam\n", data->times, data->table, pkt_type, srcipstr, srcmac, data->cliport, dstipstr, dstmac, data->serport, data->userid, #if GA_TEST zinfo.security_level, #endif "UTF-8", data->interval_time, strlen(data->operation)); int fd = open(curFileName[data->thid], O_CREAT|O_RDWR|O_APPEND, 0666); if (fd < 0) { printf("%d:open file failed", __LINE__); return -1; } write(fd, buffer, strlen(buffer)); write(fd, data->operation, strlen(data->operation)); write(fd, "\n", 1); /* response缓存 */ data->response[0] = '\0'; if (data->request_size > 0) { TDS_parser(data->response_data, data->response_size, data->response, 1024*1024*5-10, &line_num); } /* response_content的偏移量不计算偏移内容后的\n */ sprintf(buffer, "rowkey=%lu" "|colfam1:line_num=%d" "|colfam1:response_content=%d" "|colfam\n", data->times, line_num, strlen(data->response)); write(fd, buffer, strlen(buffer)); write(fd, data->response, strlen(data->response)); write(fd, "\n", 1); close(fd); /* 移动填数据库的文件 */ itemCount[data->thid]++; if (itemCount[data->thid] >= ITEM_MAX || isOld(curFileName[data->thid], 60)) { rename(curFileName[data->thid], curDstFileName[data->thid]); unlink(curFileName[data->thid]); itemCount[data->thid] = 0; curFileName[data->thid][0] = '\0'; curDstFileName[data->thid][0] = '\0'; } return 0; }