> This page is for version 1.4.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 1.4.0 (Latest) (default): https://docs.nvidia.com/halos/outside-in-safety/1.4.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/halos/outside-in-safety/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/halos/outside-in-safety/_mcp/server.

# NvPSDGatewayProtocol.h

> Generated reference for NvPSDGatewayProtocol.h: The gateway wire format: registration (REGR), registration refusal (RGNK) and its reasons, and the envelope that carries each decision request to an SDM.

The gateway wire format: registration (REGR), registration refusal (RGNK) and its reasons, and the envelope that carries each decision request to an SDM.

Part of the NvPSD Gateway 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`.

```c
#include "NvPSDGatewayProtocol.h"
```

## Functions

### NvPSDGatewayBuildRegReject

```c
static inline void NvPSDGatewayBuildRegReject(uint8_t out[NVPSD_GATEWAY_REG_REJECT_MSG_SIZE], uint8_t reason);
```

### NvPSDGatewayParseRegReject

```c
static inline bool NvPSDGatewayParseRegReject(const void *buf, size_t n, uint8_t *reason);
```

### NvPSDGatewayRegRejectReasonName

```c
static inline const char * NvPSDGatewayRegRejectReasonName(uint8_t reason);
```

### NvPSDGatewayDecisionPacketEpochIsValid

```c
static inline bool NvPSDGatewayDecisionPacketEpochIsValid(uint64_t epoch);
```

### NvPSDGatewayDecisionPacketSequenceIsValid

```c
static inline bool NvPSDGatewayDecisionPacketSequenceIsValid(uint32_t txSeq);
```

### NvPSDGatewayDecisionPacketHeaderIsValid

```c
static inline bool NvPSDGatewayDecisionPacketHeaderIsValid(const NvPSDGatewayDecisionRequestPacket *packet);
```

## Types

### NvPSDGatewayDecisionRequestPacket

```c
struct NvPSDGatewayDecisionRequestPacket
```

| Field          | Declaration               | Description |
| -------------- | ------------------------- | ----------- |
| `magic`        | `char magic[4]`           |             |
| `version`      | `uint16_t version`        |             |
| `headerSize`   | `uint16_t headerSize`     |             |
| `gatewayEpoch` | `uint64_t gatewayEpoch`   |             |
| `gatewayTxSeq` | `uint32_t gatewayTxSeq`   |             |
| `request`      | `DecisionRequest request` |             |

### NvPSDGatewayRegRejectReason

```c
enum NvPSDGatewayRegRejectReason
```

| Value                                   | Initializer | Description |
| --------------------------------------- | ----------- | ----------- |
| `NVPSD_REG_REJECT_MALFORMED`            | `1`         |             |
| `NVPSD_REG_REJECT_NO_VALID_EVENT_TYPES` | `2`         |             |
| `NVPSD_REG_REJECT_TABLE_FULL`           | `3`         |             |
| `NVPSD_REG_REJECT_RATE_LIMITED`         | `4`         |             |

### Type aliases

| Name                                | Definition                                                                           | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------ | ----------- |
| `NvPSDGatewayDecisionRequestPacket` | `typedef struct NvPSDGatewayDecisionRequestPacket NvPSDGatewayDecisionRequestPacket` |             |

## Macros

| Macro                                   | Value                                                              | Description                                                                                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NVPSD_GATEWAY_MAX_CLIENTS`             | `10`                                                               | Maximum number of decision-maker clients that can register over UDP.                                                                                                                                                                                                                                                                                                                                 |
| `NVPSD_GATEWAY_REG_MAGIC`               | `"REGR"`                                                           | Registration packet magic (4 bytes). Send to gateway to subscribe to EVENT\_\* types.                                                                                                                                                                                                                                                                                                                |
| `NVPSD_GATEWAY_HB_MAGIC_GATEWAY`        | `"HBPG"`                                                           | Heartbeat: gateway → client (4 bytes).                                                                                                                                                                                                                                                                                                                                                               |
| `NVPSD_GATEWAY_HB_MAGIC_CLIENT`         | `"HBPC"`                                                           | Heartbeat ACK: client → gateway (4 bytes).                                                                                                                                                                                                                                                                                                                                                           |
| `NVPSD_GATEWAY_HB_MSG_SIZE`             | `8`                                                                | Heartbeat message size: 4-byte magic + 4-byte seq (network byte order).                                                                                                                                                                                                                                                                                                                              |
| `NVPSD_GATEWAY_REG_REJECT_MAGIC`        | `"RGNK"`                                                           | Registration refusal: gateway -> client, 4-byte magic + one reason byte (NvPSDGatewayRegRejectReason). Sent for every REGR the gateway refuses, so a refused client can tell refusal and why from silence. Additive: its size matches no other message on this link, and a client built before it discards it as an unexpected size. Smaller than any REGR, so answering one cannot amplify traffic. |
| `NVPSD_GATEWAY_REG_REJECT_MSG_SIZE`     | `5`                                                                |                                                                                                                                                                                                                                                                                                                                                                                                      |
| `NVPSD_GATEWAY_DECISION_MAGIC`          | `"DRPG"`                                                           | `DecisionRequest` packet: gateway -> SDM (4 bytes).                                                                                                                                                                                                                                                                                                                                                  |
| `NVPSD_GATEWAY_DECISION_PACKET_VERSION` | `1U`                                                               | `DecisionRequest` packet version for the Gateway-to-SDM UDP envelope.                                                                                                                                                                                                                                                                                                                                |
| `NVPSD_GATEWAY_DECISION_TX_SEQ_MIN`     | `1U`                                                               | Valid Gateway-to-SDM sequence range. 0 and UINT32_MAX are reserved sentinels.                                                                                                                                                                                                                                                                                                                        |
| `NVPSD_GATEWAY_DECISION_TX_SEQ_MAX`     | `(UINT32_MAX - 1U)`                                                |                                                                                                                                                                                                                                                                                                                                                                                                      |
| `NVPSD_GATEWAY_DECISION_EPOCH_MAX`      | `UINT64_MAX`                                                       |                                                                                                                                                                                                                                                                                                                                                                                                      |
| `NVPSD_GATEWAY_DECISION_HEADER_SIZE`    | `((uint16_t)offsetof(NvPSDGatewayDecisionRequestPacket, request))` |                                                                                                                                                                                                                                                                                                                                                                                                      |