DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1
8#ifndef DPDKLIBS_SRC_UTILS_HPP_
9#define DPDKLIBS_SRC_UTILS_HPP_
10
11#include "IPV4UDPPacket.hpp"
12
14#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
15
16#include "fmt/core.h"
17#include "rte_ether.h"
18#include "rte_mbuf.h"
19
20#include <cstdint>
21#include <iostream>
22#include <mutex>
23#include <set>
24#include <string>
25#include <utility>
26#include <vector>
27
28namespace dunedaq {
29
31 BadPacketHeaderIssue,
32 "BadPacketHeaderIssue: \"" << ers_messg << "\"",
33 ((std::string)ers_messg))
34
35namespace dpdklibs {
36namespace udp {
37
38uint16_t
39get_payload_size_udp_hdr(struct rte_udp_hdr* udp_hdr);
40uint16_t
41get_payload_size(struct ipv4_udp_packet_hdr* ipv4_udp_hdr);
42
43rte_be32_t
44ip_address_dotdecimal_to_binary(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
45struct ipaddr
46ip_address_binary_to_dotdecimal(rte_le32_t binary_ipv4_address);
47
48std::string
49get_ipv4_decimal_addr_str(struct ipaddr ipv4_address);
50
51char*
52get_udp_payload(const rte_mbuf* mbuf);
53
54// void dump_udp_header(struct ipv4_udp_packet_hdr * pkt);
55std::string
56get_udp_header_str(struct rte_mbuf* mbuf);
57
58std::string
59get_udp_packet_str(struct rte_mbuf* mbuf);
60
61void
62add_file_contents_to_vector(const std::string& filename, std::vector<char>& buffervec);
63
64std::vector<std::pair<const void*, int>>
65get_ethernet_packets(const std::vector<char>& buffervec);
66
67void
69
70std::string
71get_rte_mbuf_str(const rte_mbuf* mbuf) noexcept;
72
73struct StreamUID
74{
75 uint64_t det_id : 6;
76 uint64_t crate_id : 10;
77 uint64_t slot_id : 4;
78 uint64_t stream_id : 8;
79
80 StreamUID() = default;
81
82 StreamUID(const detdataformats::DAQEthHeader& daq_hdr)
83 : det_id(daq_hdr.det_id)
84 , crate_id(daq_hdr.crate_id)
85 , slot_id(daq_hdr.slot_id)
86 , stream_id(daq_hdr.stream_id){};
87
88 bool operator<(const StreamUID& rhs) const { return std::tie(det_id, crate_id, slot_id, stream_id) < std::tie(rhs.det_id, rhs.crate_id, rhs.slot_id, rhs.stream_id); }
89
90 bool operator==(const StreamUID& rhs) const { return det_id == rhs.det_id && crate_id == rhs.crate_id && slot_id == rhs.slot_id && stream_id == rhs.stream_id; }
91 operator std::string() const { return fmt::format("({}, {}, {}, {})", det_id, crate_id, slot_id, stream_id); }
92};
93
94} // namespace udp
95} // namespace dpdklibs
96} // namespace dunedaq
97
98#endif // DPDKLIBS_SRC_UTILS_HPP_
bool operator==(const OksSystem::File &a, const OksSystem::File &b)
Definition File.cpp:857
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
rte_be32_t ip_address_dotdecimal_to_binary(std::uint8_t byte1, std::uint8_t byte2, std::uint8_t byte3, std::uint8_t byte4)
Definition Utils.cpp:41
std::uint16_t get_payload_size(struct ipv4_udp_packet_hdr *ipv4_udp_hdr)
Definition Utils.cpp:35
std::string get_udp_packet_str(struct rte_mbuf *mbuf)
Definition Utils.cpp:153
std::vector< std::pair< const void *, int > > get_ethernet_packets(const std::vector< char > &buffervec)
Definition Utils.cpp:188
char * get_udp_payload(const rte_mbuf *mbuf)
Definition Utils.cpp:70
std::string get_ipv4_decimal_addr_str(struct ipaddr ipv4_address)
Definition Utils.cpp:56
std::string get_udp_header_str(struct rte_mbuf *mbuf)
Definition Utils.cpp:108
struct ipaddr ip_address_binary_to_dotdecimal(rte_le32_t binary_ipv4_address)
Definition Utils.cpp:48
void add_file_contents_to_vector(const std::string &filename, std::vector< char > &buffervec)
Definition Utils.cpp:168
std::uint16_t get_payload_size_udp_hdr(struct rte_udp_hdr *udp_hdr)
Definition Utils.cpp:29
std::string get_rte_mbuf_str(const rte_mbuf *mbuf) noexcept
Definition Utils.cpp:246
void set_daqethheader_test_values(detdataformats::DAQEthHeader &daqethheader_obj) noexcept
Definition Utils.cpp:232
Including Qt Headers.
DAQEthHeader is a versioned and unified structure for every FE electronics.