PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
util.h File Reference

Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack. More...

#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <span>
#include <string>
#include <vector>
+ Include dependency graph for util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  profinet::IMacAddressProvider
 Provides the MAC address of a network interface. More...
 
class  profinet::MacAddressProvider
 Production implementation of IMacAddressProvider. More...
 
class  profinet::MaxTimeout
 Time-limited-operation helper. More...
 

Namespaces

namespace  profinet
 

Typedefs

using profinet::MacAddress = std::array< std::uint8_t, macAddressLength >
 A 6-byte Ethernet MAC address.
 

Functions

std::string profinet::Hex4 (std::uint16_t value)
 Format a 16-bit unsigned integer as a 4-digit hexadecimal string.
 
std::string profinet::Hex2 (std::uint8_t value)
 Format an 8-bit unsigned integer as a 2-digit hexadecimal string.
 
std::vector< std::uint8_t > profinet::ToVec (const std::string &input)
 Convert a string into a vector of raw bytes.
 
std::string profinet::HexFallback (const char *widthPrefix, std::uint32_t value, int digitWidth)
 Format a hexadecimal string with a custom prefix and dynamic width.
 
std::size_t profinet::SkipVlanTags (std::span< const std::uint8_t > frame) noexcept
 Return the byte offset of the real EtherType in a raw Ethernet frame.
 
std::string profinet::ToHex (const std::uint8_t *data, std::size_t len)
 Hex-encode a byte buffer.
 
std::string profinet::ToHex (const std::vector< std::uint8_t > &data)
 Hex-encode a byte buffer.
 
MacAddress profinet::String2Mac (const std::string &macStr)
 Parse a colon-separated MAC address string.
 
std::string profinet::Mac2String (const MacAddress &mac)
 Format a MAC address as a colon-separated string.
 
std::string profinet::Mac2String (const std::uint8_t *macBytes, std::size_t len)
 Format a MAC address as a colon-separated string.
 
std::string profinet::String2Ip (std::span< const std::uint8_t > ipBytes)
 Format raw IPv4 address bytes as a dotted string.
 
std::string profinet::String2Ip (const std::uint8_t *ipBytes, std::size_t len)
 Format raw IPv4 address bytes as a dotted string.
 
std::array< std::uint8_t, 4 > profinet::Ip2String (const std::string &ipStr)
 Parse a dotted-decimal IPv4 address string.
 
std::string profinet::DecodeBytes (const std::uint8_t *data, std::size_t len)
 Decode bytes to a UTF-8 string, stripping trailing NUL bytes.
 
std::string profinet::DecodeBytes (const std::vector< std::uint8_t > &data)
 Decode bytes to a UTF-8 string, stripping trailing NUL bytes.
 
MacAddress profinet::GetInterfaceMac (const std::string &interface)
 Get the MAC address assigned to a network interface.
 
std::filesystem::path profinet::GetExecutableDirectory ()
 Retrieves the absolute directory path of the currently running executable.
 
template<typename T >
constexpr T profinet::ByteSwap (T value)
 
template<typename T >
constexpr std::uint8_t profinet::ByteAt (T value, std::size_t index)
 Return one byte from an integral value.
 

Variables

constexpr std::size_t profinet::MAX_ETHERNET_FRAME = 1522
 Maximum PROFINET Ethernet frame size in bytes (including VLAN tag headroom).
 
constexpr std::uint16_t profinet::PROFINET_ETHERTYPE = 0x8892
 EtherType value identifying PROFINET frames (0x8892).
 
constexpr std::uint16_t profinet::IP_ETHERTYPE = 0x8000
 EtherType value identifying IP frames (0x8000).
 
constexpr std::uint16_t profinet::VLAN_ETHERTYPE = 0x8100
 EtherType value identifying an 802.1Q VLAN tag (0x8100).
 
constexpr int profinet::macAddressLength = 6
 Constant lenght of a mac address.
 
constexpr int profinet::uuidLenght = 16
 Constant lenght of a UUID.
 
constexpr std::size_t profinet::RECEIVE_BUFFER_LENGTH = 4096
 Receive buffer length.
 

Detailed Description

Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.

Provides raw Ethernet socket abstractions, MAC and IP address utilities, timeout helpers, VLAN handling, byte utilities, and common protocol constants.

Definition in file util.h.