215 std::optional<std::string>
fqdn;
218 std::optional<std::string>
uuid;
285 std::string
ip =
"0.0.0.0";
346 std::map<BlockKey, std::vector<std::uint8_t>>
rawBlocks;
368 [[nodiscard]] std::string
ToString()
const;
400 const std::string& param,
401 const std::string& value,
422const std::map<std::string, BlockKey>&
Params();
433 const std::string& target,
const std::string& param,
465 const std::string& ip,
const std::string& netmask,
const std::string& gateway,
480 const std::vector<std::uint8_t>& value);
483using ResponseMap = std::map<MacAddress, std::map<BlockKey, std::vector<std::uint8_t>>>;
493 bool once =
false, std::optional<std::uint32_t> expectedXid = std::nullopt);
505 const std::string& ip =
"0.0.0.0",
const std::string& netmask =
"0.0.0.0",
506 const std::string& gateway =
"0.0.0.0", std::pair<std::uint16_t, std::uint16_t> deviceId = {0, 0},
517 const std::function<
void(
const DCPDeviceDescription&)>& callback =
nullptr);
540 const std::string& target,
Abstraction for sending and receiving raw Ethernet frames.
Abstract interface for raw Ethernet frame transport.
Parsed PROFINET device information from a DCP response.
std::pair< std::uint8_t, std::uint8_t > deviceInstance
Device instance (high, low) pair.
bool ipConflict
Whether an IP address conflict was detected.
std::uint8_t vendorLow
Low byte of the PROFINET vendor ID.
std::string netmask
IPv4 subnet mask, or "0.0.0.0" if unset.
std::string ToString() const
Multi-line human-readable summary of this device.
std::string name
Station name.
std::uint8_t vendorHigh
High byte of the PROFINET vendor ID.
std::uint8_t deviceLow
Low byte of the PROFINET device ID.
std::uint16_t VendorId() const
Combine VendorHigh/VendorLow into a 16-bit vendor ID.
DcpIpBlockInfo ipBlockInfo
IP block info flags (see IPBlockInfo).
std::uint8_t deviceRole
Raw device role bitmask.
std::string gateway
IPv4 default gateway, or "0.0.0.0" if unset.
std::uint16_t DeviceId() const
Combine DeviceHigh/DeviceLow into a 16-bit device ID.
std::string aliasName
Device alias name, if set.
std::uint16_t vendorId
The PROFINET vendor ID.
std::map< BlockKey, std::vector< std::uint8_t > > rawBlocks
Any parsed blocks not covered by the named fields above.
DcpDeviceInitiative deviceInitiative
Raw device-initiative value (see DeviceInitiative).
std::vector< BlockKey > supportedOptions
List of (option, suboption) blocks the device supports.
bool issuesHello
Whether the device issues a DCP-Hello after power-on.
std::uint8_t deviceHigh
High byte of the PROFINET device ID.
std::string VendorName() const
Look up the vendor name for this device's vendor ID.
std::string mac
Device's MAC address, formatted as a string.
std::string ip
IPv4 address, or "0.0.0.0" if unset.
bool ipSetByDhcp
Whether the IP address was assigned via DHCP.
std::uint16_t deviceId
The PROFINET device ID.
std::vector< DCPDHCPBlock > dhcpBlocks
Parsed DHCP blocks from the response, if any.
std::vector< std::string > deviceRoles
Decoded device role names (see DecodeDeviceRole()).
std::string deviceType
Device type string (e.g. model name).
bool HasConflict(DcpIpBlockInfo info)
Whether an address conflict was detected.
void SendDiscover(IRawEthernetSocket &sock, const MacAddress &src, std::uint16_t responseDelay=DEFAULT_RESPONSE_DELAY_FACTOR)
Send a DCP Identify multicast request to discover all devices on the segment.
std::optional< std::vector< std::uint8_t > > GetParam(IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string ¶m, int timeoutSec=DEFAULT_TIMEOUT)
Read a named parameter from a device.
Bytes BuildSetParamRequest(const MacAddress &dst, const MacAddress &src, const std::string ¶m, const std::string &value, bool permanent)
Build a serialized DCP SET request for a named parameter.
std::string GetResetQualifierName(std::uint16_t qualifier)
Get the human-readable name for a reset qualifier value.
void SendHello(IRawEthernetSocket &sock, const MacAddress &src, const std::string &stationName, const std::string &ip="0.0.0.0", const std::string &netmask="0.0.0.0", const std::string &gateway="0.0.0.0", std::pair< std::uint16_t, std::uint16_t > deviceId={0, 0}, DcpDeviceRole deviceRole=DcpDeviceRole::IoDevice)
Send a DCP Hello multicast announcement (device self-announce after power-on).
Bytes BuildDcpSignalRequest(const MacAddress &dst, const MacAddress &src)
Build a serialized DCP Signal request.
bool SetIp(IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string &ip, const std::string &netmask, const std::string &gateway, bool permanent=false, int timeoutSec=DEFAULT_TIMEOUT, int threadSleepMs=DEFAULT_THREAD_SLEEP_MS)
Set a device's IP configuration via DCP.
const std::map< std::string, BlockKey > & Params()
Table of supported parameter names, mapping to their (option, suboption).
std::string DeviceRoleName(DcpDeviceRole role)
Get the human-readable name of a DCP device role.
bool SignalDevice(IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, int durationMs=FLASH_DURATION_MS, double timeoutSec=DEFAULT_TIMEOUT)
Flash a device's identification LEDs.
constexpr DcpBlockKey MakeBlockKey(std::uint16_t option, std::uint8_t suboption)
constexpr std::uint16_t DEFAULT_RESPONSE_DELAY_FACTOR
Default dcp response delay factor.
DcpBlockKey BlockKey
(option, suboption) key identifying a DCP block.
DcpBlockError RecvSetResponse(IRawEthernetSocket &sock, const MacAddress &srcMac, int timeoutSec)
Receive and parse a DCP SET response, filtering out unrelated frames.
std::string GetDeviceInitiativeName(DcpDeviceInitiative value)
std::string GetDcpBlockQualifierDescription(DcpBlockQualifier qualifier)
Get the human-readable description of a DCP block qualifier.
constexpr std::uint16_t DCP_IP_DHCP_BIT
Bit mask indicating DHCP bit is set.
constexpr std::uint16_t FLASH_DURATION_MS
Default flash duration of the leds.
bool IsDhcp(DcpIpBlockInfo info)
Whether the address was assigned via DHCP.
constexpr std::uint16_t DEFAULT_HELLO_TIMEOUT
Default HELLO timeout.
constexpr std::uint16_t blockNameVendorRangeMin
Default flash duration of the leds.
constexpr std::uint16_t DEFAULT_TIMEOUT
Default timeout.
constexpr std::uint16_t blockNameVendorRangeMax
Default flash duration of the leds.
void SendRequest(IRawEthernetSocket &sock, const MacAddress &src, BlockKey blockType, const std::vector< std::uint8_t > &value)
Send a DCP Identify request filtered to a specific (option, suboption).
const std::string DCP_MULTICAST_MAC
DCP Identify/Get/Set multicast destination MAC.
const std::string DCP_HELLO_MULTICAST_MAC
DCP Hello multicast destination MAC.
std::string GetIPBlockInfoName(DcpIpBlockInfo info)
Get the human-readable name for an IP block info value.
std::vector< std::string > DecodeDeviceRole(std::uint8_t roleByte)
Decode a device role bitmask into a list of role names.
std::map< MacAddress, std::map< BlockKey, std::vector< std::uint8_t > > > ResponseMap
Result of ReadResponse(): MAC address -> parsed (option,suboption) -> payload blocks.
std::string GetBlockName(std::uint16_t option, std::uint8_t suboption)
Get the human-readable name for a (option, suboption) DCP block.
ResponseMap ReadResponse(IRawEthernetSocket &sock, const MacAddress &myMac, double timeoutSec=DEFAULT_RESPONSE_TIMEOUT, bool once=false, std::optional< std::uint32_t > expectedXid=std::nullopt)
Read and parse DCP Identify responses.
constexpr std::uint16_t DEFAULT_RESPONSE_TIMEOUT
Default response timeout. How long to keep listening for responses.
constexpr std::uint16_t DCP_IP_CONFLICT_BIT
Bit mask indicating an IP address conflict.
std::string GetDcpBlockErrorDescription(DcpBlockError error)
Get the human-readable name for a DCP SET block-level error code.
constexpr std::uint16_t DEFAULT_THREAD_SLEEP_MS
std::string GetDcpResponseCodeName(DcpResponseCode value)
Get the human-readable name for a device-response value.
bool SetParam(IRawEthernetSocket &sock, const MacAddress &src, const std::string &target, const std::string ¶m, const std::string &value, int timeoutSec=DEFAULT_TIMEOUT, bool permanent=false, int threadSleepMs=DEFAULT_THREAD_SLEEP_MS)
Write a named parameter to a device.
DcpBlockError ParseSetResponse(const Bytes &data)
Parses the raw byte response payload received from a SET operation.
std::vector< DCPDeviceDescription > ReceiveHello(IRawEthernetSocket &sock, const MacAddress &myMac, double timeoutSec=DEFAULT_HELLO_TIMEOUT, const std::function< void(const DCPDeviceDescription &)> &callback=nullptr)
Listen for DCP Hello announcements from other devices.
constexpr std::size_t DCP_MAX_NAME_LENGTH
Maximum allowed length in bytes for a station name.
DcpBlockQualifier
DCP block qualifier values.
DcpIpSuboption
DCP IP suboptions.
DcpDeviceInitiativeSuboption
DCP DeviceInitiative suboptions.
DcpDhcpSuboption
DCP DHCP suboptions.
@ Unknown
Not set / initialize value.
DcpControlSuboption
DCP Control suboptions.
@ ResetToFactory
Reset to factory.
DcpBlockError
DCP block-level SET response errors.
std::array< std::uint8_t, macAddressLength > MacAddress
A 6-byte Ethernet MAC address.
DcpResetMode
Reset mode bitmask.
@ Communication
Reset communication parameters.
DcpDeviceSuboption
DCP Device suboptions.
DcpDeviceInitiative
DCP device-initiative values.
@ NoHello
Device does not issue DCP-Hello after power-on.
std::vector< std::uint8_t > Bytes
Generic byte buffer alias used throughout the library for raw wire data.
DcpResetQualifier
Reset qualifier values for ResetToFactory().
DcpIpBlockInfo
PROFINET DCP IP block status values. IP block status flags (IEC 61158-6-10 IPBlockInfo).
@ NotSet
IP address not set.
DcpDeviceRole
Device role bitmask.
DcpResponseCode
DCP GET/SET response codes.
PROFINET protocol wire-format structures and serialization helpers.
Identifies a PROFINET DCP block by option and suboption.
DcpOption option
DCP option.
Parsed DHCP block from a DCP response.
std::optional< std::string > fqdn
Decoded fully qualified domain name, if this is an FQDN suboption.
std::vector< std::uint8_t > rawData
Raw, undecoded block payload.
DcpDhcpSuboption suboption
DHCP suboption code.
std::optional< std::vector< std::uint8_t > > vendorSpecific
Decoded vendor-specific data, if this is a VendorSpec suboption.
std::optional< std::string > hostname
Decoded hostname, if this is a Hostname suboption.
static DCPDHCPBlock Parse(DcpDhcpSuboption suboption, const std::vector< std::uint8_t > &data)
Parse a DHCP suboption's payload into a DCPDHCPBlock.
std::string suboptionName
Human-readable name of the suboption.
std::optional< std::vector< std::uint8_t > > clientId
Decoded client ID, if this is a ClientID suboption.
std::optional< std::string > uuid
Decoded UUID string, if this is a UUID suboption.
Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.