Operator Id

include/rid/operator_id.h Operator ID message handling per ASTM F3411-22a.

Example usage:

    rid_operator_id_t operator_id;

    rid_operator_id_init(&operator_id);
    rid_operator_id_set_type(&operator_id, RID_OPERATOR_ID_TYPE_DEFAULT);
    rid_operator_id_set(&operator_id, "FIN87astrdge12k8");

    hexdump(&operator_id, sizeof(operator_id));

    char id[RID_OPERATOR_ID_SIZE + 1];
    rid_operator_id_get(&operator_id, id, sizeof(id));
    rid_operator_id_type_t id_type = rid_operator_id_get_type(&operator_id);

    printf("Operator ID: %s\n", id);
    printf("ID type:     %d\n", id_type);

Structures and Types

Type Name
struct rid_operator_id_t
Operator ID message structure per ASTM F3411-22a.
enum rid_operator_id_type_t
Operator ID type classification per ASTM F3411-22a.

Functions

Type Name
int rid_operator_id_get (const rid_operator_id_t *message, char *buffer, size_t buffer_size)
Get the Operator ID from an Operator ID message.
rid_operator_id_type_t rid_operator_id_get_type (const rid_operator_id_t *message)
Get the ID type from an Operator ID message.
int rid_operator_id_init (rid_operator_id_t *message)
Initialize an Operator ID message with default values.
int rid_operator_id_set (rid_operator_id_t *message, const char *operator_id)
Set the Operator ID for an Operator ID message.
int rid_operator_id_set_type (rid_operator_id_t *message, rid_operator_id_type_t type)
Set the ID type for an Operator ID message.
int rid_operator_id_to_json (const rid_operator_id_t *message, char *buffer, size_t buffer_size, size_t *needed_size)
Format an Operator ID message as a JSON string.
const char * rid_operator_id_type_to_string (rid_operator_id_type_t type)
Convert operator ID type to string representation.
int rid_operator_id_validate (const rid_operator_id_t *message)
Validate an Operator ID message structure.

Macros

Type Name
define RID_OPERATOR_ID_SIZE 20
Operator ID field size in bytes per ASTM F3411-22a.

Structures and Types Documentation

struct rid_operator_id_t

Operator ID message structure per ASTM F3411-22a.

Variables:

  • uint8_t id_type

  • uint8_t message_type

  • char operator_id

  • uint8_t protocol_version

  • char reserved

enum rid_operator_id_type_t

Operator ID type classification per ASTM F3411-22a.

enum rid_operator_id_type_t {
    RID_OPERATOR_ID_TYPE_DEFAULT = 0,
    RID_OPERATOR_ID_TYPE_MAX = 255
};

Functions Documentation

function rid_operator_id_get

Get the Operator ID from an Operator ID message.

int rid_operator_id_get (
    const rid_operator_id_t *message,
    char *buffer,
    size_t buffer_size
) 

Copies the Operator ID to the provided buffer as a null-terminated string.

Parameters:

  • message Pointer to the Operator ID message structure.
  • buffer Buffer to store the Operator ID.
  • buffer_size Size of the buffer (must be at least RID_OPERATOR_ID_SIZE + 1).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or buffer is NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer_size is insufficient.

function rid_operator_id_get_type

Get the ID type from an Operator ID message.

rid_operator_id_type_t rid_operator_id_get_type (
    const rid_operator_id_t *message
) 

Parameters:

  • message Pointer to the Operator ID message structure.

Returns:

The ID type or RID_OPERATOR_ID_TYPE_DEFAULT if message is NULL.

function rid_operator_id_init

Initialize an Operator ID message with default values.

int rid_operator_id_init (
    rid_operator_id_t *message
) 

Sets protocol version to 2 and message type to OPERATOR_ID. All other fields are set to zero.

Parameters:

  • message Pointer to the Operator ID message structure.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.

function rid_operator_id_set

Set the Operator ID for an Operator ID message.

int rid_operator_id_set (
    rid_operator_id_t *message,
    const char *operator_id
) 

The Operator ID is a null-terminated string up to RID_OPERATOR_ID_SIZE characters.

Parameters:

  • message Pointer to the Operator ID message structure.
  • operator_id The Operator ID string to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or operator_id is NULL.
  • RID_ERROR_BUFFER_TOO_LARGE if operator_id exceeds RID_OPERATOR_ID_SIZE characters.
  • RID_ERROR_INVALID_CHARACTER if operator ID contains non-ASCII or control characters.

function rid_operator_id_set_type

Set the ID type for an Operator ID message.

int rid_operator_id_set_type (
    rid_operator_id_t *message,
    rid_operator_id_type_t type
) 

Parameters:

  • message Pointer to the Operator ID message structure.
  • type The ID type to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if type exceeds RID_OPERATOR_ID_TYPE_MAX.

function rid_operator_id_to_json

Format an Operator ID message as a JSON string.

int rid_operator_id_to_json (
    const rid_operator_id_t *message,
    char *buffer,
    size_t buffer_size,
    size_t *needed_size
) 

Parameters:

  • message Pointer to the Operator ID message structure.
  • buffer Buffer to store the JSON string or NULL.
  • buffer_size Size of the buffer.
  • needed_size If non-NULL receives the required buffer size.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL or if bothbuffer andneeded_size are NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer is too small.

function rid_operator_id_type_to_string

Convert operator ID type to string representation.

const char * rid_operator_id_type_to_string (
    rid_operator_id_type_t type
) 

Parameters:

  • type The operator ID type to convert.

Returns:

String representation of the operator ID type. Returns "UNKNOWN" for invalid values.

function rid_operator_id_validate

Validate an Operator ID message structure.

int rid_operator_id_validate (
    const rid_operator_id_t *message
) 

Checks that all fields contain valid encoded values according to ASTM F3411-22a.

Parameters:

  • message Pointer to the Operator ID message structure to validate.

Return value:

  • RID_SUCCESS if all fields are valid.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_INVALID_PROTOCOL_VERSION if protocol version is invalid.
  • RID_ERROR_UNKNOWN_MESSAGE_TYPE if message type is not OPERATOR_ID.
  • RID_ERROR_INVALID_CHARACTER if operator ID contains non-ASCII or control characters.

Macros Documentation

define RID_OPERATOR_ID_SIZE

Operator ID field size in bytes per ASTM F3411-22a.

#define RID_OPERATOR_ID_SIZE 20