DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ipv4_addr.hpp
Go to the documentation of this file.
1#ifndef _IPV4_ADDR_H_
2#define _IPV4_ADDR_H_
3
4#include <cstdint>
5#include <sstream>
6#include <string>
7#include <vector>
8
9namespace dunedaq::dpdklibs {
10
11struct IpAddr
12{
13 IpAddr(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3)
14 : addr_bytes{ byte0, byte1, byte2, byte3 }
15 {
16 }
17 IpAddr(std::string ip_address)
18 {
19 std::vector<uint8_t> bytes;
20 std::istringstream f(ip_address);
21 std::string s;
22 while (getline(f, s, '.')) {
23 // std::cout << s << std::endl;
24 bytes.push_back(std::stoi(s));
25 }
26
27 for (size_t i = 0; i < bytes.size(); ++i) {
28 addr_bytes[i] = bytes[i];
29 }
30 }
31
32 uint8_t addr_bytes[4];
33};
34
35}
36
37#endif /* _IPV4_ADDR_H_ */
IpAddr(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3)
Definition ipv4_addr.hpp:13
IpAddr(std::string ip_address)
Definition ipv4_addr.hpp:17