本文整理汇总了C++中Flow::get_detected_protocol方法的典型用法代码示例。如果您正苦于以下问题:C++ Flow::get_detected_protocol方法的具体用法?C++ Flow::get_detected_protocol怎么用?C++ Flow::get_detected_protocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flow
的用法示例。
在下文中一共展示了Flow::get_detected_protocol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flow_processing
void NetworkInterface::flow_processing(ZMQ_Flow *zflow)
{
bool src2dst_direction;
Flow *flow;
if((time_t)zflow->last_switched > (time_t)last_pkt_rcvd)
last_pkt_rcvd = zflow->last_switched;
/* Updating Flow */
flow = getFlow(zflow->src_mac, zflow->dst_mac,
zflow->vlan_id,
&zflow->src_ip, &zflow->dst_ip,
zflow->src_port, zflow->dst_port,
zflow->l4_proto, &src2dst_direction,
zflow->first_switched,
zflow->last_switched);
if(flow == NULL) return;
if(zflow->l4_proto == IPPROTO_TCP) flow->updateTcpFlags(zflow->tcp_flags);
flow->addFlowStats(src2dst_direction,
zflow->pkt_sampling_rate*zflow->in_pkts,
zflow->pkt_sampling_rate*zflow->in_bytes,
zflow->pkt_sampling_rate*zflow->out_pkts,
zflow->pkt_sampling_rate*zflow->out_bytes,
zflow->last_switched);
flow->setDetectedProtocol(zflow->l7_proto);
flow->setJSONInfo(json_object_to_json_string(zflow->additional_fields));
flow->updateActivities();
incStats(zflow->src_ip.isIPv4() ? ETHERTYPE_IP : ETHERTYPE_IPV6,
flow->get_detected_protocol(),
zflow->pkt_sampling_rate*(zflow->in_bytes + zflow->out_bytes),
zflow->pkt_sampling_rate*(zflow->in_pkts + zflow->out_pkts),
24 /* 8 Preamble + 4 CRC + 12 IFG */ + 14 /* Ethernet header */);
purgeIdle(zflow->last_switched);
}
示例2: packet_processing
//.........这里部分代码省略.........
tcp_flags = l4[13];
} else if((l4_proto == IPPROTO_UDP) && (l4_packet_len >= 8)) {
/* udp */
udph = (struct ndpi_udphdr *)l4;
src_port = udph->source, dst_port = udph->dest;
} else {
/* non tcp/udp protocols */
src_port = dst_port = 0;
}
if(iph != NULL) {
src_ip.set_ipv4(iph->saddr);
dst_ip.set_ipv4(iph->daddr);
} else {
src_ip.set_ipv6(&ip6->ip6_src);
dst_ip.set_ipv6(&ip6->ip6_dst);
}
#if defined(WIN32) && defined(DEMO_WIN32)
if(this->ethStats.getNumPackets() > MAX_NUM_PACKETS) {
static bool showMsg = false;
if(!showMsg) {
ntop->getTrace()->traceEvent(TRACE_NORMAL, "-----------------------------------------------------------");
ntop->getTrace()->traceEvent(TRACE_NORMAL, "WARNING: this demo application is a limited ntopng version able to");
ntop->getTrace()->traceEvent(TRACE_NORMAL, "capture up to %d packets. If you are interested", MAX_NUM_PACKETS);
ntop->getTrace()->traceEvent(TRACE_NORMAL, "in the full version please have a look at the ntop");
ntop->getTrace()->traceEvent(TRACE_NORMAL, "home page http://www.ntop.org/.");
ntop->getTrace()->traceEvent(TRACE_NORMAL, "-----------------------------------------------------------");
ntop->getTrace()->traceEvent(TRACE_NORMAL, "");
showMsg = true;
}
return;
}
#endif
/* Updating Flow */
flow = getFlow(eth_src, eth_dst, vlan_id, &src_ip, &dst_ip, src_port, dst_port,
l4_proto, &src2dst_direction, last_pkt_rcvd, last_pkt_rcvd);
if(flow == NULL) {
incStats(iph ? ETHERTYPE_IP : ETHERTYPE_IPV6, NDPI_PROTOCOL_UNKNOWN, rawsize, 1, 24 /* 8 Preamble + 4 CRC + 12 IFG */);
return;
} else {
flow->incStats(src2dst_direction, rawsize);
if(l4_proto == IPPROTO_TCP) flow->updateTcpFlags(tcp_flags);
}
/* Protocol Detection */
flow->updateActivities();
if(flow->isDetectionCompleted()) {
/* Handle aggregations here */
switch(flow->get_detected_protocol()) {
case NDPI_PROTOCOL_DNS:
struct ndpi_flow_struct *ndpi_flow = flow->get_ndpi_flow();
struct ndpi_id_struct *cli = (struct ndpi_id_struct*)flow->get_cli_id();
struct ndpi_id_struct *srv = (struct ndpi_id_struct*)flow->get_srv_id();
if(ndpi_flow) {
memset(&ndpi_flow->detected_protocol_stack,
0, sizeof(ndpi_flow->detected_protocol_stack));
ndpi_detection_process_packet(ndpi_struct, ndpi_flow,
ip, ipsize, (u_int32_t)time,
cli, srv);
if(ndpi_flow->protos.dns.ret_code != 0) {
/*
This is a negative reply thus we notify the system that
this aggregation must not be tracked
*/
flow->aggregateInfo((char*)ndpi_flow->host_server_name, l4_proto,
NDPI_PROTOCOL_DNS, false);
}
}
break;
}
flow->processDetectedProtocol();
flow->deleteFlowMemory();
incStats(iph ? ETHERTYPE_IP : ETHERTYPE_IPV6, flow->get_detected_protocol(), rawsize, 1, 24 /* 8 Preamble + 4 CRC + 12 IFG */);
return;
} else
incStats(iph ? ETHERTYPE_IP : ETHERTYPE_IPV6, flow->get_detected_protocol(), rawsize, 1, 24 /* 8 Preamble + 4 CRC + 12 IFG */);
if(!is_fragment) {
struct ndpi_flow_struct *ndpi_flow = flow->get_ndpi_flow();
struct ndpi_id_struct *cli = (struct ndpi_id_struct*)flow->get_cli_id();
struct ndpi_id_struct *srv = (struct ndpi_id_struct*)flow->get_srv_id();
flow->setDetectedProtocol(ndpi_detection_process_packet(ndpi_struct, ndpi_flow,
ip, ipsize, (u_int32_t)time,
cli, srv));
} else {
// FIX - only handle unfragmented packets
// ntop->getTrace()->traceEvent(TRACE_WARNING, "IP fragments are not handled yet!");
}
}