111 std::ostringstream ostrs;
112 ostrs <<
"\n------ start of packet ----- \n";
113 ostrs <<
"dst mac addr: ";
120 ostrs <<
"src mac addr: ";
127 ostrs <<
"ethtype: " << (unsigned)pkt->
eth_hdr.ether_type <<
'\n';
129 ostrs <<
"------ IP header ----- \n";
130 ostrs <<
"ipv4 version: " << (unsigned)pkt->
ipv4_hdr.version_ihl <<
'\n';
131 ostrs <<
"ipv4 type_of_service: " << (unsigned)pkt->
ipv4_hdr.type_of_service <<
'\n';
132 ostrs <<
"ipv4 total lenght: " << (unsigned)rte_be_to_cpu_16(pkt->
ipv4_hdr.total_length) <<
'\n';
133 ostrs <<
"ipv4 packet_id: " << (unsigned)pkt->
ipv4_hdr.packet_id <<
'\n';
134 ostrs <<
"ipv4 fragment_offset: " << (unsigned)pkt->
ipv4_hdr.fragment_offset <<
'\n';
135 ostrs <<
"ipv4 time_to_live: " << (unsigned)pkt->
ipv4_hdr.time_to_live <<
'\n';
136 ostrs <<
"ipv4 next_proto_id: " << (unsigned)pkt->
ipv4_hdr.next_proto_id <<
'\n';
137 ostrs <<
"ipv4 checksum: " << (unsigned)rte_be_to_cpu_16(pkt->
ipv4_hdr.hdr_checksum) <<
'\n';
140 ostrs <<
"src_addr: " << srcaddr <<
'\n';
141 ostrs <<
"dst_addr: " << dstaddr <<
'\n';
143 ostrs <<
"------ UDP header ----- \n";
144 ostrs <<
"UDP src_port: " << (unsigned)rte_be_to_cpu_16(pkt->
udp_hdr.src_port) <<
'\n';
145 ostrs <<
"UDP dst_port: " << (unsigned)rte_be_to_cpu_16(pkt->
udp_hdr.dst_port) <<
'\n';
146 ostrs <<
"UDP len: " << (unsigned)rte_be_to_cpu_16(pkt->
udp_hdr.dgram_len) <<
'\n';
147 ostrs <<
"UDP checksum: " << (unsigned)rte_be_to_cpu_16(pkt->
udp_hdr.dgram_cksum) <<
'\n';
191 std::vector<std::pair<const void*, int>> ethernet_packets;
192 const std::vector<uint16_t> allowed_ethertypes{ 0x0800, 0x0806 };
194 for (
int byte_index = 0; byte_index < buffervec.size();) {
195 const auto buf_ptr = &buffervec.at(byte_index);
200 for (
auto allowed_ethertype : allowed_ethertypes) {
201 if (hdr->eth_hdr.ether_type == rte_be_to_cpu_16(allowed_ethertype)) {
208 std::stringstream msgstr;
209 msgstr <<
"Ether type in ethernet header (value " << std::hex << rte_be_to_cpu_16(hdr->eth_hdr.ether_type) << std::dec <<
") either unknown or unsupported";
210 throw dunedaq::dpdklibs::BadPacketHeaderIssue(
ERS_HERE, msgstr.str());
213 int ipv4_packet_size = rte_be_to_cpu_16(hdr->ipv4_hdr.total_length);
214 constexpr int min_packet_size =
sizeof(rte_ipv4_hdr) +
sizeof(rte_udp_hdr);
215 constexpr int max_packet_size = 10000;
217 if (ipv4_packet_size < min_packet_size || ipv4_packet_size > max_packet_size) {
218 std::stringstream msgstr;
219 msgstr <<
"Calculated IPv4 packet size of " << ipv4_packet_size <<
" bytes is out of the required range of (" << min_packet_size <<
", " << max_packet_size <<
") bytes";
220 throw dunedaq::dpdklibs::BadPacketHeaderIssue(
ERS_HERE, msgstr.str());
223 int ethernet_packet_size =
sizeof(rte_ether_hdr) + ipv4_packet_size;
224 ethernet_packets.emplace_back(std::pair<const void*, int>{ buf_ptr, ethernet_packet_size });
225 byte_index += ethernet_packet_size;
228 return ethernet_packets;
234 daqethheader_obj.version = 0;
235 daqethheader_obj.det_id = 1;
236 daqethheader_obj.crate_id = 2;
237 daqethheader_obj.slot_id = 3;
238 daqethheader_obj.stream_id = 4;
239 daqethheader_obj.reserved = 5;
240 daqethheader_obj.seq_id = 6;
241 daqethheader_obj.block_length = 7;
242 daqethheader_obj.timestamp = 8;