void crofconntest::handle_recv( rofl::crofconn& conn, rofl::openflow::cofmsg* pmsg) { CPPUNIT_ASSERT(pmsg != nullptr); //std::cerr << "crofconntest::handle_recv() " << std::endl << *pmsg; dpid = 0xc1c2c3c4c5c6c7c8; auxid = 0xd1; n_buffers = 0xe1e2e3e4; n_tables = 0xff; switch (pmsg->get_type()) { case rofl::openflow::OFPT_FEATURES_REQUEST: { rofl::openflow::cofmsg_features_reply* msg = new rofl::openflow::cofmsg_features_reply( pmsg->get_version(), pmsg->get_xid(), dpid, n_buffers, n_tables, auxid); conn.send_message(msg); } break; case rofl::openflow::OFPT_PACKET_IN: { srv_pkts_rcvd++; //std::cerr << "RECV(Packet-In): s:" << srv_pkts_rcvd << "(" << cli_pkts_sent << "), "; if (srv_pkts_sent < num_of_packets) { send_packet_out(conn.get_version()); } } break; case rofl::openflow::OFPT_PACKET_OUT: { cli_pkts_rcvd++; //std::cerr << "RECV(Packet-Out): c:" << cli_pkts_rcvd << "(" << srv_pkts_sent << "), "; if (cli_pkts_sent < num_of_packets) { send_packet_in(conn.get_version()); } } break; default: { CPPUNIT_ASSERT(false); }; } delete pmsg; }
void crofchantest::handle_recv(rofl::crofchan &chan, rofl::crofconn &conn, rofl::openflow::cofmsg *pmsg) { rofl::AcquireReadWriteLock lock(tlock); switch (pmsg->get_type()) { case rofl::openflow13::OFPT_FEATURES_REQUEST: { LOG(INFO) << "crofchantest::handle_recv() message: " << std::endl << *pmsg << "sending FEATURES-REPLY auxid: " << (int)conn.get_auxid().get_id() << std::endl; rofl::openflow::cofmsg_features_reply *msg = new rofl::openflow::cofmsg_features_reply(rofl::openflow13::OFP_VERSION, pmsg->get_xid(), dpid); msg->set_auxid(conn.get_auxid().get_id()); conn.send_message(msg); } break; case rofl::openflow13::OFPT_PACKET_IN: { std::cerr << "r"; num_of_pkts_rcvd++; if ((num_of_pkts_sent == num_of_pkts_rcvd) && (max_congestion_rounds <= 0)) { LOG(INFO) << "TEST: received all packets, initiating test shutdown " << std::endl; LOG(INFO) << "sent: " << num_of_pkts_sent << std::endl; LOG(INFO) << "rcvd: " << num_of_pkts_rcvd << std::endl; keep_running = false; } } break; case rofl::openflow13::OFPT_PACKET_OUT: { } break; default: {}; } delete pmsg; }