7 #include <pugixml/pugixml.hpp> 
    8 #include <boost/uuid/uuid.hpp> 
    9 #include <boost/uuid/string_generator.hpp> 
   11 #include <test/test_cmn_util.h> 
   12 #include <pkt/test/test_pkt_util.h> 
   23 using namespace boost::uuids;
 
   40     tunnel_sip_ = 
"0.0.0.0";
 
   41     tunnel_dip_ = 
"0.0.0.0";
 
   45     smac_ = 
"00:00:00:00:00:01";
 
   46     dmac_ = 
"00:00:00:00:00:02";
 
   64     if (tunnel_type_ == 
"gre" || tunnel_type_ == 
"GRE")
 
   66     if (tunnel_type_ == 
"udp" || tunnel_type_ == 
"UDP")
 
   68     if (tunnel_type_ == 
"vxlan" || tunnel_type_ == 
"VXLAN")
 
   81     return atoi(proto_.c_str());
 
   85     if (trap_code_ == 
"flow")
 
   93     if (pkt_module_ == 
"flow" || pkt_module_ == 
"FLOW")
 
   95     if (pkt_module_ == 
"invalid" || pkt_module_ == 
"INVALID")
 
  103     if (fwd_mode_ == 
"l2" || fwd_mode_ == 
"L2")
 
  109     if (fwd_mode_ == 
"l3" || fwd_mode_ == 
"L3")
 
  119     if (tunnel_type_ != 
"") {
 
  149     if (tunnel_type_ == 
"") {
 
  150         s << 
"Packet < " << name_ << 
"> Interface <" << intf_ << 
"> ";
 
  152         s << 
"Packet < " << name_ << 
"> Tunnel <" << tunnel_type_ << 
" : " 
  153             << intf_ << 
" : " << label_ << 
" : " << tunnel_sip_ << 
" : " 
  154             << tunnel_dip_ << 
"> ";
 
  156     s << 
"<" << sip_ << 
" : " << dip_ << 
" : " << proto_ << 
" : " << sport_
 
  157         << 
" : " << dport_ << 
">" << endl;
 
  176         pkt->AddEthHdr(
"00:00:00:00:00:01", 
"00:00:00:00:00:02", 0x800);
 
  179         string dip = tunnel_dip_;
 
  180         if (dip == 
"0.0.0.0") {
 
  184         uint8_t proto = IPPROTO_UDP;
 
  188         pkt->AddIpHdr(tunnel_sip_.c_str(), dip.c_str(), proto);
 
  191             pkt->AddMplsHdr(label_, 
true);
 
  193             pkt->AddUdpHdr(VR_MPLS_OVER_UDP_SRC_PORT, VR_MPLS_OVER_UDP_DST_PORT,
 
  195             pkt->AddMplsHdr(label_, 
true);
 
  197             pkt->AddUdpHdr(VR_VXLAN_UDP_SRC_PORT, VR_VXLAN_UDP_DST_PORT, 0);
 
  199             pkt->AddVxlanHdr(vxlan);
 
  202         if (fwd_mode_ == 
"l2") {
 
  203             pkt->AddEthHdr(dmac_.c_str(), smac_.c_str(), 0x800);
 
  206         pkt->AddEthHdr(dmac_.c_str(), smac_.c_str(), 0x800);
 
  209     pkt->AddIpHdr(sip_.c_str(), dip_.c_str(), proto_id_);
 
  210     if (proto_id_ == 17) {
 
  211         pkt->AddUdpHdr(sport_, dport_, len_);
 
  212     } 
else if (proto_id_ == 6) {
 
  213         pkt->AddTcpHdr(sport_, dport_, 
false, 
false, tcp_ack_, len_);
 
  214     } 
else if (proto_id_ == 1) {
 
  230     boost::system::error_code ec;
 
  231     IpAddress ip = IpAddress::from_string(sip_, ec);
 
  233     bool ingress_flow = 
true;
 
  236         ingress_flow = 
false;
 
  240     if (atoi(intf_.c_str())) {
 
  241         intf = 
static_cast<VmInterface *
>(VmPortGet(atoi(intf_.c_str())));
 
  243             intf_id_ = intf->
id();
 
  251             label_ = intf->
label();
 
  255     if (fwd_mode_ != 
"l2") {
 
  262     if (proto_id_ == 0) {
 
  263         proto_id_ = GetIpProto();
 
  266     uint16_t if_id = intf_id_;
 
  282     pkt->AddEthHdr(
"00:00:00:00:00:01", 
"00:00:00:00:00:02", 0x800);
 
  283     pkt->AddAgentHdr(if_id, GetTrapCode(), hash_id_, vrf_id_, label_, vxlan_id);
 
  285         ret = InetPacket(intf, agent, pkt);
 
  287         ret = Inet6Packet(intf, agent, pkt);
 
  324     cout << 
"Generate packet" << endl;
 
  329     uint8_t *ptr(
new uint8_t[pkt.GetBuffLen()]);
 
  330     memcpy(ptr, pkt.GetBuff(), pkt.GetBuffLen());
 
  332     TestPkt0Interface *pkt0 = 
static_cast<TestPkt0Interface *
> 
  334     pkt0->ProcessFlowPacket(ptr, pkt.GetBuffLen(), pkt.GetBuffLen());
 
  342                                                        const xml_node &node) :
 
  398     cout << 
"Generating packet" << endl;
 
  403     uint32_t buff_len = pkt.GetBuffLen();
 
  404     uint32_t payload_len = pkt.GetBuffLen();
 
  405     uint8_t *ptr(
new uint8_t[buff_len]);
 
  406     memcpy(ptr, pkt.GetBuff(), pkt.GetBuffLen());
 
  422                                                     sizeof(
struct agent_hdr)));
 
boost::asio::ip::address IpAddress
 
const pugi::xml_node & node() const
 
TunnelType::Type GetTunnelType() const
 
bool ReadXml(const pugi::xml_node &node)
 
bool InetPacket(Interface *intf, Agent *agent, PktGen *pkt)
 
virtual ~AgentUtXmlPacketUtils()
 
PktHandler::PktModuleName GetPacketModule() const
 
uint8_t GetTrapCode() const
 
bool MakePacket(Agent *agent, PktGen *pkt)
 
bool Inet6Packet(Interface *intf, Agent *agent, PktGen *pkt)
 
uint8_t GetIpProto() const
 
AgentUtXmlPacketUtils pkt_
 
virtual std::string NodeType()
 
virtual void ToString(std::string *str)
 
AgentUtXmlPacket(const std::string &name, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
 
virtual ~AgentUtXmlPacket()
 
virtual bool ToXml(pugi::xml_node *parent)
 
virtual const std::string ToString()
 
AgentUtXmlPacketUtils pkt_
 
AgentUtXmlPktParseValidate(const std::string &name, const pugi::xml_node &node)
 
virtual ~AgentUtXmlPktParseValidate()
 
const pugi::xml_node & node() const
 
static const MacAddress & vrrp_mac()
 
static Agent * GetInstance()
 
const Interface * vhost_interface() const
 
const MacAddress & mac() const
 
uint32_t l2_label() const
 
const uint32_t id() const
 
std::string ToString() const
 
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
 
PacketBufferPtr Allocate(uint32_t module, uint16_t len, uint32_t mdata)
 
PktModuleName ParsePacket(const AgentHdr &hdr, PktInfo *pkt_info, uint8_t *pkt)
 
PacketBufferManager * packet_buffer_manager() const
 
PktHandler * pkt_handler() const
 
ControlInterface * control_interface() const
 
VmInterface::VmiType vmi_type() const
 
const VnEntry * vn() const
 
const Ip4Address & primary_ip_addr() const
 
InterfaceList parent_list() const
 
int DecodeAgentHdr(AgentHdr *hdr, uint8_t *buff, uint32_t len)
 
bool GetUintAttribute(const xml_node &node, const string &name, uint16_t *value)
 
bool GetStringAttribute(const xml_node &node, const string &name, string *value)
 
boost::shared_ptr< PacketBuffer > PacketBufferPtr
 
static int GetVxlan(Interface *intf)