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

A base message class for sending or replying. More...

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

Static Public Member Functions

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

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.

Protected Member Functions

ReadOnlySpan< byte > Data ()
 The data.

Static Protected Member Functions

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.

Properties

byte Address [get, protected set]
 Address assigned to the device.
MessageType MessageType [get, protected set]
 Type of message.

Detailed Description

A base message class for sending or replying.

Definition at line 11 of file Message.cs.

Member Function Documentation

◆ AddChecksum()

void OSDP.Net.Messages.Message.AddChecksum ( IList< byte > packet)
inlinestaticprotected

Adds the checksum to the packet.

Parameters
packetThe packet.

Definition at line 160 of file Message.cs.

References CalculateChecksum().

◆ AddPacketLength()

void OSDP.Net.Messages.Message.AddPacketLength ( Span< byte > packet,
ushort additionalLength = 0 )
inlinestaticprotected

Calculates the length and adds it to the packet.

Parameters
packetThe packet.
additionalLengthAdditional length to add to the calculation.

Definition at line 137 of file Message.cs.

◆ CalculateChecksum()

byte OSDP.Net.Messages.Message.CalculateChecksum ( byte[] packet)
inlinestaticprotected

Calculates the checksum from the packet data.

Parameters
packetThe packet data.
Returns
The calculated checksum.

Definition at line 127 of file Message.cs.

Referenced by AddChecksum(), and OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ CalculateCrc()

ushort OSDP.Net.Messages.Message.CalculateCrc ( ReadOnlySpan< byte > packet)
inlinestaticprotected

Calculates the CRC from the packet data.

Parameters
packetThe packet data.
Returns
The calculated CRC.

Definition at line 111 of file Message.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ CalculateMaximumMessageSize()

ushort OSDP.Net.Messages.Message.CalculateMaximumMessageSize ( ushort dataSize,
bool isEncrypted = false,
ushort cryptoLength = 16 )
inlinestatic

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.

Parameters
dataSizeTotal size in bytes available for the message.
isEncryptedTrue when the message is sent over an established secure channel.
cryptoLengthEncryption block size used for padding.
Returns
The maximum number of payload bytes the message can carry.

Definition at line 202 of file Message.cs.

◆ Data()

ReadOnlySpan< byte > OSDP.Net.Messages.Message.Data ( )
abstractprotected

The data.

Returns
The data

Member Data Documentation

◆ AddressMask

const byte OSDP.Net.Messages.Message.AddressMask = 0x7F
static

OSDP message address mask.

Definition at line 16 of file Message.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ FirstPaddingByte

const byte OSDP.Net.Messages.Message.FirstPaddingByte = 0x80
static

While padding bytes are generally 0x00, the first byte of padding is not.

This is the value of that first byte when the payload (or message for MAC signing) is padded

Definition at line 39 of file Message.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ MacSize

const ushort OSDP.Net.Messages.Message.MacSize = 4
static

Size in bytes of MAC signature in message suffix when the secure channel has been established.

Definition at line 32 of file Message.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ MsgTypeIndex

const ushort OSDP.Net.Messages.Message.MsgTypeIndex = 5
static

Index of command/reply code within the message header.

Definition at line 26 of file Message.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ StartOfMessage

const byte OSDP.Net.Messages.Message.StartOfMessage = 0x53
static

OSDP message SOM (start of the message) byte.

Definition at line 21 of file Message.cs.

Referenced by OSDP.Net.Tracing.PacketBuffer.Append(), and OSDP.Net.Tracing.PacketBuffer.TryExtractPacket().

Property Documentation

◆ Address

byte OSDP.Net.Messages.Message.Address
getprotected set

Address assigned to the device.

Definition at line 68 of file Message.cs.

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

◆ MessageType

MessageType OSDP.Net.Messages.Message.MessageType
getprotected set

Type of message.

Definition at line 73 of file Message.cs.

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


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