Skip to navigation

pss_message_validate.h

View as Markdown

CRC-32 integrity and field-range validation of SafetyEvent and DecisionRequest.

Part of the SEI client interface. Generated from the header published in safety-core/, release 1.3-26.07.5. The development packages install it in /opt/nvidia/psf/include.

#include "pss_message_validate.h"

CRC-32 integrity and field-range validation for SafetyEvent and DecisionRequest wire messages.

Pure C with extern “C” linkage so the same object can be linked into C++ host binaries (PSS daemon, PSD, Gateway) and into C firmware builds.

Typical receiver sequence:

  1. pssSafetyEventVerifyCRC() / pssDecisionRequestVerifyCRC()
  2. validateSafetyEvent() / validateDecisionRequest()

Typical sender sequence:

  1. Fill struct fields
  2. pssSafetyEventSetCRC() / pssDecisionRequestSetCRC()

Any component that modifies a struct after CRC computation (e.g. fusion, filtering) must call the SetCRC function again before forwarding.

Functions

pssGetSchemaVersion

static inline uint16_t pssGetSchemaVersion(const MessageIntegrity *mi);

pssSetSchemaVersion

static inline void pssSetSchemaVersion(MessageIntegrity *mi, uint16_t val);

pssGetCrc32

static inline uint32_t pssGetCrc32(const MessageIntegrity *mi);

pssSetCrc32

static inline void pssSetCrc32(MessageIntegrity *mi, uint32_t val);

pssComputeCRC32

uint32_t pssComputeCRC32(const void *data, size_t length);

Compute CRC-32 (ISO 3309 / ITU-T V.42, polynomial 0xEDB88320 reflected) over an arbitrary byte buffer.

ParameterDescription
dataPointer to input buffer (must not be NULL if length > 0).
lengthNumber of bytes.

Returns: CRC-32 value.

pssSafetyEventSetCRC

void pssSafetyEventSetCRC(SafetyEvent *event);

Set integrity.schemaVersion and compute + store integrity.crc32 for a SafetyEvent.

CRC covers bytes [0 .. offsetof(SafetyEvent, integrity.crc32) - 1], i.e. all fields including schemaVersion but excluding crc32 itself.

pssSafetyEventVerifyCRC

bool pssSafetyEventVerifyCRC(const SafetyEvent *event);

Verify the CRC-32 stored in a received SafetyEvent.

Returns: true if the CRC matches, false otherwise.

pssDecisionRequestSetCRC

void pssDecisionRequestSetCRC(DecisionRequest *req);

Set integrity.schemaVersion and compute + store integrity.crc32 for a DecisionRequest.

pssDecisionRequestVerifyCRC

bool pssDecisionRequestVerifyCRC(const DecisionRequest *req);

Verify the CRC-32 stored in a received DecisionRequest.

Returns: true if the CRC matches, false otherwise.

validateSafetyEvent

uint32_t validateSafetyEvent(const SafetyEvent *event);

Validate all fields of a SafetyEvent (including CRC and schema version).

Checks performed:

  • Non-NULL pointer
  • Schema version == PSS_SCHEMA_VERSION
  • CRC-32 integrity
  • EventType and ObjectType enum ranges
  • confidenceLevel in [0.0f, 1.0f] (NaN is rejected)
  • timestamp != 0 (rejects uninitialized events)
  • sensorIdentifier NUL-terminated within bounds
  • cause within the EventCause enum. An in-range value the receiver does not recognise is accepted deliberately: unknown causes must reach the SDMs, which treat anything other than CAUSE_SAIM_INIT as a genuine failure.

Returns: PSS_VALID (0) on success, or a bitmask of PSS_ERR_* flags indicating which checks failed.

validateDecisionRequest

uint32_t validateDecisionRequest(const DecisionRequest *req);

Validate all fields of a DecisionRequest (including CRC, schema version, and nested FusedSafetyEvent entries).

Checks performed:

  • Non-NULL pointer
  • Schema version == PSS_SCHEMA_VERSION
  • CRC-32 integrity
  • sensorDataSummarySize <= MAX_SENSORS_DATA_SUMMARY_SIZE
  • OperationalMode range
  • Per-sensor FusedSafetyEvent field validation (types, daemon-owned OPERATIONAL/CRITICAL severity, confidence, timestamp, status, strings, object types)
  • Populated SensorData entries have homogeneous severity so PSD’s first-event routing rule is safe
  • Explicit critical evidence is not labeled OPERATIONAL

Returns: PSS_VALID (0) on success, or a bitmask of PSS_ERR_* flags.

Macros

MacroValueDescription
PSS_VALID0UBitmask returned by validateSafetyEvent / validateDecisionRequest. Zero (PSS_VALID) means all checks passed.
PSS_ERR_NULL_POINTER(1U << 0)
PSS_ERR_SCHEMA_VERSION(1U << 1)
PSS_ERR_CRC(1U << 2)
PSS_ERR_EVENT_TYPE(1U << 3)
PSS_ERR_SEVERITY(1U << 4)
PSS_ERR_CONFIDENCE(1U << 5)
PSS_ERR_SENSOR_IDENTIFIER(1U << 6)
PSS_ERR_EVENT_CAUSE(1U << 7)
PSS_ERR_OBJECT_TYPE(1U << 8)
PSS_ERR_EVENT_STATUS(1U << 9)
PSS_ERR_OPERATIONAL_MODE(1U << 10)
PSS_ERR_SENSOR_DATA_SUMMARY_SIZE(1U << 11)
PSS_ERR_TIMESTAMP(1U << 12)
PSS_CLIENT_EVENTTYPE_MAX((int)AI_PIPELINE_VALID)Maximum valid wire integer for each protocol enum. Used by the validation helpers; update these when new enumerators are appended.
PSS_EVENTTYPE_MAX((int)PSS_STATUS_NOOP)
PSS_OBJECTTYPE_MAX((int)OBJECT)
PSS_SEVERITY_LEVEL_MAX((int)CRITICAL)
PSS_OPERATIONAL_MODE_MAX((int)ERROR)
PSS_SAFETY_EVENT_STATUS_MAX((int)UNKNOWN)