From fa8792d5faeabbd212dd252670bcca8d5b6eb412 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Tue, 21 Mar 2017 19:12:26 +0200 Subject: flow stat parsers refactor and adding tests Signed-off-by: Ido Barnea --- src/pkt_gen.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/pkt_gen.cpp') diff --git a/src/pkt_gen.cpp b/src/pkt_gen.cpp index 9f6a3d34..9dc5ade1 100644 --- a/src/pkt_gen.cpp +++ b/src/pkt_gen.cpp @@ -4,7 +4,7 @@ */ /* - Copyright (c) 2016-2016 Cisco Systems, Inc. + Copyright (c) 2016-2017 Cisco Systems, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -45,8 +45,12 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t // ASA 1 // uint8_t dst_mac[6] = {0xd4, 0x8c, 0xb5, 0xc9, 0x54, 0x2b}; // uint8_t src_mac[6] = {0xa0, 0x36, 0x9f, 0x38, 0xa4, 0x0}; - if (flags & DPF_VLAN) { - l2_proto = 0x0081; + if (flags & (DPF_VLAN | DPF_QINQ)) { + if (flags & DPF_QINQ) { + l2_proto = htons(EthernetHeader::Protocol::QINQ); + } else { + l2_proto = htons(EthernetHeader::Protocol::VLAN); + } } else { l2_proto = htons(l3_type); } @@ -106,7 +110,7 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t pkt_size = 14; - if (flags & DPF_VLAN) { + if (flags & (DPF_VLAN | DPF_QINQ)) { pkt_size += 4; if (flags & DPF_QINQ) { pkt_size += 4; @@ -159,8 +163,10 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t memcpy(p, src_mac, sizeof(src_mac)); p += sizeof(src_mac); memcpy(p, &l2_proto, sizeof(l2_proto)); p += sizeof(l2_proto); - if (flags & DPF_VLAN) { + if (flags & (DPF_VLAN | DPF_QINQ)) { if (flags & DPF_QINQ) { + uint16_t vlan_type = htons(EthernetHeader::Protocol::VLAN); + memcpy(&vlan_header2[2], &vlan_type, sizeof(vlan_type)); memcpy(p, &vlan_header2, sizeof(vlan_header2)); p += sizeof(vlan_header2); } -- cgit 1.2.3-korg