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

PROFINET protocol wire-format structures and serialization helpers. More...

#include <algorithm>
#include <array>
#include <cstdint>
#include <magic_enum.hpp>
#include <stdexcept>
#include <string>
#include <vector>
#include "profinet/indices.h"
#include "profinet/util.h"
#include "profinet/wire.h"
+ Include dependency graph for protocol.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  profinet::DcpBlockKey
 Identifies a PROFINET DCP block by option and suboption. More...
 
struct  profinet::EthernetHeader
 Plain (untagged) Ethernet II frame header. More...
 
struct  profinet::EthernetVLANHeader
 802.1Q VLAN-tagged Ethernet II frame header. More...
 
struct  profinet::PNDCPHeader
 DCP (Discovery and Configuration Protocol) frame header. More...
 
struct  profinet::IPConfiguration
 Decoded IPv4 address/netmask/gateway triple. More...
 
struct  profinet::PNDCPBlockRequest
 DCP request block: Option(1) + SubOption(1) + Length(2) + payload(Length). More...
 
struct  profinet::PNDCPBlock
 DCP response block: Option(1) + SubOption(1) + Length(2) + Status(2) + payload. More...
 
struct  profinet::PNRPCHeader
 DCE/RPC PDU header used to carry PROFINET connect/read/write/control requests. More...
 
struct  profinet::PNNRDData
 NRD (Network Representation Data) wrapper carrying the actual IOD payload. More...
 
struct  profinet::PNIODHeader
 IOD read/write request/response header (RPC body for READ/WRITE/IMPLICIT_READ). More...
 
struct  profinet::PNBlockHeader
 
struct  profinet::PNARBlockRequest
 ARBlockReq: establishes an Application Relationship (sent in the CONNECT request). More...
 
struct  profinet::PNIODReleaseBlock
 Control block used for Release/PrmBegin/PrmEnd/ApplicationReady/RTClass3 requests. More...
 
struct  profinet::PNInM0
 I&M0: mandatory identification data (vendor, order ID, serial number, revisions). More...
 
struct  profinet::PNInM1
 I&M1: user-assigned tag function and location strings. More...
 
struct  profinet::PNInM2
 I&M2: installation date. More...
 
struct  profinet::PNInM3
 I&M3: free-text descriptor. More...
 
struct  profinet::PNInM4
 I&M4: PROFIsafe signature (binary, not text). More...
 
struct  profinet::PNInM5
 I&M5: free-text annotation. More...
 
struct  profinet::PNInMReserved< Idx >
 I&M6-I&M15: reserved for future use per IEC 61158-6-10. More...
 
struct  profinet::IOCRAPIObject
 One slot/subslot's placement within an IOCR's cyclic data frame. More...
 
struct  profinet::PNIOCRBlockRes
 IOCRBlockRes: device's response confirming an IOCR (part of the CONNECT response). More...
 
struct  profinet::PNIOCRBlockReqHeader
 IOCRBlockReq header: requests establishment of one IOCR (part of the CONNECT request). More...
 
struct  profinet::PNAlarmCRBlockReq
 AlarmCRBlockReq: requests establishment of the alarm connection (part of the CONNECT request). More...
 
struct  profinet::PNAlarmCRBlockRes
 AlarmCRBlockRes: device's response confirming the alarm connection (part of the CONNECT response). More...
 
struct  profinet::PNAlarmNotificationPDU
 AlarmNotification-PDU: carries a diagnosis/process/pull/plug/... alarm event. More...
 
struct  profinet::PNAlarmAckPDU
 AlarmAck-PDU: acknowledges receipt of an AlarmNotification-PDU. More...
 
struct  profinet::PNRTAHeader
 RTA-PDU Header - Real-Time Acyclic PDU for Layer 2 alarm transport. More...
 
struct  profinet::RtaError
 Decoded PROFINET RTA ERR-PDU. More...
 
struct  profinet::PNExpectedSubmoduleDataDescription
 Describes one direction (input or output) of a submodule's cyclic data. More...
 
struct  profinet::PNIODWriteReq
 IODWriteReqHeader: request header for writing a data record. More...
 
struct  profinet::PNIODWriteRes
 IODWriteResHeader: response header confirming (or rejecting) a data record write. More...
 

Namespaces

namespace  profinet
 

Macros

#define MAGIC_ENUM_RANGE_MIN   0
 
#define MAGIC_ENUM_RANGE_MAX   255
 

Typedefs

using profinet::Bytes = std::vector< std::uint8_t >
 Generic byte buffer alias used throughout the library for raw wire data.
 
using profinet::PNInM6 = PNInMReserved< 0xAFF6 >
 I&M6 record type (reserved).
 
using profinet::PNInM7 = PNInMReserved< 0xAFF7 >
 I&M7 record type (reserved).
 
using profinet::PNInM8 = PNInMReserved< 0xAFF8 >
 I&M8 record type (reserved).
 
using profinet::PNInM9 = PNInMReserved< 0xAFF9 >
 I&M9 record type (reserved).
 
using profinet::PNInM10 = PNInMReserved< 0xAFFA >
 I&M10 record type (reserved).
 
using profinet::PNInM11 = PNInMReserved< 0xAFFB >
 I&M11 record type (reserved).
 
using profinet::PNInM12 = PNInMReserved< 0xAFFC >
 I&M12 record type (reserved).
 
using profinet::PNInM13 = PNInMReserved< 0xAFFD >
 I&M13 record type (reserved).
 
using profinet::PNInM14 = PNInMReserved< 0xAFFE >
 I&M14 record type (reserved).
 
using profinet::PNInM15 = PNInMReserved< 0xAFFF >
 I&M15 record type (reserved).
 

Enumerations

enum class  profinet::DcpFrameId : std::uint16_t {
  profinet::Unknown = 0x0000 , profinet::IdentifyRequest = 0xFEFE , profinet::IdentifyResponse = 0xFEFF , profinet::GetSet = 0xFEFD ,
  profinet::Hello = 0xFEFC
}
 PROFINET DCP frame identifiers. More...
 
enum class  profinet::DcpServiceId : std::uint8_t {
  profinet::Unknown = 0x00 , profinet::Get = 0x03 , profinet::Set = 0x04 , profinet::Identify = 0x05 ,
  profinet::Hello = 0x06
}
 DCP service identifiers. More...
 
enum class  profinet::DcpServiceType : std::uint8_t { profinet::Request = 0x00 , profinet::ResponseSuccess = 0x01 , profinet::ResponseUnsupported = 0x05 }
 DCP service types. More...
 
enum class  profinet::DcpOption : std::uint8_t {
  profinet::Unknown = 0x00 , profinet::Ip = 0x01 , profinet::Device = 0x02 , profinet::Dhcp = 0x03 ,
  profinet::Reserved = 0x04 , profinet::Control = 0x05 , profinet::DeviceInitiative = 0x06 , profinet::Nme = 0x07 ,
  profinet::All = 0xFF
}
 DCP options. More...
 
enum class  profinet::DcpIpSuboption : std::uint8_t { profinet::Unknown = 0x00 , profinet::Mac = 0x01 , profinet::IpParameter = 0x02 , profinet::FullIpSuite = 0x03 }
 DCP IP suboptions. More...
 
enum class  profinet::DcpDeviceSuboption : std::uint8_t {
  profinet::Unknown = 0x00 , profinet::Type = 0x01 , profinet::Name = 0x02 , profinet::DeviceId = 0x03 ,
  profinet::Role = 0x04 , profinet::Options = 0x05 , profinet::Alias = 0x06 , profinet::Instance = 0x07 ,
  profinet::OemId = 0x08 , profinet::Rsi = 0x0A
}
 DCP Device suboptions. More...
 
enum class  profinet::DcpControlSuboption : std::uint8_t {
  profinet::Unknown = 0x00 , profinet::Start = 0x01 , profinet::Stop = 0x02 , profinet::Signal = 0x03 ,
  profinet::Response = 0x04 , profinet::FactoryReset = 0x05 , profinet::ResetToFactory = 0x06
}
 DCP Control suboptions. More...
 
enum class  profinet::DcpDhcpSuboption : std::uint8_t {
  profinet::Unknown = 0x00 , profinet::Hostname = 0x0C , profinet::VendorSpec = 0x2B , profinet::ServerId = 0x36 ,
  profinet::ParamReq = 0x37 , profinet::ClassId = 0x3C , profinet::ClientId = 0x3D , profinet::Fqdn = 0x51 ,
  profinet::Uuid = 0x61 , profinet::Control = 0xFF
}
 DCP DHCP suboptions. More...
 
enum class  profinet::DcpDeviceInitiativeSuboption : std::uint8_t { profinet::Initiative = 0x01 }
 DCP DeviceInitiative suboptions. More...
 
enum class  profinet::DcpDeviceRole : std::uint8_t { profinet::IoDevice = 0x01 , profinet::IoController = 0x02 , profinet::IoMultidevice = 0x04 , profinet::PnSupervisor = 0x08 }
 Device role bitmask. More...
 
enum class  profinet::DcpResetMode : std::uint16_t {
  profinet::Communication = 0x0002 , profinet::Application = 0x0004 , profinet::Engineering = 0x0008 , profinet::AllData = 0x0010 ,
  profinet::Device = 0x0020 , profinet::Factory = 0x0040
}
 Reset mode bitmask. More...
 
enum class  profinet::DcpDeviceInitiative : std::uint16_t { profinet::NoHello = 0x0000 , profinet::IssueHello = 0x0001 }
 DCP device-initiative values. More...
 
enum class  profinet::DcpBlockError : std::uint8_t {
  profinet::Ok = 0x00 , profinet::OptionUnsupported = 0x01 , profinet::SuboptionUnsupported = 0x02 , profinet::SuboptionNotSet = 0x03 ,
  profinet::Resource = 0x04 , profinet::SetNotPossible = 0x05 , profinet::InOperation = 0x06
}
 DCP block-level SET response errors. More...
 
enum class  profinet::DcpResponseCode : std::uint8_t {
  profinet::NoError = 0x00 , profinet::OptionNotSupported = 0x01 , profinet::SuboptionNotSupported = 0x02 , profinet::SuboptionNotSet = 0x03 ,
  profinet::ResourceError = 0x04 , profinet::SetNotPossible = 0x05 , profinet::InOperationSetNotPossible = 0x06
}
 DCP GET/SET response codes. More...
 
enum class  profinet::DcpResetQualifier : std::uint16_t {
  profinet::Unknown = 0x0000 , profinet::ApplicationData = 0x0002 , profinet::ApplicationDataAlternate = 0x0003 , profinet::CommunicationParameter = 0x0004 ,
  profinet::CommunicationParameterAlternate = 0x0005 , profinet::EngineeringParameter = 0x0006 , profinet::EngineeringParameterAlternate = 0x0007 , profinet::AllStoredData = 0x0008 ,
  profinet::AllStoredDataAlternate = 0x0009 , profinet::EngineeringParameterExtended = 0x000A , profinet::EngineeringParameterExtendedAlternate = 0x000B , profinet::ToFactory = 0x0010 ,
  profinet::ToFactoryAlternate = 0x0011 , profinet::Restore = 0x0012 , profinet::RestoreAlternate = 0x0013
}
 Reset qualifier values for ResetToFactory(). More...
 
enum class  profinet::DcpBlockQualifier : std::uint16_t { profinet::Temporary = 0x0000 , profinet::Permanent = 0x0001 }
 DCP block qualifier values. More...
 
enum class  profinet::DcpIpBlockInfo : std::uint16_t {
  profinet::NotSet = 0x0000 , profinet::Set = 0x0001 , profinet::SetByDhcp = 0x0002 , profinet::NotSetConflict = 0x0080 ,
  profinet::SetConflict = 0x0081 , profinet::SetByDhcpConflict = 0x0082
}
 PROFINET DCP IP block status values. IP block status flags (IEC 61158-6-10 IPBlockInfo). More...
 
enum class  profinet::RtaErrorClass : std::uint8_t {
  profinet::Reserved = 0x00 , profinet::SequenceNumber = 0x01 , profinet::Abort = 0x02 , profinet::Extended = 0x03 ,
  profinet::Obsoleted = 0x04 , profinet::UserSpecific = 0x05
}
 Classification of an RTA protocol error reason. More...
 
enum class  profinet::RtaErrorReason : std::uint8_t {
  profinet::Reserved = 0x00 , profinet::SequenceNumber = 0x01 , profinet::InstanceClosed = 0x02 , profinet::ArOutOfMemory = 0x03 ,
  profinet::ArAddProviderConsumerFailed = 0x04 , profinet::ArConsumerDhtWdtExpired = 0x05 , profinet::ArCmiTimeout = 0x06 , profinet::ArAlarmOpenFailed = 0x07 ,
  profinet::ArAlarmSendConfirmationNegative = 0x08 , profinet::ArAlarmAckSendConfirmationNegative = 0x09 , profinet::ArAlarmDataTooLong = 0x0A , profinet::ArAlarmIndError = 0x0B ,
  profinet::ArRpcClientCallConfirmationNegative = 0x0C , profinet::ArAbortRequest = 0x0D , profinet::ArRerunAbortsExisting = 0x0E , profinet::ArReleaseIndReceived = 0x0F ,
  profinet::ArDeviceDeactivated = 0x10 , profinet::ArRemoved = 0x11 , profinet::ArProtocolViolation = 0x12 , profinet::ArNameResolutionError = 0x13 ,
  profinet::ArRpcBindError = 0x14 , profinet::ArRpcConnectError = 0x15 , profinet::ArRpcReadError = 0x16 , profinet::ArRpcWriteError = 0x17 ,
  profinet::ArRpcControlError = 0x18 , profinet::ArForbiddenPullPlug = 0x19 , profinet::ArApRemoved = 0x1A , profinet::ArLinkDown = 0x1B ,
  profinet::ArMulticastMacRegistrationFailed = 0x1C , profinet::NotSynchronized = 0x1D , profinet::WrongTopology = 0x1E , profinet::DcpStationNameChanged = 0x1F ,
  profinet::DcpResetToFactorySettings = 0x20 , profinet::CompanionAr8ippSubmodule = 0x21 , profinet::NoIrdataRecordYet = 0x22 , profinet::Pdev = 0x23 ,
  profinet::PdevNoRequiredSpeedDuplexity = 0x24 , profinet::IpSuiteChanged = 0x25 , profinet::IocarSrRdhtExpired = 0x26 , profinet::IocarSrPdevParameterizationImpossible = 0x27 ,
  profinet::RemoteApplicationReadyTimeout = 0x28 , profinet::IocarSrRedundantInterfaceLost = 0x29 , profinet::IocarSrMtotExpired = 0x2A , profinet::IocarSrArProtocolViolation = 0x2B ,
  profinet::PdevPlugPortWithoutCombinedObjectContainer = 0x2C , profinet::ObsoletedNmeNoConfiguration = 0x2D , profinet::UserAbort = 0xFF
}
 Exact current PROFINET RTA ErrorCode2 values. More...
 

Functions

constexpr DcpDeviceRole profinet::operator| (DcpDeviceRole lhs, DcpDeviceRole rhs)
 
constexpr DcpDeviceRole profinet::operator& (DcpDeviceRole lhs, DcpDeviceRole rhs)
 
constexpr DcpResetMode profinet::operator| (DcpResetMode lhs, DcpResetMode rhs)
 
constexpr DcpResetMode profinet::operator& (DcpResetMode lhs, DcpResetMode rhs)
 
RtaError profinet::ParseRtaError (const PNRTAHeader &header)
 Parse an RTA ERR-PDU from an already parsed RTA header.
 
RtaError profinet::ParseRtaError (const Bytes &data)
 Parse an RTA ERR-PDU from raw RTA PDU bytes.
 

Variables

constexpr int profinet::blockHeaderLength = 6
 Constant lenght of a blockHeader.
 
constexpr std::array< std::uint8_t, 12 > profinet::kPnUuidSuffix
 PROFINET UUID suffix, shared by all interface/object UUIDs.
 

Detailed Description

PROFINET protocol wire-format structures and serialization helpers.

Defines the C++ representations of the PROFINET protocol structures used by the controller, including Ethernet/DCP, DCE/RPC, IOD, IOCR, AlarmCR, RTA, I&M, and record-data blocks.

Each structure provides explicit parsing and/or serialization functionality for converting between strongly typed C++ objects and their binary on-the-wire representation. The layouts are ported from the corresponding IEC 61158-6-10 protocol definitions and are intended to maintain wire-level compatibility with PROFINET devices.

The header includes:

  • Ethernet II and VLAN frame headers.
  • DCP discovery and configuration headers and blocks.
  • DCE/RPC headers and PROFINET interface UUIDs.
  • Network Representation Data (NRD) and IOD record headers.
  • Generic PROFINET block headers.
  • ARBlockReq and control blocks.
  • Identification & Maintenance (I&M0-I&M15) records.
  • IOCR request/response and API objects.
  • AlarmCR request/response blocks.
  • Alarm notification and acknowledgement PDUs.
  • RTA headers for Layer 2 alarm transport.
  • Expected-submodule data descriptions.
  • IOD write request and response blocks.

Fixed-size constants are explicitly defined for wire structures to make their expected binary layout visible and testable. Parsing uses the profinet::wire reader utilities, while serialization uses the corresponding wire-writing helpers.

Definition in file protocol.h.

Macro Definition Documentation

◆ MAGIC_ENUM_RANGE_MAX

#define MAGIC_ENUM_RANGE_MAX   255

Definition at line 37 of file protocol.h.

◆ MAGIC_ENUM_RANGE_MIN

#define MAGIC_ENUM_RANGE_MIN   0

Definition at line 36 of file protocol.h.