summaryrefslogtreecommitdiffstats
path: root/src/flow_stat_parser.h
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-07-20 10:19:11 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-08-03 16:35:11 +0300
commit810dd7d0a48c17679e385b93d595a92b51254ce4 (patch)
tree09f9ca6ddd2358c688c2ba41b4297d39928eea2f /src/flow_stat_parser.h
parent0f863b48e742ecd6b6dd522803e95a528024bbc9 (diff)
ipv6 flow stat on vm working
Diffstat (limited to 'src/flow_stat_parser.h')
-rw-r--r--src/flow_stat_parser.h87
1 files changed, 84 insertions, 3 deletions
diff --git a/src/flow_stat_parser.h b/src/flow_stat_parser.h
index b4f01900..d44c8a7f 100644
--- a/src/flow_stat_parser.h
+++ b/src/flow_stat_parser.h
@@ -22,27 +22,65 @@
#ifndef __FLOW_STAT_PARSER_H__
#define __FLOW_STAT_PARSER_H__
-// Basic flow stat parser. Relevant for xl710/x710/x350 cards
+#include <arpa/inet.h>
#include "common/Network/Packet/IPHeader.h"
+#include "common/Network/Packet/IPv6Header.h"
+#include "common/Network/Packet/TcpHeader.h"
+#include "mbuf.h"
+// Basic flow stat parser. Relevant for xl710/x710/x350 cards
class CFlowStatParser {
public:
virtual ~CFlowStatParser() {}
virtual void reset();
virtual int parse(uint8_t *pkt, uint16_t len);
virtual bool is_stat_supported() {return m_stat_supported == true;}
- virtual int get_ip_id(uint16_t &ip_id);
- virtual int set_ip_id(uint16_t ip_id);
+ virtual int get_ip_id(uint32_t &ip_id);
+ virtual int set_ip_id(uint32_t ip_id);
virtual int get_l4_proto(uint8_t &proto);
virtual int get_payload_len(uint8_t *p, uint16_t len, uint16_t &payload_len);
+ virtual uint16_t get_pkt_size();
+ virtual uint8_t get_ttl();
virtual int test();
+ uint8_t *get_l3() {
+ if (m_ipv4)
+ return (uint8_t *)m_ipv4;
+ else
+ return (uint8_t *)m_ipv6;
+ }
+ uint8_t * get_l4() {return m_l4;}
+
+ inline bool IsNatInfoPkt(bool &first) {
+ if (!m_ipv4 || (m_l4_proto != IPPROTO_TCP)) {
+ return false;
+ }
+ if ((m_l4 + TCP_HEADER_LEN) > (uint8_t *)m_ipv4 + get_pkt_size()) {
+ return false;
+ }
+ // If we are here, relevant fields from tcp header are inside the packet boundaries
+ // We want to handle SYN and SYN+ACK packets
+ TCPHeader *tcp = (TCPHeader *)m_l4;
+ if (! tcp->getSynFlag())
+ return false;
+
+ if (! tcp->getAckFlag()) {
+ first = true;
+ } else {
+ first = false;
+ }
+ return true;
+ }
protected:
IPHeader *m_ipv4;
+ IPv6Header *m_ipv6;
+ uint8_t *m_l4;
bool m_stat_supported;
uint8_t m_l4_proto;
+ uint8_t m_vlan_offset;
};
+// relevant for 82599 card
class C82599Parser : public CFlowStatParser {
public:
C82599Parser(bool vlan_supported) {m_vlan_supported = vlan_supported;}
@@ -53,4 +91,47 @@ class C82599Parser : public CFlowStatParser {
bool m_vlan_supported;
};
+// Used for latency statefull packets. Need to be merged with above parser
+class CSimplePacketParser {
+ public:
+ CSimplePacketParser(rte_mbuf_t * m){
+ m_m = m;
+ m_l4 = NULL;
+ }
+ bool Parse();
+
+ // Check if this packet contains NAT info in TCP ack
+ // first - set to true if this is the first packet of the flow. false otherwise.
+ // relevant only if return value is true
+ inline bool IsNatInfoPkt(bool &first) {
+ if (!m_ipv4 || (m_protocol != IPPROTO_TCP)) {
+ return false;
+ }
+ if (! m_l4 || (m_l4 - rte_pktmbuf_mtod(m_m, uint8_t*) + TCP_HEADER_LEN) > m_m->data_len) {
+ return false;
+ }
+ // If we are here, relevant fields from tcp header are guaranteed to be in first mbuf
+ // We want to handle SYN and SYN+ACK packets
+ TCPHeader *tcp = (TCPHeader *)m_l4;
+ if (! tcp->getSynFlag())
+ return false;
+
+ if (! tcp->getAckFlag()) {
+ first = true;
+ } else {
+ first = false;
+ }
+ return true;
+ }
+
+ public:
+ IPHeader * m_ipv4;
+ IPv6Header * m_ipv6;
+ uint8_t m_protocol;
+ uint16_t m_vlan_offset;
+ uint8_t * m_l4;
+ private:
+ rte_mbuf_t * m_m ;
+};
+
#endif