hi, after I create arp and ethernet message, how to wrapping them into packet-out message ?
what's wrong with my code ? Any idea is appreciated. // Create the ARP Reply message arp arp_packet = arp(); arp_packet.hrd = arp::ETHER; // -- format of hardware address. arp_packet.pro = ethernet::IP; // -- format of protocol address. arp_packet.hln = htons(6); // -- length of hardware address. arp_packet.pln = htons(4); // -- length of protocol address. arp_packet.op = arp::REPLY; // -- arp opcode (command). arp_packet.sha = dstmac; // Sender hardware address arp_packet.sip = htons(pie.flow.nw_dst); // Sender IP address arp_packet.tha = pie.flow.dl_src; // Target hardware address arp_packet.tip = htons(pie.flow.nw_src); // Target IP address assert(sizeof(arp_packet) >= 28); // Create the ethernet packet, fill in the info and set the arp as payload ethernet eth_pkt = ethernet(); eth_pkt.daddr = pie.flow.dl_src; // destination ethernet address eth_pkt.saddr = dstmac; // source ethernet address eth_pkt.type = ethernet::ARP; // packet type ID assert(sizeof(eth_pkt) >= 14); //Create the packet_out message uint8_t actions_len = 8; size_t opo_size = sizeof(ofp_packet_out) + actions_len + sizeof(eth_pkt); assert(opo_size <= UINT16_MAX); Array_buffer b(opo_size); ofp_packet_out& opo = b.at<ofp_packet_out>(0); memset(&opo, 0, sizeof opo); opo.header.version = OFP_VERSION; opo.header.type = OFPT_PACKET_OUT; opo.header.length = htons(opo_size); opo.header.xid = htons(openflow_pack::get_xid()); //how to fill this field? opo.buffer_id = htons(-1); opo.in_port = htons(pie.flow.in_port); opo.actions_len = htons(actions_len); ofp_action_header actions; memset(&actions,0,sizeof(ofp_action_header)); actions.type = OFPAT_OUTPUT; actions.len = sizeof(ofp_action_header); memcpy((uint8_t *)opo.actions, &actions, actions.len); memcpy((uint8_t *)opo.actions + actions.len, ð_pkt, sizeof(eth_pkt)); memcpy((uint8_t *)opo.actions + actions.len + sizeof(eth_pkt),&arp_packet,sizeof(arp_packet)); //send arp reply message send_openflow_packet(pie.datapath_id,b,opo.actions,actions.len+sizeof(eth_pkt)+sizeof(arp_packet),opo.in_port,false); -------------------------------------------------------- ZTE Information Security Notice: The information contained in this mail is solely property of the sender's organization. This mail communication is confidential. Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others. This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the originator of the message. Any views expressed in this message are those of the individual sender. This message has been scanned for viruses and Spam by ZTE Anti-Spam system.
_______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev