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 <string>
5#include <vector>
6#include <sstream>
7#include <cstdint>
8
9namespace dunedaq::dpdklibs {
10
11 struct IpAddr {
12 IpAddr(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3) :
13 addr_bytes{byte0, byte1, byte2, byte3} {
14 }
15 IpAddr(std::string ip_address) {
16 std::vector<uint8_t> bytes;
17 std::istringstream f(ip_address);
18 std::string s;
19 while (getline(f, s, '.')) {
20 //std::cout << s << std::endl;
21 bytes.push_back(std::stoi(s));
22 }
23
24 for (size_t i = 0; i < bytes.size(); ++i) {
25 addr_bytes[i] = bytes[i];
26 }
27 }
28
29 uint8_t addr_bytes[4];
30 };
31
32}
33
34#endif /* _IPV4_ADDR_H_ */
35
IpAddr(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3)
Definition ipv4_addr.hpp:12
IpAddr(std::string ip_address)
Definition ipv4_addr.hpp:15