PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::rpc::RpcTests Class Reference
+ Inheritance diagram for profinet::rpc::RpcTests:
+ Collaboration diagram for profinet::rpc::RpcTests:

Classes

class  TestRpcTransport
 Deterministic RPC transport used to test RPCCon without UDP. More...
 

Protected Member Functions

void SetUp () override
 
void TearDown () override
 
dcp::DCPDeviceDescription MakeRpcTestDeviceInfo ()
 Creates a deterministic DCP device description suitable for RPC constructor tests.
 
bool IsAllZeroUuid (const std::array< std::uint8_t, uuidLenght > &uuid)
 Checks whether every byte in a UUID is zero.
 
PNRPCHeader CreateRpc (const Bytes &payload, RPCCon *conn=nullptr)
 Calls the private RPC header construction helper.
 
Bytes InvokeBuildIocrBlock (IocrType iocrType, const IOCRSetup &setup)
 Calls the IOCR block construction helper.
 
Bytes MakeEpmTowerFloor (const Bytes &lhs, const Bytes &rhs)
 Builds one EPM tower floor from an LHS and RHS field.
 
Bytes MakeEpmTower (const std::vector< Bytes > &floors)
 Builds a complete EPM tower from encoded floors.
 
Bytes MakeInterfaceTowerLhs (const std::string &uuid, std::uint16_t major)
 Builds the LHS of an EPM interface tower floor.
 
Bytes MakeInterfaceTowerRhs (std::uint16_t minor)
 Builds the RHS of an EPM interface tower floor.
 
Bytes MakeCompleteEpmTower (const std::string &interfaceUuid, std::uint16_t major, std::uint16_t minor, std::uint16_t port, const std::array< std::uint8_t, 4 > &ipAddress)
 Builds a complete EPM tower for an endpoint.
 
bool IsZeroUuid (const std::array< std::uint8_t, uuidLenght > &uuid)
 Checks whether a UUID byte array contains only zero bytes.
 
Bytes MakeEpmLookupBody (const std::array< std::uint8_t, uuidLenght > &objectUuid, const std::string &annotation, const Bytes &tower)
 Builds a synthetic EPM lookup response body containing one entry.
 
Bytes MakeEpmResponse (const Bytes &body)
 Builds a minimal DCE/RPC response containing the supplied body.
 
void ReplyToEpmLookup (asio::ip::udp::socket &server, const Bytes &response, Bytes &request)
 Receives an EPM lookup request and sends a synthetic response.
 
Bytes MakeDcpBlock (DcpOption option, std::uint8_t suboption, const Bytes &payload)
 Builds a serialized DCP block.
 
Bytes MakeDcpResponseFrame (const MacAddress &src, const MacAddress &dst, DcpServiceId serviceId, std::uint32_t xid, const Bytes &payload)
 Builds an untagged Ethernet frame containing a DCP response.
 
Bytes MakeStationNameResponse (const MacAddress &deviceMac, const MacAddress &controllerMac, const std::string &stationName)
 Builds a DCP response containing a station-name block.
 
Bytes MakeDeviceResponse (const MacAddress &deviceMac, const MacAddress &controllerMac, const std::string &stationName, const Bytes &additionalBlocks={})
 Builds a DCP response containing multiple station/device blocks.
 
std::map< dcp::BlockKey, std::vector< std::uint8_t > > MakeStationBlocks (const std::string &stationName)
 Creates a map of DCP blocks containing only a station name.
 
PNNRDData InvokeCreateNrd (const Bytes &payload)
 Calls the private RPCCon::CreateNrd helper.
 
Bytes InvokeBuildAlarmCrBlock (int transport, int priority)
 Calls the private RPCCon::BuildAlarmCrBlock helper.
 
int InvokeParseAlarmCrResponse (const Bytes &responseData)
 Calls the private RPCCon::ParseAlarmCrResponse helper.
 
std::unique_ptr< RPCCon > MakeTestRpcConnection ()
 Creates a deterministic RPC connection for helper tests.
 
Bytes MakeAlarmCrResponseBlock (std::uint16_t localAlarmReference)
 Creates a valid AlarmCR response block.
 
Bytes MakeBlockHeader (BlockType blockType, std::uint16_t blockLength)
 Creates an unrelated serialized block header.
 
std::unique_ptr< RPCCon > MakeTestTransportRpcConnection (std::unique_ptr< IRpcTransport > transport, std::unique_ptr< IRpcTransport > ctransport=nullptr)
 Creates a test RPC connection using the injected transport.
 
Bytes MakeRpcResponseBytes (std::uint8_t packetType=PNRPCHeader::RESPONSE, std::uint16_t operationNumber=0, const Bytes &payload={})
 Creates an empty successful RPC response.
 
Bytes MakeNrdResponseBytes (const Bytes &payload={})
 Creates a successful NRD response wrapping the supplied payload.
 
Bytes MakeNrdRpcResponseBytes (std::uint16_t operationNumber, const Bytes &payload={})
 Creates an RPC response containing an NRD response.
 
Bytes MakePnioErrorNrdResponse (std::uint32_t status, const Bytes &payload={})
 Creates an NRD response containing a PROFINET error status.
 
Bytes MakeIodResponsePayload (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes &payload)
 Creates a valid IOD response block.
 
Bytes MakeImPayload (std::uint16_t index)
 Creates a deterministic I&M payload of the required size.
 
Bytes MakeDiagnosisPayload ()
 Builds a diagnosis block containing one ChannelDiagnosis entry.
 
Bytes MakeRealIdentificationPayload ()
 Builds a v1.0 RealIdentificationData payload.
 
Bytes MakeModuleDiffPayload ()
 Builds a valid ModuleDiffBlock payload.
 
Bytes MakeWriteMultipleResponsePayload ()
 Builds a minimal WriteMultiple response containing one successful entry.
 
Bytes MakeIocrResponseBlock (std::uint16_t iocrType, std::uint16_t iocrReference, std::uint16_t frameId)
 Creates a serialized IOCR response block.
 
std::uint16_t InvokeParseIocrResponse (const Bytes &responseData, int iocrType)
 
PNRPCHeader InvokeSendReceive (const PNRPCHeader &request)
 
void InvokeSetRPCConLive (bool live)
 
void InvokeSetRPCConArUuid (std::uint8_t byte)
 
void InvokeSetRPCConArUuid (const std::array< std::uint8_t, uuidLenght > &bytes)
 
void InvokeSetRPCConSessionKey (std::uint16_t byte)
 
void InvokeSetRPCConInfo (std::uint8_t deviceHigh, std::uint8_t deviceLow, std::uint8_t vendorHigh, std::uint8_t vendorLow)
 
void InvokeSetRPCConSrcMac (std::string mac)
 
void InvokeSetRPCConLiveMonotonic (std::chrono::steady_clock::time_point time)
 
void InvokeRPCConCheckTimeout ()
 
bool InvokeGetRPCConLive ()
 
std::optional< MacAddress > InvokeGetRPCConSrcMac ()
 
Bytes InvokeSendControl (BlockType blockType, ControlCommand controlCommand, bool waitResponse=true, const Bytes &subBlocks={})
 
Bytes MakeRawRpcHeader (bool littleEndian, std::uint8_t packetType, std::uint32_t interfaceVersion, std::uint32_t sequenceNumber, std::uint16_t operationNumber, const Bytes &payload)
 Creates a raw DCE/RPC message for unit-test input.
 
Bytes MakeApplicationReadyControlBlock (std::uint16_t blockType=BLOCK_IOD_CONTROL_APP_READY_REQ, ControlCommand controlCommand=ControlCommand::ApplicationReady)
 Creates a serialized IOD control block.
 
Bytes MakeApplicationReadyNrd (const Bytes &block, bool littleEndian)
 Creates an NRD payload containing an IOD control block.
 
Bytes MakeApplicationReadyRequest (bool littleEndian, std::uint16_t blockType=BLOCK_IOD_CONTROL_APP_READY_REQ, ControlCommand controlCommand=ControlCommand::ApplicationReady)
 Creates a raw DCE/RPC Application Ready request.
 

Protected Attributes

std::unique_ptr< RPCCon > conn
 
std::unique_ptr< TestRpcTransport > transport
 
TestRpcTransport * rawTransport = nullptr
 
std::unique_ptr< TestRpcTransport > ctransport
 
TestRpcTransport * rawcTransport = nullptr
 

Detailed Description

Definition at line 39 of file test_rpc.cpp.

Member Function Documentation

◆ CreateRpc()

PNRPCHeader profinet::rpc::RpcTests::CreateRpc ( const Bytes &  payload,
RPCCon *  conn = nullptr 
)
inlineprotected

Calls the private RPC header construction helper.

Parameters
payloadRPC payload.
Returns
Constructed RPC header.

Definition at line 88 of file test_rpc.cpp.

References conn, profinet::PNRPCHeader::CONNECT, and payload.

◆ InvokeBuildAlarmCrBlock()

Bytes profinet::rpc::RpcTests::InvokeBuildAlarmCrBlock ( int  transport,
int  priority 
)
inlineprotected

Calls the private RPCCon::BuildAlarmCrBlock helper.

Parameters
connRPC connection under test.
transportAlarm transport selector.
priorityAlarm priority.
Returns
Serialized AlarmCR request block.

Definition at line 441 of file test_rpc.cpp.

References conn, and transport.

◆ InvokeBuildIocrBlock()

Bytes profinet::rpc::RpcTests::InvokeBuildIocrBlock ( IocrType  iocrType,
const IOCRSetup &  setup 
)
inlineprotected

Calls the IOCR block construction helper.

Parameters
iocrTypeIOCR type.
setupIOCR configuration.
Returns
Serialized IOCR block.

Definition at line 103 of file test_rpc.cpp.

References profinet::rpc::RPCCon::BuildIocrBlock().

+ Here is the call graph for this function:

◆ InvokeCreateNrd()

PNNRDData profinet::rpc::RpcTests::InvokeCreateNrd ( const Bytes &  payload)
inlineprotected

Calls the private RPCCon::CreateNrd helper.

Parameters
connRPC connection under test.
payloadPayload to wrap.
Returns
Serialized NRD wrapper.

Definition at line 430 of file test_rpc.cpp.

References conn, and payload.

◆ InvokeGetRPCConLive()

bool profinet::rpc::RpcTests::InvokeGetRPCConLive ( )
inlineprotected

Definition at line 970 of file test_rpc.cpp.

References conn.

◆ InvokeGetRPCConSrcMac()

std::optional< MacAddress > profinet::rpc::RpcTests::InvokeGetRPCConSrcMac ( )
inlineprotected

Definition at line 975 of file test_rpc.cpp.

References conn.

◆ InvokeParseAlarmCrResponse()

int profinet::rpc::RpcTests::InvokeParseAlarmCrResponse ( const Bytes &  responseData)
inlineprotected

Calls the private RPCCon::ParseAlarmCrResponse helper.

Parameters
responseDataSerialized RPC response block data.
Returns
Local alarm reference, or -1 when no valid AlarmCR response is found.

Definition at line 450 of file test_rpc.cpp.

References conn.

◆ InvokeParseIocrResponse()

std::uint16_t profinet::rpc::RpcTests::InvokeParseIocrResponse ( const Bytes &  responseData,
int  iocrType 
)
inlineprotected

Definition at line 913 of file test_rpc.cpp.

References profinet::rpc::RPCCon::ParseIocrResponse().

+ Here is the call graph for this function:

◆ InvokeRPCConCheckTimeout()

void profinet::rpc::RpcTests::InvokeRPCConCheckTimeout ( )
inlineprotected

Definition at line 966 of file test_rpc.cpp.

References conn.

◆ InvokeSendControl()

Bytes profinet::rpc::RpcTests::InvokeSendControl ( BlockType  blockType,
ControlCommand  controlCommand,
bool  waitResponse = true,
const Bytes &  subBlocks = {} 
)
inlineprotected

Definition at line 979 of file test_rpc.cpp.

◆ InvokeSendReceive()

PNRPCHeader profinet::rpc::RpcTests::InvokeSendReceive ( const PNRPCHeader &  request)
inlineprotected

Definition at line 925 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConArUuid() [1/2]

void profinet::rpc::RpcTests::InvokeSetRPCConArUuid ( const std::array< std::uint8_t, uuidLenght > &  bytes)
inlineprotected

Definition at line 938 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConArUuid() [2/2]

void profinet::rpc::RpcTests::InvokeSetRPCConArUuid ( std::uint8_t  byte)
inlineprotected

Definition at line 933 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConInfo()

void profinet::rpc::RpcTests::InvokeSetRPCConInfo ( std::uint8_t  deviceHigh,
std::uint8_t  deviceLow,
std::uint8_t  vendorHigh,
std::uint8_t  vendorLow 
)
inlineprotected

Definition at line 947 of file test_rpc.cpp.

References profinet::rpc::BuildObjectUuid(), and conn.

+ Here is the call graph for this function:

◆ InvokeSetRPCConLive()

void profinet::rpc::RpcTests::InvokeSetRPCConLive ( bool  live)
inlineprotected

Definition at line 929 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConLiveMonotonic()

void profinet::rpc::RpcTests::InvokeSetRPCConLiveMonotonic ( std::chrono::steady_clock::time_point  time)
inlineprotected

Definition at line 962 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConSessionKey()

void profinet::rpc::RpcTests::InvokeSetRPCConSessionKey ( std::uint16_t  byte)
inlineprotected

Definition at line 943 of file test_rpc.cpp.

References conn.

◆ InvokeSetRPCConSrcMac()

void profinet::rpc::RpcTests::InvokeSetRPCConSrcMac ( std::string  mac)
inlineprotected

Definition at line 957 of file test_rpc.cpp.

References conn, and profinet::String2Mac().

+ Here is the call graph for this function:

◆ IsAllZeroUuid()

bool profinet::rpc::RpcTests::IsAllZeroUuid ( const std::array< std::uint8_t, uuidLenght > &  uuid)
inlineprotected

Checks whether every byte in a UUID is zero.

Parameters
uuidUUID byte array to inspect.
Returns
True when all UUID bytes are zero.

Definition at line 75 of file test_rpc.cpp.

◆ IsZeroUuid()

bool profinet::rpc::RpcTests::IsZeroUuid ( const std::array< std::uint8_t, uuidLenght > &  uuid)
inlineprotected

Checks whether a UUID byte array contains only zero bytes.

Parameters
uuidUUID byte array.
Returns
True when all bytes are zero.

Definition at line 213 of file test_rpc.cpp.

◆ MakeAlarmCrResponseBlock()

Bytes profinet::rpc::RpcTests::MakeAlarmCrResponseBlock ( std::uint16_t  localAlarmReference)
inlineprotected

Creates a valid AlarmCR response block.

Parameters
localAlarmReferenceLocal alarm reference to encode.
Returns
Serialized AlarmCR response block.

Definition at line 467 of file test_rpc.cpp.

References profinet::AlarmCrResponse, profinet::PNAlarmCRBlockRes::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNAlarmCRBlockRes::kSize, profinet::PNAlarmCRBlockRes::localAlarmReference, profinet::PNBlockHeader::ToBytes(), and profinet::PNAlarmCRBlockRes::ToBytes().

+ Here is the call graph for this function:

◆ MakeApplicationReadyControlBlock()

Bytes profinet::rpc::RpcTests::MakeApplicationReadyControlBlock ( std::uint16_t  blockType = BLOCK_IOD_CONTROL_APP_READY_REQ,
ControlCommand  controlCommand = ControlCommand::ApplicationReady 
)
inlineprotected

Creates a serialized IOD control block.

Parameters
blockTypePROFINET IOD control block type.
controlCommandControl command encoded in the block.
Returns
Serialized 32-byte IOD control block.

Definition at line 1063 of file test_rpc.cpp.

References profinet::PNIODReleaseBlock::arUuid, profinet::PNIODReleaseBlock::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNIODReleaseBlock::controlBlockProperties, profinet::PNIODReleaseBlock::controlCommand, profinet::PNIODReleaseBlock::kSize, profinet::PNIODReleaseBlock::padding1, profinet::PNIODReleaseBlock::padding2, profinet::PNIODReleaseBlock::sessionKey, profinet::PNBlockHeader::ToBytes(), and profinet::PNIODReleaseBlock::ToBytes().

Referenced by MakeApplicationReadyRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeApplicationReadyNrd()

Bytes profinet::rpc::RpcTests::MakeApplicationReadyNrd ( const Bytes &  block,
bool  littleEndian 
)
inlineprotected

Creates an NRD payload containing an IOD control block.

Parameters
blockSerialized IOD control block.
littleEndianWhether NRD header fields use little-endian encoding.
Returns
Serialized NRD payload.

Definition at line 1091 of file test_rpc.cpp.

References profinet::wire::PutLittleEndian(), and profinet::wire::PutU32().

Referenced by MakeApplicationReadyRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeApplicationReadyRequest()

Bytes profinet::rpc::RpcTests::MakeApplicationReadyRequest ( bool  littleEndian,
std::uint16_t  blockType = BLOCK_IOD_CONTROL_APP_READY_REQ,
ControlCommand  controlCommand = ControlCommand::ApplicationReady 
)
inlineprotected

Creates a raw DCE/RPC Application Ready request.

Parameters
littleEndianWhether RPC and NRD numeric fields use little-endian byte order.
blockTypeIOD control block type.
controlCommandControl command contained in the block.
Returns
Serialized Application Ready request.

Definition at line 1125 of file test_rpc.cpp.

References profinet::PNRPCHeader::CONTROL, MakeApplicationReadyControlBlock(), MakeApplicationReadyNrd(), MakeRawRpcHeader(), and profinet::PNRPCHeader::REQUEST.

+ Here is the call graph for this function:

◆ MakeBlockHeader()

Bytes profinet::rpc::RpcTests::MakeBlockHeader ( BlockType  blockType,
std::uint16_t  blockLength 
)
inlineprotected

Creates an unrelated serialized block header.

Parameters
blockTypeBlock type to encode.
blockLengthBlock length.
Returns
Serialized block header.

Definition at line 491 of file test_rpc.cpp.

References profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, and profinet::PNBlockHeader::ToBytes().

Referenced by MakeModuleDiffPayload().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeCompleteEpmTower()

Bytes profinet::rpc::RpcTests::MakeCompleteEpmTower ( const std::string &  interfaceUuid,
std::uint16_t  major,
std::uint16_t  minor,
std::uint16_t  port,
const std::array< std::uint8_t, 4 > &  ipAddress 
)
inlineprotected

Builds a complete EPM tower for an endpoint.

Parameters
interfaceUuidInterface UUID.
majorInterface major version.
minorInterface minor version.
portEndpoint port.
ipAddressEndpoint IPv4 address.
Returns
Complete EPM tower.

Definition at line 187 of file test_rpc.cpp.

References MakeEpmTower(), MakeEpmTowerFloor(), MakeInterfaceTowerLhs(), MakeInterfaceTowerRhs(), and profinet::wire::PutBigEndian().

+ Here is the call graph for this function:

◆ MakeDcpBlock()

Bytes profinet::rpc::RpcTests::MakeDcpBlock ( DcpOption  option,
std::uint8_t  suboption,
const Bytes &  payload 
)
inlineprotected

Builds a serialized DCP block.

Parameters
optionDCP option.
suboptionDCP suboption.
payloadBlock payload.
Returns
Serialized DCP block including alignment padding.

Definition at line 331 of file test_rpc.cpp.

References profinet::PNDCPBlockRequest::length, profinet::PNDCPBlockRequest::option, option, profinet::PNDCPBlockRequest::payload, payload, profinet::PNDCPBlockRequest::suboption, suboption, and profinet::PNDCPBlockRequest::ToBytes().

Referenced by MakeStationNameResponse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeDcpResponseFrame()

Bytes profinet::rpc::RpcTests::MakeDcpResponseFrame ( const MacAddress &  src,
const MacAddress &  dst,
DcpServiceId  serviceId,
std::uint32_t  xid,
const Bytes &  payload 
)
inlineprotected

Builds an untagged Ethernet frame containing a DCP response.

Parameters
srcDevice source MAC address.
dstController destination MAC address.
serviceIdDCP service identifier.
xidDCP transaction identifier.
payloadSerialized DCP response blocks.
Returns
Complete Ethernet frame.

Definition at line 358 of file test_rpc.cpp.

References profinet::EthernetHeader::dst, profinet::PNDCPHeader::frameId, profinet::GetSet, profinet::PNDCPHeader::length, profinet::EthernetHeader::payload, profinet::PNDCPHeader::payload, payload, profinet::PROFINET_ETHERTYPE, profinet::PNDCPHeader::respDelay, profinet::ResponseSuccess, profinet::PNDCPHeader::serviceId, profinet::PNDCPHeader::serviceType, profinet::EthernetHeader::src, profinet::EthernetHeader::ToBytes(), profinet::PNDCPHeader::ToBytes(), profinet::EthernetHeader::type, and profinet::PNDCPHeader::xId.

Referenced by MakeStationNameResponse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeDeviceResponse()

Bytes profinet::rpc::RpcTests::MakeDeviceResponse ( const MacAddress &  deviceMac,
const MacAddress &  controllerMac,
const std::string &  stationName,
const Bytes &  additionalBlocks = {} 
)
inlineprotected

Builds a DCP response containing multiple station/device blocks.

Parameters
deviceMacDevice source MAC address.
controllerMacController destination MAC address.
stationNameStation name.
additionalBlocksAdditional serialized DCP blocks.
Returns
Complete DCP response Ethernet frame.

Definition at line 400 of file test_rpc.cpp.

◆ MakeDiagnosisPayload()

Bytes profinet::rpc::RpcTests::MakeDiagnosisPayload ( )
inlineprotected

Builds a diagnosis block containing one ChannelDiagnosis entry.

Returns
Serialized diagnosis data.

Definition at line 803 of file test_rpc.cpp.

References profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ MakeEpmLookupBody()

Bytes profinet::rpc::RpcTests::MakeEpmLookupBody ( const std::array< std::uint8_t, uuidLenght > &  objectUuid,
const std::string &  annotation,
const Bytes &  tower 
)
inlineprotected

Builds a synthetic EPM lookup response body containing one entry.

Parameters
objectUuidObject UUID.
annotationEntry annotation.
towerEPM tower.
Returns
Encoded EPM lookup response body.

Definition at line 228 of file test_rpc.cpp.

References profinet::wire::PutFixed(), and profinet::wire::PutLittleEndian().

+ Here is the call graph for this function:

◆ MakeEpmResponse()

Bytes profinet::rpc::RpcTests::MakeEpmResponse ( const Bytes &  body)
inlineprotected

Builds a minimal DCE/RPC response containing the supplied body.

Parameters
bodyRPC response body.
Returns
Complete DCE/RPC response.

Definition at line 272 of file test_rpc.cpp.

References profinet::PNRPCHeader::defaultActivityHint, profinet::PNRPCHeader::defaultInterfaceHint, profinet::rpc::EPM_LOOKUP, profinet::PNRPCHeader::kFixedSize, profinet::wire::PutFixed(), profinet::wire::PutLittleEndian(), and profinet::PNRPCHeader::RESPONSE.

+ Here is the call graph for this function:

◆ MakeEpmTower()

Bytes profinet::rpc::RpcTests::MakeEpmTower ( const std::vector< Bytes > &  floors)
inlineprotected

Builds a complete EPM tower from encoded floors.

Parameters
floorsEncoded EPM tower floors.
Returns
Complete EPM tower.

Definition at line 133 of file test_rpc.cpp.

References profinet::wire::PutFixed(), and profinet::wire::PutLittleEndian().

Referenced by MakeCompleteEpmTower().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeEpmTowerFloor()

Bytes profinet::rpc::RpcTests::MakeEpmTowerFloor ( const Bytes &  lhs,
const Bytes &  rhs 
)
inlineprotected

Builds one EPM tower floor from an LHS and RHS field.

Parameters
lhsLHS field including the EPM protocol identifier.
rhsRHS field.
Returns
Encoded EPM tower floor.

Definition at line 114 of file test_rpc.cpp.

References profinet::wire::PutFixed(), and profinet::wire::PutLittleEndian().

Referenced by MakeCompleteEpmTower().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeImPayload()

Bytes profinet::rpc::RpcTests::MakeImPayload ( std::uint16_t  index)
inlineprotected

Creates a deterministic I&M payload of the required size.

Parameters
indexI&M record index.
Returns
Raw I&M record data.

Definition at line 762 of file test_rpc.cpp.

References profinet::PNInM0::IDX, profinet::PNInM1::IDX, profinet::PNInM2::IDX, profinet::PNInM3::IDX, profinet::PNInM4::IDX, profinet::PNInM5::IDX, profinet::PNInM0::kSize, profinet::PNInM1::kSize, profinet::PNInM2::kSize, profinet::PNInM3::kSize, profinet::PNInM4::kSize, and profinet::PNInM5::kSize.

◆ MakeInterfaceTowerLhs()

Bytes profinet::rpc::RpcTests::MakeInterfaceTowerLhs ( const std::string &  uuid,
std::uint16_t  major 
)
inlineprotected

Builds the LHS of an EPM interface tower floor.

Parameters
uuidInterface UUID in canonical UUID notation.
majorInterface major version.
Returns
Encoded interface LHS.

Definition at line 153 of file test_rpc.cpp.

References profinet::wire::PutFixed(), profinet::wire::PutLittleEndian(), and profinet::rpc::StringToUuidBytes().

Referenced by MakeCompleteEpmTower().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeInterfaceTowerRhs()

Bytes profinet::rpc::RpcTests::MakeInterfaceTowerRhs ( std::uint16_t  minor)
inlineprotected

Builds the RHS of an EPM interface tower floor.

Parameters
minorInterface minor version.
Returns
Encoded interface minor version.

Definition at line 171 of file test_rpc.cpp.

References profinet::wire::PutLittleEndian().

Referenced by MakeCompleteEpmTower().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeIocrResponseBlock()

Bytes profinet::rpc::RpcTests::MakeIocrResponseBlock ( std::uint16_t  iocrType,
std::uint16_t  iocrReference,
std::uint16_t  frameId 
)
inlineprotected

Creates a serialized IOCR response block.

Parameters
iocrTypeIOCR type.
iocrReferenceIOCR reference.
frameIdAssigned frame ID.
Returns
Serialized IOCR response.

Definition at line 899 of file test_rpc.cpp.

References profinet::PNIOCRBlockRes::BLOCK_TYPE, frameId, profinet::PNIOCRBlockRes::kSize, profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ MakeIodResponsePayload()

Bytes profinet::rpc::RpcTests::MakeIodResponsePayload ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx,
const Bytes &  payload 
)
inlineprotected

Creates a valid IOD response block.

Parameters
apiAPI number.
slotSlot number.
subslotSubslot number.
idxRecord index.
payloadRecord payload.
Returns
Serialized PNIOD response.

Definition at line 734 of file test_rpc.cpp.

References profinet::PNIODHeader::api, profinet::PNIODHeader::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNIODHeader::index, profinet::PNBlockHeader::IODReadResponseHeader, profinet::PNIODHeader::kFixedSize, profinet::PNIODHeader::length, profinet::PNIODHeader::payload, payload, profinet::PNIODHeader::sequenceNumber, profinet::PNIODHeader::slot, profinet::PNIODHeader::subslot, profinet::PNIODHeader::ToBytes(), and profinet::PNBlockHeader::ToBytes().

+ Here is the call graph for this function:

◆ MakeModuleDiffPayload()

Bytes profinet::rpc::RpcTests::MakeModuleDiffPayload ( )
inlineprotected

Builds a valid ModuleDiffBlock payload.

Returns
Serialized ModuleDiffBlock.

Definition at line 840 of file test_rpc.cpp.

References MakeBlockHeader(), profinet::MODULE_STATE_PROPER_MODULE, profinet::ModuleDifference, profinet::wire::PutU16(), profinet::wire::PutU32(), and profinet::SUBMODULE_STATE_OK.

+ Here is the call graph for this function:

◆ MakeNrdResponseBytes()

Bytes profinet::rpc::RpcTests::MakeNrdResponseBytes ( const Bytes &  payload = {})
inlineprotected

Creates a successful NRD response wrapping the supplied payload.

Parameters
payloadNRD payload.
Returns
Serialized NRD data.

Definition at line 682 of file test_rpc.cpp.

◆ MakeNrdRpcResponseBytes()

Bytes profinet::rpc::RpcTests::MakeNrdRpcResponseBytes ( std::uint16_t  operationNumber,
const Bytes &  payload = {} 
)
inlineprotected

Creates an RPC response containing an NRD response.

Parameters
operationNumberRPC operation number.
payloadNRD payload.
Returns
Serialized RPC response.

Definition at line 700 of file test_rpc.cpp.

◆ MakePnioErrorNrdResponse()

Bytes profinet::rpc::RpcTests::MakePnioErrorNrdResponse ( std::uint32_t  status,
const Bytes &  payload = {} 
)
inlineprotected

Creates an NRD response containing a PROFINET error status.

Parameters
statusPROFINET argument/status value.
payloadOptional response payload.
Returns
Serialized NRD data.

Definition at line 713 of file test_rpc.cpp.

◆ MakeRawRpcHeader()

Bytes profinet::rpc::RpcTests::MakeRawRpcHeader ( bool  littleEndian,
std::uint8_t  packetType,
std::uint32_t  interfaceVersion,
std::uint32_t  sequenceNumber,
std::uint16_t  operationNumber,
const Bytes &  payload 
)
inlineprotected

Creates a raw DCE/RPC message for unit-test input.

Builds a fixed-size PROFINET DCE/RPC header and appends the supplied payload. The byte order of the RPC header fields is controlled by the DREP little-endian flag. The generated message is suitable for testing raw RPC header parsing.

Parameters
littleEndianWhether RPC multi-byte header fields are encoded in little-endian byte order.
packetTypeDCE/RPC packet type.
interfaceVersionRPC interface version.
sequenceNumberRPC sequence number.
operationNumberRPC operation number.
payloadRaw payload bytes appended after the RPC header.
Returns
Serialized raw DCE/RPC message.

Definition at line 1001 of file test_rpc.cpp.

References profinet::PNRPCHeader::kFixedSize, payload, profinet::wire::PutBigEndian(), profinet::wire::PutFixed(), profinet::wire::PutLittleEndian(), profinet::wire::PutU8(), and profinet::uuidLenght.

Referenced by MakeApplicationReadyRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeRealIdentificationPayload()

Bytes profinet::rpc::RpcTests::MakeRealIdentificationPayload ( )
inlineprotected

Builds a v1.0 RealIdentificationData payload.

Returns
Serialized RealIdentificationData body.

Definition at line 823 of file test_rpc.cpp.

References profinet::wire::PutU16(), and profinet::wire::PutU32().

+ Here is the call graph for this function:

◆ MakeRpcResponseBytes()

Bytes profinet::rpc::RpcTests::MakeRpcResponseBytes ( std::uint8_t  packetType = PNRPCHeader::RESPONSE,
std::uint16_t  operationNumber = 0,
const Bytes &  payload = {} 
)
inlineprotected

Creates an empty successful RPC response.

Parameters
packetTypeDCE/RPC packet type.
operationNumberRPC operation number.
payloadResponse payload.
Returns
Serialized RPC response.

Definition at line 667 of file test_rpc.cpp.

◆ MakeRpcTestDeviceInfo()

dcp::DCPDeviceDescription profinet::rpc::RpcTests::MakeRpcTestDeviceInfo ( )
inlineprotected

Creates a deterministic DCP device description suitable for RPC constructor tests.

Returns
A device description with explicit vendor and device identifiers.

Definition at line 59 of file test_rpc.cpp.

References profinet::dcp::DCPDeviceDescription::name, and profinet::String2Mac().

Referenced by MakeTestRpcConnection(), and MakeTestTransportRpcConnection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeStationBlocks()

std::map< dcp::BlockKey, std::vector< std::uint8_t > > profinet::rpc::RpcTests::MakeStationBlocks ( const std::string &  stationName)
inlineprotected

Creates a map of DCP blocks containing only a station name.

Parameters
stationNameStation name.
Returns
DCP response block map suitable for DCPDeviceDescription.

Definition at line 414 of file test_rpc.cpp.

References profinet::Device, profinet::dcp::MakeBlockKey(), and profinet::PNDCPBlock::NAME_OF_STATION.

+ Here is the call graph for this function:

◆ MakeStationNameResponse()

Bytes profinet::rpc::RpcTests::MakeStationNameResponse ( const MacAddress &  deviceMac,
const MacAddress &  controllerMac,
const std::string &  stationName 
)
inlineprotected

Builds a DCP response containing a station-name block.

Parameters
deviceMacDevice source MAC address.
controllerMacController destination MAC address.
stationNameStation name encoded in the response.
Returns
Complete DCP response Ethernet frame.

Definition at line 385 of file test_rpc.cpp.

References profinet::Device, profinet::Get, MakeDcpBlock(), MakeDcpResponseFrame(), and profinet::PNDCPBlock::NAME_OF_STATION.

+ Here is the call graph for this function:

◆ MakeTestRpcConnection()

std::unique_ptr< RPCCon > profinet::rpc::RpcTests::MakeTestRpcConnection ( )
inlineprotected

Creates a deterministic RPC connection for helper tests.

Returns
RPC connection with known device information.

Definition at line 458 of file test_rpc.cpp.

References MakeRpcTestDeviceInfo().

+ Here is the call graph for this function:

◆ MakeTestTransportRpcConnection()

std::unique_ptr< RPCCon > profinet::rpc::RpcTests::MakeTestTransportRpcConnection ( std::unique_ptr< IRpcTransport >  transport,
std::unique_ptr< IRpcTransport >  ctransport = nullptr 
)
inlineprotected

Creates a test RPC connection using the injected transport.

Parameters
transportTransport used by the connection.
Returns
Test RPC connection.

Definition at line 652 of file test_rpc.cpp.

References ctransport, MakeRpcTestDeviceInfo(), profinet::rpc::RPCConOptions::rpcPort, profinet::rpc::RPCConOptions::timeoutSec, and transport.

Referenced by SetUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeWriteMultipleResponsePayload()

Bytes profinet::rpc::RpcTests::MakeWriteMultipleResponsePayload ( )
inlineprotected

Builds a minimal WriteMultiple response containing one successful entry.

Returns
Serialized IODWriteMultiple response.

Definition at line 864 of file test_rpc.cpp.

References profinet::wire::PutU16(), profinet::wire::PutU32(), profinet::wire::PutU8(), and profinet::uuidLenght.

+ Here is the call graph for this function:

◆ ReplyToEpmLookup()

void profinet::rpc::RpcTests::ReplyToEpmLookup ( asio::ip::udp::socket &  server,
const Bytes &  response,
Bytes &  request 
)
inlineprotected

Receives an EPM lookup request and sends a synthetic response.

Parameters
serverUDP server socket.
responseResponse bytes to send.
requestReceives the client's request bytes.

Definition at line 312 of file test_rpc.cpp.

References buffer.

◆ SetUp()

void profinet::rpc::RpcTests::SetUp ( )
inlineoverrideprotected

Definition at line 42 of file test_rpc.cpp.

References conn, ctransport, MakeTestTransportRpcConnection(), rawcTransport, rawTransport, and transport.

+ Here is the call graph for this function:

◆ TearDown()

void profinet::rpc::RpcTests::TearDown ( )
inlineoverrideprotected

Definition at line 51 of file test_rpc.cpp.

Member Data Documentation

◆ conn

◆ ctransport

std::unique_ptr<TestRpcTransport> profinet::rpc::RpcTests::ctransport
protected

Definition at line 922 of file test_rpc.cpp.

Referenced by MakeTestTransportRpcConnection(), and SetUp().

◆ rawcTransport

TestRpcTransport* profinet::rpc::RpcTests::rawcTransport = nullptr
protected

Definition at line 923 of file test_rpc.cpp.

Referenced by SetUp().

◆ rawTransport

TestRpcTransport* profinet::rpc::RpcTests::rawTransport = nullptr
protected

Definition at line 920 of file test_rpc.cpp.

Referenced by SetUp().

◆ transport

std::unique_ptr<TestRpcTransport> profinet::rpc::RpcTests::transport
protected

Definition at line 919 of file test_rpc.cpp.

Referenced by InvokeBuildAlarmCrBlock(), MakeTestTransportRpcConnection(), and SetUp().


The documentation for this class was generated from the following file: