|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
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 "profinet/IRawEthernetSocket.h"
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::EthernetSocket |
| A minimal RAII wrapper around a Linux AF_PACKET raw socket bound to an interface. More... | |
| class | profinet::UdpSocket |
| A connected UDP socket with a timeout. More... | |
| class | profinet::MaxTimeout |
| Time-limited-operation helper, mirroring util.py's MaxTimeout context manager. 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::GetMac (const std::string &ifname) |
| Get the MAC address of a network interface. | |
| std::filesystem::path | profinet::GetExecutableDirectory () |
| Retrieves the absolute directory path of the currently running executable. | |
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::ETH_P_ALL = 0x0003 |
| Linux AF_PACKET protocol value matching every EtherType. | |
| constexpr int | profinet::macAddressLength = 6 |
| Constant lenght of a mac address. | |
| constexpr int | profinet::uuidLenght = 16 |
| Constant lenght of a UUID. | |
| static constexpr int | profinet::BitsPerOctet = 8 |
| static constexpr int | profinet::OneOctetShift = BitsPerOctet |
| The bit-shift distance required to move data across a single octet. | |
| static constexpr int | profinet::TwoOctetsShift = BitsPerOctet * 2 |
| The bit-shift distance required to move data across two octets. | |
| static constexpr int | profinet::ThreeOctetsShift = BitsPerOctet * 3 |
| The bit-shift distance required to move data across three octets. | |
| static constexpr std::uint8_t | profinet::LowByteMask = 0xFF |
| Bitmask used to isolate the lowest significant byte (8 bits) of a larger integer. | |
| constexpr std::size_t | profinet::RECEIVE_BUFFER_LENGTH = 4096 |
| Receive buffer length. | |
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.