OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OSDP.Net.Messages.IncomingMessage Class Reference

Represents a message that was received from the wire. More...

Inheritance diagram for OSDP.Net.Messages.IncomingMessage:
OSDP.Net.Messages.Message

Public Member Functions

 IncomingMessage (ReadOnlySpan< byte > data, IMessageSecureChannel channel)
 Creates a new instance of IncomingMessage class.
bool SecureCryptogramHasBeenAccepted ()
 Checks whether the secure cryptogram has been accepted.

Protected Member Functions

override ReadOnlySpan< byte > Data ()
Protected Member Functions inherited from OSDP.Net.Messages.Message
ReadOnlySpan< byte > Data ()
 The data.

Properties

bool IsUsingCrc [get]
 If true, the message has a CRC suffix; otherwise it has a checksum.
byte Type [get]
 Command/reply code of the message.
byte Sequence [get]
 Message sequence number.
bool IsSecureMessage [get]
 Indicates if the message was sent via an established secure channel.
bool IsValidMac [get]
 Indicates if the message has a valid MAC signature which was validated via local message channel context.
bool IsUsingDefaultKey [get, set]
 Gets whether the incoming message is using the default key.
bool HasSecureData [get]
 Determines whether the incoming message has secure data.
bool IsPayloadDecrypted = true [get]
 Indicates whether the payload was successfully decrypted.
byte[] Payload [get]
 Returns the raw message payload.
ReadOnlySpan< byte > OriginalMessageData [get]
 Original byte data which includes the header, security control block, payload, MAC and CRC/Checksum suffix.
byte SecurityBlockType [get]
 Type of the security block, if there is one.
byte[] SecureBlockData [get]
 Raw security block bytes.
bool IsDataCorrect [get]
 Gets a value indicating whether the data in the incoming message is correct.
Properties inherited from OSDP.Net.Messages.Message
byte Address [get, protected set]
 Address assigned to the device.
MessageType MessageType [get, protected set]
 Type of message.

Additional Inherited Members

Static Public Member Functions inherited from OSDP.Net.Messages.Message
static ushort CalculateMaximumMessageSize (ushort dataSize, bool isEncrypted=false, ushort cryptoLength=16)
 Calculates the largest payload that fits in a message of the given total size, accounting for the message header, security control block, message code, CRC, MAC and encryption padding.
Static Public Attributes inherited from OSDP.Net.Messages.Message
const byte AddressMask = 0x7F
 OSDP message address mask.
const byte StartOfMessage = 0x53
 OSDP message SOM (start of the message) byte.
const ushort MsgTypeIndex = 5
 Index of command/reply code within the message header.
const ushort MacSize = 4
 Size in bytes of MAC signature in message suffix when the secure channel has been established.
const byte FirstPaddingByte = 0x80
 While padding bytes are generally 0x00, the first byte of padding is not.
Static Protected Member Functions inherited from OSDP.Net.Messages.Message
static ushort CalculateCrc (ReadOnlySpan< byte > packet)
 Calculates the CRC from the packet data.
static byte CalculateChecksum (byte[] packet)
 Calculates the checksum from the packet data.
static void AddPacketLength (Span< byte > packet, ushort additionalLength=0)
 Calculates the length and adds it to the packet.
static void AddChecksum (IList< byte > packet)
 Adds the checksum to the packet.

Detailed Description

Represents a message that was received from the wire.

It extends base Message class with extra properties/methods that specifically indicate the parsing and validation of incoming raw bytes.

Definition at line 14 of file IncomingMessage.cs.

Constructor & Destructor Documentation

◆ IncomingMessage()

Member Function Documentation

◆ SecureCryptogramHasBeenAccepted()

bool OSDP.Net.Messages.IncomingMessage.SecureCryptogramHasBeenAccepted ( )

Checks whether the secure cryptogram has been accepted.

Per the OSDP spec (section D.1.3.4), the osdp_RMAC_I (SCS_14) security block data byte is 0x01 when the PD accepted the ACU's server cryptogram and the secure channel is established.

Returns
Returns true if the secure cryptogram has been accepted; otherwise, false.

References SecureBlockData.

Property Documentation

◆ HasSecureData

bool OSDP.Net.Messages.IncomingMessage.HasSecureData
get

Determines whether the incoming message has secure data.

The HasSecureData property is used to check if the incoming message has secure data.

true if the incoming message has secure data; otherwise, false.

Definition at line 146 of file IncomingMessage.cs.

Referenced by IncomingMessage().

◆ IsDataCorrect

bool OSDP.Net.Messages.IncomingMessage.IsDataCorrect
get

Gets a value indicating whether the data in the incoming message is correct.

Returns
true if the data is correct; otherwise, false.

Definition at line 194 of file IncomingMessage.cs.

Referenced by OSDP.Net.Device.EnqueuePollReply(), and IncomingMessage().

◆ IsPayloadDecrypted

bool OSDP.Net.Messages.IncomingMessage.IsPayloadDecrypted = true
get

Indicates whether the payload was successfully decrypted.

When true, the Payload contains decrypted data that can be parsed. When false, the payload is still encrypted because the secure channel was not established or the required key was not available.

Definition at line 158 of file IncomingMessage.cs.

Referenced by IncomingMessage().

◆ IsSecureMessage

bool OSDP.Net.Messages.IncomingMessage.IsSecureMessage
get

Indicates if the message was sent via an established secure channel.

Definition at line 119 of file IncomingMessage.cs.

Referenced by IncomingMessage().

◆ IsUsingCrc

bool OSDP.Net.Messages.IncomingMessage.IsUsingCrc
get

If true, the message has a CRC suffix; otherwise it has a checksum.

Definition at line 102 of file IncomingMessage.cs.

Referenced by IncomingMessage(), and OSDP.Net.Model.Packet.Packet().

◆ IsUsingDefaultKey

bool OSDP.Net.Messages.IncomingMessage.IsUsingDefaultKey
getset

Gets whether the incoming message is using the default key.

The IsUsingDefaultKey property is a boolean value that indicates whether the incoming message is using the default key. This property is true if the incoming message is using the default key; otherwise, false. The default key is a pre-configured key that is used for cryptographic operations.

Definition at line 135 of file IncomingMessage.cs.

Referenced by IncomingMessage(), and OSDP.Net.Model.Packet.Packet().

◆ IsValidMac

bool OSDP.Net.Messages.IncomingMessage.IsValidMac
get

Indicates if the message has a valid MAC signature which was validated via local message channel context.

Definition at line 125 of file IncomingMessage.cs.

Referenced by IncomingMessage().

◆ OriginalMessageData

ReadOnlySpan<byte> OSDP.Net.Messages.IncomingMessage.OriginalMessageData
get

Original byte data which includes the header, security control block, payload, MAC and CRC/Checksum suffix.

Definition at line 169 of file IncomingMessage.cs.

Referenced by OSDP.Net.Model.Packet.Packet().

◆ Payload

byte [] OSDP.Net.Messages.IncomingMessage.Payload
get

Returns the raw message payload.

Definition at line 163 of file IncomingMessage.cs.

Referenced by Data(), OSDP.Net.Device.EnqueuePollReply(), IncomingMessage(), and OSDP.Net.Model.Packet.Packet().

◆ SecureBlockData

byte [] OSDP.Net.Messages.IncomingMessage.SecureBlockData
get

Raw security block bytes.

Definition at line 179 of file IncomingMessage.cs.

Referenced by IncomingMessage(), and SecureCryptogramHasBeenAccepted().

◆ SecurityBlockType

byte OSDP.Net.Messages.IncomingMessage.SecurityBlockType
get

Type of the security block, if there is one.

Definition at line 174 of file IncomingMessage.cs.

Referenced by Data(), and IncomingMessage().

◆ Sequence

byte OSDP.Net.Messages.IncomingMessage.Sequence
get

Message sequence number.

Definition at line 112 of file IncomingMessage.cs.

Referenced by IncomingMessage(), and OSDP.Net.Model.Packet.Packet().

◆ Type

byte OSDP.Net.Messages.IncomingMessage.Type
get

Command/reply code of the message.

Definition at line 107 of file IncomingMessage.cs.

Referenced by OSDP.Net.Device.EnqueuePollReply(), IncomingMessage(), and OSDP.Net.Model.Packet.Packet().


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